SafetyDevice.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  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="VpwHotConectState";
  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="Res12HotConectState";
  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="Res34HotConectState";
  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="FacilityHotConectState";
  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="Plating12HotConectState";
  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="Plating34HotConectState";
  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. private const string SAFETY_DATA="SafetyData";
  233. #endregion
  234. #region 内部变量
  235. /// <summary>
  236. /// Reset Routine
  237. /// </summary>
  238. private SafetyResetRoutine _resetRoutine;
  239. /// <summary>
  240. /// All Switch On Routine
  241. /// </summary>
  242. private SafetyAllOnRoutine _allOnRoutine;
  243. /// <summary>
  244. /// AllOnRoutine状态
  245. /// </summary>
  246. private RState _allOnStatus;
  247. /// <summary>
  248. /// 操作当前状态
  249. /// </summary>
  250. private RState _status;
  251. /// <summary>
  252. /// 变量是否初始化字典
  253. /// </summary>
  254. private Dictionary<string, bool> _variableInitializeDic = new Dictionary<string, bool>();
  255. /// <summary>
  256. /// 定时器Job
  257. /// </summary>
  258. PeriodicJob _periodicJob = null;
  259. #endregion
  260. #region 属性
  261. /// <summary>
  262. /// 数据对象
  263. /// </summary>
  264. public SafetyData SafetyData { get; set; }
  265. /// <summary>
  266. /// 状态
  267. /// </summary>
  268. public RState Status { get; set; }
  269. /// <summary>
  270. /// 所有io变量是否初始化
  271. /// </summary>
  272. public bool IOInitialized { get { return IOVariableDictionaryUtil.AllIoVariableInitialized(eEvent.ERR_SAFETY,Module,_variableInitializeDic); } }
  273. #endregion
  274. /// <summary>
  275. /// 构造函数
  276. /// </summary>
  277. /// <param name="moduleName"></param>
  278. public SafetyDevice() : base("Safety", "Safety", "Safety", "Safety")
  279. {
  280. SafetyData = new SafetyData();
  281. }
  282. /// <summary>
  283. /// 定时器
  284. /// </summary>
  285. /// <returns></returns>
  286. private bool OnTimer()
  287. {
  288. if (_status==RState.Running)
  289. {
  290. _status = _resetRoutine.Monitor();
  291. if(_status==RState.End)
  292. {
  293. LOG.WriteLog(eEvent.INFO_SAFETY, Module, "Reset Complete");
  294. }
  295. else if(_status==RState.Failed)
  296. {
  297. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "Reset Error");
  298. }
  299. }
  300. //AllOnRoutine监控
  301. if (_allOnStatus == RState.Running)
  302. {
  303. _allOnStatus = _allOnRoutine.Monitor();
  304. if (_allOnStatus == RState.End)
  305. {
  306. LOG.WriteLog(eEvent.INFO_SAFETY, Module, "All On Complete");
  307. }
  308. else if (_allOnStatus == RState.Failed)
  309. {
  310. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "All On Error");
  311. }
  312. }
  313. return true;
  314. }
  315. /// <summary>
  316. /// 初始化
  317. /// </summary>
  318. /// <returns></returns>
  319. public bool Initialize()
  320. {
  321. InitializeRoutine();
  322. InitializeData();
  323. SubscribeValueAction();
  324. InitializeOperation();
  325. _periodicJob = new PeriodicJob(200, OnTimer, $"{Module}.OnTimer", true);
  326. return true;
  327. }
  328. /// <summary>
  329. /// 初始化Routine
  330. /// </summary>
  331. private void InitializeRoutine()
  332. {
  333. _resetRoutine = new SafetyResetRoutine(Module);
  334. _allOnRoutine = new SafetyAllOnRoutine(Module);
  335. }
  336. /// <summary>
  337. /// 初始化DATA
  338. /// </summary>
  339. private void InitializeData()
  340. {
  341. DATA.Subscribe($"{Module}.{SAFETY_DATA}",() => SafetyData, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  342. DATA.Subscribe($"{Module}.{IS_INITIALIZED}", () => IOInitialized, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  343. DATA.Subscribe($"{Module}.TwincatState", () => SafetyData.TwincatState, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  344. }
  345. /// <summary>
  346. /// 初始化Operation
  347. /// </summary>
  348. private void InitializeOperation()
  349. {
  350. OP.Subscribe($"{Module}.LockAlignerDoor", (cmd,args) => LockAlignerDoor());
  351. OP.Subscribe($"{Module}.UnlockAlignerDoor", (cmd, args) => UnlockAlignerDoor());
  352. OP.Subscribe($"{Module}.LockCasseteDoor", (cmd, args) => LockCasseteDoor());
  353. OP.Subscribe($"{Module}.UnlockCasseteDoor", (cmd, args) => UnlockCasseteDoor());
  354. OP.Subscribe($"{Module}.LockCell12Door", (cmd, args) => LockCell12Door());
  355. OP.Subscribe($"{Module}.UnlockCell12Door", (cmd, args) => UnlockCell12Door());
  356. OP.Subscribe($"{Module}.LockCell34Door", (cmd, args) => LockCell34Door());
  357. OP.Subscribe($"{Module}.UnlockCell34Door", (cmd, args) => UnlockCell34Door());
  358. OP.Subscribe($"{Module}.ResetOperation",(cmd, args) => ResetOperation());
  359. OP.Subscribe($"{Module}.AllOnOperation", (cmd, args) => AllOnOperation());
  360. }
  361. /// <summary>
  362. /// 订阅变量数值发生变化
  363. /// </summary>
  364. private void SubscribeValueAction()
  365. {
  366. BeckhoffIoSubscribeUpdateVariable( MAIN_COMM_ERR);
  367. BeckhoffIoSubscribeUpdateVariable( TWINCAT_STATE);
  368. BeckhoffIoSubscribeUpdateVariable( MAIN_FB_ERR);
  369. BeckhoffIoSubscribeUpdateVariable( VPW_HOTCONNECT_STATE);
  370. BeckhoffIoSubscribeUpdateVariable( VPW_COMM_ERR);
  371. BeckhoffIoSubscribeUpdateVariable( VPW_FB_ERR);
  372. BeckhoffIoSubscribeUpdateVariable( FACILITY_HOT_CONNECT_STATE);
  373. BeckhoffIoSubscribeUpdateVariable( FACILITY_COMM_ERR);
  374. BeckhoffIoSubscribeUpdateVariable( FACILITY_FB_ERR);
  375. BeckhoffIoSubscribeUpdateVariable( RES1_2_HOT_CONNECT_STATE);
  376. BeckhoffIoSubscribeUpdateVariable( RES1_2_COMM_ERR);
  377. BeckhoffIoSubscribeUpdateVariable( RES1_2_FB_ERR);
  378. BeckhoffIoSubscribeUpdateVariable( RES3_4_HOT_CONNECT_STATE);
  379. BeckhoffIoSubscribeUpdateVariable( RES3_4_COMM_ERR);
  380. BeckhoffIoSubscribeUpdateVariable( RES3_4_FB_ERR);
  381. BeckhoffIoSubscribeUpdateVariable( PLATING1_2_HOT_CONNECT_STATE);
  382. BeckhoffIoSubscribeUpdateVariable( PLATING1_2_COMM_ERR);
  383. BeckhoffIoSubscribeUpdateVariable( PLATING1_2_FB_ERR);
  384. BeckhoffIoSubscribeUpdateVariable( PLATING3_4_HOT_CONNECT_STATE);
  385. BeckhoffIoSubscribeUpdateVariable( PLATING3_4_COMM_ERR);
  386. BeckhoffIoSubscribeUpdateVariable( PLATING3_4_FB_ERR);
  387. BeckhoffIoSubscribeUpdateVariable( SRD_HOT_CONNECT_STATE);
  388. BeckhoffIoSubscribeUpdateVariable( SRD_COMM_ERR);
  389. BeckhoffIoSubscribeUpdateVariable( SRD_FB_ERR);
  390. BeckhoffIoSubscribeUpdateVariable( ERR_ACK);
  391. BeckhoffIoSubscribeUpdateVariable( RUN_STOP);
  392. BeckhoffIoSubscribeUpdateVariable( CASSETE_DOORS_LEFT_LOCKED);
  393. BeckhoffIoSubscribeUpdateVariable( CASSETE_DOORS_RIGHT_LOCKED);
  394. BeckhoffIoSubscribeUpdateVariable( CELL1_2_DOORS_LEFT_LOCKED);
  395. BeckhoffIoSubscribeUpdateVariable( CELL1_2_DOORS_RIGHT_LOCKED);
  396. BeckhoffIoSubscribeUpdateVariable( CELL3_4_DOORS_LEFT_LOCKED);
  397. BeckhoffIoSubscribeUpdateVariable( CELL3_4_DOORS_RIGHT_LOCKED);
  398. BeckhoffIoSubscribeUpdateVariable( VPW_DOOR_CLOSED);
  399. BeckhoffIoSubscribeUpdateVariable( SRD_PANEL_CLOSED);
  400. BeckhoffIoSubscribeUpdateVariable( ALIGNER_DOOR_CLOSED);
  401. BeckhoffIoSubscribeUpdateVariable( PLUMBLING_DOOR_CLOSED);
  402. BeckhoffIoSubscribeUpdateVariable( SRD_PANEL_CLOSED);
  403. BeckhoffIoSubscribeUpdateVariable( FACILITY_STO_ESTOP_RESTART);
  404. BeckhoffIoSubscribeUpdateVariable( PLATING_CELL1_2_STO1_ESTOP_RESTART);
  405. BeckhoffIoSubscribeUpdateVariable( PLATING_CELL1_2_STO2_ESTOP_RESTART);
  406. BeckhoffIoSubscribeUpdateVariable( PLATING_CELL3_4_STO1_ESTOP_RESTART);
  407. BeckhoffIoSubscribeUpdateVariable( PLATING_CELL3_4_STO2_ESTOP_RESTART);
  408. BeckhoffIoSubscribeUpdateVariable( RES1_2_STO_ESTOP_RESTART);
  409. BeckhoffIoSubscribeUpdateVariable( RES3_4_STO_ESTOP_RESTART);
  410. BeckhoffIoSubscribeUpdateVariable( SRD_STO_ESTOP_RESTART);
  411. BeckhoffIoSubscribeUpdateVariable( VPW_STO_ESTOP_RESTART);
  412. BeckhoffIoSubscribeUpdateVariable( REQ_ALIGNER_DOOR_LOCK);
  413. BeckhoffIoSubscribeUpdateVariable( REQ_CASSETE_DOORS_LOCK);
  414. BeckhoffIoSubscribeUpdateVariable( REQ_CELL1_2_DOORS_LOCK);
  415. BeckhoffIoSubscribeUpdateVariable( REQ_CELL3_4_DOORS_LOCK);
  416. BeckhoffIoSubscribeUpdateVariable(HALT_BUTTON_LEFT);
  417. BeckhoffIoSubscribeUpdateVariable(HALT_BUTTON_RIGHT);
  418. }
  419. /// <summary>
  420. /// 订阅IO变量
  421. /// </summary>
  422. /// <param name="variable"></param>
  423. private void BeckhoffIoSubscribeUpdateVariable(string variable)
  424. {
  425. _variableInitializeDic[variable] = false;
  426. IOModuleManager.Instance.SubscribeModuleVariable(Module,variable, UpdateVariableValue);
  427. }
  428. /// <summary>
  429. /// 更新变量数值
  430. /// </summary>
  431. /// <param name="variable"></param>
  432. /// <param name="value"></param>
  433. private void UpdateVariableValue(string variable, object value)
  434. {
  435. if (!SafetyData.IsDataInitialized)
  436. {
  437. SafetyData.IsDataInitialized = true;
  438. }
  439. PropertyInfo property = SafetyData.GetType().GetProperty(variable);
  440. if (property != null)
  441. {
  442. property.SetValue(SafetyData, value);
  443. }
  444. if (_variableInitializeDic.ContainsKey(variable) && !_variableInitializeDic[variable])
  445. {
  446. _variableInitializeDic[variable] = true;
  447. }
  448. CheckIsDataAbonrmal(variable, value);
  449. }
  450. #region 监控指示灯是否异常 方法
  451. /// <summary>
  452. /// 监控指示灯是否异常,是则打印log
  453. /// </summary>
  454. /// <param name="variable"></param>
  455. /// <param name="value"></param>
  456. private void CheckIsDataAbonrmal(string variable,object value)
  457. {
  458. if (variable == "ReservoirHighLevel" && (bool)value == true)
  459. {
  460. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "ReservoirHigh Level Error");
  461. }
  462. else if (variable == "MainCommErr" && (bool)value == true)
  463. {
  464. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "MainCommErr Error");
  465. }
  466. else if (variable == "LoaderPufCommErr" && (bool)value == true)
  467. {
  468. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "LoaderPufCommErr Error");
  469. }
  470. else if (variable == "SrdCommErr" && (bool)value == true)
  471. {
  472. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "SrdCommErr Error");
  473. }
  474. else if (variable == "TransportCommErr" && (bool)value == true)
  475. {
  476. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "TransportCommErr Error");
  477. }
  478. else if (variable == "MainFunctionBlockErr" && (bool)value == true)
  479. {
  480. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "MainFunctionBlockErr Error");
  481. }
  482. else if (variable == "LoaderPufFunctionBlockErr" && (bool)value == true)
  483. {
  484. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "LoaderPufFunctionBlockErr Error");
  485. }
  486. else if (variable == "SrdFunctionBlockErr" && (bool)value == true)
  487. {
  488. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "SrdFunctionBlockErr Error");
  489. }
  490. else if (variable == "TransporterFunctionBlockErr" && (bool)value == true)
  491. {
  492. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "TransporterFunctionBlockErr Error");
  493. }
  494. else if (variable == "ProcessHaltButton1" && (bool)value == true)
  495. {
  496. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "ProcessHaltButton1 Activate");
  497. }
  498. else if (variable == "ProcessHaltButton2" && (bool)value == true)
  499. {
  500. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "ProcessHaltButton2 Activate");
  501. }
  502. else if (variable == "LoaderHaltButton" && (bool)value == true)
  503. {
  504. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "LoaderHaltButton Activate");
  505. }
  506. else if (variable == "LoaderPanelRemoved" && (bool)value == true)
  507. {
  508. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "LoaderPanelRemoved Activate");
  509. }
  510. else if (variable == "BufferPanelRemoved" && (bool)value == true)
  511. {
  512. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "BufferPanelRemoved Activate");
  513. }
  514. else if (variable == "SrdTopPanelRemoved" && (bool)value == true)
  515. {
  516. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "SrdTopPanelRemoved Activate");
  517. }
  518. else if (variable == "SrdLowerPanelRemoved" && (bool)value == true)
  519. {
  520. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "SrdLowerPanelRemoved Activate");
  521. }
  522. else if (variable == "PlumbingDoorClosed" && (bool)value == false) //信号是反的
  523. {
  524. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "PlumbingDoorClosed Activate");
  525. }
  526. else if (variable == "ProcessUpperPanelsOn" && (bool)value == false) //信号是反的
  527. {
  528. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "ProcessUpperPanelsOn Activate");
  529. }
  530. else if (variable == "PumpEdm" && (bool)value == false) //信号是反的
  531. {
  532. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "PumpEdm Activate");
  533. }
  534. }
  535. #endregion
  536. #region Reset
  537. /// <summary>
  538. /// Reset Operation
  539. /// </summary>
  540. /// <returns></returns>
  541. private bool ResetOperation()
  542. {
  543. _status = _resetRoutine.Start();
  544. return _status == RState.Running;
  545. }
  546. #endregion
  547. #region All On
  548. /// <summary>
  549. /// All On Operation
  550. /// </summary>
  551. /// <returns></returns>
  552. private bool AllOnOperation()
  553. {
  554. _allOnStatus = _allOnRoutine.Start();
  555. return _allOnStatus == RState.Running;
  556. }
  557. #endregion
  558. #region Lock Door
  559. /// <summary>
  560. /// Lock Aligner Door
  561. /// </summary>
  562. /// <returns></returns>
  563. public bool LockAlignerDoor()
  564. {
  565. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_ALIGNER_DOOR_LOCK}");
  566. return IOModuleManager.Instance.WriteIoValue(ioName, true);
  567. }
  568. /// <summary>
  569. /// Unlock Process Door
  570. /// </summary>
  571. /// <returns></returns>
  572. public bool UnlockAlignerDoor()
  573. {
  574. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_ALIGNER_DOOR_LOCK}");
  575. return IOModuleManager.Instance.WriteIoValue(ioName, false);
  576. }
  577. /// <summary>
  578. /// Lock cassete Door
  579. /// </summary>
  580. /// <returns></returns>
  581. public bool LockCasseteDoor()
  582. {
  583. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CASSETE_DOORS_LOCK}");
  584. return IOModuleManager.Instance.WriteIoValue(ioName, true);
  585. }
  586. /// <summary>
  587. /// Unlock cassete Door
  588. /// </summary>
  589. /// <returns></returns>
  590. public bool UnlockCasseteDoor()
  591. {
  592. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CASSETE_DOORS_LOCK}");
  593. return IOModuleManager.Instance.WriteIoValue(ioName, false);
  594. }
  595. /// <summary>
  596. /// Lock Cell1_2 Door
  597. /// </summary>
  598. /// <returns></returns>
  599. public bool LockCell12Door()
  600. {
  601. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CELL1_2_DOORS_LOCK}");
  602. return IOModuleManager.Instance.WriteIoValue(ioName, true);
  603. }
  604. /// <summary>
  605. /// Unlock Cell1_2 Door
  606. /// </summary>
  607. /// <returns></returns>
  608. public bool UnlockCell12Door()
  609. {
  610. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CELL1_2_DOORS_LOCK}");
  611. return IOModuleManager.Instance.WriteIoValue(ioName, false);
  612. }
  613. /// <summary>
  614. /// Lock Cell3_4 Door
  615. /// </summary>
  616. /// <returns></returns>
  617. public bool LockCell34Door()
  618. {
  619. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CELL3_4_DOORS_LOCK}");
  620. return IOModuleManager.Instance.WriteIoValue(ioName, true);
  621. }
  622. /// <summary>
  623. /// Unlock Cell3_4 Door
  624. /// </summary>
  625. /// <returns></returns>
  626. public bool UnlockCell34Door()
  627. {
  628. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CELL3_4_DOORS_LOCK}");
  629. return IOModuleManager.Instance.WriteIoValue(ioName, false);
  630. }
  631. #endregion
  632. public void Monitor()
  633. {
  634. }
  635. public void Reset()
  636. {
  637. }
  638. public void Terminate()
  639. {
  640. _periodicJob.Stop(false);
  641. }
  642. }
  643. }