Action.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  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 (FJ_YING_XING_MACHINE == 1)
  239. YX_Mechine_Config();
  240. #endif
  241. }
  242. void InitAction(void)
  243. {
  244. //生产测试程序
  245. #if (TEST_MACHINE == 1)
  246. Test_Mechine_InitAction();
  247. #endif
  248. //昌盛给力
  249. #if (CHANG_SHENG_GEI_LI_MACHINE == 1)
  250. GL_Mechine_InitAction();
  251. #endif
  252. //金龙拉链
  253. #if (JIN_LONG_MACHINE == 1)
  254. JL_Mechine_InitAction();
  255. #endif
  256. //传驰拉链
  257. #if (CHUAN_CHI_MACHINE == 1)
  258. CC_Mechine_InitAction();
  259. #endif
  260. //聚星拉链
  261. #if (JU_XING_MACHINE == 1)
  262. JX_Mechine_InitAction();
  263. #endif
  264. //安正拉练
  265. #if (An_Zhen_MACHINE == 1)
  266. AZ_Mechine_InitAction();
  267. #endif
  268. //锦泓拉链
  269. #if (JIN_HONG_MACHINE == 1)
  270. JH_Mechine_InitAction();
  271. #endif
  272. #if (FJ_YING_XING_MACHINE == 1)
  273. YX_Mechine_InitAction();
  274. #endif
  275. }
  276. void Action(void)
  277. {
  278. InputPinConfig();
  279. //生产测试程序
  280. #if (TEST_MACHINE == 1)
  281. Test_Mechine_Action();
  282. #endif
  283. //昌盛给力
  284. #if (CHANG_SHENG_GEI_LI_MACHINE == 1)
  285. GL_Mechine_Action();
  286. #endif
  287. //金龙拉链
  288. #if (JIN_LONG_MACHINE == 1)
  289. JL_Mechine_Action();
  290. #endif
  291. //传驰拉链
  292. #if (CHUAN_CHI_MACHINE == 1)
  293. CC_Mechine_Action();
  294. #endif
  295. //聚星拉链
  296. #if (JU_XING_MACHINE == 1)
  297. JX_Mechine_Action();
  298. #endif
  299. //安正拉链
  300. #if (An_Zhen_MACHINE == 1)
  301. AZ_Mechine_Action();
  302. #endif
  303. //锦泓拉链
  304. #if (JIN_HONG_MACHINE == 1)
  305. JH_Mechine_Action();
  306. #endif
  307. //盈兴拉链
  308. #if (FJ_YING_XING_MACHINE == 1)
  309. YX_Mechine_Action();
  310. #endif
  311. OutputPinConfig();
  312. }
  313. void DelayAction(void)
  314. {
  315. #if (JIN_HONG_MACHINE == 1)
  316. switch(MACHINE_TYPE)
  317. {
  318. case JIAO_YA_DIN_CUN:JYDC_DelayAction();break;
  319. // case CHU_CHI_JI:CCJ_DelayAction();break;
  320. // case JIAO_YA_CHU_CHI:
  321. // {
  322. // JYDC_DelayAction();
  323. // CCJ_DelayAction();
  324. // }break;
  325. default:;
  326. }
  327. #endif
  328. }
  329. //X30/X16外部中断动作
  330. void ExtiAcitionX30(void)
  331. {
  332. static int count;
  333. #if (JIN_HONG_MACHINE == 1)
  334. switch(cMachineType)
  335. {
  336. case JIAO_YA_DIN_CUN:
  337. count++;
  338. if(count>5)
  339. {
  340. jydc_use_x20=0;//检测到使用X30,关闭X20
  341. EXTI20Disable();
  342. }
  343. JYDC_ExtiActionX30(X30EXTI_IOIN);
  344. break;
  345. // case CHU_CHI_JI:;break;
  346. // case JIAO_YA_CHU_CHI:
  347. // {
  348. // JYDC_ExtiActionX30();
  349. // }break;
  350. default:;
  351. }
  352. #endif
  353. #if (CHANG_SHENG_GEI_LI_MACHINE == 1)
  354. switch(cMachineType)
  355. {
  356. case JIAO_YA_CHU_CHI:
  357. count++;
  358. if(count>5)
  359. {
  360. jydc_use_x20=0;//检测到使用X30,关闭X20
  361. EXTI20Disable();
  362. }
  363. JYDC_ExtiActionX30();
  364. break;
  365. // case CHU_CHI_JI:;break;
  366. // case JIAO_YA_CHU_CHI:
  367. // {
  368. // JYDC_ExtiActionX30();
  369. // }break;
  370. default:;
  371. }
  372. #endif
  373. }
  374. //X31/X17外部中断动作
  375. void ExtiAcitionX31(void)
  376. {
  377. //昌盛给力
  378. #if (CHANG_SHENG_GEI_LI_MACHINE == 1)
  379. switch(MACHINE_TYPE)
  380. {
  381. //case JIAO_YA_DIN_CUN:JYDC_ExtiActionX31();break;
  382. case MXC_NILONG:MXC_ExtiActionX31();break;
  383. //case QIE_DUAN_JI:QueDuan_ExtiActionX31();break;
  384. case CHUAN_TOU_QIE_DUAN_JI:QDCT_ExtiActionX31();break;
  385. default:;
  386. }
  387. #endif
  388. #if (JIN_HONG_MACHINE == 1)
  389. switch(MACHINE_TYPE)
  390. {
  391. case JIAO_YA_DIN_CUN:JYDC_ExtiActionX31();break;
  392. //case MXC_NILONG:MXC_ExtiActionX31();break;
  393. //case QIE_DUAN_JI:QueDuan_ExtiActionX31();break;
  394. //case CHUAN_TOU_QIE_DUAN_JI:QDCT_ExtiActionX31();break;
  395. default:;
  396. }
  397. #endif
  398. }
  399. //X20外部中断动作
  400. void ExtiAcitionX20(void)
  401. {
  402. static int count;
  403. //昌盛给力
  404. #if (CHANG_SHENG_GEI_LI_MACHINE == 1)
  405. switch(cMachineType)
  406. {
  407. case MXC_NILONG:MXC_ExtiActionX20();break;
  408. case JIAO_YA_CHU_CHI:
  409. count++;
  410. if(count>5)
  411. {
  412. jydc_use_x30=0;//检测到使用X20,关闭X30
  413. EXTI30Disable();
  414. }
  415. JYDC_ExtiActionX30();
  416. break;
  417. default:;
  418. }
  419. #endif
  420. #if (JIN_HONG_MACHINE == 1)
  421. switch(cMachineType)
  422. {
  423. case JIAO_YA_DIN_CUN:
  424. count++;
  425. if(count>5)
  426. {
  427. jydc_use_x30=0;//检测到使用X20,关闭X30
  428. EXTI30Disable();
  429. }
  430. JYDC_ExtiActionX30(X20EXTI_IOIN);
  431. break;
  432. // case CHU_CHI_JI:;break;
  433. // case JIAO_YA_CHU_CHI:
  434. // {
  435. // JYDC_ExtiActionX30();
  436. // }break;
  437. default:;
  438. }
  439. #endif
  440. }
  441. void PWMAction(void)
  442. {
  443. #if 0
  444. switch(MACHINE_TYPE)
  445. {
  446. case TEST_ACTION:break;
  447. case JIAO_YA_DIN_CUN:break;
  448. case CHU_CHI_JI:break;
  449. case JIAO_YA_CHU_CHI:break;
  450. case QIE_DUAN_JI:break;
  451. case CHUAN_TOU_QIE_DUAN_JI:break;
  452. case MXC_NILONG:break;
  453. case DA_KONG_JI:break;
  454. case JIN_SHU_DIN_CUN:break;
  455. case CHUAN_TOU_JI:break;
  456. case HUA_XIAN_JI:break;
  457. case JIN_SHU_KLSZ_JI:break;
  458. case HE_LIAN_JI:HL_PWMAction();break;
  459. case TIE_BU_JI:break;
  460. case YYA_JI:break;
  461. case SYYA_JI:break;
  462. case FANG_KUAI_CHA_XIAO_JI:break;
  463. case GONG_ZHI_MA:break;
  464. case LA_SI_JI:break;
  465. case DING_ZHI_JI:break;
  466. default:;
  467. }
  468. #endif
  469. }
  470. unsigned long no_addr_buff[2];
  471. //故障记录保存功能
  472. void AlarmMessageSave(unsigned short alarm_addr)
  473. {
  474. unsigned short i = 0;
  475. hw_flash_data_read(SAVE_MESSAGE_START_ADDR, no_addr_buff,8);
  476. alarm_message_buff[0] = (no_addr_buff[0] + 1) & 0x0000FFFF;
  477. alarm_message_buff[1] = (no_addr_buff[0] + 1) >> 16;
  478. 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];
  479. alarm_message_buff[ONE_MESSAGE_SIZE_WORD - 1] = mh_crc16_calc((unsigned char *)&alarm_message_buff[0],(ONE_MESSAGE_SIZE_WORD - 1) * 2);
  480. hw_flash_data_write(no_addr_buff[1],alarm_message_buff,ONE_MESSAGE_SIZE_WORD*2);
  481. hw_flash_data_write(SAVE_MESSAGE_START_ADDR,no_addr_buff,10);
  482. }
  483. //故障记录通讯读取功能
  484. void AlarmMessageRead(void)
  485. {
  486. unsigned short i;
  487. switch(ALARM_MESSAGE_CMD)
  488. {
  489. case CMD_READ_MESSAGE:
  490. {
  491. hw_flash_data_read(SAVE_MESSAGE_START_ADDR, no_addr_buff,8);
  492. user_datas[SAV_MESSAGE_USER_DATAS_START_ADDR] = no_addr_buff[0] & 0x0000FFFF;
  493. user_datas[SAV_MESSAGE_USER_DATAS_START_ADDR+1] = no_addr_buff[0] << 16;
  494. user_datas[SAV_MESSAGE_USER_DATAS_START_ADDR+2] = no_addr_buff[1] & 0x0000FFFF;
  495. user_datas[SAV_MESSAGE_USER_DATAS_START_ADDR+3] = no_addr_buff[1] << 16;
  496. }break;
  497. case CMD_READ_ALARM_MESSAGE:
  498. {
  499. hw_flash_data_read(SAVE_MESSAGE_START_ADDR, alarm_message_buff,ONE_MESSAGE_SIZE_WORD*2);
  500. for(i=1;i<ONE_MESSAGE_SIZE_WORD;i++)user_datas[SAV_MESSAGE_USER_DATAS_START_ADDR+2] = alarm_message_buff[i];
  501. }break;
  502. default:;
  503. }
  504. }
  505. //WIFI恢复默认出厂连接 wifi名: 123456 密码:88888888
  506. void ReSetWifi(void)
  507. {
  508. static unsigned short save_times;
  509. static unsigned long reset_wifi_delay;
  510. char wifi_name[] = "tiaoshiwifi";
  511. char wifi_psd[] = "88888888";
  512. unsigned char i,j;
  513. if(CHANG_SHENG_GEI_LI_MACHINE)
  514. {
  515. strcpy(wifi_name, "123456");
  516. }
  517. if(((GPIOD->IDR >> 8) & 0x01) == 0)
  518. save_times++;
  519. else
  520. save_times = 0;
  521. if((save_times >= 10000) && (cWifiStep == 0))cWifiStep = 1;
  522. switch(cWifiStep)
  523. {
  524. case 0:break;
  525. case 1:
  526. {
  527. j =(unsigned char)( round(sizeof(wifi_name) / 2));
  528. for(i=0;i<j;i++)
  529. {
  530. user_datas[1605+i] = wifi_name[2*i];
  531. user_datas[1605+i] |= wifi_name[2*i+1] << 8;
  532. }
  533. j = 12;
  534. for(;i<j;i++)
  535. {
  536. user_datas[1605+i] = 0;
  537. }
  538. j = (unsigned char)(round(sizeof(wifi_psd) / 2));
  539. for(i=0;i<j;i++)
  540. {
  541. user_datas[1617+i] = wifi_psd[2*i];
  542. user_datas[1617+i] |= wifi_psd[2*i+1] << 8;
  543. }
  544. j = 12;
  545. for(;i<j;i++)
  546. {
  547. user_datas[1617+i] = 0;
  548. }
  549. run_led_speed = 50000;
  550. cWifiStep = 2;
  551. }break;
  552. case 2:
  553. {
  554. user_datas[1604] = 3;
  555. cWifiStep = 3;
  556. reset_wifi_delay = dwTickCount + 30000;
  557. }break;
  558. case 3:
  559. {
  560. if(user_datas[1602] == 2)
  561. {
  562. cWifiStep = 4;
  563. }
  564. else if(dwTickCount >= reset_wifi_delay)
  565. {
  566. cWifiStep = 0;
  567. run_led_speed = 500000;
  568. }
  569. }break;
  570. case 4:
  571. {
  572. if(save_times == 0)
  573. {
  574. cWifiStep = 0;
  575. run_led_speed = 500000;
  576. }
  577. }break;
  578. default:;
  579. }
  580. }
  581. void CheckTimeOver(void)
  582. {
  583. /* #if USE_PSW
  584. static unsigned long psw_cnt_delay = 0;
  585. if(dwTickCount >= psw_cnt_delay)
  586. {
  587. psw_cnt_delay = dwTickCount + 3600000;
  588. MACHINE_LOCK_TIME++;
  589. }
  590. if(MACHINE_LOCK_PSW != (MACHINE_BASE_PSW * MACHINE_TYPE+1))
  591. {
  592. if(MACHINE_LOCK_TIME >= (MACHINE_USE_DAY*24))
  593. {
  594. LockMachineFlg = 1;
  595. MACHINE_LOCK_TIME = (MACHINE_USE_DAY*24);
  596. }
  597. }
  598. else
  599. {
  600. MACHINE_PSW_ENABLE = 9527;
  601. }
  602. if(LockMachineFlg && (MACHINE_PSW_ENABLE != 9527))
  603. {
  604. Y00 = 0;
  605. Y04 = 0;
  606. Y06 = 0;
  607. AxisEgmStop(X_AXIS);
  608. }
  609. #endif*/
  610. }