IoTriStateLift2.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Event;
  3. using Aitex.Core.RT.IOCore;
  4. using System.Xml;
  5. using System.Diagnostics;
  6. using Aitex.Core.Common.DeviceData;
  7. using Aitex.Core.RT.DataCenter;
  8. using Aitex.Core.RT.SCCore;
  9. using Aitex.Core.RT.OperationCenter;
  10. using VirgoCommon;
  11. using Aitex.Core.RT.Log;
  12. using Aitex.Core.Util;
  13. namespace VirgoRT.Devices
  14. {
  15. public class IoTriStateLift2 : BaseDevice, IDevice
  16. {
  17. private readonly DIAccessor _diOrigin;//是否到达原点
  18. private readonly DIAccessor _diOrigin2;
  19. private readonly DIAccessor _diOrigin3;
  20. private readonly DIAccessor _diP1;//是否到达位置1
  21. private readonly DIAccessor _diP2;//是否到达位置2
  22. private readonly DIAccessor _diP3;//是否到达位置3
  23. private readonly DIAccessor _diCOMMAlarm;//去位置1,2,3超时
  24. private readonly DIAccessor _diBatteryLowAlarm;//去原点超时
  25. private readonly DIAccessor _di1_L_Servo_Driver_Alarm;
  26. private readonly DIAccessor _di1_L_Servo_Driver_Warning;
  27. private readonly DIAccessor _di1_Search_ORG_Fail_Alarm;
  28. private readonly DIAccessor _di1_ABS_Fail_Alarm;
  29. private readonly DIAccessor _di1_Up_Limit_Alarm;
  30. private readonly DIAccessor _di1_Down_Limit_Alarm;
  31. private readonly DIAccessor _di1_Over_Software_Alarm;
  32. private readonly DIAccessor _di2_L_Servo_Driver_Alarm;
  33. private readonly DIAccessor _di2_L_Servo_Driver_Warning;
  34. private readonly DIAccessor _di2_Search_ORG_Fail_Alarm;
  35. private readonly DIAccessor _di2_ABS_Fail_Alarm;
  36. private readonly DIAccessor _di2_Up_Limit_Alarm;
  37. private readonly DIAccessor _di2_Down_Limit_Alarm;
  38. private readonly DIAccessor _di2_Over_Software_Alarm;
  39. // private readonly DIAccessor _diServoAlarm; // servo alarm
  40. // private readonly DIAccessor _diCCWLimitSensorAlarm; //
  41. //private readonly DIAccessor _diOverSoftwareLimitAlarm; //
  42. private readonly DOAccessor _doReset;
  43. private readonly DOAccessor _doOrigin;//去原点
  44. private readonly DOAccessor _doP1;//去位置1
  45. private readonly DOAccessor _doP2;//去位置2
  46. private readonly DOAccessor _doP3;//去位置3
  47. private readonly DOAccessor _doStop;
  48. private readonly DOAccessor _doUp;
  49. private readonly DOAccessor _doDown;
  50. private readonly AIAccessor _currentValue;
  51. private readonly AOAccessor _aoSetP1;
  52. private readonly AOAccessor _aoSetP2;
  53. private readonly AOAccessor _aoSetP3;
  54. private readonly AOAccessor _aoServoEnable;
  55. private readonly AOAccessor _aoServoWorkMode;
  56. private readonly AOAccessor _aoOriginSpeed;
  57. private readonly AOAccessor _aoAutoSpeed;
  58. private readonly AOAccessor _aoManualSpeed;
  59. private readonly AOAccessor _aoAccDecSpeedTime;
  60. private readonly AOAccessor _aoPosDiff;
  61. private readonly AOAccessor _aoDecTime;
  62. private readonly AOAccessor _aoSoftUpLimit;
  63. private readonly AOAccessor _aoSoftDownLimit;
  64. private readonly AOAccessor _aoCorrectionValue;
  65. private Stopwatch swOrigin = new Stopwatch();
  66. private Stopwatch sw = new Stopwatch();
  67. private Stopwatch _manualStopTimer = new Stopwatch();
  68. private readonly int _stopButtonAutoResetTime = 1000;
  69. private Position _currentTarget = Position.Invalid;
  70. private Position _preTarget = Position.Invalid;
  71. long _timeout = 60000;
  72. private bool _bAlarmReported = false;
  73. private AITTriStateLiftPinData DeviceData
  74. {
  75. get
  76. {
  77. AITTriStateLiftPinData deviceData = new AITTriStateLiftPinData
  78. {
  79. Module = Module,
  80. DeviceName = Name,
  81. DeviceSchematicId = DeviceID,
  82. DisplayName = Display,
  83. };
  84. return deviceData;
  85. }
  86. }
  87. public MovementPosition PinPosition
  88. {
  89. get
  90. {
  91. if ((_preTarget == Position.position1 && _diP1.Value) && _diP2.Value == false && _diP3.Value == false)
  92. return MovementPosition.Up;
  93. else if (_diP1.Value == false && (_diP2.Value && _preTarget == Position.position2) && _diP3.Value == false)
  94. return MovementPosition.Middle;
  95. else if (_diP1.Value == false && _diP2.Value == false && (_diP3.Value && _preTarget == Position.position3))
  96. return MovementPosition.Down;
  97. else if (_diOrigin.Value && _diOrigin2.Value && _diOrigin3.Value && _preTarget == Position.origin)
  98. return MovementPosition.Origin;
  99. return MovementPosition.Unknown;
  100. }
  101. }
  102. public int PinPositionint
  103. {
  104. get
  105. {
  106. if (PinPosition == MovementPosition.Up)
  107. return 3;
  108. else if (PinPosition == MovementPosition.Middle)
  109. return 2;
  110. else if (PinPosition == MovementPosition.Down)
  111. return 1;
  112. else if (PinPosition == MovementPosition.Origin)
  113. return 0;
  114. return -1;
  115. }
  116. }
  117. public IoTriStateLift2(string module, XmlElement node, string ioModule = "")
  118. {
  119. base.Module = module;
  120. base.Name = node.GetAttribute("id");
  121. base.Display = node.GetAttribute("display");
  122. base.DeviceID = node.GetAttribute("schematicId");
  123. _diOrigin = ParseDiNode("diOrigin", node, ioModule);
  124. _diOrigin2 = ParseDiNode("diOrigin2", node, ioModule);
  125. _diOrigin3 = ParseDiNode("diOrigin3", node, ioModule);
  126. _diP1 = ParseDiNode("diP1", node, ioModule);
  127. _diP2 = ParseDiNode("diP2", node, ioModule);
  128. _diP3 = ParseDiNode("diP3", node, ioModule);
  129. _diCOMMAlarm = ParseDiNode("diCOMMAlarm", node, ioModule);
  130. _diBatteryLowAlarm = ParseDiNode("diBatteryLowAlarm", node, ioModule);
  131. _di1_L_Servo_Driver_Alarm = ParseDiNode("di1_L_Servo_Driver_Alarm", node, ioModule);
  132. _di1_L_Servo_Driver_Warning = ParseDiNode("di1_L_Servo_Driver_Warning", node, ioModule);
  133. _di1_Search_ORG_Fail_Alarm = ParseDiNode("di1_Search_ORG_Fail_Alarm", node, ioModule);
  134. _di1_ABS_Fail_Alarm = ParseDiNode("di1_ABS_Fail_Alarm", node, ioModule);
  135. _di1_Up_Limit_Alarm = ParseDiNode("di1_Up_Limit_Alarm", node, ioModule);
  136. _di1_Down_Limit_Alarm = ParseDiNode("di1_Down_Limit_Alarm", node, ioModule);
  137. _di1_Over_Software_Alarm = ParseDiNode("di1_Over_Software_Alarm", node, ioModule);
  138. _di2_L_Servo_Driver_Alarm = ParseDiNode("di2_L_Servo_Driver_Alarm", node, ioModule);
  139. _di2_L_Servo_Driver_Warning = ParseDiNode("di2_L_Servo_Driver_Warning", node, ioModule);
  140. _di2_Search_ORG_Fail_Alarm = ParseDiNode("di2_Search_ORG_Fail_Alarm", node, ioModule);
  141. _di2_ABS_Fail_Alarm = ParseDiNode("di2_ABS_Fail_Alarm", node, ioModule);
  142. _di2_Up_Limit_Alarm = ParseDiNode("di2_Up_Limit_Alarm", node, ioModule);
  143. _di2_Down_Limit_Alarm = ParseDiNode("di2_Down_Limit_Alarm", node, ioModule);
  144. _di2_Over_Software_Alarm = ParseDiNode("di2_Over_Software_Alarm", node, ioModule);
  145. _doReset = ParseDoNode("doReset", node, ioModule);
  146. _doOrigin = ParseDoNode("doOrigin", node, ioModule);
  147. _doP1 = ParseDoNode("doP1", node, ioModule);
  148. _doP2 = ParseDoNode("doP2", node, ioModule);
  149. _doP3 = ParseDoNode("doP3", node, ioModule);
  150. _doStop = ParseDoNode("doStop", node, ioModule);
  151. _doUp = ParseDoNode("doUp", node, ioModule);
  152. _doDown = ParseDoNode("doDown", node, ioModule);
  153. _currentValue = ParseAiNode("aiCurrentValue", node, ioModule);
  154. _aoSetP1 = ParseAoNode("aoSetP1", node, ioModule);
  155. _aoSetP2 = ParseAoNode("aoSetP2", node, ioModule);
  156. _aoSetP3 = ParseAoNode("aoSetP3", node, ioModule);
  157. _aoServoEnable = ParseAoNode("aoServoEnable", node, ioModule);
  158. _aoServoWorkMode = ParseAoNode("aoServoWorkMode", node, ioModule);
  159. _aoOriginSpeed = ParseAoNode("aoOriginSpeed", node, ioModule);
  160. _aoAutoSpeed = ParseAoNode("aoAutoSpeed", node, ioModule);
  161. _aoManualSpeed = ParseAoNode("aoManualSpeed", node, ioModule);
  162. _aoSoftUpLimit = ParseAoNode("aoSoftUpLimit", node, ioModule);
  163. _aoSoftDownLimit = ParseAoNode("aoSoftDownLimit", node, ioModule);
  164. _aoAccDecSpeedTime = ParseAoNode("aoAccDecSpeedTime", node, ioModule);
  165. _aoPosDiff = ParseAoNode("aoPosDiff", node, ioModule);
  166. }
  167. private void updatePinCfg()
  168. {
  169. // AO-27, Lift Servo Enable: 0=Lift Pin ,1=Lift Servo
  170. _SetRealFloat(_aoServoEnable, 1);
  171. void _updateItem(string data, AOAccessor ao)
  172. {
  173. var value = (float)SC.GetValue<double>($"{Module}.{Name}.{data}");
  174. _SetRealFloat(ao, value);
  175. }
  176. _updateItem("ServoWorkMode", _aoOriginSpeed);
  177. _updateItem("OriginSpeed", _aoOriginSpeed);
  178. _updateItem("AutoSpeed", _aoAutoSpeed);
  179. _updateItem("ManualSpeed", _aoManualSpeed);
  180. _updateItem("SoftUpLimit", _aoSoftUpLimit);
  181. _updateItem("SoftDownLimit", _aoSoftDownLimit);
  182. _updateItem("AccDecSpeedTime", _aoAccDecSpeedTime);
  183. _updateItem("Position1", _aoSetP1);
  184. _updateItem("Position2", _aoSetP2);
  185. _updateItem("Position3", _aoSetP3);
  186. _updateItem("PosDiff", _aoPosDiff);
  187. }
  188. public bool GoPosition(Position position)
  189. {
  190. if (_diCOMMAlarm.Value)
  191. return false;
  192. _currentTarget = position;
  193. _preTarget = position;
  194. sw.Restart();
  195. swOrigin.Restart();
  196. switch (position)
  197. {
  198. case Position.position1:
  199. _doP1.Value = true;
  200. _doP2.Value = false;
  201. _doP3.Value = false;
  202. break;
  203. case Position.position2:
  204. _doP1.Value = false;
  205. _doP2.Value = true;
  206. _doP3.Value = false;
  207. break;
  208. case Position.position3:
  209. _doP1.Value = false;
  210. _doP2.Value = false;
  211. _doP3.Value = true;
  212. break;
  213. case Position.origin:
  214. {
  215. //if (_diOrigin.Value && _diOrigin2.Value && _diOrigin3.Value)
  216. //{
  217. // EV.PostInfoLog(Module, $"Lift Pin already on original position.");
  218. // sw.Stop();
  219. // return true;
  220. //}
  221. _doOrigin.Value = true;
  222. }
  223. break;
  224. }
  225. EV.PostInfoLog(Module, $"Lift Pin goto {_currentTarget}");
  226. return true;
  227. }
  228. public bool ManulStop()
  229. {
  230. if (_diCOMMAlarm.Value)
  231. return false;
  232. _doUp.Value = false;
  233. _doDown.Value = false;
  234. _doStop.Value = true;
  235. _manualStopTimer.Restart();
  236. return true;
  237. }
  238. public bool ManulUp()
  239. {
  240. if (_diCOMMAlarm.Value)
  241. return false;
  242. _doDown.Value = false;
  243. _doStop.Value = false;
  244. _doUp.Value = !_doUp.Value;
  245. return true;
  246. }
  247. public bool ManulDown()
  248. {
  249. if (_diCOMMAlarm.Value)
  250. return false;
  251. _doUp.Value = false;
  252. _doStop.Value = false;
  253. _doDown.Value = !_doDown.Value;
  254. return true;
  255. }
  256. public float CurrentValue
  257. {
  258. get
  259. {
  260. if (_currentValue == null)
  261. {
  262. return 0;
  263. }
  264. return _GetRealFloat(_currentValue); ;
  265. }
  266. }
  267. public bool Initialize()
  268. {
  269. DATA.Subscribe($"{Module}.{Name}.DeviceData", () => DeviceData);
  270. DATA.Subscribe($"{Module}.{Name}.PinPosition", () => PinPositionint);
  271. DATA.Subscribe($"{Module}.{Name}.CurrentValue", () => CurrentValue);
  272. DATA.Subscribe($"{Module}.{Name}.ManualStopState", () => _doStop.Value);
  273. DATA.Subscribe($"{Module}.{Name}.ManualUpState", () => _doUp.Value);
  274. DATA.Subscribe($"{Module}.{Name}.ManualDownState", () => _doDown.Value);
  275. OP.Subscribe($"{Module}.{Name}.SetState", (out string reason, int time, object[] param) => {
  276. reason = string.Empty;
  277. Position pos = Position.Invalid;
  278. if ((string)param[0] == "Up")
  279. pos = Position.position1;
  280. else if ((string)param[0] == "Down")
  281. pos = Position.position3;
  282. else if ((string)param[0] == "Middle")
  283. pos = Position.position2;
  284. else
  285. {
  286. reason = "Invalid moving position";
  287. return false;
  288. }
  289. GoPosition(pos);
  290. return true;
  291. });
  292. OP.Subscribe($"{Module}.{Name}.Stop", (out string reason, int time, object[] param) => {
  293. reason = string.Empty;
  294. ManulStop();
  295. return true;
  296. });
  297. OP.Subscribe($"{Module}.{Name}.Up", (out string reason, int time, object[] param) => {
  298. reason = string.Empty;
  299. ManulUp();
  300. return true;
  301. });
  302. OP.Subscribe($"{Module}.{Name}.Down", (out string reason, int time, object[] param) => {
  303. reason = string.Empty;
  304. ManulDown();
  305. return true;
  306. });
  307. OP.Subscribe($"{Module}.{Name}.Home", (out string reason, int time, object[] param) => {
  308. reason = string.Empty;
  309. GoPosition(Position.origin);
  310. return true;
  311. });
  312. OP.Subscribe($"{Module}.{Name}.UpdateConfig", (out string reason, int time, object[] param) => {
  313. reason = string.Empty;
  314. return true;
  315. });
  316. updatePinCfg();
  317. return true;
  318. }
  319. public void Terminate()
  320. {
  321. }
  322. private readonly R_TRIG _trigdiBatteryLowAlarm = new R_TRIG();
  323. private readonly R_TRIG _trigdiCOMMAlarm = new R_TRIG();
  324. private readonly R_TRIG _trigdi1_L_Servo_Driver_Alarm = new R_TRIG();
  325. private readonly R_TRIG _trigdi1_L_Servo_Driver_Warning = new R_TRIG();
  326. private readonly R_TRIG _trigdi1_Search_ORG_Fail_Alarm = new R_TRIG();
  327. private readonly R_TRIG _trigdi1_ABS_Fail_Alarm = new R_TRIG();
  328. private readonly R_TRIG _trigdi1_Up_Limit_Alarm = new R_TRIG();
  329. private readonly R_TRIG _trigdi1_Down_Limit_Alarm = new R_TRIG();
  330. private readonly R_TRIG _trigdi1_Over_Software_Alarm = new R_TRIG();
  331. private readonly R_TRIG _trigdi2_L_Servo_Driver_Alarm = new R_TRIG();
  332. private readonly R_TRIG _trigdi2_L_Servo_Driver_Warning = new R_TRIG();
  333. private readonly R_TRIG _trigdi2_Search_ORG_Fail_Alarm = new R_TRIG();
  334. private readonly R_TRIG _trigdi2_ABS_Fail_Alarm = new R_TRIG();
  335. private readonly R_TRIG _trigdi2_Up_Limit_Alarm = new R_TRIG();
  336. private readonly R_TRIG _trigdi2_Down_Limit_Alarm = new R_TRIG();
  337. private readonly R_TRIG _trigdi2_Over_Software_Alarm = new R_TRIG();
  338. public void Monitor()
  339. {
  340. if (_manualStopTimer.ElapsedMilliseconds > _stopButtonAutoResetTime)
  341. {
  342. _doStop.Value = false;
  343. _manualStopTimer.Stop();
  344. }
  345. _trigdiBatteryLowAlarm.CLK = _diBatteryLowAlarm.Value;
  346. if (_trigdiBatteryLowAlarm.Q)
  347. {
  348. NoDuplicatedAlarm($"Lift Pin DI-{_diBatteryLowAlarm.Index} alarm");
  349. }
  350. _trigdiCOMMAlarm.CLK = _diCOMMAlarm.Value;
  351. if (_trigdiCOMMAlarm.Q)
  352. {
  353. NoDuplicatedAlarm($"Lift Pin DI-{_diCOMMAlarm.Index} alarm");
  354. }
  355. _trigdi1_L_Servo_Driver_Alarm.CLK = _di1_L_Servo_Driver_Alarm.Value;
  356. if (_trigdi1_L_Servo_Driver_Alarm.Q)
  357. {
  358. NoDuplicatedAlarm($"Lift Pin DI-{_di1_L_Servo_Driver_Alarm.Index} alarm");
  359. }
  360. _trigdi1_L_Servo_Driver_Warning.CLK = _di1_L_Servo_Driver_Warning.Value;
  361. if (_trigdi1_L_Servo_Driver_Warning.Q)
  362. {
  363. NoDuplicatedAlarm($"Lift Pin DI-{_di1_L_Servo_Driver_Warning.Index} alarm");
  364. }
  365. _trigdi1_Search_ORG_Fail_Alarm.CLK = _di1_Search_ORG_Fail_Alarm.Value;
  366. if (_trigdi1_Search_ORG_Fail_Alarm.Q)
  367. {
  368. NoDuplicatedAlarm($"Lift Pin DI-{_di1_Search_ORG_Fail_Alarm.Index} alarm");
  369. }
  370. _trigdi1_ABS_Fail_Alarm.CLK = _di1_ABS_Fail_Alarm.Value;
  371. if (_trigdi1_ABS_Fail_Alarm.Q)
  372. {
  373. NoDuplicatedAlarm($"Lift Pin DI-{_di1_ABS_Fail_Alarm.Index} alarm");
  374. }
  375. _trigdi1_Up_Limit_Alarm.CLK = _di1_Up_Limit_Alarm.Value;
  376. if (_trigdi1_Up_Limit_Alarm.Q)
  377. {
  378. NoDuplicatedAlarm($"Lift Pin DI-{_di1_Up_Limit_Alarm.Index} alarm");
  379. }
  380. _trigdi1_Down_Limit_Alarm.CLK = _di1_Down_Limit_Alarm.Value;
  381. if (_trigdi1_Down_Limit_Alarm.Q)
  382. {
  383. NoDuplicatedAlarm($"Lift Pin DI-{_di1_Down_Limit_Alarm.Index} alarm");
  384. }
  385. _trigdi1_Over_Software_Alarm.CLK = _di1_Over_Software_Alarm.Value;
  386. if (_trigdi1_Over_Software_Alarm.Q)
  387. {
  388. NoDuplicatedAlarm($"Lift Pin DI-{_di1_Over_Software_Alarm.Index} alarm");
  389. }
  390. _trigdi2_L_Servo_Driver_Alarm.CLK = _di2_L_Servo_Driver_Alarm.Value;
  391. if (_trigdi2_L_Servo_Driver_Alarm.Q)
  392. {
  393. NoDuplicatedAlarm($"Lift Pin DI-{_di2_L_Servo_Driver_Alarm.Index} alarm");
  394. }
  395. _trigdi2_L_Servo_Driver_Warning.CLK = _di2_L_Servo_Driver_Warning.Value;
  396. if (_trigdi2_L_Servo_Driver_Warning.Q)
  397. {
  398. NoDuplicatedAlarm($"Lift Pin DI-{_di2_L_Servo_Driver_Warning.Index} alarm");
  399. }
  400. _trigdi2_Search_ORG_Fail_Alarm.CLK = _di2_Search_ORG_Fail_Alarm.Value;
  401. if (_trigdi2_Search_ORG_Fail_Alarm.Q)
  402. {
  403. NoDuplicatedAlarm($"Lift Pin DI-{_di2_Search_ORG_Fail_Alarm.Index} alarm");
  404. }
  405. _trigdi2_ABS_Fail_Alarm.CLK = _di2_ABS_Fail_Alarm.Value;
  406. if (_trigdi2_ABS_Fail_Alarm.Q)
  407. {
  408. NoDuplicatedAlarm($"Lift Pin DI-{_di2_ABS_Fail_Alarm.Index} alarm");
  409. }
  410. _trigdi2_Up_Limit_Alarm.CLK = _di2_Up_Limit_Alarm.Value;
  411. if (_trigdi2_Up_Limit_Alarm.Q)
  412. {
  413. NoDuplicatedAlarm($"Lift Pin DI-{_di2_Up_Limit_Alarm.Index} alarm");
  414. }
  415. _trigdi2_Down_Limit_Alarm.CLK = _di2_Down_Limit_Alarm.Value;
  416. if (_trigdi2_Down_Limit_Alarm.Q)
  417. {
  418. NoDuplicatedAlarm($"Lift Pin DI-{_di2_Down_Limit_Alarm.Index} alarm");
  419. }
  420. _trigdi2_Over_Software_Alarm.CLK = _di2_Over_Software_Alarm.Value;
  421. if (_trigdi2_Over_Software_Alarm.Q)
  422. {
  423. NoDuplicatedAlarm($"Lift Pin DI-{_di2_Over_Software_Alarm.Index} alarm");
  424. }
  425. if (_currentTarget == Position.Invalid)
  426. return;
  427. var servoOriginComplete = _diOrigin.Value;
  428. var servoOrigin2Complete = _diOrigin2.Value;
  429. var goPosOriginComplete = _diOrigin3.Value;
  430. if ((_currentTarget == Position.position1 && _diP1.Value) ||
  431. (_currentTarget == Position.position2 && _diP2.Value) ||
  432. (_currentTarget == Position.position3 && _diP3.Value) ||
  433. (_currentTarget == Position.origin && swOrigin.ElapsedMilliseconds > 1000 && (servoOriginComplete && servoOrigin2Complete && goPosOriginComplete)))
  434. {
  435. //EV.PostInfoLog(Module, $"Lift Pin arrive {_currentTarget}, ({_diOrigin.Index})_DI_Lift_Servo_1_Servo_Origin_Complete={servoOriginComplete} ({_diOrigin2.Index})_DI_Lift_Servo_2_Servo_Origin_Complete={servoOrigin2Complete} ({_diOrigin3.Index})_DI_Lift_Servo_Group_Go_Pos_Origin_Complete={goPosOriginComplete} ");
  436. Reset();
  437. return;
  438. }
  439. if (sw.ElapsedMilliseconds > _timeout)
  440. {
  441. NoDuplicatedAlarm($"Lift Pin timeout, go {_currentTarget} failed");
  442. }
  443. }
  444. public void Reset()
  445. {
  446. _currentTarget = Position.Invalid;
  447. sw.Reset();
  448. swOrigin.Reset();
  449. _doP1.Value = false;
  450. _doP2.Value = false;
  451. _doP3.Value = false;
  452. _doOrigin.Value = false;
  453. _doUp.Value = false;
  454. _doDown.Value = false;
  455. _doStop.Value = false;
  456. _bAlarmReported = false;
  457. _trigdiBatteryLowAlarm.RST = true;
  458. _trigdiCOMMAlarm.RST = true;
  459. _trigdi1_L_Servo_Driver_Alarm.RST = true;
  460. _trigdi1_L_Servo_Driver_Warning.RST = true;
  461. _trigdi1_Search_ORG_Fail_Alarm.RST = true;
  462. _trigdi1_ABS_Fail_Alarm.RST = true;
  463. _trigdi1_Up_Limit_Alarm.RST = true;
  464. _trigdi1_Down_Limit_Alarm.RST = true;
  465. _trigdi1_Over_Software_Alarm.RST = true;
  466. _trigdi2_L_Servo_Driver_Alarm.RST = true;
  467. _trigdi2_L_Servo_Driver_Warning.RST = true;
  468. _trigdi2_Search_ORG_Fail_Alarm.RST = true;
  469. _trigdi2_ABS_Fail_Alarm.RST = true;
  470. _trigdi2_Up_Limit_Alarm.RST = true;
  471. _trigdi2_Down_Limit_Alarm.RST = true;
  472. _trigdi2_Over_Software_Alarm.RST = true;
  473. EV.PostInfoLog(Module, $"Lift Pin reset all do to off.");
  474. }
  475. private void NoDuplicatedAlarm(string log)
  476. {
  477. //if (_bAlarmReported == false)
  478. {
  479. EV.PostAlarmLog(Module, log);
  480. _bAlarmReported = true;
  481. }
  482. }
  483. }
  484. }