SafetyDevice.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. using Aitex.Core.RT.DataCenter;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.RT.Log;
  4. using Aitex.Core.RT.OperationCenter;
  5. using Aitex.Core.Util;
  6. using MECF.Framework.Common.Beckhoff.ModuleIO;
  7. using MECF.Framework.Common.CommonData.Prewet;
  8. using MECF.Framework.Common.Device.Safety;
  9. using MECF.Framework.Common.Equipment;
  10. using MECF.Framework.Common.TwinCat;
  11. using MECF.Framework.Common.Utilities;
  12. using PunkHPX8_Core;
  13. using System;
  14. using System.Collections.Generic;
  15. using System.Linq;
  16. using System.Reflection;
  17. using System.Text;
  18. using System.Threading.Tasks;
  19. using PunkHPX8_RT.Devices.AXIS;
  20. using Aitex.Core.RT.SCCore;
  21. using MECF.Framework.Common.IOCore;
  22. namespace PunkHPX8_RT.Devices.Safety
  23. {
  24. public class SafetyDevice : BaseDevice, IDevice
  25. {
  26. #region 常量
  27. private const string IS_INITIALIZED = "IsInitialized";
  28. private const double OP_HOT_CONNECT_STATE = 8;
  29. #region Hot_Connect
  30. /// <summary>
  31. /// Twincat状态
  32. /// </summary>
  33. private const string TWINCAT_STATE="TwincatState";
  34. /// <summary>
  35. /// Main通信故障
  36. /// </summary>
  37. private const string MAIN_COMM_ERR="MainCommErr";
  38. /// <summary>
  39. /// Main Function Block故障
  40. /// </summary>
  41. private const string MAIN_FB_ERR="MainFbErr";
  42. /// <summary>
  43. /// VPW状态
  44. /// </summary>
  45. private const string VPW_HOTCONNECT_STATE="VpwHotConnectState";
  46. /// <summary>
  47. /// VPW通信故障
  48. /// </summary>
  49. private const string VPW_COMM_ERR="VpwCommErr";
  50. /// <summary>
  51. /// VPW function block故障
  52. /// </summary>
  53. private const string VPW_FB_ERR="VpwFbErr";
  54. /// <summary>
  55. /// RES1_2状态
  56. /// </summary>
  57. private const string RES1_2_HOT_CONNECT_STATE="Res12HotConnectState";
  58. /// <summary>
  59. /// RES1_2通信故障
  60. /// </summary>
  61. private const string RES1_2_COMM_ERR="Res12CommErr";
  62. /// <summary>
  63. /// RES1_2 Function Block故障
  64. /// </summary>
  65. private const string RES1_2_FB_ERR="Res12FbErr";
  66. /// <summary>
  67. /// RES3_4状态
  68. /// </summary>
  69. private const string RES3_4_HOT_CONNECT_STATE="Res34HotConnectState";
  70. /// <summary>
  71. /// RES3_4通信故障
  72. /// </summary>
  73. private const string RES3_4_COMM_ERR="Res34CommErr";
  74. /// <summary>
  75. /// RES3_4Function Block故障
  76. /// </summary>
  77. private const string RES3_4_FB_ERR="Res34FbErr";
  78. /// <summary>
  79. /// Facility状态
  80. /// </summary>
  81. private const string FACILITY_HOT_CONNECT_STATE="FacilityHotConnectState";
  82. /// <summary>
  83. /// Facility通信故障
  84. /// </summary>
  85. private const string FACILITY_COMM_ERR="FacilityCommErr";
  86. /// <summary>
  87. /// Facility Function Block故障
  88. /// </summary>
  89. private const string FACILITY_FB_ERR="FacilityFbErr";
  90. /// <summary>
  91. /// PlatingCell1_2状态
  92. /// </summary>
  93. private const string PLATING1_2_HOT_CONNECT_STATE="Plating12HotConnectState";
  94. /// <summary>
  95. /// Plating1_2通信故障
  96. /// </summary>
  97. private const string PLATING1_2_COMM_ERR="Plating12CommErr";
  98. /// <summary>
  99. /// Plating1_2 Function Block故障
  100. /// </summary>
  101. private const string PLATING1_2_FB_ERR="Plating12FbErr";
  102. /// <summary>
  103. /// Plating3_4状态
  104. /// </summary>
  105. private const string PLATING3_4_HOT_CONNECT_STATE="Plating34HotConnectState";
  106. /// <summary>
  107. /// Plating3_4通信故障
  108. /// </summary>
  109. private const string PLATING3_4_COMM_ERR="Plating34CommErr";
  110. /// <summary>
  111. /// Plating34 Function Block故障
  112. /// </summary>
  113. private const string PLATING3_4_FB_ERR="Plating34FbErr";
  114. /// <summary>
  115. /// SRD状态
  116. /// </summary>
  117. private const string SRD_HOT_CONNECT_STATE="SrdHotConnectState";
  118. /// <summary>
  119. /// SRD通信故障
  120. /// </summary>
  121. private const string SRD_COMM_ERR="SrdCommErr";
  122. /// <summary>
  123. /// SRD Function Block故障
  124. /// </summary>
  125. private const string SRD_FB_ERR="SrdFbErr";
  126. #endregion
  127. #region restart
  128. /// <summary>
  129. /// Run stop
  130. /// </summary>
  131. private const string RUN_STOP="RunStop";
  132. /// <summary>
  133. /// Err ack
  134. /// </summary>
  135. private const string ERR_ACK="ErrAck";
  136. /// <summary>
  137. /// VPW Estop restart
  138. /// </summary>
  139. private const string VPW_STO_ESTOP_RESTART="VpwStoEstopRestart";
  140. /// <summary>
  141. /// Res12 Estop restart
  142. /// </summary>
  143. private const string RES1_2_STO_ESTOP_RESTART="Res12StoEstopRestart";
  144. /// <summary>
  145. /// Res34 Estop restart
  146. /// </summary>
  147. private const string RES3_4_STO_ESTOP_RESTART="Res34StoEstopRestart";
  148. /// <summary>
  149. /// Plating cell 1_2 sto1 estop restart
  150. /// </summary>
  151. private const string PLATING_CELL1_2_STO1_ESTOP_RESTART="PlatingCell12Sto1EstopRestart";
  152. /// <summary>
  153. /// Plating cell 1_2 sto2 estop restart
  154. /// </summary>
  155. private const string PLATING_CELL1_2_STO2_ESTOP_RESTART="PlatingCell12Sto2EstopRestart";
  156. /// <summary>
  157. /// Plating cell 3_4 sto1 estop restart
  158. /// </summary>
  159. private const string PLATING_CELL3_4_STO1_ESTOP_RESTART="PlatingCell34Sto1EstopRestart";
  160. /// <summary>
  161. /// Plating cell 3_4 sto2 estop restart
  162. /// </summary>
  163. private const string PLATING_CELL3_4_STO2_ESTOP_RESTART="PlatingCell34Sto2EstopRestart";
  164. /// <summary>
  165. /// Facility sto estop restart
  166. /// </summary>
  167. private const string FACILITY_STO_ESTOP_RESTART="FacilityStoEstopRestart";
  168. /// <summary>
  169. /// SRD Sto Estop restart
  170. /// </summary>
  171. private const string SRD_STO_ESTOP_RESTART="SrdStoEstopRestart";
  172. #endregion
  173. #region Doors Lock
  174. /// <summary>
  175. /// Req Aligner Door Lock
  176. /// </summary>
  177. private const string REQ_ALIGNER_DOOR_LOCK="ReqAlignerDoorLock";
  178. /// <summary>
  179. /// Req cassette doors lock
  180. /// </summary>
  181. private const string REQ_CASSETE_DOORS_LOCK="ReqCassetteDoorsLock";
  182. /// <summary>
  183. /// Req cell 1_2 doors lock
  184. /// </summary>
  185. private const string REQ_CELL1_2_DOORS_LOCK="ReqCell12DoorsLock";
  186. /// <summary>
  187. /// Req cell doors lock
  188. /// </summary>
  189. private const string REQ_CELL3_4_DOORS_LOCK="ReqCell34DoorsLock";
  190. #endregion
  191. #region locked
  192. /// <summary>
  193. /// Cell1_2 Doors Left Locked
  194. /// </summary>
  195. private const string CELL1_2_DOORS_LEFT_LOCKED="Cell12DoorsLeftLocked";
  196. /// <summary>
  197. /// Cell1_2 Doors Right Locked
  198. /// </summary>
  199. private const string CELL1_2_DOORS_RIGHT_LOCKED="Cell12DoorsRightLocked";
  200. /// <summary>
  201. /// Cell3_4 Doors Left Locked
  202. /// </summary>
  203. private const string CELL3_4_DOORS_LEFT_LOCKED="Cell34DoorsLeftLocked";
  204. /// <summary>
  205. /// Cell3_4 Doors Right Locked
  206. /// </summary>
  207. private const string CELL3_4_DOORS_RIGHT_LOCKED="Cell34DoorsRightLocked";
  208. /// <summary>
  209. /// Cassette Doors Left locked
  210. /// </summary>
  211. private const string CASSETE_DOORS_LEFT_LOCKED="CassetteDoorsLeftLocked";
  212. /// <summary>
  213. /// Cassette Doors Right locked
  214. /// </summary>
  215. private const string CASSETE_DOORS_RIGHT_LOCKED="CassetteDoorsRightLocked";
  216. #endregion
  217. #region Closed
  218. /// <summary>
  219. /// Aligner Door closed
  220. /// </summary>
  221. private const string ALIGNER_DOOR_CLOSED="AlignerDoorClosed";
  222. private const string RES1_2_DOOR_CLOED="Res12DoorClosed";
  223. private const string RES3_4_DOOR_CLOED="Res34DoorClosed";
  224. private const string VPW_DOOR_CLOSED="VpwDoorClosed";
  225. private const string PLUMBLING_DOOR_CLOSED="PlumblingDoorClosed";
  226. private const string SRD_PANEL_CLOSED="SrdPanelClosed";
  227. #endregion
  228. #region Halt
  229. private const string HALT_BUTTON_LEFT="HaltButtonLeft";
  230. private const string HALT_BUTTON_RIGHT="HaltButtonRight";
  231. #endregion
  232. #region Leak Detected
  233. private const string PLATINGCELL12LEAKDETECTED = "PlatingCell12LeakDetected";
  234. private const string PLATINGCELL34LEAKDETECTED = "PlatingCell34LeakDetected";
  235. private const string VACUUMPREWETLEAKDETECTED = "VacuumPrewetLeakDetected";
  236. private const string SAMPLESTATION1LEAKDETECTED= "SampleStation1LeakDetected";
  237. private const string SAMPLESTATION2LEAKDETECTED = "SampleStation2LeakDetected";
  238. private const string FRAMECONTAINMENTLEAKDETECTED = "FrameContainmentLeakDetected";
  239. #endregion
  240. #region EDM
  241. private const string RESERVOIR12CAPUMPEDM = "Reservoir12CAPumpEdm";
  242. private const string RESERVOIR34CAPUMPEDM = "Reservoir34CAPumpEdm";
  243. private const string RESDEGAS1PUMPEDM = "ResDegas1PumpEdm";
  244. private const string RESDEGAS2PUMPEDM = "ResDegas2PumpEdm";
  245. private const string VPWVACUUMPUMPEDM = "VpwVacuumPumpEdm";
  246. private const string VPWBOOSTERPUMPEDM = "VpwBoosterPumpEdm";
  247. private const string EXTFLUDIENABLEEDM = "ExtFluidEnableEdm";
  248. #endregion
  249. #region Level High
  250. private const string RESERVOIR1CALEVELHIGH = "Reservoir1CALevelHigh";
  251. private const string RESERVOIR2CALEVELHIGH = "Reservoir2CALevelHigh";
  252. private const string RESERVOIR3CALEVELHIGH = "Reservoir3CALevelHigh";
  253. private const string RESERVOIR4CALEVELHIGH = "Reservoir4CALevelHigh";
  254. #endregion
  255. #region Axis STO
  256. private const string VPWCELL1ROTATIONSTOEDM = "VpwCell1RotationStoEdm";
  257. private const string VPWCELL2ROTATIONSTOEDM = "VpwCell2RotationStoEdm";
  258. private const string PLATINGCELL1ROTATIONSTOEDM = "PlatingCell1RotationStoEdm";
  259. private const string PLATINGCELL2ROTATIONSTOEDM = "PlatingCell2RotationStoEdm";
  260. private const string PLATINGCELL3ROTATIONSTOEDM = "PlatingCell3RotationStoEdm";
  261. private const string PLATINGCELL4ROTATIONSTOEDM = "PlatingCell4RotationStoEdm";
  262. private const string PLATINGCELL12VERTICALSTOEDM = "PlatingCell12VerticalStoEdm";
  263. private const string PLATINGCELL34VERTICALSTOEDM = "PlatingCell34VerticalStoEdm";
  264. private const string SRD1ROTATIONSTOEDM = "Srd1RotationStoEdm";
  265. private const string SRD2ROTATIONSTOEDM = "Srd2RotationStoEdm";
  266. #endregion
  267. private const string SAFETY_DATA="SafetyData";
  268. #endregion
  269. #region 内部变量
  270. /// <summary>
  271. /// Reset Routine
  272. /// </summary>
  273. private SafetyResetRoutine _resetRoutine;
  274. /// <summary>
  275. /// All Switch On Routine
  276. /// </summary>
  277. private SafetyAllOnRoutine _allOnRoutine;
  278. /// <summary>
  279. /// AllOnRoutine状态
  280. /// </summary>
  281. private RState _allOnStatus;
  282. /// <summary>
  283. /// 操作当前状态
  284. /// </summary>
  285. private RState _status;
  286. /// <summary>
  287. /// 变量是否初始化字典
  288. /// </summary>
  289. private Dictionary<string, bool> _variableInitializeDic = new Dictionary<string, bool>();
  290. /// <summary>
  291. /// 定时器Job
  292. /// </summary>
  293. PeriodicJob _periodicJob = null;
  294. #endregion
  295. #region 属性
  296. /// <summary>
  297. /// 数据对象
  298. /// </summary>
  299. public SafetyData SafetyData { get; set; }
  300. /// <summary>
  301. /// 状态
  302. /// </summary>
  303. public RState Status { get; set; }
  304. /// <summary>
  305. /// 所有io变量是否初始化
  306. /// </summary>
  307. public bool IOInitialized { get { return IOVariableDictionaryUtil.AllIoVariableInitialized(eEvent.ERR_SAFETY,Module,_variableInitializeDic); } }
  308. #endregion
  309. /// <summary>
  310. /// 构造函数
  311. /// </summary>
  312. /// <param name="moduleName"></param>
  313. public SafetyDevice() : base("Safety", "Safety", "Safety", "Safety")
  314. {
  315. SafetyData = new SafetyData();
  316. }
  317. /// <summary>
  318. /// 定时器
  319. /// </summary>
  320. /// <returns></returns>
  321. private bool OnTimer()
  322. {
  323. if (_status==RState.Running)
  324. {
  325. _status = _resetRoutine.Monitor();
  326. if(_status==RState.End)
  327. {
  328. LOG.WriteLog(eEvent.INFO_SAFETY, Module, "Reset Complete");
  329. }
  330. else if(_status==RState.Failed)
  331. {
  332. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "Reset Error");
  333. }
  334. }
  335. //AllOnRoutine监控
  336. if (_allOnStatus == RState.Running)
  337. {
  338. _allOnStatus = _allOnRoutine.Monitor();
  339. if (_allOnStatus == RState.End)
  340. {
  341. LOG.WriteLog(eEvent.INFO_SAFETY, Module, "All On Complete");
  342. }
  343. else if (_allOnStatus == RState.Failed)
  344. {
  345. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "All On Error");
  346. }
  347. }
  348. return true;
  349. }
  350. /// <summary>
  351. /// 初始化
  352. /// </summary>
  353. /// <returns></returns>
  354. public bool Initialize()
  355. {
  356. InitializeRoutine();
  357. InitializeData();
  358. SubscribeValueAction();
  359. InitializeOperation();
  360. _periodicJob = new PeriodicJob(200, OnTimer, $"{Module}.OnTimer", true);
  361. return true;
  362. }
  363. /// <summary>
  364. /// 初始化Routine
  365. /// </summary>
  366. private void InitializeRoutine()
  367. {
  368. _resetRoutine = new SafetyResetRoutine(Module);
  369. _allOnRoutine = new SafetyAllOnRoutine(Module);
  370. }
  371. /// <summary>
  372. /// 初始化DATA
  373. /// </summary>
  374. private void InitializeData()
  375. {
  376. DATA.Subscribe($"{Module}.{SAFETY_DATA}",() => SafetyData, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  377. DATA.Subscribe($"{Module}.{IS_INITIALIZED}", () => IOInitialized, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  378. DATA.Subscribe($"{Module}.TwincatState", () => SafetyData.TwincatState, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  379. }
  380. /// <summary>
  381. /// 初始化Operation
  382. /// </summary>
  383. private void InitializeOperation()
  384. {
  385. OP.Subscribe($"{Module}.LockAlignerDoor", (cmd,args) => LockAlignerDoor());
  386. OP.Subscribe($"{Module}.UnlockAlignerDoor", (cmd, args) => UnlockAlignerDoor());
  387. OP.Subscribe($"{Module}.LockCasseteDoor", (cmd, args) => LockCasseteDoor());
  388. OP.Subscribe($"{Module}.UnlockCasseteDoor", (cmd, args) => UnlockCasseteDoor());
  389. OP.Subscribe($"{Module}.LockCell12Door", (cmd, args) => LockCell12Door());
  390. OP.Subscribe($"{Module}.UnlockCell12Door", (cmd, args) => UnlockCell12Door());
  391. OP.Subscribe($"{Module}.LockCell34Door", (cmd, args) => LockCell34Door());
  392. OP.Subscribe($"{Module}.UnlockCell34Door", (cmd, args) => UnlockCell34Door());
  393. OP.Subscribe($"{Module}.ResetOperation",(cmd, args) => ResetOperation());
  394. OP.Subscribe($"{Module}.AllOnOperation", (cmd, args) => AllOnOperation());
  395. }
  396. /// <summary>
  397. /// 订阅变量数值发生变化
  398. /// </summary>
  399. private void SubscribeValueAction()
  400. {
  401. BeckhoffIoSubscribeUpdateVariable( MAIN_COMM_ERR);
  402. BeckhoffIoSubscribeUpdateVariable( TWINCAT_STATE);
  403. BeckhoffIoSubscribeUpdateVariable( MAIN_FB_ERR);
  404. BeckhoffIoSubscribeUpdateVariable( VPW_HOTCONNECT_STATE);
  405. BeckhoffIoSubscribeUpdateVariable( VPW_COMM_ERR);
  406. BeckhoffIoSubscribeUpdateVariable( VPW_FB_ERR);
  407. BeckhoffIoSubscribeUpdateVariable( FACILITY_HOT_CONNECT_STATE);
  408. BeckhoffIoSubscribeUpdateVariable( FACILITY_COMM_ERR);
  409. BeckhoffIoSubscribeUpdateVariable( FACILITY_FB_ERR);
  410. BeckhoffIoSubscribeUpdateVariable( RES1_2_HOT_CONNECT_STATE);
  411. BeckhoffIoSubscribeUpdateVariable( RES1_2_COMM_ERR);
  412. BeckhoffIoSubscribeUpdateVariable( RES1_2_FB_ERR);
  413. BeckhoffIoSubscribeUpdateVariable( RES3_4_HOT_CONNECT_STATE);
  414. BeckhoffIoSubscribeUpdateVariable( RES3_4_COMM_ERR);
  415. BeckhoffIoSubscribeUpdateVariable( RES3_4_FB_ERR);
  416. BeckhoffIoSubscribeUpdateVariable( PLATING1_2_HOT_CONNECT_STATE);
  417. BeckhoffIoSubscribeUpdateVariable( PLATING1_2_COMM_ERR);
  418. BeckhoffIoSubscribeUpdateVariable( PLATING1_2_FB_ERR);
  419. BeckhoffIoSubscribeUpdateVariable( PLATING3_4_HOT_CONNECT_STATE);
  420. BeckhoffIoSubscribeUpdateVariable( PLATING3_4_COMM_ERR);
  421. BeckhoffIoSubscribeUpdateVariable( PLATING3_4_FB_ERR);
  422. BeckhoffIoSubscribeUpdateVariable( SRD_HOT_CONNECT_STATE);
  423. BeckhoffIoSubscribeUpdateVariable( SRD_COMM_ERR);
  424. BeckhoffIoSubscribeUpdateVariable( SRD_FB_ERR);
  425. BeckhoffIoSubscribeUpdateVariable( ERR_ACK);
  426. BeckhoffIoSubscribeUpdateVariable( RUN_STOP);
  427. BeckhoffIoSubscribeUpdateVariable( CASSETE_DOORS_LEFT_LOCKED);
  428. BeckhoffIoSubscribeUpdateVariable( CASSETE_DOORS_RIGHT_LOCKED);
  429. BeckhoffIoSubscribeUpdateVariable( CELL1_2_DOORS_LEFT_LOCKED);
  430. BeckhoffIoSubscribeUpdateVariable( CELL1_2_DOORS_RIGHT_LOCKED);
  431. BeckhoffIoSubscribeUpdateVariable( CELL3_4_DOORS_LEFT_LOCKED);
  432. BeckhoffIoSubscribeUpdateVariable( CELL3_4_DOORS_RIGHT_LOCKED);
  433. BeckhoffIoSubscribeUpdateVariable( VPW_DOOR_CLOSED);
  434. BeckhoffIoSubscribeUpdateVariable( SRD_PANEL_CLOSED);
  435. BeckhoffIoSubscribeUpdateVariable( ALIGNER_DOOR_CLOSED);
  436. BeckhoffIoSubscribeUpdateVariable( PLUMBLING_DOOR_CLOSED);
  437. BeckhoffIoSubscribeUpdateVariable( SRD_PANEL_CLOSED);
  438. BeckhoffIoSubscribeUpdateVariable( FACILITY_STO_ESTOP_RESTART);
  439. BeckhoffIoSubscribeUpdateVariable( PLATING_CELL1_2_STO1_ESTOP_RESTART);
  440. BeckhoffIoSubscribeUpdateVariable( PLATING_CELL1_2_STO2_ESTOP_RESTART);
  441. BeckhoffIoSubscribeUpdateVariable( PLATING_CELL3_4_STO1_ESTOP_RESTART);
  442. BeckhoffIoSubscribeUpdateVariable( PLATING_CELL3_4_STO2_ESTOP_RESTART);
  443. BeckhoffIoSubscribeUpdateVariable( RES1_2_STO_ESTOP_RESTART);
  444. BeckhoffIoSubscribeUpdateVariable( RES3_4_STO_ESTOP_RESTART);
  445. BeckhoffIoSubscribeUpdateVariable( SRD_STO_ESTOP_RESTART);
  446. BeckhoffIoSubscribeUpdateVariable( VPW_STO_ESTOP_RESTART);
  447. BeckhoffIoSubscribeUpdateVariable( REQ_ALIGNER_DOOR_LOCK);
  448. BeckhoffIoSubscribeUpdateVariable( REQ_CASSETE_DOORS_LOCK);
  449. BeckhoffIoSubscribeUpdateVariable( REQ_CELL1_2_DOORS_LOCK);
  450. BeckhoffIoSubscribeUpdateVariable( REQ_CELL3_4_DOORS_LOCK);
  451. BeckhoffIoSubscribeUpdateVariable(HALT_BUTTON_LEFT);
  452. BeckhoffIoSubscribeUpdateVariable(HALT_BUTTON_RIGHT);
  453. BeckhoffIoSubscribeUpdateVariable(PLATINGCELL12LEAKDETECTED);
  454. BeckhoffIoSubscribeUpdateVariable(PLATINGCELL34LEAKDETECTED);
  455. BeckhoffIoSubscribeUpdateVariable(VACUUMPREWETLEAKDETECTED);
  456. BeckhoffIoSubscribeUpdateVariable(SAMPLESTATION1LEAKDETECTED);
  457. BeckhoffIoSubscribeUpdateVariable(SAMPLESTATION2LEAKDETECTED);
  458. BeckhoffIoSubscribeUpdateVariable(FRAMECONTAINMENTLEAKDETECTED);
  459. BeckhoffIoSubscribeUpdateVariable(RESERVOIR12CAPUMPEDM);
  460. BeckhoffIoSubscribeUpdateVariable(RESERVOIR34CAPUMPEDM);
  461. BeckhoffIoSubscribeUpdateVariable(RESDEGAS1PUMPEDM);
  462. BeckhoffIoSubscribeUpdateVariable(RESDEGAS2PUMPEDM);
  463. BeckhoffIoSubscribeUpdateVariable(VPWVACUUMPUMPEDM);
  464. BeckhoffIoSubscribeUpdateVariable(VPWBOOSTERPUMPEDM);
  465. BeckhoffIoSubscribeUpdateVariable(EXTFLUDIENABLEEDM);
  466. BeckhoffIoSubscribeUpdateVariable(RESERVOIR1CALEVELHIGH);
  467. BeckhoffIoSubscribeUpdateVariable(RESERVOIR2CALEVELHIGH);
  468. BeckhoffIoSubscribeUpdateVariable(RESERVOIR3CALEVELHIGH);
  469. BeckhoffIoSubscribeUpdateVariable(RESERVOIR4CALEVELHIGH);
  470. BeckhoffIoSubscribeUpdateVariable(VPWCELL1ROTATIONSTOEDM);
  471. BeckhoffIoSubscribeUpdateVariable(VPWCELL2ROTATIONSTOEDM);
  472. BeckhoffIoSubscribeUpdateVariable(PLATINGCELL1ROTATIONSTOEDM);
  473. BeckhoffIoSubscribeUpdateVariable(PLATINGCELL2ROTATIONSTOEDM);
  474. BeckhoffIoSubscribeUpdateVariable(PLATINGCELL3ROTATIONSTOEDM);
  475. BeckhoffIoSubscribeUpdateVariable(PLATINGCELL4ROTATIONSTOEDM);
  476. BeckhoffIoSubscribeUpdateVariable(PLATINGCELL12VERTICALSTOEDM);
  477. BeckhoffIoSubscribeUpdateVariable(PLATINGCELL34VERTICALSTOEDM);
  478. BeckhoffIoSubscribeUpdateVariable(SRD1ROTATIONSTOEDM);
  479. BeckhoffIoSubscribeUpdateVariable(SRD2ROTATIONSTOEDM);
  480. }
  481. /// <summary>
  482. /// 订阅IO变量
  483. /// </summary>
  484. /// <param name="variable"></param>
  485. private void BeckhoffIoSubscribeUpdateVariable(string variable)
  486. {
  487. _variableInitializeDic[variable] = false;
  488. IOModuleManager.Instance.SubscribeModuleVariable(Module,variable, UpdateVariableValue);
  489. }
  490. /// <summary>
  491. /// 更新变量数值
  492. /// </summary>
  493. /// <param name="variable"></param>
  494. /// <param name="value"></param>
  495. private void UpdateVariableValue(string variable, object value)
  496. {
  497. if (!SafetyData.IsDataInitialized)
  498. {
  499. SafetyData.IsDataInitialized = true;
  500. }
  501. PropertyInfo property = SafetyData.GetType().GetProperty(variable);
  502. if (property != null)
  503. {
  504. property.SetValue(SafetyData, value);
  505. }
  506. if (_variableInitializeDic.ContainsKey(variable) && !_variableInitializeDic[variable])
  507. {
  508. _variableInitializeDic[variable] = true;
  509. }
  510. CheckIsDataAbonrmal(variable, value);
  511. }
  512. #region 监控指示灯是否异常 方法
  513. /// <summary>
  514. /// 监控指示灯是否异常,是则打印log
  515. /// </summary>
  516. /// <param name="variable"></param>
  517. /// <param name="value"></param>
  518. private void CheckIsDataAbonrmal(string variable,object value)
  519. {
  520. if (variable == "Reservoir1CALevelHigh" && (bool)value == false) //没有触发是false,红灯
  521. {
  522. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "Reservoir1CALevelHigh Level Error");
  523. }
  524. else if (variable == "Reservoir2CALevelHigh" && (bool)value == false)
  525. {
  526. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "Reservoir2CALevelHigh Error");
  527. }
  528. else if (variable == "Reservoir3CALevelHigh" && (bool)value == false)
  529. {
  530. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "Reservoir3CALevelHigh Error");
  531. }
  532. else if (variable == "Reservoir4CALevelHigh" && (bool)value == false)
  533. {
  534. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "Reservoir4CALevelHigh Error");
  535. }
  536. else if (variable == "MainCommErr" && (bool)value == true)
  537. {
  538. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "MainCommErr Error");
  539. }
  540. else if (variable == "LoaderPufCommErr" && (bool)value == true)
  541. {
  542. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "LoaderPufCommErr Error");
  543. }
  544. else if (variable == "SrdCommErr" && (bool)value == true)
  545. {
  546. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "SrdCommErr Error");
  547. }
  548. else if (variable == "TransportCommErr" && (bool)value == true)
  549. {
  550. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "TransportCommErr Error");
  551. }
  552. else if (variable == "MainFunctionBlockErr" && (bool)value == true)
  553. {
  554. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "MainFunctionBlockErr Error");
  555. }
  556. else if (variable == "LoaderPufFunctionBlockErr" && (bool)value == true)
  557. {
  558. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "LoaderPufFunctionBlockErr Error");
  559. }
  560. else if (variable == "SrdFunctionBlockErr" && (bool)value == true)
  561. {
  562. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "SrdFunctionBlockErr Error");
  563. }
  564. else if (variable == "TransporterFunctionBlockErr" && (bool)value == true)
  565. {
  566. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "TransporterFunctionBlockErr Error");
  567. }
  568. else if (variable == "ProcessHaltButton1" && (bool)value == true)
  569. {
  570. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "ProcessHaltButton1 Activate");
  571. }
  572. else if (variable == "ProcessHaltButton2" && (bool)value == true)
  573. {
  574. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "ProcessHaltButton2 Activate");
  575. }
  576. else if (variable == "LoaderHaltButton" && (bool)value == true)
  577. {
  578. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "LoaderHaltButton Activate");
  579. }
  580. else if (variable == "LoaderPanelRemoved" && (bool)value == true)
  581. {
  582. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "LoaderPanelRemoved Activate");
  583. }
  584. else if (variable == "BufferPanelRemoved" && (bool)value == true)
  585. {
  586. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "BufferPanelRemoved Activate");
  587. }
  588. else if (variable == "SrdTopPanelRemoved" && (bool)value == true)
  589. {
  590. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "SrdTopPanelRemoved Activate");
  591. }
  592. else if (variable == "SrdLowerPanelRemoved" && (bool)value == true)
  593. {
  594. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "SrdLowerPanelRemoved Activate");
  595. }
  596. else if (variable == "PlumbingDoorClosed" && (bool)value == false) //信号是反的
  597. {
  598. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "PlumbingDoorClosed Activate");
  599. }
  600. else if (variable == "ProcessUpperPanelsOn" && (bool)value == false) //信号是反的
  601. {
  602. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "ProcessUpperPanelsOn Activate");
  603. }
  604. else if (variable == "PumpEdm" && (bool)value == false) //信号是反的
  605. {
  606. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "PumpEdm Activate");
  607. }
  608. }
  609. #endregion
  610. #region Reset
  611. /// <summary>
  612. /// Reset Operation
  613. /// </summary>
  614. /// <returns></returns>
  615. private bool ResetOperation()
  616. {
  617. _status = _resetRoutine.Start();
  618. return _status == RState.Running;
  619. }
  620. #endregion
  621. #region All On
  622. /// <summary>
  623. /// All On Operation
  624. /// </summary>
  625. /// <returns></returns>
  626. private bool AllOnOperation()
  627. {
  628. _allOnStatus = _allOnRoutine.Start();
  629. return _allOnStatus == RState.Running;
  630. }
  631. #endregion
  632. #region Lock Door
  633. /// <summary>
  634. /// Lock Aligner Door
  635. /// </summary>
  636. /// <returns></returns>
  637. public bool LockAlignerDoor()
  638. {
  639. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_ALIGNER_DOOR_LOCK}");
  640. return IOModuleManager.Instance.WriteIoValue(ioName, true);
  641. }
  642. /// <summary>
  643. /// Unlock Process Door
  644. /// </summary>
  645. /// <returns></returns>
  646. public bool UnlockAlignerDoor()
  647. {
  648. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_ALIGNER_DOOR_LOCK}");
  649. return IOModuleManager.Instance.WriteIoValue(ioName, false);
  650. }
  651. /// <summary>
  652. /// Lock cassete Door
  653. /// </summary>
  654. /// <returns></returns>
  655. public bool LockCasseteDoor()
  656. {
  657. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CASSETE_DOORS_LOCK}");
  658. return IOModuleManager.Instance.WriteIoValue(ioName, true);
  659. }
  660. /// <summary>
  661. /// Unlock cassete Door
  662. /// </summary>
  663. /// <returns></returns>
  664. public bool UnlockCasseteDoor()
  665. {
  666. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CASSETE_DOORS_LOCK}");
  667. return IOModuleManager.Instance.WriteIoValue(ioName, false);
  668. }
  669. /// <summary>
  670. /// Lock Cell1_2 Door
  671. /// </summary>
  672. /// <returns></returns>
  673. public bool LockCell12Door()
  674. {
  675. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CELL1_2_DOORS_LOCK}");
  676. return IOModuleManager.Instance.WriteIoValue(ioName, true);
  677. }
  678. /// <summary>
  679. /// Unlock Cell1_2 Door
  680. /// </summary>
  681. /// <returns></returns>
  682. public bool UnlockCell12Door()
  683. {
  684. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CELL1_2_DOORS_LOCK}");
  685. return IOModuleManager.Instance.WriteIoValue(ioName, false);
  686. }
  687. /// <summary>
  688. /// Lock Cell3_4 Door
  689. /// </summary>
  690. /// <returns></returns>
  691. public bool LockCell34Door()
  692. {
  693. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CELL3_4_DOORS_LOCK}");
  694. return IOModuleManager.Instance.WriteIoValue(ioName, true);
  695. }
  696. /// <summary>
  697. /// Unlock Cell3_4 Door
  698. /// </summary>
  699. /// <returns></returns>
  700. public bool UnlockCell34Door()
  701. {
  702. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CELL3_4_DOORS_LOCK}");
  703. return IOModuleManager.Instance.WriteIoValue(ioName, false);
  704. }
  705. #endregion
  706. public void Monitor()
  707. {
  708. }
  709. public void Reset()
  710. {
  711. }
  712. public void Terminate()
  713. {
  714. _periodicJob.Stop(false);
  715. }
  716. }
  717. }