Action.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. #include "global.h"
  2. #include "Action.h"
  3. byte_bits_t cRunState,cRunState1,cRunState2,cRunState3,cRunState4,cRunState5,cRunState6,cRunState7;
  4. byte_bits_t cTimeState;
  5. unsigned long cMachineType;
  6. unsigned long cScreenEnable;
  7. unsigned long cWifiEnable;
  8. unsigned short cSetPulseType;
  9. unsigned char AllRunFlg = 0;
  10. unsigned char JYDCRunFlg = 0,CCJRunFlg = 0;
  11. unsigned char LockMachineFlg = 0;
  12. unsigned char Y05Flg =0;
  13. unsigned char Y06Flg =0;
  14. unsigned char Y04Flg =0;
  15. unsigned char Y07Flg =0;
  16. static unsigned short old_machine_type;
  17. static unsigned short old_screen_type;
  18. static unsigned short old_wifi_type;
  19. //动作步就量
  20. unsigned short cStepMByte,cStepMByte1,cStepMByte2,cStepMByte3,cStepMByte4,cStepMByte5,
  21. cStepMByte6,cStepMByte7,cStepMByte8,cStepMByte9,cStepMByte10,cStepMByte11,cStepMByte12,
  22. cStepMByte13,cStepMByte14,cStepMByte15,cStepMByte16,cStepMByte17,cStepMByte18,cStepMByte19,
  23. cStepMByte20,cStepMByte21,cStepMByte22,cStepMByte23,cStepMByte24,cStepMByte25,cStepMByte26;
  24. //定时器
  25. unsigned long cDelayTime1,cDelayTime2,cDelayTime3,cDelayTime4,cDelayTime5,cDelayTime6,
  26. cDelayTime7,cDelayTime8,cDelayTime9,cDelayTime10,cDelayTime11,cDelayTime12,cDelayTime13,cDelayTime14,
  27. cDelayTime15,cDelayTime16,cDelayTime17,cDelayTime18,cDelayTime19,cDelayTime20,cDelayTime21,cDelayTime22,
  28. cDelayTime23,cDelayTime24,cDelayTime25,cDelayTime26,cDelayTime27,cDelayTime28,cDelayTime29,cDelayTime30,
  29. cDelayTime31,cDelayTime32,cDelayTime33,cDelayTime34,cDelayTime35;
  30. //8位变量
  31. unsigned char cCharBuff1,cCharBuff2,cCharBuff3,cCharBuff4,cCharBuff5,cCharBuff6,cCharBuff7,cCharBuff8,
  32. cCharBuff9,cCharBuff10,cCharBuff11,cCharBuff12,cCharBuff13,cCharBuff14,cCharBuff15,
  33. cCharBuff16,cCharBuff17,cCharBuff18,cCharBuff19,cCharBuff20,cCharBuff21,cCharBuff22,
  34. cCharBuff23,cCharBuff24,cCharBuff25,cCharBuff26,cCharBuff27,cCharBuff28,cCharBuff29,
  35. cCharBuff30,cCharBuff31,cCharBuff32,cCharBuff33,cCharBuff34,cCharBuff35,cCharBuff36,
  36. cCharBuff37,cCharBuff38,cCharBuff39,cCharBuff40,cCharBuff41,cCharBuff41,cCharBuff42,
  37. cCharBuff43,cCharBuff44,cCharBuff45,cCharBuff46,cCharBuff47,cCharBuff48,cCharBuff49,
  38. cCharBuff50,cCharBuff51,cCharBuff52,cCharBuff53,cCharBuff54,cCharBuff55,cCharBuff56,
  39. cCharBuff57,cCharBuff58,cCharBuff59,cCharBuff60;
  40. //16位变量
  41. unsigned short cUShort16Buff1,cUShort16Buff2,cUShort16Buff3,cUShort16Buff4,cUShort16Buff5,cUShort16Buff6,cUShort16Buff7,
  42. cUShort16Buff8,cUShort16Buff9,cUShort16Buff10,cUShort16Buff11,cUShort16Buff12,cUShort16Buff13,cUShort16Buff14,
  43. cUShort16Buff15,cUShort16Buff16,cUShort16Buff17,cUShort16Buff18,cUShort16Buff18,cUShort16Buff19,cUShort16Buff20,
  44. cUShort16Buff20,cUShort16Buff21,cUShort16Buff22,cUShort16Buff23,cUShort16Buff24,cUShort16Buff25,cUShort16Buff26,
  45. cUShort16Buff27,cUShort16Buff28,cUShort16Buff29,cUShort16Buff30,cUShort16Buff31,cUShort16Buff32,cUShort16Buff33,
  46. cUShort16Buff34,cUShort16Buff35,cUShort16Buff36,cUShort16Buff37,cUShort16Buff38,cUShort16Buff39,cUShort16Buff40;
  47. //有符号变量
  48. //32位变量
  49. unsigned long cUDword32Buff1,cUDword32Buff2,cUDword32Buff3,cUDword32Buff4,cUDword32Buff5,cUDword32Buff6,cUDword32Buff7,
  50. cUDword32Buff8,cUDword32Buff9,cUDword32Buff10,cUDword32Buff11,cUDword32Buff12,cUDword32Buff13,
  51. cUDword32Buff14,cUDword32Buff15;
  52. //有符号变量
  53. long cDword32Buff1,cDword32Buff2,cDword32Buff3,cDword32Buff4,cDword32Buff5,cDword32Buff6,cDword32Buff7,cDword32Buff8,cDword32Buff9,
  54. cDword32Buff10,cDword32Buff11,cDword32Buff12,cDword32Buff13,cDword32Buff14,cDword32Buff15;
  55. short *Short16Buff1,*Short16Buff2,*Short16Buff3;
  56. long dwXRealPos,dwYRealPos,dwYRealPos_com,dwZRealPos,dwARealPos;
  57. long olddwXRealPos[5],olddwYRealPos[5];
  58. unsigned char SingOneFlg = 0;
  59. unsigned long dwZipCnt = 0;
  60. unsigned char cSeBiaoEn = 0;
  61. unsigned char cSeBiaoOk = 0;
  62. unsigned short alarm_message_buff[ONE_MESSAGE_SIZE_WORD];
  63. unsigned short message_size_buff[5];
  64. unsigned char cWifiStep = 0;
  65. unsigned long CalInch(unsigned long length)
  66. {
  67. float length_buff;
  68. length_buff = length;
  69. return (unsigned long)round(length_buff / 2.539999);
  70. }
  71. unsigned long CalLengthCM(unsigned long length)
  72. {
  73. float length_buff;
  74. length_buff = length;
  75. return (unsigned long)round(length_buff * 2.539999);
  76. }
  77. long CalInch2(long length)
  78. {
  79. float length_buff;
  80. length_buff = length;
  81. return (long)round(length_buff / 2.539999);
  82. }
  83. long CalLengthCM2(long length)
  84. {
  85. float length_buff;
  86. length_buff = length;
  87. return (long)round(length_buff * 2.539999);
  88. }
  89. //计算生成速度
  90. void CalProSP(unsigned short addr)
  91. {
  92. static unsigned long cProSpTime = 0;
  93. unsigned short i;
  94. long temp;
  95. i = dwTickCount - cProSpTime;
  96. temp=(60000)%i;
  97. if(temp)
  98. {
  99. user_datas[addr] = ((60000)/i)+1;
  100. }
  101. else
  102. {
  103. user_datas[addr] = (60000)/i;
  104. }
  105. cProSpTime = dwTickCount;
  106. }
  107. //增加产量
  108. void AddToTal(unsigned short addr)
  109. {
  110. unsigned long buff;
  111. buff = user_datas[addr + 1] << 16;
  112. buff |= user_datas[addr];
  113. buff++;
  114. user_datas[addr + 1] = buff >> 16;
  115. user_datas[addr] = buff & 0x0000FFFF;
  116. }
  117. //获取产量
  118. unsigned long GetTotal(unsigned short addr)
  119. {
  120. unsigned long buff;
  121. buff = user_datas[addr + 1] << 16;
  122. buff |= user_datas[addr];
  123. return buff;
  124. }
  125. //清除产量
  126. void ClrcToTal(unsigned short addr)
  127. {
  128. user_datas[addr + 1] = 0;
  129. user_datas[addr] = 0;
  130. }
  131. //设置故障编号
  132. void SetAlarmCode(unsigned short addr,unsigned short alarm_code)
  133. {
  134. user_datas[addr] = alarm_code;
  135. }
  136. //获取故障编号
  137. unsigned short GetAlarmCode(unsigned short addr)
  138. {
  139. return user_datas[addr];
  140. }
  141. void SetData32bits(unsigned short addr,long source_data)
  142. {
  143. user_datas[addr + 1] = (source_data & 0xFFFF0000) >> 16;
  144. user_datas[addr] = source_data & 0x0000FFFF;
  145. }
  146. unsigned long GetData32bits(unsigned short addr)
  147. {
  148. return (user_datas[addr] | (user_datas[addr + 1] >> 16));
  149. }
  150. //开机读取机型
  151. void GetMachineType(void)
  152. {
  153. hw_flash_data_read(MACHINE_TYPE_SAVE_ADDR, &cMachineType,4);
  154. if(cMachineType > 100) cMachineType = 0;
  155. MACHINE_TYPE_SET_DATA = cMachineType;
  156. old_machine_type = MACHINE_TYPE_SET_DATA;
  157. hw_flash_data_read(MACHINE_SCREEN_SAVE_ADDR, &cScreenEnable,4);
  158. if(cScreenEnable > 1) cScreenEnable = 1;
  159. MACHINE_SCREEN_SET_DATA = cScreenEnable;
  160. old_screen_type = MACHINE_SCREEN_SET_DATA;
  161. hw_flash_data_read(MACHINE_WIFI_SAVE_ADDR, &cWifiEnable,4);
  162. if(cWifiEnable > 1) cWifiEnable = 1;
  163. MACHINE_WIFI_SET_DATA = cWifiEnable;
  164. old_wifi_type = MACHINE_WIFI_SET_DATA;
  165. }
  166. //设置保存机型
  167. void SetMachineType(void)
  168. {
  169. if(old_machine_type != MACHINE_TYPE_SET_DATA)
  170. {
  171. old_machine_type = MACHINE_TYPE_SET_DATA;
  172. hw_flash_data_write(MACHINE_TYPE_SAVE_ADDR, &old_machine_type,4);
  173. }
  174. if(old_screen_type != MACHINE_SCREEN_SET_DATA)
  175. {
  176. old_screen_type = MACHINE_SCREEN_SET_DATA;
  177. hw_flash_data_write(MACHINE_SCREEN_SAVE_ADDR, &old_screen_type,4);
  178. hw_flash_data_read(MACHINE_SCREEN_SAVE_ADDR, &cScreenEnable,4);
  179. }
  180. if(old_wifi_type != MACHINE_WIFI_SET_DATA)
  181. {
  182. old_wifi_type = MACHINE_WIFI_SET_DATA;
  183. hw_flash_data_write(MACHINE_WIFI_SAVE_ADDR, &old_wifi_type,4);
  184. }
  185. }
  186. //根据机型来选初始化脉冲
  187. void InitPWM(void)
  188. {
  189. hw_pwm_init(120);
  190. }
  191. void InitAction(void)
  192. {
  193. //机型选择,重上电才有效
  194. cMachineType =MACHINE_TYPE; //D300
  195. //鑫业
  196. #if (XIN_YE_MACHINE == 1) //由厂家程序内部选择
  197. XY_Mechine_InitAction();
  198. #endif
  199. //金龙
  200. #if (JING_LONG_MACHINE == 1)
  201. JL_Mechine_InitAction();
  202. #endif
  203. //龙一机械
  204. #if (LONG_YI_MACHINE == 1) //由厂家程序内部选择
  205. LY_Mechine_InitAction();
  206. #endif
  207. //昌盛给力
  208. #if (CHANG_SHENG_GEI_LI_MACHINE == 1)
  209. GL_Mechine_InitAction();
  210. #endif
  211. //宇纹轩
  212. #if (YU_WEN_XUAN_MACHINE == 1)
  213. YWX_Mechine_InitAction();
  214. #endif
  215. //福建盈兴
  216. #if (FJ_YING_XING_MACHINE == 1)
  217. YX_Mechine_InitAction();
  218. #endif
  219. //张春阳
  220. #if (ZHANG_CHUN_YANG_MACHINE == 1)
  221. ZCY_Mechine_InitAction();
  222. #endif
  223. //福建传驰
  224. #if (FIE_YUE_MACHINE == 1)
  225. FY_Mechine_InitAction();
  226. #endif
  227. //虎门飞跃
  228. #if (Chuan_Chi_MACHINE == 1)
  229. CC_Mechine_InitAction();
  230. #endif
  231. //付小伟
  232. #if (FU_XIAO_WEI_MACHINE == 1)
  233. FXW_Mechine_InitAction();
  234. #endif
  235. //锦泓
  236. #if (JIN_HONG_MACHINE == 1)
  237. JH_Mechine_InitAction();
  238. #endif
  239. //振宇
  240. #if (ZHEN_YU_MACHINE == 1)
  241. ZHENYU_Mechine_InitAction();
  242. #endif
  243. // DEFAULT_OUT = 0;
  244. // DEFAULT_IN = 0;
  245. IOPinConfigure(); //初始化默認值
  246. if(MACHINE_BOOT_WIFI)
  247. {
  248. M1000 = 1;
  249. user_datas[1604] = 1;
  250. }
  251. }
  252. void DelayAction(void)
  253. {
  254. #if 0
  255. switch(MACHINE_TYPE)
  256. {
  257. case JIAO_YA_DIN_CUN:JYDC_DelayAction();break;
  258. case CHU_CHI_JI:CCJ_DelayAction();break;
  259. case JIAO_YA_CHU_CHI:
  260. {
  261. JYDC_DelayAction();
  262. CCJ_DelayAction();
  263. }break;
  264. default:;
  265. }
  266. #endif
  267. }
  268. //X30/X16外部中断动作
  269. void ExtiAcitionX30(void)
  270. {
  271. #if 0
  272. switch(MACHINE_TYPE)
  273. {
  274. case JIAO_YA_DIN_CUN:JYDC_ExtiActionX30();break;
  275. case CHU_CHI_JI:;break;
  276. case JIAO_YA_CHU_CHI:
  277. {
  278. JYDC_ExtiActionX30();
  279. }break;
  280. default:;
  281. }
  282. #endif
  283. }
  284. //X31/X17外部中断动作
  285. void ExtiAcitionX31(void)
  286. {
  287. #if 0
  288. switch(MACHINE_TYPE)
  289. {
  290. case JIAO_YA_DIN_CUN:JYDC_ExtiActionX31();break;
  291. case MXC_NILONG:MXC_ExtiActionX31();break;
  292. case QIE_DUAN_JI:QueDuan_ExtiActionX31();break;
  293. case CHUAN_TOU_QIE_DUAN_JI:QDCT_ExtiActionX31();break;
  294. default:;
  295. }
  296. #endif
  297. }
  298. //X20外部中断动作
  299. void ExtiAcitionX20(void)
  300. {
  301. #if 0
  302. switch(MACHINE_TYPE)
  303. {
  304. case MXC_NILONG:MXC_ExtiActionX20();break;
  305. default:;
  306. }
  307. #endif
  308. }
  309. void Action(void)
  310. {
  311. InputPinConfig(); //输入可变
  312. #if (XIN_YE_MACHINE == 1) //由厂家程序内部选择
  313. XY_Mechine_Action();
  314. #endif
  315. //金龙
  316. #if (JING_LONG_MACHINE == 1)
  317. JL_Mechine_Action();
  318. #endif
  319. #if (LONG_YI_MACHINE == 1) //由厂家程序内部选择
  320. LY_Mechine_Action();
  321. #endif
  322. //昌盛给力
  323. #if (CHANG_SHENG_GEI_LI_MACHINE == 1)
  324. GL_Mechine_Action();
  325. #endif
  326. //宇纹轩
  327. #if (YU_WEN_XUAN_MACHINE == 1)
  328. YWX_Mechine_Action();
  329. #endif
  330. //福建盈兴
  331. #if (FJ_YING_XING_MACHINE == 1)
  332. YX_Mechine_Action();
  333. #endif
  334. //张春阳
  335. #if (ZHANG_CHUN_YANG_MACHINE == 1)
  336. ZCY_Mechine_Action();
  337. #endif
  338. //福建传驰
  339. #if (Chuan_Chi_MACHINE == 1)
  340. CC_Mechine_Action();
  341. #endif
  342. //虎门飞跃
  343. #if (FIE_YUE_MACHINE == 1)
  344. FY_Mechine_Action();
  345. #endif
  346. //付小伟
  347. #if (FU_XIAO_WEI_MACHINE == 1)
  348. FXW_Mechine_Action();
  349. #endif
  350. //锦泓
  351. #if (JIN_HONG_MACHINE == 1)
  352. JH_Mechine_Action();
  353. #endif
  354. //振宇
  355. #if (ZHEN_YU_MACHINE == 1)
  356. ZHENYU_Mechine_Action();
  357. #endif
  358. OutputPinConfig(); //输出可变
  359. #if 0
  360. switch(MACHINE_TYPE)
  361. {
  362. case TEST_ACTION:TestAction();break;
  363. case JIAO_YA_DIN_CUN:JYDC_Action();break;
  364. case CHU_CHI_JI:CCJ_Action();break;
  365. case JIAO_YA_CHU_CHI:
  366. {
  367. if(bStop)
  368. {
  369. bStop = 0;
  370. JYDC_bStop = 1;
  371. CCJ_bStop = 1;
  372. }
  373. if(START_IN_UP)
  374. {
  375. AllRunFlg = 1;
  376. }
  377. if(STOP_IN_UP)
  378. {
  379. AllRunFlg = 0;
  380. }
  381. if(AllRunFlg)
  382. {
  383. if(JYDC_ChuDai_IN)JYDCRunFlg = 0;
  384. else
  385. JYDCRunFlg = 1;
  386. if(CCJ_ChuDai_IN)CCJRunFlg = 0;
  387. else CCJRunFlg = 1;
  388. }
  389. else
  390. {
  391. JYDCRunFlg = 1;
  392. if(CCJ_ChuDai_IN)CCJRunFlg = 0;
  393. else CCJRunFlg = 1;
  394. }
  395. JYDC_Action();
  396. CCJ_Action();
  397. }break;
  398. case QIE_DUAN_JI:QueDuan_Action();break;
  399. case CHUAN_TOU_QIE_DUAN_JI:QDCT_Action();break;
  400. case MXC_NILONG:MXC_NiLongXiuCiJiAction();break;
  401. case DA_KONG_JI:DK_Action();break;
  402. case JIN_SHU_DIN_CUN:JSDC_Action();break;
  403. case CHUAN_TOU_JI:ChuanTou_Action();break;
  404. case HUA_XIAN_JI:HuaXian_Action();break;
  405. case JIN_SHU_KLSZ_JI:JSKL_Action();break;
  406. case HE_LIAN_JI:HL_Action();break;
  407. case TIE_BU_JI:TBJ_Action();break;
  408. case YYA_JI:YYa_Action();break;
  409. case SYYA_JI:SYYa_Action();break;
  410. case FANG_KUAI_CHA_XIAO_JI:FKCX_Action();break;
  411. case GONG_ZHI_MA:GZM_Action();break;
  412. case LA_SI_JI:LS_Action();break;
  413. case DING_ZHI_JI:HMDZ_Action();break;
  414. case DA_ZHE_JI: BRUCE_DaZheJiAction();break;
  415. default:;
  416. }
  417. #endif
  418. }
  419. void PWMAction(void)
  420. {
  421. #if 0
  422. switch(MACHINE_TYPE)
  423. {
  424. case TEST_ACTION:break;
  425. case JIAO_YA_DIN_CUN:break;
  426. case CHU_CHI_JI:break;
  427. case JIAO_YA_CHU_CHI:break;
  428. case QIE_DUAN_JI:break;
  429. case CHUAN_TOU_QIE_DUAN_JI:break;
  430. case MXC_NILONG:break;
  431. case DA_KONG_JI:break;
  432. case JIN_SHU_DIN_CUN:break;
  433. case CHUAN_TOU_JI:break;
  434. case HUA_XIAN_JI:break;
  435. case JIN_SHU_KLSZ_JI:break;
  436. case HE_LIAN_JI:HL_PWMAction();break;
  437. case TIE_BU_JI:break;
  438. case YYA_JI:break;
  439. case SYYA_JI:break;
  440. case FANG_KUAI_CHA_XIAO_JI:break;
  441. case GONG_ZHI_MA:break;
  442. case LA_SI_JI:break;
  443. case DING_ZHI_JI:break;
  444. default:;
  445. }
  446. #endif
  447. }
  448. unsigned long no_addr_buff[2];
  449. //故障记录保存功能
  450. void AlarmMessageSave(unsigned short alarm_addr)
  451. {
  452. unsigned short i = 0;
  453. hw_flash_data_read(SAVE_MESSAGE_START_ADDR, no_addr_buff,8);
  454. alarm_message_buff[0] = (no_addr_buff[0] + 1) & 0x0000FFFF;
  455. alarm_message_buff[1] = (no_addr_buff[0] + 1) >> 16;
  456. for(i = 1;i < (ONE_MESSAGE_SIZE_WORD - 3);i++)alarm_message_buff[i + 1] = user_datas[SAV_MESSAGE_USER_DATAS_START_ADDR + i - 1];
  457. alarm_message_buff[ONE_MESSAGE_SIZE_WORD - 1] = mh_crc16_calc((unsigned char *)&alarm_message_buff[0],(ONE_MESSAGE_SIZE_WORD - 1) * 2);
  458. hw_flash_data_write(no_addr_buff[1],alarm_message_buff,ONE_MESSAGE_SIZE_WORD*2);
  459. hw_flash_data_write(SAVE_MESSAGE_START_ADDR,no_addr_buff,10);
  460. }
  461. //故障记录通讯读取功能
  462. void AlarmMessageRead(void)
  463. {
  464. unsigned short i;
  465. switch(ALARM_MESSAGE_CMD)
  466. {
  467. case CMD_READ_MESSAGE:
  468. {
  469. hw_flash_data_read(SAVE_MESSAGE_START_ADDR, no_addr_buff,8);
  470. user_datas[SAV_MESSAGE_USER_DATAS_START_ADDR] = no_addr_buff[0] & 0x0000FFFF;
  471. user_datas[SAV_MESSAGE_USER_DATAS_START_ADDR+1] = no_addr_buff[0] << 16;
  472. user_datas[SAV_MESSAGE_USER_DATAS_START_ADDR+2] = no_addr_buff[1] & 0x0000FFFF;
  473. user_datas[SAV_MESSAGE_USER_DATAS_START_ADDR+3] = no_addr_buff[1] << 16;
  474. }break;
  475. case CMD_READ_ALARM_MESSAGE:
  476. {
  477. hw_flash_data_read(SAVE_MESSAGE_START_ADDR, alarm_message_buff,ONE_MESSAGE_SIZE_WORD*2);
  478. for(i=1;i<ONE_MESSAGE_SIZE_WORD;i++)user_datas[SAV_MESSAGE_USER_DATAS_START_ADDR+2] = alarm_message_buff[i];
  479. }break;
  480. default:;
  481. }
  482. }
  483. //WIFI恢复默认出厂连接 wifi名: 123456 密码:88888888
  484. void ReSetWifi(void)
  485. {
  486. static unsigned short save_times;
  487. static unsigned long reset_wifi_delay;
  488. char wifi_name[] = "123456";
  489. char wifi_psd[] = "88888888";
  490. unsigned char i,j;
  491. if(CHANG_SHENG_GEI_LI_MACHINE)
  492. {
  493. strcpy(wifi_name, "123456");
  494. }
  495. if(((GPIOC->IDR >> 0) & 0x01) == 0)
  496. save_times++;
  497. else
  498. save_times = 0;
  499. if((save_times >= 10000) && (cWifiStep == 0))cWifiStep = 1;
  500. switch(cWifiStep)
  501. {
  502. case 0:break;
  503. case 1:
  504. {
  505. j =(unsigned char) (round(sizeof(wifi_name) / 2));
  506. for(i=0;i<j;i++)
  507. {
  508. user_datas[1605+i] = wifi_name[2*i];
  509. user_datas[1605+i] |= wifi_name[2*i+1] << 8;
  510. }
  511. j = 12;
  512. for(;i<j;i++)
  513. {
  514. user_datas[1605+i] = 0;
  515. }
  516. j = (unsigned char) (round(sizeof(wifi_psd) / 2));
  517. for(i=0;i<j;i++)
  518. {
  519. user_datas[1617+i] = wifi_psd[2*i];
  520. user_datas[1617+i] |= wifi_psd[2*i+1] << 8;
  521. }
  522. j = 12;
  523. for(;i<j;i++)
  524. {
  525. user_datas[1617+i] = 0;
  526. }
  527. run_led_speed = 50000;
  528. cWifiStep = 2;
  529. }break;
  530. case 2:
  531. {
  532. user_datas[1604] = 3;
  533. cWifiStep = 3;
  534. reset_wifi_delay = dwTickCount + 30000;
  535. }break;
  536. case 3:
  537. {
  538. if(user_datas[1602] == 2)
  539. {
  540. cWifiStep = 4;
  541. }
  542. else if(dwTickCount >= reset_wifi_delay)
  543. {
  544. cWifiStep = 0;
  545. run_led_speed = 500000;
  546. }
  547. }break;
  548. case 4:
  549. {
  550. if(save_times == 0)
  551. {
  552. cWifiStep = 0;
  553. run_led_speed = 500000;
  554. }
  555. }break;
  556. default:;
  557. }
  558. }
  559. void CheckTimeOver(void)
  560. {
  561. /* #if USE_PSW
  562. static unsigned long psw_cnt_delay = 0;
  563. if(dwTickCount >= psw_cnt_delay)
  564. {
  565. psw_cnt_delay = dwTickCount + 3600000;
  566. MACHINE_LOCK_TIME++;
  567. }
  568. if(MACHINE_LOCK_PSW != (MACHINE_BASE_PSW * MACHINE_TYPE+1))
  569. {
  570. if(MACHINE_LOCK_TIME >= (MACHINE_USE_DAY*24))
  571. {
  572. LockMachineFlg = 1;
  573. MACHINE_LOCK_TIME = (MACHINE_USE_DAY*24);
  574. }
  575. }
  576. else
  577. {
  578. MACHINE_PSW_ENABLE = 9527;
  579. }
  580. if(LockMachineFlg && (MACHINE_PSW_ENABLE != 9527))
  581. {
  582. Y00 = 0;
  583. Y04 = 0;
  584. Y06 = 0;
  585. AxisEgmStop(X_AXIS);
  586. }
  587. #endif*/
  588. }