Action.c 16 KB

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