SrdCommonDevice.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. using Aitex.Core.RT.DataCenter;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.RT.Event;
  4. using Aitex.Core.RT.Log;
  5. using Aitex.Core.RT.OperationCenter;
  6. using Aitex.Core.RT.Routine;
  7. using Aitex.Core.RT.SCCore;
  8. using Aitex.Core.Util;
  9. using MECF.Framework.Common.Beckhoff.ModuleIO;
  10. using MECF.Framework.Common.CommonData.SRD;
  11. using MECF.Framework.Common.Persistent.Prewet;
  12. using MECF.Framework.Common.Persistent.SRD;
  13. using MECF.Framework.Common.TwinCat;
  14. using CyberX8_Core;
  15. using System.Reflection;
  16. using CyberX8_RT.Modules.Rinse;
  17. using CyberX8_RT.Modules;
  18. using CyberX8_RT.Modules.SRD;
  19. using CyberX8_RT.Devices.AXIS;
  20. using MECF.Framework.Common.Persistent.Rinse;
  21. using System.Security.Principal;
  22. using MECF.Framework.Common.IOCore;
  23. namespace CyberX8_RT.Devices.SRD
  24. {
  25. public class SrdCommonDevice : BaseDevice, IDevice
  26. {
  27. /// <summary>
  28. /// Srd操作枚举
  29. /// </summary>
  30. private enum SrdCommonOperation
  31. {
  32. None,
  33. DoorClose,
  34. DoorOpen,
  35. ChuckVacuumOn,
  36. ChuckVacuumOff,
  37. }
  38. #region 常量
  39. private const string FLUID_CONTAINMENT = "FluidContainment";
  40. private const string VACUUM_VALUE = "VacuumValue";
  41. private const string WAFER_PRESENCE = "WaferPresence";
  42. private const string WAFER_PRESENCE_STATUS = "WaferPresenceStatus";
  43. private const string WATER_PRESSURE = "WaterPressure";
  44. private const string DOOR_CLOSE="DoorClose";
  45. private const string DOOR_CLOSED = "DoorClosed";
  46. private const string DOOR_OPENED = "DoorOpened";
  47. private const string WATER_ABOVE="WaterAbove";
  48. private const string WATER_BELOW = "WaterBelow";
  49. private const string CHUCK_VACUUM="ChuckVacuum";
  50. private const string EXHAUST_ON="ExhaustOn";
  51. private const string COMMON_DATA = "CommonData";
  52. private const string PERSISTENT_VALUE= "PersistentValue";
  53. private const string CHUCK_ATM_ON = "ChuckATMOn";
  54. private const string CHUCK_VACUUM_OK = "ChuckVacuumOK";
  55. private const string WAFER_PRESENT = "WaferPresent";
  56. private const string LIFT_UP = "LiftUp";
  57. private const string LIFT_UP_STATUS = "LiftUpStatus";
  58. private const string FLIPPER1_OUT_150_STATUS = "Flipper1Out150Status";
  59. private const string FLIPPER2_OUT_150_STATUS = "Flipper2Out150Status";
  60. private const string FLIPPER3_OUT_150_STATUS = "Flipper3Out150Status";
  61. private const string FLIPPER1_OUT_200_STATUS = "Flipper1Out200Status";
  62. private const string FLIPPER2_OUT_200_STATUS = "Flipper2Out200Status";
  63. private const string FLIPPER3_OUT_200_STATUS = "Flipper3Out200Status";
  64. private const string FLIPPERS_IN_150_STATUS = "FlippersIn150";
  65. private const string FLIPPERS_IN_200_STATUS = "FlippersIn200";
  66. private const string WATER_FLOW = "WaterFlow";
  67. private const string N2_ON= "N2On";
  68. #endregion
  69. #region 内部变量
  70. /// <summary>
  71. /// Common数据
  72. /// </summary>
  73. private SrdCommonData _commonData = new SrdCommonData();
  74. /// <summary>
  75. /// 状态
  76. /// </summary>
  77. private RState _status;
  78. /// <summary>
  79. /// 当前操作
  80. /// </summary>
  81. private SrdCommonOperation _currentOperation;
  82. /// <summary>
  83. /// Wafer Presence
  84. /// </summary>
  85. private string _waferPresence;
  86. /// <summary>
  87. /// Persistent Value对象
  88. /// </summary>
  89. private SRDPersistentValue _srdPersistentValue;
  90. /// <summary>
  91. /// IsWaferPresence
  92. /// </summary>
  93. private bool _isWaferPresence = true;
  94. /// <summary>
  95. /// Total Device
  96. /// </summary>
  97. private TotalSRDDevice _totalSRDDevice;
  98. #region Routine
  99. /// <summary>
  100. /// Close Routine
  101. /// </summary>
  102. private SrdCommonDoorCloseRoutine _doorCloseRoutine;
  103. /// <summary>
  104. /// Vacuum Routine
  105. /// </summary>
  106. private SrdCommonChuckVacuumRoutine _chuckVacuumRoutine;
  107. #endregion
  108. #endregion
  109. #region 属性
  110. /// <summary>
  111. /// Common数据
  112. /// </summary>
  113. public SrdCommonData CommonData
  114. {
  115. get { return _commonData; }
  116. }
  117. /// <summary>
  118. /// 状态
  119. /// </summary>
  120. public RState Status { get { return _status; } }
  121. /// <summary>
  122. /// Wafer Presence
  123. /// </summary>
  124. public string WaferPresence
  125. {
  126. get { return _waferPresence; }
  127. }
  128. /// <summary>
  129. /// IsWaferPresence
  130. /// </summary>
  131. public bool IsWaferPresence
  132. {
  133. get { return _isWaferPresence; }
  134. }
  135. #endregion
  136. /// <summary>
  137. /// 构造函数
  138. /// </summary>
  139. /// <param name="moduleName"></param>
  140. /// <param name="name"></param>
  141. public SrdCommonDevice(string moduleName) : base(moduleName, "Common", "Common", "Common")
  142. {
  143. }
  144. /// <summary>
  145. /// 初始化
  146. /// </summary>
  147. /// <returns></returns>
  148. public bool Initialize()
  149. {
  150. InitializeRoutine();
  151. SubscribeData();
  152. SubscribeValueAction();
  153. InitializeOperation();
  154. return true;
  155. }
  156. /// <summary>
  157. /// 初始化Routine
  158. /// </summary>
  159. private void InitializeRoutine()
  160. {
  161. _doorCloseRoutine = new SrdCommonDoorCloseRoutine(Module);
  162. _chuckVacuumRoutine = new SrdCommonChuckVacuumRoutine(Module);
  163. }
  164. /// <summary>
  165. /// 订阅数据
  166. /// </summary>
  167. private void SubscribeData()
  168. {
  169. _srdPersistentValue = SRDPersistentManager.Instance.GetModulePersistentValue(Module);
  170. if(_srdPersistentValue==null)
  171. {
  172. LOG.WriteLog(eEvent.ERR_SRD, Module, "Persistent Value Object is not exist");
  173. }
  174. DATA.Subscribe($"{Module}.{PERSISTENT_VALUE}", () => _srdPersistentValue, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  175. DATA.Subscribe($"{Module}.{COMMON_DATA}", () => _commonData, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  176. DATA.Subscribe($"{Module}.{WAFER_PRESENCE_STATUS}", () => _waferPresence, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  177. DATA.Subscribe($"{Module}.IsWaferPresence", () => IsWaferPresence, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  178. }
  179. /// <summary>
  180. /// 订阅变量数值发生变化
  181. /// </summary>
  182. private void SubscribeValueAction()
  183. {
  184. IOModuleManager.Instance.SubscribeModuleVariable(Module, VACUUM_VALUE, UpdateVariableValue);
  185. IOModuleManager.Instance.SubscribeModuleVariable(Module, WAFER_PRESENCE, UpdateVariableValue);
  186. IOModuleManager.Instance.SubscribeModuleVariable(Module, DOOR_CLOSE, UpdateVariableValue);
  187. IOModuleManager.Instance.SubscribeModuleVariable(Module, DOOR_CLOSED, UpdateVariableValue);
  188. IOModuleManager.Instance.SubscribeModuleVariable(Module, DOOR_OPENED, UpdateVariableValue);
  189. IOModuleManager.Instance.SubscribeModuleVariable(Module, WATER_ABOVE, UpdateVariableValue);
  190. IOModuleManager.Instance.SubscribeModuleVariable(Module, WATER_BELOW, UpdateVariableValue);
  191. IOModuleManager.Instance.SubscribeModuleVariable(Module, CHUCK_VACUUM, UpdateVariableValue);
  192. IOModuleManager.Instance.SubscribeModuleVariable(Module, EXHAUST_ON, UpdateVariableValue);
  193. IOModuleManager.Instance.SubscribeModuleVariable(Module, CHUCK_ATM_ON, UpdateVariableValue);
  194. IOModuleManager.Instance.SubscribeModuleVariable(Module, CHUCK_VACUUM_OK, UpdateVariableValue);
  195. IOModuleManager.Instance.SubscribeModuleVariable(Module, WAFER_PRESENT, UpdateVariableValue);
  196. IOModuleManager.Instance.SubscribeModuleVariable(Module, LIFT_UP, UpdateVariableValue);
  197. IOModuleManager.Instance.SubscribeModuleVariable(Module, LIFT_UP_STATUS, UpdateVariableValue);
  198. IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER1_OUT_150_STATUS, UpdateVariableValue);
  199. IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER2_OUT_150_STATUS, UpdateVariableValue);
  200. IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER3_OUT_150_STATUS, UpdateVariableValue);
  201. IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER1_OUT_200_STATUS, UpdateVariableValue);
  202. IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER2_OUT_200_STATUS, UpdateVariableValue);
  203. IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER3_OUT_200_STATUS, UpdateVariableValue);
  204. IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPERS_IN_150_STATUS, UpdateVariableValue);
  205. IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPERS_IN_200_STATUS, UpdateVariableValue);
  206. IOModuleManager.Instance.SubscribeModuleVariable(Module, WATER_FLOW, UpdateVariableValue);
  207. IOModuleManager.Instance.SubscribeModuleVariable(Module, N2_ON, UpdateVariableValue);
  208. }
  209. /// <summary>
  210. /// 初始化操作
  211. /// </summary>
  212. private void InitializeOperation()
  213. {
  214. OP.Subscribe($"{Module}.{Name}.DoorClose", DoorCloseAction);
  215. OP.Subscribe($"{Module}.{Name}.DoorOpen", DoorOpenAction);
  216. OP.Subscribe($"{Module}.{Name}.WaterAboveOn", WaterAboveOnAction);
  217. OP.Subscribe($"{Module}.{Name}.WaterAboveOff", WaterAboveOffAction);
  218. OP.Subscribe($"{Module}.{Name}.WaterBelowOn", WaterBelowOnAction);
  219. OP.Subscribe($"{Module}.{Name}.WaterBelowOff", WaterBelowOffAction);
  220. OP.Subscribe($"{Module}.{Name}.ChuckVacuumOn", ChuckVacuumOnAction);
  221. OP.Subscribe($"{Module}.{Name}.ChuckVacuumOff", ChuckVacuumOffAction);
  222. OP.Subscribe($"{Module}.{Name}.ExhaustOn", ExhaustOnAction);
  223. OP.Subscribe($"{Module}.{Name}.ExhaustOff", ExhaustOffAction);
  224. OP.Subscribe($"{Module}.KeyDown", KeyDownAction);
  225. OP.Subscribe($"{Module}.DisabledAction", DisabledOperation);
  226. OP.Subscribe($"{Module}.ManualAction", ManualOperation);
  227. OP.Subscribe($"{Module}.AutoAction", AutoOperation);
  228. OP.Subscribe($"{Module}.EngineeringModeAction", EngineeringModeOperation);
  229. OP.Subscribe($"{Module}.ProductionModeAction", ProductionModeOperation);
  230. OP.Subscribe($"{Module}.UpdateIsWaferPresenceAction", UpdateIsWaferPresenceAction);
  231. }
  232. /// 更新变量数值
  233. /// </summary>
  234. /// <param name="variable"></param>
  235. /// <param name="value"></param>
  236. private void UpdateVariableValue(string variable, object value)
  237. {
  238. if(!CommonData.IsDataInitialized)
  239. {
  240. CommonData.IsDataInitialized = true;
  241. }
  242. PropertyInfo property = CommonData.GetType().GetProperty(variable);
  243. if (property != null)
  244. {
  245. property.SetValue(CommonData, value);
  246. }
  247. UpdateWaferPresence(variable, value);
  248. }
  249. /// <summary>
  250. /// 更新Wafer Presence
  251. /// </summary>
  252. private void UpdateWaferPresence(string variable,object value)
  253. {
  254. if (variable == WAFER_PRESENCE&&value is double)
  255. {
  256. UpdateWaferPresence((double)value);
  257. }
  258. }
  259. /// <summary>
  260. /// 更新Wafer Presence
  261. /// </summary>
  262. /// <param name="waferPresence"></param>
  263. private void UpdateWaferPresence(double waferPresence)
  264. {
  265. if (_srdPersistentValue != null)
  266. {
  267. if (waferPresence > _srdPersistentValue.EmptyThreshold)
  268. {
  269. _waferPresence = "Empty";
  270. }
  271. else if (waferPresence >= _srdPersistentValue.WellPlacedHighThreshold && waferPresence <= _srdPersistentValue.EmptyThreshold)
  272. {
  273. _waferPresence = "PoorlyPlaced";
  274. }
  275. else if (waferPresence < _srdPersistentValue.WellPlacedLowThreshold)
  276. {
  277. _waferPresence = "PoorlyPlaced";
  278. }
  279. else
  280. {
  281. _waferPresence = "WellPlaced";
  282. }
  283. }
  284. }
  285. #region Operation
  286. #region OperationStatus
  287. /// <summary>
  288. /// DisabledAction
  289. /// </summary>
  290. /// <param name="cmd"></param>
  291. /// <param name="param"></param>
  292. /// <returns></returns>
  293. private bool DisabledOperation(string cmd, object[] args)
  294. {
  295. string currentOperation = "Disabled";
  296. SRDEntity srdEntity = Singleton<RouteManager>.Instance.GetModule<SRDEntity>(Module);
  297. if (srdEntity == null || _srdPersistentValue == null) return false;
  298. if (_srdPersistentValue.OperatingMode != "Disabled") srdEntity.EnterInit();
  299. SRDPersistentManager.Instance.UpdateOperationModeValue(Module,currentOperation);
  300. return true;
  301. }
  302. /// <summary>
  303. /// ManualAction
  304. /// </summary>
  305. /// <param name="cmd"></param>
  306. /// <param name="param"></param>
  307. /// <returns></returns>
  308. private bool ManualOperation(string cmd, object[] args)
  309. {
  310. string currentOperation = "Manual";
  311. SRDEntity srdEntity = Singleton<RouteManager>.Instance.GetModule<SRDEntity>(Module);
  312. if (srdEntity == null || _srdPersistentValue == null) return false;
  313. if (_srdPersistentValue.OperatingMode == "Auto" && srdEntity.IsBusy)
  314. {
  315. LOG.WriteLog(eEvent.ERR_SRD, Module, $"{Module} is Busy, can't change to manual mode");
  316. return false;
  317. }
  318. if (_srdPersistentValue.OperatingMode != "Manual") srdEntity.EnterInit();
  319. SRDPersistentManager.Instance.UpdateOperationModeValue(Module,currentOperation);
  320. return true;
  321. }
  322. /// <summary>
  323. /// AutoAction
  324. /// </summary>
  325. /// <param name="cmd"></param>
  326. /// <param name="param"></param>
  327. /// <returns></returns>
  328. private bool AutoOperation(string cmd, object[] args)
  329. {
  330. string currentOperation = "Auto";
  331. SRDEntity srdEntity = Singleton<RouteManager>.Instance.GetModule<SRDEntity>(Module);
  332. if (srdEntity == null || _srdPersistentValue == null) return false;
  333. if (_srdPersistentValue.OperatingMode != "Auto") srdEntity.EnterInit();
  334. SRDPersistentManager.Instance.UpdateOperationModeValue(Module,currentOperation);
  335. return true;
  336. }
  337. /// <summary>
  338. /// EngineeringModeAction
  339. /// </summary>
  340. /// <param name="cmd"></param>
  341. /// <param name="param"></param>
  342. /// <returns></returns>
  343. private bool EngineeringModeOperation(string cmd, object[] args)
  344. {
  345. string currentRecipeOperation = "Engineering";
  346. SRDPersistentManager.Instance.UpdateRecipeOperationModeValue(Module, currentRecipeOperation);
  347. return true;
  348. }
  349. /// <summary>
  350. /// ProductionAction
  351. /// </summary>
  352. /// <param name="cmd"></param>
  353. /// <param name="param"></param>
  354. /// <returns></returns>
  355. private bool ProductionModeOperation(string cmd, object[] args)
  356. {
  357. string currentRecipeOperation = "Production";
  358. SRDPersistentManager.Instance.UpdateRecipeOperationModeValue(Module, currentRecipeOperation);
  359. return true;
  360. }
  361. #endregion
  362. #region keydown
  363. private bool KeyDownAction(string cmd, object[] args)
  364. {
  365. string variableName = args[0].ToString();
  366. PropertyInfo property = _srdPersistentValue.GetType().GetProperty(variableName);
  367. if(property!=null)
  368. {
  369. property.SetValue(_srdPersistentValue, args[1]);
  370. }
  371. SRDPersistentManager.Instance.UpdateModulePersistentValue(Module);
  372. UpdateWaferPresence(CommonData.WaferPresence);
  373. return true;
  374. }
  375. #endregion
  376. #region Door
  377. /// <summary>
  378. /// Door Close操作
  379. /// </summary>
  380. public bool DoorCloseAction(string cmd, object[] args)
  381. {
  382. if (!JudgeRunningState(SrdCommonOperation.DoorClose))
  383. {
  384. _currentOperation = SrdCommonOperation.DoorClose;
  385. _status = _doorCloseRoutine.Start(true);
  386. return _status==RState.Running;
  387. }
  388. else
  389. {
  390. return false;
  391. }
  392. }
  393. /// <summary>
  394. /// Door Open操作
  395. /// </summary>
  396. public bool DoorOpenAction(string cmd, object[] args)
  397. {
  398. if (!JudgeRunningState(SrdCommonOperation.DoorOpen))
  399. {
  400. _currentOperation = SrdCommonOperation.DoorOpen;
  401. _status = _doorCloseRoutine.Start(false);
  402. return _status==RState.Running;
  403. }
  404. else
  405. {
  406. return false;
  407. }
  408. }
  409. #endregion
  410. #region Exhaust On
  411. /// <summary>
  412. /// Exhaust On
  413. /// </summary>
  414. /// <param name="cmd"></param>
  415. /// <param name="args"></param>
  416. /// <returns></returns>
  417. public bool ExhaustOnAction(string cmd, object[] args)
  418. {
  419. return ExhaustOn();
  420. }
  421. /// <summary>
  422. /// Exhaust Off
  423. /// </summary>
  424. /// <param name="cmd"></param>
  425. /// <param name="args"></param>
  426. /// <returns></returns>
  427. public bool ExhaustOffAction(string cmd, object[] args)
  428. {
  429. return ExhaustOff();
  430. }
  431. /// <summary>
  432. /// Exhaust On(不确认信号)
  433. /// </summary>
  434. /// <returns></returns>
  435. public bool ExhaustOn()
  436. {
  437. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{EXHAUST_ON}");
  438. return IOModuleManager.Instance.WriteIoValue(ioName, true);
  439. }
  440. /// <summary>
  441. /// Exhaust On(不确认信号)
  442. /// </summary>
  443. /// <returns></returns>
  444. public bool ExhaustOff()
  445. {
  446. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{EXHAUST_ON}");
  447. return IOModuleManager.Instance.WriteIoValue(ioName, false);
  448. }
  449. #endregion
  450. #region Chuck Vacuum
  451. /// <summary>
  452. /// Chuck Vacuum操作
  453. /// </summary>
  454. public bool ChuckVacuumOnAction(string cmd, object[] args)
  455. {
  456. if (!JudgeRunningState(SrdCommonOperation.ChuckVacuumOn))
  457. {
  458. _currentOperation = SrdCommonOperation.ChuckVacuumOn;
  459. _status = _chuckVacuumRoutine.Start(false);
  460. return _status==RState.Running;
  461. }
  462. else
  463. {
  464. return false;
  465. }
  466. }
  467. /// <summary>
  468. /// chuck Vacuum Off操作
  469. /// </summary>
  470. public bool ChuckVacuumOffAction(string cmd, object[] args)
  471. {
  472. if (!JudgeRunningState(SrdCommonOperation.ChuckVacuumOff))
  473. {
  474. _currentOperation = SrdCommonOperation.ChuckVacuumOff;
  475. _status= _chuckVacuumRoutine.Start(true);
  476. return _status==RState.Running;
  477. }
  478. else
  479. {
  480. return false;
  481. }
  482. }
  483. #endregion
  484. #region Water Above
  485. /// <summary>
  486. /// Water Above On操作
  487. /// </summary>
  488. public bool WaterAboveOnAction(string cmd, object[] args)
  489. {
  490. return WaterAboveOn();
  491. }
  492. /// <summary>
  493. /// water above Off操作
  494. /// </summary>
  495. public bool WaterAboveOffAction(string cmd, object[] args)
  496. {
  497. return WaterAboveOff();
  498. }
  499. /// <summary>
  500. /// Water Above On(不确认信号)
  501. /// </summary>
  502. /// <returns></returns>
  503. public bool WaterAboveOn()
  504. {
  505. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{WATER_ABOVE}");
  506. return IOModuleManager.Instance.WriteIoValue(ioName, true);
  507. }
  508. /// <summary>
  509. /// Water Above Off(不确认信号)
  510. /// </summary>
  511. /// <returns></returns>
  512. public bool WaterAboveOff()
  513. {
  514. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{WATER_ABOVE}");
  515. return IOModuleManager.Instance.WriteIoValue(ioName, false);
  516. }
  517. #endregion
  518. #region Water Below
  519. /// <summary>
  520. /// Water Below On操作
  521. /// </summary>
  522. public bool WaterBelowOnAction(string cmd, object[] args)
  523. {
  524. return WaterBelowOn();
  525. }
  526. /// <summary>
  527. /// water Below Off操作
  528. /// </summary>
  529. public bool WaterBelowOffAction(string cmd, object[] args)
  530. {
  531. return WaterBelowOff();
  532. }
  533. /// <summary>
  534. /// Water Below On(不确认信号)
  535. /// </summary>
  536. /// <returns></returns>
  537. public bool WaterBelowOn()
  538. {
  539. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{WATER_BELOW}");
  540. return IOModuleManager.Instance.WriteIoValue(ioName, true);
  541. }
  542. /// <summary>
  543. /// Water Below Off(不确认信号)
  544. /// </summary>
  545. /// <returns></returns>
  546. public bool WaterBelowOff()
  547. {
  548. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{WATER_BELOW}");
  549. return IOModuleManager.Instance.WriteIoValue(ioName, false);
  550. }
  551. #endregion
  552. /// <summary>
  553. /// Update IsWaferPresence 标志位
  554. /// </summary>
  555. /// <param name="cmd"></param>
  556. /// <param name="args"></param>
  557. /// <returns></returns>
  558. public bool UpdateIsWaferPresenceAction(string cmd, object[] args)
  559. {
  560. _isWaferPresence = (bool)args[0];
  561. return true;
  562. }
  563. /// <summary>
  564. /// 判定运行状态
  565. /// </summary>
  566. /// <returns></returns>
  567. private bool JudgeRunningState(SrdCommonOperation operation)
  568. {
  569. if (_status == RState.Running)
  570. {
  571. EV.PostAlarmLog($"{Module}", eEvent.ERR_SRD, $"{Module} current execute {_currentOperation},cannot {operation}");
  572. return true;
  573. }
  574. return false;
  575. }
  576. /// <summary>
  577. /// ErrorOperation
  578. /// </summary>
  579. public void EnterErrorOperation()
  580. {
  581. //关闭风扇
  582. if (CommonData.ExhaustOn)
  583. {
  584. bool result = ExhaustOffAction("", null);
  585. if (!result)
  586. {
  587. LOG.WriteLog(eEvent.ERR_SRD, Module, "EnterError: Exhaust Off is failed");
  588. }
  589. }
  590. //关闭WaterAbove
  591. if (CommonData.WaterAbove)
  592. {
  593. bool result = WaterAboveOff();
  594. if (!result)
  595. {
  596. LOG.WriteLog(eEvent.INFO_SRD, Module, "EnterError: Water Above Off is failed");
  597. }
  598. }
  599. //关闭WaterBelow
  600. if (CommonData.WaterBelow)
  601. {
  602. bool result = WaterBelowOff();
  603. if (!result)
  604. {
  605. LOG.WriteLog(eEvent.INFO_SRD, Module, "EnterError: Water Below Off is failed");
  606. }
  607. }
  608. //停电机
  609. JetAxisBase _armAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Arm");
  610. if (_armAxis != null && _armAxis.IsRun) _armAxis.StopPositionOperation();
  611. JetAxisBase _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
  612. if (_rotationAxis != null && _rotationAxis.IsRun) _rotationAxis.StopPositionOperation();
  613. }
  614. #endregion
  615. /// <summary>
  616. /// 定时器
  617. /// </summary>
  618. /// <returns></returns>
  619. public bool OnTimer()
  620. {
  621. if (_status == RState.Running)
  622. {
  623. if (_currentOperation != SrdCommonOperation.None)
  624. {
  625. IRoutine routine = GetCurrentRoutine(_currentOperation);
  626. if (routine != null)
  627. {
  628. CheckRoutineState(routine, _currentOperation);
  629. }
  630. else
  631. {
  632. EndOperation();
  633. }
  634. }
  635. }
  636. //将公有的数据赋值于对象的数值
  637. if (_totalSRDDevice == null)
  638. {
  639. _totalSRDDevice = DEVICE.GetDevice<TotalSRDDevice>("SRD");
  640. }
  641. if (_totalSRDDevice != null)
  642. {
  643. CommonData.FluidContainment = _totalSRDDevice.FluidContainment;
  644. CommonData.WaterPressure = _totalSRDDevice.WaterPressure;
  645. }
  646. return true;
  647. }
  648. /// <summary>
  649. /// 获取当前操作对应的Routine
  650. /// </summary>
  651. /// <param name="currentOperation"></param>
  652. /// <returns></returns>
  653. private IRoutine GetCurrentRoutine(SrdCommonOperation currentOperation)
  654. {
  655. switch (currentOperation)
  656. {
  657. case SrdCommonOperation.DoorClose:
  658. case SrdCommonOperation.DoorOpen:
  659. return _doorCloseRoutine;
  660. case SrdCommonOperation.ChuckVacuumOn:
  661. case SrdCommonOperation.ChuckVacuumOff:
  662. return _chuckVacuumRoutine;
  663. default:
  664. return null;
  665. }
  666. }
  667. /// <summary>
  668. /// 检验Routine状态
  669. /// </summary>
  670. /// <param name="routine"></param>
  671. /// <param name="currentOperation"></param>
  672. private void CheckRoutineState(IRoutine routine, SrdCommonOperation currentOperation)
  673. {
  674. RState state = routine.Monitor();
  675. if (state == RState.End)
  676. {
  677. EndOperation();
  678. }
  679. else if (state == RState.Failed || state == RState.Timeout)
  680. {
  681. LOG.WriteLog(eEvent.ERR_SRD, $"{Module}", $"{currentOperation} error");
  682. EndOperation();
  683. }
  684. }
  685. /// <summary>
  686. /// 结束操作
  687. /// </summary>
  688. private void EndOperation()
  689. {
  690. _status = RState.End;
  691. _currentOperation = SrdCommonOperation.None;
  692. }
  693. #region 设备接口
  694. /// <summary>
  695. /// 监控
  696. /// </summary>
  697. public void Monitor()
  698. {
  699. }
  700. public void Reset()
  701. {
  702. }
  703. public void Terminate()
  704. {
  705. }
  706. #endregion
  707. }
  708. }