Action.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  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. //俊跃
  244. #if (JUN_YUE_MACHINE == 1)
  245. JUNYUE_Mechine_InitAction();
  246. #endif
  247. // DEFAULT_OUT = 0;
  248. // DEFAULT_IN = 0;
  249. IOPinConfigure(); //初始化默認值
  250. if(MACHINE_BOOT_WIFI)
  251. {
  252. M1000 = 1;
  253. user_datas[1604] = 1;
  254. }
  255. }
  256. void DelayAction(void)
  257. {
  258. #if 0
  259. switch(MACHINE_TYPE)
  260. {
  261. case JIAO_YA_DIN_CUN:JYDC_DelayAction();break;
  262. case CHU_CHI_JI:CCJ_DelayAction();break;
  263. case JIAO_YA_CHU_CHI:
  264. {
  265. JYDC_DelayAction();
  266. CCJ_DelayAction();
  267. }break;
  268. default:;
  269. }
  270. #endif
  271. }
  272. //X30/X16外部中断动作
  273. void ExtiAcitionX30(void)
  274. {
  275. #if 0
  276. switch(MACHINE_TYPE)
  277. {
  278. case JIAO_YA_DIN_CUN:JYDC_ExtiActionX30();break;
  279. case CHU_CHI_JI:;break;
  280. case JIAO_YA_CHU_CHI:
  281. {
  282. JYDC_ExtiActionX30();
  283. }break;
  284. default:;
  285. }
  286. #endif
  287. }
  288. //X31/X17外部中断动作
  289. void ExtiAcitionX31(void)
  290. {
  291. #if 0
  292. switch(MACHINE_TYPE)
  293. {
  294. case JIAO_YA_DIN_CUN:JYDC_ExtiActionX31();break;
  295. case MXC_NILONG:MXC_ExtiActionX31();break;
  296. case QIE_DUAN_JI:QueDuan_ExtiActionX31();break;
  297. case CHUAN_TOU_QIE_DUAN_JI:QDCT_ExtiActionX31();break;
  298. default:;
  299. }
  300. #endif
  301. }
  302. //X20外部中断动作
  303. void ExtiAcitionX20(void)
  304. {
  305. #if 0
  306. switch(MACHINE_TYPE)
  307. {
  308. case MXC_NILONG:MXC_ExtiActionX20();break;
  309. default:;
  310. }
  311. #endif
  312. }
  313. void Action(void)
  314. {
  315. InputPinConfig(); //输入可变
  316. #if (XIN_YE_MACHINE == 1) //由厂家程序内部选择
  317. XY_Mechine_Action();
  318. #endif
  319. //金龙
  320. #if (JING_LONG_MACHINE == 1)
  321. JL_Mechine_Action();
  322. #endif
  323. #if (LONG_YI_MACHINE == 1) //由厂家程序内部选择
  324. LY_Mechine_Action();
  325. #endif
  326. //昌盛给力
  327. #if (CHANG_SHENG_GEI_LI_MACHINE == 1)
  328. GL_Mechine_Action();
  329. #endif
  330. //宇纹轩
  331. #if (YU_WEN_XUAN_MACHINE == 1)
  332. YWX_Mechine_Action();
  333. #endif
  334. //福建盈兴
  335. #if (FJ_YING_XING_MACHINE == 1)
  336. YX_Mechine_Action();
  337. #endif
  338. //张春阳
  339. #if (ZHANG_CHUN_YANG_MACHINE == 1)
  340. ZCY_Mechine_Action();
  341. #endif
  342. //福建传驰
  343. #if (Chuan_Chi_MACHINE == 1)
  344. CC_Mechine_Action();
  345. #endif
  346. //虎门飞跃
  347. #if (FIE_YUE_MACHINE == 1)
  348. FY_Mechine_Action();
  349. #endif
  350. //付小伟
  351. #if (FU_XIAO_WEI_MACHINE == 1)
  352. FXW_Mechine_Action();
  353. #endif
  354. //锦泓
  355. #if (JIN_HONG_MACHINE == 1)
  356. JH_Mechine_Action();
  357. #endif
  358. //振宇
  359. #if (ZHEN_YU_MACHINE == 1)
  360. ZHENYU_Mechine_Action();
  361. #endif
  362. //俊跃
  363. #if (JUN_YUE_MACHINE == 1)
  364. JUNYUE_Mechine_Action();
  365. #endif
  366. OutputPinConfig(); //输出可变
  367. #if 0
  368. switch(MACHINE_TYPE)
  369. {
  370. case TEST_ACTION:TestAction();break;
  371. case JIAO_YA_DIN_CUN:JYDC_Action();break;
  372. case CHU_CHI_JI:CCJ_Action();break;
  373. case JIAO_YA_CHU_CHI:
  374. {
  375. if(bStop)
  376. {
  377. bStop = 0;
  378. JYDC_bStop = 1;
  379. CCJ_bStop = 1;
  380. }
  381. if(START_IN_UP)
  382. {
  383. AllRunFlg = 1;
  384. }
  385. if(STOP_IN_UP)
  386. {
  387. AllRunFlg = 0;
  388. }
  389. if(AllRunFlg)
  390. {
  391. if(JYDC_ChuDai_IN)JYDCRunFlg = 0;
  392. else
  393. JYDCRunFlg = 1;
  394. if(CCJ_ChuDai_IN)CCJRunFlg = 0;
  395. else CCJRunFlg = 1;
  396. }
  397. else
  398. {
  399. JYDCRunFlg = 1;
  400. if(CCJ_ChuDai_IN)CCJRunFlg = 0;
  401. else CCJRunFlg = 1;
  402. }
  403. JYDC_Action();
  404. CCJ_Action();
  405. }break;
  406. case QIE_DUAN_JI:QueDuan_Action();break;
  407. case CHUAN_TOU_QIE_DUAN_JI:QDCT_Action();break;
  408. case MXC_NILONG:MXC_NiLongXiuCiJiAction();break;
  409. case DA_KONG_JI:DK_Action();break;
  410. case JIN_SHU_DIN_CUN:JSDC_Action();break;
  411. case CHUAN_TOU_JI:ChuanTou_Action();break;
  412. case HUA_XIAN_JI:HuaXian_Action();break;
  413. case JIN_SHU_KLSZ_JI:JSKL_Action();break;
  414. case HE_LIAN_JI:HL_Action();break;
  415. case TIE_BU_JI:TBJ_Action();break;
  416. case YYA_JI:YYa_Action();break;
  417. case SYYA_JI:SYYa_Action();break;
  418. case FANG_KUAI_CHA_XIAO_JI:FKCX_Action();break;
  419. case GONG_ZHI_MA:GZM_Action();break;
  420. case LA_SI_JI:LS_Action();break;
  421. case DING_ZHI_JI:HMDZ_Action();break;
  422. case DA_ZHE_JI: BRUCE_DaZheJiAction();break;
  423. default:;
  424. }
  425. #endif
  426. }
  427. void PWMAction(void)
  428. {
  429. #if 0
  430. switch(MACHINE_TYPE)
  431. {
  432. case TEST_ACTION:break;
  433. case JIAO_YA_DIN_CUN:break;
  434. case CHU_CHI_JI:break;
  435. case JIAO_YA_CHU_CHI:break;
  436. case QIE_DUAN_JI:break;
  437. case CHUAN_TOU_QIE_DUAN_JI:break;
  438. case MXC_NILONG:break;
  439. case DA_KONG_JI:break;
  440. case JIN_SHU_DIN_CUN:break;
  441. case CHUAN_TOU_JI:break;
  442. case HUA_XIAN_JI:break;
  443. case JIN_SHU_KLSZ_JI:break;
  444. case HE_LIAN_JI:HL_PWMAction();break;
  445. case TIE_BU_JI:break;
  446. case YYA_JI:break;
  447. case SYYA_JI:break;
  448. case FANG_KUAI_CHA_XIAO_JI:break;
  449. case GONG_ZHI_MA:break;
  450. case LA_SI_JI:break;
  451. case DING_ZHI_JI:break;
  452. default:;
  453. }
  454. #endif
  455. }
  456. unsigned long no_addr_buff[2];
  457. //故障记录保存功能
  458. void AlarmMessageSave(unsigned short alarm_addr)
  459. {
  460. unsigned short i = 0;
  461. hw_flash_data_read(SAVE_MESSAGE_START_ADDR, no_addr_buff,8);
  462. alarm_message_buff[0] = (no_addr_buff[0] + 1) & 0x0000FFFF;
  463. alarm_message_buff[1] = (no_addr_buff[0] + 1) >> 16;
  464. 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];
  465. alarm_message_buff[ONE_MESSAGE_SIZE_WORD - 1] = mh_crc16_calc((unsigned char *)&alarm_message_buff[0],(ONE_MESSAGE_SIZE_WORD - 1) * 2);
  466. hw_flash_data_write(no_addr_buff[1],alarm_message_buff,ONE_MESSAGE_SIZE_WORD*2);
  467. hw_flash_data_write(SAVE_MESSAGE_START_ADDR,no_addr_buff,10);
  468. }
  469. //故障记录通讯读取功能
  470. void AlarmMessageRead(void)
  471. {
  472. unsigned short i;
  473. switch(ALARM_MESSAGE_CMD)
  474. {
  475. case CMD_READ_MESSAGE:
  476. {
  477. hw_flash_data_read(SAVE_MESSAGE_START_ADDR, no_addr_buff,8);
  478. user_datas[SAV_MESSAGE_USER_DATAS_START_ADDR] = no_addr_buff[0] & 0x0000FFFF;
  479. user_datas[SAV_MESSAGE_USER_DATAS_START_ADDR+1] = no_addr_buff[0] << 16;
  480. user_datas[SAV_MESSAGE_USER_DATAS_START_ADDR+2] = no_addr_buff[1] & 0x0000FFFF;
  481. user_datas[SAV_MESSAGE_USER_DATAS_START_ADDR+3] = no_addr_buff[1] << 16;
  482. }break;
  483. case CMD_READ_ALARM_MESSAGE:
  484. {
  485. hw_flash_data_read(SAVE_MESSAGE_START_ADDR, alarm_message_buff,ONE_MESSAGE_SIZE_WORD*2);
  486. for(i=1;i<ONE_MESSAGE_SIZE_WORD;i++)user_datas[SAV_MESSAGE_USER_DATAS_START_ADDR+2] = alarm_message_buff[i];
  487. }break;
  488. default:;
  489. }
  490. }
  491. //WIFI恢复默认出厂连接 wifi名: 123456 密码:88888888
  492. void ReSetWifi(void)
  493. {
  494. static unsigned short save_times;
  495. static unsigned long reset_wifi_delay;
  496. char wifi_name[] = "123456";
  497. char wifi_psd[] = "88888888";
  498. unsigned char i,j;
  499. if(CHANG_SHENG_GEI_LI_MACHINE)
  500. {
  501. strcpy(wifi_name, "123456");
  502. }
  503. if(((GPIOC->IDR >> 0) & 0x01) == 0)
  504. save_times++;
  505. else
  506. save_times = 0;
  507. if((save_times >= 10000) && (cWifiStep == 0))cWifiStep = 1;
  508. switch(cWifiStep)
  509. {
  510. case 0:break;
  511. case 1:
  512. {
  513. j =(unsigned char) (round(sizeof(wifi_name) / 2));
  514. for(i=0;i<j;i++)
  515. {
  516. user_datas[1605+i] = wifi_name[2*i];
  517. user_datas[1605+i] |= wifi_name[2*i+1] << 8;
  518. }
  519. j = 12;
  520. for(;i<j;i++)
  521. {
  522. user_datas[1605+i] = 0;
  523. }
  524. j = (unsigned char) (round(sizeof(wifi_psd) / 2));
  525. for(i=0;i<j;i++)
  526. {
  527. user_datas[1617+i] = wifi_psd[2*i];
  528. user_datas[1617+i] |= wifi_psd[2*i+1] << 8;
  529. }
  530. j = 12;
  531. for(;i<j;i++)
  532. {
  533. user_datas[1617+i] = 0;
  534. }
  535. run_led_speed = 50000;
  536. cWifiStep = 2;
  537. }break;
  538. case 2:
  539. {
  540. user_datas[1604] = 3;
  541. cWifiStep = 3;
  542. reset_wifi_delay = dwTickCount + 30000;
  543. }break;
  544. case 3:
  545. {
  546. if(user_datas[1602] == 2)
  547. {
  548. cWifiStep = 4;
  549. }
  550. else if(dwTickCount >= reset_wifi_delay)
  551. {
  552. cWifiStep = 0;
  553. run_led_speed = 500000;
  554. }
  555. }break;
  556. case 4:
  557. {
  558. if(save_times == 0)
  559. {
  560. cWifiStep = 0;
  561. run_led_speed = 500000;
  562. }
  563. }break;
  564. default:;
  565. }
  566. }
  567. void CheckTimeOver(void)
  568. {
  569. /* #if USE_PSW
  570. static unsigned long psw_cnt_delay = 0;
  571. if(dwTickCount >= psw_cnt_delay)
  572. {
  573. psw_cnt_delay = dwTickCount + 3600000;
  574. MACHINE_LOCK_TIME++;
  575. }
  576. if(MACHINE_LOCK_PSW != (MACHINE_BASE_PSW * MACHINE_TYPE+1))
  577. {
  578. if(MACHINE_LOCK_TIME >= (MACHINE_USE_DAY*24))
  579. {
  580. LockMachineFlg = 1;
  581. MACHINE_LOCK_TIME = (MACHINE_USE_DAY*24);
  582. }
  583. }
  584. else
  585. {
  586. MACHINE_PSW_ENABLE = 9527;
  587. }
  588. if(LockMachineFlg && (MACHINE_PSW_ENABLE != 9527))
  589. {
  590. Y00 = 0;
  591. Y04 = 0;
  592. Y06 = 0;
  593. AxisEgmStop(X_AXIS);
  594. }
  595. #endif*/
  596. }