TYYYaJi.c 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. #include "global.h"
  2. #if TONG_YONG_MACHINE
  3. void YYa_AlarmProtect(void);
  4. void YYa_ManualAction(void);
  5. void YYa_AutoAction(void);
  6. void YYa_StepCheckStart(void);
  7. void YYa_ExtiActionX31(void);
  8. void YYa_SongLiao(void);
  9. YY_SingleParam_str *YY_SingleParam;
  10. YY_GroupParam_str *YY_GroupParam;
  11. YY_SystemParam_str *YY_SystemParam;
  12. YY_ComponentParam_str *YY_ComponentParam;
  13. void YYa_ExtiActionX31(void)
  14. {
  15. }
  16. void YYa_SetAlarmCode(unsigned alarm_code)
  17. {
  18. SetAlarmCode(YY_ALARM_ADDR,alarm_code);
  19. bAlarmStop = 1;
  20. }
  21. void YYa_SetLifeAlarmCode(unsigned alarm_code)
  22. {
  23. YY_ComponentParam->LifeAlarm |= 0x0001 << alarm_code;
  24. }
  25. void YYa_InitAction(void)
  26. {
  27. YY_SingleParam = (YY_SingleParam_str *)&user_datas[YY_SINGLE_ADDR];
  28. YY_GroupParam = (YY_GroupParam_str *)&user_datas[YY_GROUP_ADDR];
  29. YY_SystemParam = (YY_SystemParam_str *)&user_datas[YY_SYSTEM_ADDR];
  30. YY_ComponentParam = (YY_ComponentParam_str *)&user_datas[YY_LIFE_ADDR];
  31. }
  32. void YYa_Action(void)
  33. {
  34. YYa_AlarmProtect();
  35. YYa_ManualAction();
  36. YYa_AutoAction();
  37. YYa_SongLiao();
  38. YYa_StepCheckStart(); // 调用脚踏开关检测程序
  39. }
  40. //手动动作
  41. void YYa_ManualAction(void)
  42. {
  43. //合链机启动
  44. if(YY_bHL)
  45. {
  46. if(YY_HL_DW_IN)
  47. {
  48. YY_YL_MOTOR = 1;
  49. YY_HL_MOTOR = 1;
  50. }
  51. else if(YY_HL_UP_IN)
  52. {
  53. YY_YL_MOTOR = 0;
  54. YY_HL_MOTOR = 0;
  55. }
  56. }
  57. else
  58. {
  59. YY_YL_MOTOR = 0;
  60. YY_HL_MOTOR = 0;
  61. }
  62. if(YY_bPYMotor)
  63. {
  64. YY_bPYMotor = 0;
  65. if(YY_MAIN_MOTOR)
  66. {
  67. if(!bRunning)YY_bPYControl = 0;
  68. }
  69. else if(YY_bZhuYou && !YY_bOnceStartPower) YY_bPYControl = 1;
  70. }
  71. if(YY_bPYControl)
  72. {
  73. if(YY_MAIN_MOTOR == 0)
  74. {
  75. YY_CheckDelay = dwTickCount + 1000;
  76. YY_OIL_MOTOR = 1;
  77. YY_ZhuYouDelay = dwTickCount + 1000*YY_SystemParam->OilTime;
  78. YY_CheckDelay = dwTickCount + 2500;
  79. }
  80. YY_MAIN_MOTOR = 1;
  81. YY_SD_MOTOR = 1;
  82. }
  83. else
  84. {
  85. if(YY_MAIN_MOTOR)
  86. {
  87. YY_CheckDelay = dwTickCount + 1000;
  88. }
  89. YY_MAIN_MOTOR = 0;
  90. YY_SD_MOTOR = 0;
  91. }
  92. if(bClearTotal)
  93. {
  94. bClearTotal = 0;
  95. switch(YY_bMode)
  96. {
  97. case YY_SINGLE_MODE:
  98. {
  99. YY_SingleParam->OverTotal = 0;
  100. YY_SingleParam->OverLength = 0;
  101. YY_SingleParam->SetTimeHour = 0;
  102. YY_SingleParam->SetTimeMinute = 0;
  103. }break;
  104. case YY_GROUP_MODE:
  105. {
  106. YY_GroupParam->AllOverTotal = 0;
  107. YY_GroupParam->AllOverLength = 0;
  108. YY_GroupParam->SetTimeHour = 0;
  109. YY_GroupParam->SetTimeMinute = 0;
  110. }break;
  111. }
  112. }
  113. if(YY_bClearAll)
  114. {
  115. YY_bClearAll = 0;
  116. YY_SystemParam->AllProductTime = 0;
  117. YY_SystemParam->AllProductLength = 0;
  118. }
  119. }
  120. void YYa_AlarmProtect(void)
  121. {
  122. }
  123. void YYa_AutoAction(void)
  124. {
  125. if(bRunning)
  126. {
  127. }
  128. }
  129. void YYa_SongLiao(void)
  130. {
  131. //送丝启动
  132. if(M0035)
  133. {
  134. //左送料(送丝)
  135. if(YY_LEFT_SL_DW_IN)
  136. {
  137. YY_LEFT_SL_MOTOR = 1;
  138. }
  139. else if(YY_LEFT_SL_UP_IN)
  140. {
  141. YY_LEFT_SL_MOTOR = 0;
  142. }
  143. //右送料(送丝)
  144. if(YY_RIGHT_SL_DW_IN)
  145. {
  146. YY_RIGHT_SL_MOTOR = 1;
  147. }
  148. else if(YY_RIGHT_SL_UP_IN)
  149. {
  150. YY_RIGHT_SL_MOTOR = 0;
  151. }
  152. }
  153. else
  154. {
  155. YY_LEFT_SL_MOTOR = 0;
  156. YY_RIGHT_SL_MOTOR = 0;
  157. }
  158. }
  159. void YYa_StepCheckStart(void)
  160. {
  161. // 启动
  162. if((YY_START_IN_UP) || bStart || YY_bSingle)
  163. {
  164. bStart = 0;
  165. if(!bRunning && (YY_AutoStep == 0))
  166. {
  167. {
  168. bRunning = 1;
  169. if(YY_bSingle) SingOneFlg= 1;
  170. }
  171. }
  172. YY_bSingle = 0;
  173. }
  174. //停止
  175. if(YY_STOP_IN_UP || bStop)
  176. {
  177. bStop = 0;
  178. if(bRunning)
  179. {
  180. bRunning = 0;
  181. if(GetAlarmCode(YY_ALARM_ADDR) != 0)SetAlarmCode(YY_ALARM_ADDR,0);
  182. }
  183. else
  184. {
  185. if(GetAlarmCode(YY_ALARM_ADDR) != 0)SetAlarmCode(YY_ALARM_ADDR,0);
  186. }
  187. }
  188. if(bAlarmStop)
  189. {
  190. }
  191. }
  192. //零件寿命相关控制和运算
  193. void YYa_CalParts(void)
  194. {
  195. // AddUsedLifeControl();
  196. if(YY_bClearLife1)
  197. {
  198. YY_bClearLife1 = 0;
  199. YY_ComponentParam->LeftRightLife[0] = 0;
  200. YY_ComponentParam->LeftRightUsedLife[0] = 0;
  201. YY_ComponentParam->RefreshTimes[0]++;
  202. }
  203. if(YY_bClearTimes1)
  204. {
  205. YY_bClearTimes1 = 0;
  206. YY_ComponentParam->RefreshTimes[0] = 0;
  207. }
  208. if(YY_bClearLife2)
  209. {
  210. YY_bClearLife2 = 0;
  211. YY_ComponentParam->LeftRightLife[1] = 0;
  212. YY_ComponentParam->LeftRightUsedLife[1] = 0;
  213. YY_ComponentParam->RefreshTimes[1]++;
  214. }
  215. if(YY_bClearTimes2)
  216. {
  217. YY_bClearTimes2 = 0;
  218. YY_ComponentParam->RefreshTimes[1] = 0;
  219. }
  220. if(YY_bClearLife3)
  221. {
  222. YY_bClearLife3 = 0;
  223. YY_ComponentParam->LeftRightLife[2] = 0;
  224. YY_ComponentParam->LeftRightUsedLife[2] = 0;
  225. YY_ComponentParam->RefreshTimes[2]++;
  226. }
  227. if(YY_bClearTimes3)
  228. {
  229. YY_bClearTimes3 = 0;
  230. YY_ComponentParam->RefreshTimes[2] = 0;
  231. }
  232. if(YY_bClearLife4)
  233. {
  234. YY_bClearLife4 = 0;
  235. YY_ComponentParam->LeftRightLife[3] = 0;
  236. YY_ComponentParam->LeftRightUsedLife[3] = 0;
  237. YY_ComponentParam->RefreshTimes[3]++;
  238. }
  239. if(YY_bClearTimes4)
  240. {
  241. YY_bClearTimes4 = 0;
  242. YY_ComponentParam->RefreshTimes[3] = 0;
  243. }
  244. if(YY_bClearLife5)
  245. {
  246. YY_bClearLife5 = 0;
  247. YY_ComponentParam->LeftRightLife[4] = 0;
  248. YY_ComponentParam->LeftRightUsedLife[4] = 0;
  249. YY_ComponentParam->RefreshTimes[4]++;
  250. }
  251. if(YY_bClearTimes5)
  252. {
  253. YY_bClearTimes5 = 0;
  254. YY_ComponentParam->RefreshTimes[4] = 0;
  255. }
  256. if(YY_bClearLife6)
  257. {
  258. YY_bClearLife6 = 0;
  259. YY_ComponentParam->LeftRightLife[5] = 0;
  260. YY_ComponentParam->LeftRightUsedLife[5] = 0;
  261. YY_ComponentParam->RefreshTimes[5]++;
  262. }
  263. if(YY_bClearTimes6)
  264. {
  265. YY_bClearTimes6 = 0;
  266. YY_ComponentParam->RefreshTimes[5] = 0;
  267. }
  268. if(YY_bClearLife7)
  269. {
  270. YY_bClearLife7 = 0;
  271. YY_ComponentParam->LeftRightLife[6] = 0;
  272. YY_ComponentParam->LeftRightUsedLife[6] = 0;
  273. YY_ComponentParam->RefreshTimes[6]++;
  274. }
  275. if(YY_bClearTimes7)
  276. {
  277. YY_bClearTimes7 = 0;
  278. YY_ComponentParam->RefreshTimes[6] = 0;
  279. }
  280. if(YY_bClearLife8)
  281. {
  282. YY_bClearLife8 = 0;
  283. YY_ComponentParam->LeftRightLife[7] = 0;
  284. YY_ComponentParam->LeftRightUsedLife[7] = 0;
  285. YY_ComponentParam->RefreshTimes[7]++;
  286. }
  287. if(YY_bClearTimes8)
  288. {
  289. YY_bClearTimes8 = 0;
  290. YY_ComponentParam->RefreshTimes[7] = 0;
  291. }
  292. if(YY_bClearLife9)
  293. {
  294. YY_bClearLife9 = 0;
  295. YY_ComponentParam->LeftRightLife[8] = 0;
  296. YY_ComponentParam->LeftRightUsedLife[8] = 0;
  297. YY_ComponentParam->RefreshTimes[8]++;
  298. }
  299. if(YY_bClearTimes9)
  300. {
  301. YY_bClearTimes9 = 0;
  302. YY_ComponentParam->RefreshTimes[8] = 0;
  303. }
  304. if(YY_bClearLife10)
  305. {
  306. YY_bClearLife10 = 0;
  307. YY_ComponentParam->LeftRightLife[9] = 0;
  308. YY_ComponentParam->LeftRightUsedLife[9] = 0;
  309. YY_ComponentParam->RefreshTimes[9]++;
  310. }
  311. if(YY_bClearTimes10)
  312. {
  313. YY_bClearTimes10 = 0;
  314. YY_ComponentParam->RefreshTimes[9] = 0;
  315. }
  316. if(YY_bClearLife11)
  317. {
  318. YY_bClearLife11 = 0;
  319. YY_ComponentParam->LeftRightLife[10] = 0;
  320. YY_ComponentParam->LeftRightUsedLife[10] = 0;
  321. YY_ComponentParam->RefreshTimes[10]++;
  322. }
  323. if(YY_bClearTimes11)
  324. {
  325. YY_bClearTimes1 = 0;
  326. YY_ComponentParam->RefreshTimes[10] = 0;
  327. }
  328. if(YY_bClearLife12)
  329. {
  330. YY_bClearLife12 = 0;
  331. YY_ComponentParam->LeftRightLife[11] = 0;
  332. YY_ComponentParam->LeftRightUsedLife[11] = 0;
  333. YY_ComponentParam->RefreshTimes[11]++;
  334. }
  335. if(YY_bClearTimes12)
  336. {
  337. YY_bClearTimes12 = 0;
  338. YY_ComponentParam->RefreshTimes[11] = 0;
  339. }
  340. if(YY_bClearLife13)
  341. {
  342. YY_bClearLife13 = 0;
  343. YY_ComponentParam->LeftRightLife[12] = 0;
  344. YY_ComponentParam->LeftRightUsedLife[12] = 0;
  345. YY_ComponentParam->RefreshTimes[12]++;
  346. }
  347. if(YY_bClearTimes13)
  348. {
  349. YY_bClearTimes13 = 0;
  350. YY_ComponentParam->RefreshTimes[12] = 0;
  351. }
  352. if(YY_bClearLife14)
  353. {
  354. YY_bClearLife14 = 0;
  355. YY_ComponentParam->LeftRightLife[13] = 0;
  356. YY_ComponentParam->LeftRightUsedLife[13] = 0;
  357. YY_ComponentParam->RefreshTimes[13]++;
  358. }
  359. if(YY_bClearTimes14)
  360. {
  361. YY_bClearTimes14 = 0;
  362. YY_ComponentParam->RefreshTimes[13] = 0;
  363. }
  364. if(YY_bClearLife15)
  365. {
  366. YY_bClearLife15 = 0;
  367. YY_ComponentParam->LeftRightLife[14] = 0;
  368. YY_ComponentParam->LeftRightUsedLife[14] = 0;
  369. YY_ComponentParam->RefreshTimes[14]++;
  370. }
  371. if(YY_bClearTimes15)
  372. {
  373. YY_bClearTimes15 = 0;
  374. YY_ComponentParam->RefreshTimes[14] = 0;
  375. }
  376. if(YY_bClearLife16)
  377. {
  378. YY_bClearLife16 = 0;
  379. YY_ComponentParam->LeftRightLife[15] = 0;
  380. YY_ComponentParam->LeftRightUsedLife[15] = 0;
  381. YY_ComponentParam->RefreshTimes[15]++;
  382. }
  383. if(YY_bClearTimes16)
  384. {
  385. YY_bClearTimes16 = 0;
  386. YY_ComponentParam->RefreshTimes[15] = 0;
  387. }
  388. }
  389. #endif