SafetyDevice.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  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 SafetyNewAllOnRoutine _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 SafetyNewAllOnRoutine(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( ERR_ACK);
  388. BeckhoffIoSubscribeUpdateVariable( RUN_STOP);
  389. BeckhoffIoSubscribeUpdateVariable( CASSETE_DOORS_LEFT_LOCKED);
  390. BeckhoffIoSubscribeUpdateVariable( CASSETE_DOORS_RIGHT_LOCKED);
  391. BeckhoffIoSubscribeUpdateVariable( CELL1_2_DOORS_LEFT_LOCKED);
  392. BeckhoffIoSubscribeUpdateVariable( CELL1_2_DOORS_RIGHT_LOCKED);
  393. BeckhoffIoSubscribeUpdateVariable( CELL3_4_DOORS_LEFT_LOCKED);
  394. BeckhoffIoSubscribeUpdateVariable( CELL3_4_DOORS_RIGHT_LOCKED);
  395. BeckhoffIoSubscribeUpdateVariable( VPW_DOOR_CLOSED);
  396. BeckhoffIoSubscribeUpdateVariable( SRD_PANEL_CLOSED);
  397. BeckhoffIoSubscribeUpdateVariable( ALIGNER_DOOR_CLOSED);
  398. BeckhoffIoSubscribeUpdateVariable( PLUMBLING_DOOR_CLOSED);
  399. BeckhoffIoSubscribeUpdateVariable( SRD_PANEL_CLOSED);
  400. BeckhoffIoSubscribeUpdateVariable( FACILITY_STO_ESTOP_RESTART);
  401. BeckhoffIoSubscribeUpdateVariable( PLATING_CELL1_2_STO1_ESTOP_RESTART);
  402. BeckhoffIoSubscribeUpdateVariable( PLATING_CELL1_2_STO2_ESTOP_RESTART);
  403. BeckhoffIoSubscribeUpdateVariable( PLATING_CELL3_4_STO1_ESTOP_RESTART);
  404. BeckhoffIoSubscribeUpdateVariable( PLATING_CELL3_4_STO2_ESTOP_RESTART);
  405. BeckhoffIoSubscribeUpdateVariable( RES1_2_STO_ESTOP_RESTART);
  406. BeckhoffIoSubscribeUpdateVariable( RES3_4_STO_ESTOP_RESTART);
  407. BeckhoffIoSubscribeUpdateVariable( SRD_STO_ESTOP_RESTART);
  408. BeckhoffIoSubscribeUpdateVariable( VPW_STO_ESTOP_RESTART);
  409. BeckhoffIoSubscribeUpdateVariable( REQ_ALIGNER_DOOR_LOCK);
  410. BeckhoffIoSubscribeUpdateVariable( REQ_CASSETE_DOORS_LOCK);
  411. BeckhoffIoSubscribeUpdateVariable( REQ_CELL1_2_DOORS_LOCK);
  412. BeckhoffIoSubscribeUpdateVariable( REQ_CELL3_4_DOORS_LOCK);
  413. BeckhoffIoSubscribeUpdateVariable(HALT_BUTTON_LEFT);
  414. BeckhoffIoSubscribeUpdateVariable(HALT_BUTTON_RIGHT);
  415. }
  416. /// <summary>
  417. /// 订阅IO变量
  418. /// </summary>
  419. /// <param name="variable"></param>
  420. private void BeckhoffIoSubscribeUpdateVariable(string variable)
  421. {
  422. _variableInitializeDic[variable] = false;
  423. IOModuleManager.Instance.SubscribeModuleVariable(Module,variable, UpdateVariableValue);
  424. }
  425. /// <summary>
  426. /// 更新变量数值
  427. /// </summary>
  428. /// <param name="variable"></param>
  429. /// <param name="value"></param>
  430. private void UpdateVariableValue(string variable, object value)
  431. {
  432. if (!SafetyData.IsDataInitialized)
  433. {
  434. SafetyData.IsDataInitialized = true;
  435. }
  436. PropertyInfo property = SafetyData.GetType().GetProperty(variable);
  437. if (property != null)
  438. {
  439. property.SetValue(SafetyData, value);
  440. }
  441. if (_variableInitializeDic.ContainsKey(variable) && !_variableInitializeDic[variable])
  442. {
  443. _variableInitializeDic[variable] = true;
  444. }
  445. CheckIsDataAbonrmal(variable, value);
  446. }
  447. #region 监控指示灯是否异常 方法
  448. /// <summary>
  449. /// 监控指示灯是否异常,是则打印log
  450. /// </summary>
  451. /// <param name="variable"></param>
  452. /// <param name="value"></param>
  453. private void CheckIsDataAbonrmal(string variable,object value)
  454. {
  455. if (variable == "ReservoirHighLevel" && (bool)value == true)
  456. {
  457. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "ReservoirHigh Level Error");
  458. }
  459. else if (variable == "MainCommErr" && (bool)value == true)
  460. {
  461. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "MainCommErr Error");
  462. }
  463. else if (variable == "LoaderPufCommErr" && (bool)value == true)
  464. {
  465. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "LoaderPufCommErr Error");
  466. }
  467. else if (variable == "SrdCommErr" && (bool)value == true)
  468. {
  469. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "SrdCommErr Error");
  470. }
  471. else if (variable == "TransportCommErr" && (bool)value == true)
  472. {
  473. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "TransportCommErr Error");
  474. }
  475. else if (variable == "MainFunctionBlockErr" && (bool)value == true)
  476. {
  477. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "MainFunctionBlockErr Error");
  478. }
  479. else if (variable == "LoaderPufFunctionBlockErr" && (bool)value == true)
  480. {
  481. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "LoaderPufFunctionBlockErr Error");
  482. }
  483. else if (variable == "SrdFunctionBlockErr" && (bool)value == true)
  484. {
  485. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "SrdFunctionBlockErr Error");
  486. }
  487. else if (variable == "TransporterFunctionBlockErr" && (bool)value == true)
  488. {
  489. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "TransporterFunctionBlockErr Error");
  490. }
  491. else if (variable == "ProcessHaltButton1" && (bool)value == true)
  492. {
  493. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "ProcessHaltButton1 Activate");
  494. }
  495. else if (variable == "ProcessHaltButton2" && (bool)value == true)
  496. {
  497. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "ProcessHaltButton2 Activate");
  498. }
  499. else if (variable == "LoaderHaltButton" && (bool)value == true)
  500. {
  501. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "LoaderHaltButton Activate");
  502. }
  503. else if (variable == "LoaderPanelRemoved" && (bool)value == true)
  504. {
  505. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "LoaderPanelRemoved Activate");
  506. }
  507. else if (variable == "BufferPanelRemoved" && (bool)value == true)
  508. {
  509. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "BufferPanelRemoved Activate");
  510. }
  511. else if (variable == "SrdTopPanelRemoved" && (bool)value == true)
  512. {
  513. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "SrdTopPanelRemoved Activate");
  514. }
  515. else if (variable == "SrdLowerPanelRemoved" && (bool)value == true)
  516. {
  517. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "SrdLowerPanelRemoved Activate");
  518. }
  519. else if (variable == "PlumbingDoorClosed" && (bool)value == false) //信号是反的
  520. {
  521. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "PlumbingDoorClosed Activate");
  522. }
  523. else if (variable == "ProcessUpperPanelsOn" && (bool)value == false) //信号是反的
  524. {
  525. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "ProcessUpperPanelsOn Activate");
  526. }
  527. else if (variable == "PumpEdm" && (bool)value == false) //信号是反的
  528. {
  529. LOG.WriteLog(eEvent.ERR_SAFETY, Module, "PumpEdm Activate");
  530. }
  531. }
  532. #endregion
  533. #region Reset
  534. /// <summary>
  535. /// Reset Operation
  536. /// </summary>
  537. /// <returns></returns>
  538. private bool ResetOperation()
  539. {
  540. _status = _resetRoutine.Start();
  541. return _status == RState.Running;
  542. }
  543. #endregion
  544. #region All On
  545. /// <summary>
  546. /// All On Operation
  547. /// </summary>
  548. /// <returns></returns>
  549. private bool AllOnOperation()
  550. {
  551. _allOnStatus = _allOnRoutine.Start();
  552. return _allOnStatus == RState.Running;
  553. }
  554. #endregion
  555. #region Lock Door
  556. /// <summary>
  557. /// Lock Aligner Door
  558. /// </summary>
  559. /// <returns></returns>
  560. public bool LockAlignerDoor()
  561. {
  562. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_ALIGNER_DOOR_LOCK}");
  563. return IOModuleManager.Instance.WriteIoValue(ioName, true);
  564. }
  565. /// <summary>
  566. /// Unlock Process Door
  567. /// </summary>
  568. /// <returns></returns>
  569. public bool UnlockAlignerDoor()
  570. {
  571. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_ALIGNER_DOOR_LOCK}");
  572. return IOModuleManager.Instance.WriteIoValue(ioName, false);
  573. }
  574. /// <summary>
  575. /// Lock cassete Door
  576. /// </summary>
  577. /// <returns></returns>
  578. public bool LockCasseteDoor()
  579. {
  580. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CASSETE_DOORS_LOCK}");
  581. return IOModuleManager.Instance.WriteIoValue(ioName, true);
  582. }
  583. /// <summary>
  584. /// Unlock cassete Door
  585. /// </summary>
  586. /// <returns></returns>
  587. public bool UnlockCasseteDoor()
  588. {
  589. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CASSETE_DOORS_LOCK}");
  590. return IOModuleManager.Instance.WriteIoValue(ioName, false);
  591. }
  592. /// <summary>
  593. /// Lock Cell1_2 Door
  594. /// </summary>
  595. /// <returns></returns>
  596. public bool LockCell12Door()
  597. {
  598. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CELL1_2_DOORS_LOCK}");
  599. return IOModuleManager.Instance.WriteIoValue(ioName, true);
  600. }
  601. /// <summary>
  602. /// Unlock Cell1_2 Door
  603. /// </summary>
  604. /// <returns></returns>
  605. public bool UnlockCell12Door()
  606. {
  607. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CELL1_2_DOORS_LOCK}");
  608. return IOModuleManager.Instance.WriteIoValue(ioName, false);
  609. }
  610. /// <summary>
  611. /// Lock Cell3_4 Door
  612. /// </summary>
  613. /// <returns></returns>
  614. public bool LockCell34Door()
  615. {
  616. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CELL3_4_DOORS_LOCK}");
  617. return IOModuleManager.Instance.WriteIoValue(ioName, true);
  618. }
  619. /// <summary>
  620. /// Unlock Cell3_4 Door
  621. /// </summary>
  622. /// <returns></returns>
  623. public bool UnlockCell34Door()
  624. {
  625. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{REQ_CELL3_4_DOORS_LOCK}");
  626. return IOModuleManager.Instance.WriteIoValue(ioName, false);
  627. }
  628. #endregion
  629. public void Monitor()
  630. {
  631. }
  632. public void Reset()
  633. {
  634. }
  635. public void Terminate()
  636. {
  637. _periodicJob.Stop(false);
  638. }
  639. }
  640. }