SrdCommonDevice.cs 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995
  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. using Aitex.Core.Common;
  24. namespace CyberX8_RT.Devices.SRD
  25. {
  26. public class SrdCommonDevice : BaseDevice, IDevice
  27. {
  28. /// <summary>
  29. /// Srd操作枚举
  30. /// </summary>
  31. private enum SrdCommonOperation
  32. {
  33. None,
  34. DoorClose,
  35. DoorOpen,
  36. ChuckVacuumOn,
  37. ChuckVacuumOff,
  38. LiftUpOn,
  39. LiftUpOff,
  40. FlippersIn,
  41. FlippersOut,
  42. ChuckATMClick
  43. }
  44. #region 常量
  45. private const string FLUID_CONTAINMENT = "FluidContainment";
  46. private const string VACUUM_VALUE = "VacuumValue";
  47. private const string WAFER_PRESENCE = "WaferPresence";
  48. private const string WAFER_PRESENCE_STATUS = "WaferPresenceStatus";
  49. private const string WATER_PRESSURE = "WaterPressure";
  50. private const string DOOR_CLOSE="DoorClose";
  51. private const string DOOR_CLOSED = "DoorClosed";
  52. private const string DOOR_OPENED = "DoorOpened";
  53. private const string WATER_ABOVE="WaterAbove";
  54. private const string WATER_BELOW = "WaterBelow";
  55. private const string CHUCK_VACUUM="ChuckVacuum";
  56. private const string EXHAUST_ON="ExhaustOn";
  57. private const string COMMON_DATA = "CommonData";
  58. private const string PERSISTENT_VALUE= "PersistentValue";
  59. private const string CHUCK_ATM_ON = "ChuckATMOn";
  60. private const string CHUCK_VACUUM_OK = "ChuckVacuumOK";
  61. private const string WAFER_PRESENT = "WaferPresent";
  62. private const string LIFT_UP = "LiftUp";
  63. private const string LIFT_UP_STATUS = "LiftUpStatus";
  64. private const string FLIPPER1_OUT_100_STATUS = "Flipper1Out100Status";
  65. private const string FLIPPER2_OUT_100_STATUS = "Flipper2Out100Status";
  66. private const string FLIPPER3_OUT_100_STATUS = "Flipper3Out100Status";
  67. private const string FLIPPER1_OUT_150_STATUS = "Flipper1Out150Status";
  68. private const string FLIPPER2_OUT_150_STATUS = "Flipper2Out150Status";
  69. private const string FLIPPER3_OUT_150_STATUS = "Flipper3Out150Status";
  70. private const string FLIPPER1_OUT_200_STATUS = "Flipper1Out200Status";
  71. private const string FLIPPER2_OUT_200_STATUS = "Flipper2Out200Status";
  72. private const string FLIPPER3_OUT_200_STATUS = "Flipper3Out200Status";
  73. private const string FLIPPERS_IN_100 = "FlippersIn100";
  74. private const string FLIPPERS_IN_150 = "FlippersIn150";
  75. private const string FLIPPERS_IN_200 = "FlippersIn200";
  76. private const string WATER_FLOW = "WaterFlow";
  77. private const string WATER_ON = "WaterOn";
  78. private const string N2_ON= "N2On";
  79. #endregion
  80. #region 内部变量
  81. /// <summary>
  82. /// Common数据
  83. /// </summary>
  84. private SrdCommonData _commonData = new SrdCommonData();
  85. /// <summary>
  86. /// 状态
  87. /// </summary>
  88. private RState _status;
  89. /// <summary>
  90. /// 当前操作
  91. /// </summary>
  92. private SrdCommonOperation _currentOperation;
  93. /// <summary>
  94. /// Wafer Presence
  95. /// </summary>
  96. private string _waferPresence;
  97. /// <summary>
  98. /// Persistent Value对象
  99. /// </summary>
  100. private SRDPersistentValue _srdPersistentValue;
  101. /// <summary>
  102. /// IsWaferPresence
  103. /// </summary>
  104. private bool _isWaferPresence = true;
  105. /// <summary>
  106. /// Total Device
  107. /// </summary>
  108. private TotalSRDDevice _totalSRDDevice;
  109. #region Routine
  110. /// <summary>
  111. /// Close Routine
  112. /// </summary>
  113. private SrdCommonDoorCloseRoutine _doorCloseRoutine;
  114. /// <summary>
  115. /// Vacuum Routine
  116. /// </summary>
  117. private SrdCommonChuckVacuumRoutine _chuckVacuumRoutine;
  118. /// <summary>
  119. /// Lift Up routine
  120. /// </summary>
  121. private SrdCommonLiftUpRoutine _liftUpRoutine;
  122. /// <summary>
  123. /// Flippers Routine
  124. /// </summary>
  125. private SrdCommonFlipperRoutine _flipperRoutine;
  126. /// <summary>
  127. /// Chuck ATM Click Routine
  128. /// </summary>
  129. private SrdCommonChuckATMRoutine _chuckATMRoutine;
  130. #endregion
  131. #endregion
  132. #region 属性
  133. /// <summary>
  134. /// Common数据
  135. /// </summary>
  136. public SrdCommonData CommonData
  137. {
  138. get { return _commonData; }
  139. }
  140. /// <summary>
  141. /// 状态
  142. /// </summary>
  143. public RState Status { get { return _status; } }
  144. /// <summary>
  145. /// Wafer Presence
  146. /// </summary>
  147. public string WaferPresence
  148. {
  149. get { return _waferPresence; }
  150. }
  151. /// <summary>
  152. /// IsWaferPresence
  153. /// </summary>
  154. public bool IsWaferPresence
  155. {
  156. get { return _isWaferPresence; }
  157. }
  158. #endregion
  159. /// <summary>
  160. /// 构造函数
  161. /// </summary>
  162. /// <param name="moduleName"></param>
  163. /// <param name="name"></param>
  164. public SrdCommonDevice(string moduleName) : base(moduleName, "Common", "Common", "Common")
  165. {
  166. }
  167. /// <summary>
  168. /// 初始化
  169. /// </summary>
  170. /// <returns></returns>
  171. public bool Initialize()
  172. {
  173. InitializeRoutine();
  174. SubscribeData();
  175. SubscribeValueAction();
  176. InitializeOperation();
  177. return true;
  178. }
  179. /// <summary>
  180. /// 初始化Routine
  181. /// </summary>
  182. private void InitializeRoutine()
  183. {
  184. _doorCloseRoutine = new SrdCommonDoorCloseRoutine(Module);
  185. _chuckVacuumRoutine = new SrdCommonChuckVacuumRoutine(Module);
  186. _liftUpRoutine = new SrdCommonLiftUpRoutine(Module);
  187. _flipperRoutine = new SrdCommonFlipperRoutine(Module);
  188. _chuckATMRoutine = new SrdCommonChuckATMRoutine(Module);
  189. }
  190. /// <summary>
  191. /// 订阅数据
  192. /// </summary>
  193. private void SubscribeData()
  194. {
  195. _srdPersistentValue = SRDPersistentManager.Instance.GetModulePersistentValue(Module);
  196. if(_srdPersistentValue==null)
  197. {
  198. LOG.WriteLog(eEvent.ERR_SRD, Module, "Persistent Value Object is not exist");
  199. }
  200. DATA.Subscribe($"{Module}.{PERSISTENT_VALUE}", () => _srdPersistentValue, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  201. DATA.Subscribe($"{Module}.{COMMON_DATA}", () => _commonData, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  202. DATA.Subscribe($"{Module}.{WAFER_PRESENCE_STATUS}", () => _waferPresence, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  203. DATA.Subscribe($"{Module}.IsWaferPresence", () => IsWaferPresence, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  204. }
  205. /// <summary>
  206. /// 订阅变量数值发生变化
  207. /// </summary>
  208. private void SubscribeValueAction()
  209. {
  210. IOModuleManager.Instance.SubscribeModuleVariable(Module, VACUUM_VALUE, UpdateVariableValue);
  211. IOModuleManager.Instance.SubscribeModuleVariable(Module, WAFER_PRESENCE, UpdateVariableValue);
  212. IOModuleManager.Instance.SubscribeModuleVariable(Module, DOOR_CLOSE, UpdateVariableValue);
  213. IOModuleManager.Instance.SubscribeModuleVariable(Module, DOOR_CLOSED, UpdateVariableValue);
  214. IOModuleManager.Instance.SubscribeModuleVariable(Module, DOOR_OPENED, UpdateVariableValue);
  215. IOModuleManager.Instance.SubscribeModuleVariable(Module, WATER_ABOVE, UpdateVariableValue);
  216. IOModuleManager.Instance.SubscribeModuleVariable(Module, WATER_BELOW, UpdateVariableValue);
  217. IOModuleManager.Instance.SubscribeModuleVariable(Module, CHUCK_VACUUM, UpdateVariableValue);
  218. IOModuleManager.Instance.SubscribeModuleVariable(Module, EXHAUST_ON, UpdateVariableValue);
  219. IOModuleManager.Instance.SubscribeModuleVariable(Module, CHUCK_ATM_ON, UpdateVariableValue);
  220. IOModuleManager.Instance.SubscribeModuleVariable(Module, CHUCK_VACUUM_OK, UpdateVariableValue);
  221. IOModuleManager.Instance.SubscribeModuleVariable(Module, WAFER_PRESENT, UpdateVariableValue);
  222. IOModuleManager.Instance.SubscribeModuleVariable(Module, LIFT_UP, UpdateVariableValue);
  223. IOModuleManager.Instance.SubscribeModuleVariable(Module, LIFT_UP_STATUS, UpdateVariableValue);
  224. IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER1_OUT_100_STATUS, UpdateVariableValue);
  225. IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER2_OUT_100_STATUS, UpdateVariableValue);
  226. IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER3_OUT_100_STATUS, UpdateVariableValue);
  227. IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER1_OUT_150_STATUS, UpdateVariableValue);
  228. IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER2_OUT_150_STATUS, UpdateVariableValue);
  229. IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER3_OUT_150_STATUS, UpdateVariableValue);
  230. IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER1_OUT_200_STATUS, UpdateVariableValue);
  231. IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER2_OUT_200_STATUS, UpdateVariableValue);
  232. IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER3_OUT_200_STATUS, UpdateVariableValue);
  233. IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPERS_IN_100, UpdateVariableValue);
  234. IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPERS_IN_150, UpdateVariableValue);
  235. IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPERS_IN_200, UpdateVariableValue);
  236. IOModuleManager.Instance.SubscribeModuleVariable(Module, WATER_FLOW, UpdateVariableValue);
  237. IOModuleManager.Instance.SubscribeModuleVariable(Module, N2_ON, UpdateVariableValue);
  238. IOModuleManager.Instance.SubscribeModuleVariable(Module, WATER_ON, UpdateVariableValue);
  239. }
  240. /// <summary>
  241. /// 初始化操作
  242. /// </summary>
  243. private void InitializeOperation()
  244. {
  245. OP.Subscribe($"{Module}.{Name}.DoorClose", DoorCloseAction);
  246. OP.Subscribe($"{Module}.{Name}.DoorOpen", DoorOpenAction);
  247. OP.Subscribe($"{Module}.{Name}.WaterOn", WaterOnAction);
  248. OP.Subscribe($"{Module}.{Name}.WaterOff", WaterOffAction);
  249. OP.Subscribe($"{Module}.{Name}.ChuckVacuumOn", ChuckVacuumOnAction);
  250. OP.Subscribe($"{Module}.{Name}.ChuckVacuumOff", ChuckVacuumOffAction);
  251. OP.Subscribe($"{Module}.{Name}.N2On", N2OnAction);
  252. OP.Subscribe($"{Module}.{Name}.N2Off", N2OffAction);
  253. OP.Subscribe($"{Module}.{Name}.LiftUpOn", LiftUpOnAction);
  254. OP.Subscribe($"{Module}.{Name}.LiftUpOff", LiftUpOffAction);
  255. OP.Subscribe($"{Module}.{Name}.ChuckATMOn", ChuckATMOnAction);
  256. OP.Subscribe($"{Module}.{Name}.ChuckATMOff", ChuckATMOffAction);
  257. OP.Subscribe($"{Module}.{Name}.FlipperIn", FlipperInAction);
  258. OP.Subscribe($"{Module}.{Name}.FlipperOut", FlipperOutAction);
  259. OP.Subscribe($"{Module}.KeyDown", KeyDownAction);
  260. OP.Subscribe($"{Module}.DisabledAction", DisabledOperation);
  261. OP.Subscribe($"{Module}.ManualAction", ManualOperation);
  262. OP.Subscribe($"{Module}.AutoAction", AutoOperation);
  263. OP.Subscribe($"{Module}.EngineeringModeAction", EngineeringModeOperation);
  264. OP.Subscribe($"{Module}.ProductionModeAction", ProductionModeOperation);
  265. OP.Subscribe($"{Module}.UpdateIsWaferPresenceAction", UpdateIsWaferPresenceAction);
  266. }
  267. /// 更新变量数值
  268. /// </summary>
  269. /// <param name="variable"></param>
  270. /// <param name="value"></param>
  271. private void UpdateVariableValue(string variable, object value)
  272. {
  273. if(!CommonData.IsDataInitialized)
  274. {
  275. CommonData.IsDataInitialized = true;
  276. }
  277. PropertyInfo property = CommonData.GetType().GetProperty(variable);
  278. if (property != null)
  279. {
  280. property.SetValue(CommonData, value);
  281. }
  282. UpdateWaferPresence(variable, value);
  283. }
  284. /// <summary>
  285. /// 更新Wafer Presence
  286. /// </summary>
  287. private void UpdateWaferPresence(string variable,object value)
  288. {
  289. if (variable == WAFER_PRESENCE&&value is double)
  290. {
  291. UpdateWaferPresence((double)value);
  292. }
  293. }
  294. /// <summary>
  295. /// 更新Wafer Presence
  296. /// </summary>
  297. /// <param name="waferPresence"></param>
  298. private void UpdateWaferPresence(double waferPresence)
  299. {
  300. if (_srdPersistentValue != null)
  301. {
  302. if (waferPresence > _srdPersistentValue.EmptyThreshold)
  303. {
  304. _waferPresence = "Empty";
  305. }
  306. else if (waferPresence >= _srdPersistentValue.WellPlacedHighThreshold && waferPresence <= _srdPersistentValue.EmptyThreshold)
  307. {
  308. _waferPresence = "PoorlyPlaced";
  309. }
  310. else if (waferPresence < _srdPersistentValue.WellPlacedLowThreshold)
  311. {
  312. _waferPresence = "PoorlyPlaced";
  313. }
  314. else
  315. {
  316. _waferPresence = "WellPlaced";
  317. }
  318. }
  319. }
  320. #region Operation
  321. #region OperationStatus
  322. /// <summary>
  323. /// DisabledAction
  324. /// </summary>
  325. /// <param name="cmd"></param>
  326. /// <param name="param"></param>
  327. /// <returns></returns>
  328. private bool DisabledOperation(string cmd, object[] args)
  329. {
  330. string currentOperation = "Disabled";
  331. SRDEntity srdEntity = Singleton<RouteManager>.Instance.GetModule<SRDEntity>(Module);
  332. if (srdEntity != null && _srdPersistentValue != null && _srdPersistentValue.OperatingMode != currentOperation)
  333. {
  334. string preOperation = _srdPersistentValue.OperatingMode;
  335. if (srdEntity.IsBusy)
  336. {
  337. LOG.WriteLog(eEvent.ERR_SRD, Module, $"{Module} is Busy, can't change to Disabled mode");
  338. return false;
  339. }
  340. srdEntity.EnterInit();
  341. SRDPersistentManager.Instance.UpdateOperationModeValue(Module, currentOperation);
  342. LOG.WriteLog(eEvent.INFO_SRD, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
  343. }
  344. return true;
  345. }
  346. /// <summary>
  347. /// ManualAction
  348. /// </summary>
  349. /// <param name="cmd"></param>
  350. /// <param name="param"></param>
  351. /// <returns></returns>
  352. private bool ManualOperation(string cmd, object[] args)
  353. {
  354. string currentOperation = "Manual";
  355. SRDEntity srdEntity = Singleton<RouteManager>.Instance.GetModule<SRDEntity>(Module);
  356. if (srdEntity != null && _srdPersistentValue != null && _srdPersistentValue.OperatingMode != currentOperation)
  357. {
  358. string preOperation = _srdPersistentValue.OperatingMode;
  359. if (srdEntity.IsBusy)
  360. {
  361. LOG.WriteLog(eEvent.ERR_SRD, Module, $"{Module} is Busy, can't change to Manual mode");
  362. return false;
  363. }
  364. srdEntity.EnterInit();
  365. SRDPersistentManager.Instance.UpdateOperationModeValue(Module, currentOperation);
  366. LOG.WriteLog(eEvent.INFO_SRD, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
  367. }
  368. return true;
  369. }
  370. /// <summary>
  371. /// AutoAction
  372. /// </summary>
  373. /// <param name="cmd"></param>
  374. /// <param name="param"></param>
  375. /// <returns></returns>
  376. private bool AutoOperation(string cmd, object[] args)
  377. {
  378. string currentOperation = "Auto";
  379. SRDEntity srdEntity = Singleton<RouteManager>.Instance.GetModule<SRDEntity>(Module);
  380. if (srdEntity != null && _srdPersistentValue != null && _srdPersistentValue.OperatingMode != currentOperation)
  381. {
  382. string preOperation = _srdPersistentValue.OperatingMode;
  383. if (srdEntity.IsBusy)
  384. {
  385. LOG.WriteLog(eEvent.ERR_SRD, Module, $"{Module} is Busy, can't switch to Auto mode");
  386. return false;
  387. }
  388. srdEntity.EnterInit();
  389. SRDPersistentManager.Instance.UpdateOperationModeValue(Module, currentOperation);
  390. LOG.WriteLog(eEvent.INFO_SRD, Module, $"Operating mode is switched from {preOperation} to {currentOperation}");
  391. }
  392. return true;
  393. }
  394. /// <summary>
  395. /// EngineeringModeAction
  396. /// </summary>
  397. /// <param name="cmd"></param>
  398. /// <param name="param"></param>
  399. /// <returns></returns>
  400. private bool EngineeringModeOperation(string cmd, object[] args)
  401. {
  402. string currentRecipeOperation = "Engineering";
  403. SRDPersistentManager.Instance.UpdateRecipeOperationModeValue(Module, currentRecipeOperation);
  404. return true;
  405. }
  406. /// <summary>
  407. /// ProductionAction
  408. /// </summary>
  409. /// <param name="cmd"></param>
  410. /// <param name="param"></param>
  411. /// <returns></returns>
  412. private bool ProductionModeOperation(string cmd, object[] args)
  413. {
  414. string currentRecipeOperation = "Production";
  415. SRDPersistentManager.Instance.UpdateRecipeOperationModeValue(Module, currentRecipeOperation);
  416. return true;
  417. }
  418. #endregion
  419. #region keydown
  420. private bool KeyDownAction(string cmd, object[] args)
  421. {
  422. string variableName = args[0].ToString();
  423. PropertyInfo property = _srdPersistentValue.GetType().GetProperty(variableName);
  424. if(property!=null)
  425. {
  426. property.SetValue(_srdPersistentValue, args[1]);
  427. }
  428. SRDPersistentManager.Instance.UpdateModulePersistentValue(Module);
  429. UpdateWaferPresence(CommonData.WaferPresence);
  430. return true;
  431. }
  432. #endregion
  433. #region Door
  434. /// <summary>
  435. /// Door Close操作
  436. /// </summary>
  437. public bool DoorCloseAction(string cmd, object[] args)
  438. {
  439. if (!JudgeRunningState(SrdCommonOperation.DoorClose))
  440. {
  441. _currentOperation = SrdCommonOperation.DoorClose;
  442. _status = _doorCloseRoutine.Start(true);
  443. return _status==RState.Running;
  444. }
  445. else
  446. {
  447. return false;
  448. }
  449. }
  450. /// <summary>
  451. /// Door Open操作
  452. /// </summary>
  453. public bool DoorOpenAction(string cmd, object[] args)
  454. {
  455. if (!JudgeRunningState(SrdCommonOperation.DoorOpen))
  456. {
  457. _currentOperation = SrdCommonOperation.DoorOpen;
  458. _status = _doorCloseRoutine.Start(false);
  459. return _status==RState.Running;
  460. }
  461. else
  462. {
  463. return false;
  464. }
  465. }
  466. #endregion
  467. #region N2 On
  468. /// <summary>
  469. /// N2 On
  470. /// </summary>
  471. /// <param name="cmd"></param>
  472. /// <param name="args"></param>
  473. /// <returns></returns>
  474. public bool N2OnAction(string cmd, object[] args)
  475. {
  476. return N2On();
  477. }
  478. /// <summary>
  479. /// N2 Off
  480. /// </summary>
  481. /// <param name="cmd"></param>
  482. /// <param name="args"></param>
  483. /// <returns></returns>
  484. public bool N2OffAction(string cmd, object[] args)
  485. {
  486. return N2Off();
  487. }
  488. /// <summary>
  489. /// Exhaust On(不确认信号)
  490. /// </summary>
  491. /// <returns></returns>
  492. public bool N2On()
  493. {
  494. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{N2_ON}");
  495. return IOModuleManager.Instance.WriteIoValue(ioName, true);
  496. }
  497. /// <summary>
  498. /// Exhaust On(不确认信号)
  499. /// </summary>
  500. /// <returns></returns>
  501. public bool N2Off()
  502. {
  503. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{N2_ON}");
  504. return IOModuleManager.Instance.WriteIoValue(ioName, false);
  505. }
  506. #endregion
  507. #region Flipper
  508. /// <summary>
  509. /// FlipperIn
  510. /// </summary>
  511. /// <param name="cmd"></param>
  512. /// <param name="args"></param>
  513. /// <returns></returns>
  514. public bool FlipperInAction(string cmd, object[] args)
  515. {
  516. int waferSize = (int)args[0];
  517. if (!JudgeRunningState(SrdCommonOperation.FlippersIn))
  518. {
  519. _currentOperation = SrdCommonOperation.FlippersIn;
  520. _status = _flipperRoutine.Start(true, waferSize);
  521. return _status == RState.Running;
  522. }
  523. else
  524. {
  525. return false;
  526. }
  527. }
  528. /// <summary>
  529. /// FlipperOut
  530. /// </summary>
  531. /// <param name="cmd"></param>
  532. /// <param name="args"></param>
  533. /// <returns></returns>
  534. public bool FlipperOutAction(string cmd, object[] args)
  535. {
  536. int waferSize = (int)args[0];
  537. if (!JudgeRunningState(SrdCommonOperation.FlippersOut))
  538. {
  539. _currentOperation = SrdCommonOperation.FlippersOut;
  540. _status = _flipperRoutine.Start(false, waferSize);
  541. return _status == RState.Running;
  542. }
  543. else
  544. {
  545. return false;
  546. }
  547. }
  548. #endregion
  549. #region Water
  550. /// <summary>
  551. /// Water On操作
  552. /// </summary>
  553. public bool WaterOnAction(string cmd, object[] args)
  554. {
  555. return WaterOn();
  556. }
  557. /// <summary>
  558. /// water Off操作
  559. /// </summary>
  560. public bool WaterOffAction(string cmd, object[] args)
  561. {
  562. return WaterOff();
  563. }
  564. /// <summary>
  565. /// Water On(不确认信号)
  566. /// </summary>
  567. /// <returns></returns>
  568. public bool WaterOn()
  569. {
  570. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{WATER_ON}");
  571. return IOModuleManager.Instance.WriteIoValue(ioName, true);
  572. }
  573. /// <summary>
  574. /// Water Off(不确认信号)
  575. /// </summary>
  576. /// <returns></returns>
  577. public bool WaterOff()
  578. {
  579. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{WATER_ON}");
  580. return IOModuleManager.Instance.WriteIoValue(ioName, false);
  581. }
  582. #endregion
  583. #region Chuck Vacuum
  584. /// <summary>
  585. /// Chuck Vacuum操作
  586. /// </summary>
  587. public bool ChuckVacuumOnAction(string cmd, object[] args)
  588. {
  589. if (!JudgeRunningState(SrdCommonOperation.ChuckVacuumOn))
  590. {
  591. _currentOperation = SrdCommonOperation.ChuckVacuumOn;
  592. _status = _chuckVacuumRoutine.Start(false);
  593. return _status==RState.Running;
  594. }
  595. else
  596. {
  597. return false;
  598. }
  599. }
  600. /// <summary>
  601. /// chuck Vacuum Off操作
  602. /// </summary>
  603. public bool ChuckVacuumOffAction(string cmd, object[] args)
  604. {
  605. if (!JudgeRunningState(SrdCommonOperation.ChuckVacuumOff))
  606. {
  607. _currentOperation = SrdCommonOperation.ChuckVacuumOff;
  608. _status= _chuckVacuumRoutine.Start(true);
  609. return _status==RState.Running;
  610. }
  611. else
  612. {
  613. return false;
  614. }
  615. }
  616. #endregion
  617. #region LiftUp
  618. /// <summary>
  619. /// Lift Up On
  620. /// </summary>
  621. /// <param name="cmd"></param>
  622. /// <param name="args"></param>
  623. /// <returns></returns>
  624. public bool LiftUpOnAction(string cmd, object[] args)
  625. {
  626. if (!JudgeRunningState(SrdCommonOperation.LiftUpOn))
  627. {
  628. _currentOperation = SrdCommonOperation.LiftUpOn;
  629. _status = _liftUpRoutine.Start(true);
  630. return _status == RState.Running;
  631. }
  632. else
  633. {
  634. return false;
  635. }
  636. }
  637. /// <summary>
  638. /// Lift Up Off
  639. /// </summary>
  640. /// <param name="cmd"></param>
  641. /// <param name="args"></param>
  642. /// <returns></returns>
  643. public bool LiftUpOffAction(string cmd, object[] args)
  644. {
  645. if (!JudgeRunningState(SrdCommonOperation.LiftUpOff))
  646. {
  647. _currentOperation = SrdCommonOperation.LiftUpOff;
  648. _status = _liftUpRoutine.Start(false);
  649. return _status == RState.Running;
  650. }
  651. else
  652. {
  653. return false;
  654. }
  655. }
  656. #endregion
  657. #region ChuckATM
  658. /// <summary>
  659. /// Chuck ATM On
  660. /// </summary>
  661. /// <param name="cmd"></param>
  662. /// <param name="args"></param>
  663. /// <returns></returns>
  664. public bool ChuckATMOnAction(string cmd, object[] args)
  665. {
  666. if(CommonData.LiftUp || CommonData.LiftUpStatus)
  667. {
  668. LOG.WriteLog(eEvent.ERR_SRD, Module, "LiftUp is on, can't chuckATM");
  669. return false;
  670. }
  671. return ChuckATM(true);
  672. }
  673. /// <summary>
  674. /// Chuck ATM Off
  675. /// </summary>
  676. /// <param name="cmd"></param>
  677. /// <param name="args"></param>
  678. /// <returns></returns>
  679. public bool ChuckATMOffAction(string cmd, object[] args)
  680. {
  681. return ChuckATM(false);
  682. }
  683. private bool ChuckATM(bool value)
  684. {
  685. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{CHUCK_ATM_ON}");
  686. return IOModuleManager.Instance.WriteIoValue(ioName, value);
  687. }
  688. /// <summary>
  689. /// Chuck ATM Routine
  690. /// </summary>
  691. /// <param name="cmd"></param>
  692. /// <param name="args"></param>
  693. /// <returns></returns>
  694. public bool ChuckATMAction(string cmd, object[] args)
  695. {
  696. if (!JudgeRunningState(SrdCommonOperation.ChuckATMClick))
  697. {
  698. _currentOperation = SrdCommonOperation.ChuckATMClick;
  699. _status = _chuckATMRoutine.Start();
  700. return _status == RState.Running;
  701. }
  702. else
  703. {
  704. return false;
  705. }
  706. }
  707. #endregion
  708. #region Water Above
  709. /// <summary>
  710. /// Water Above On操作
  711. /// </summary>
  712. public bool WaterAboveOnAction(string cmd, object[] args)
  713. {
  714. return WaterAboveOn();
  715. }
  716. /// <summary>
  717. /// water above Off操作
  718. /// </summary>
  719. public bool WaterAboveOffAction(string cmd, object[] args)
  720. {
  721. return WaterAboveOff();
  722. }
  723. /// <summary>
  724. /// Water Above On(不确认信号)
  725. /// </summary>
  726. /// <returns></returns>
  727. public bool WaterAboveOn()
  728. {
  729. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{WATER_ABOVE}");
  730. return IOModuleManager.Instance.WriteIoValue(ioName, true);
  731. }
  732. /// <summary>
  733. /// Water Above Off(不确认信号)
  734. /// </summary>
  735. /// <returns></returns>
  736. public bool WaterAboveOff()
  737. {
  738. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{WATER_ABOVE}");
  739. return IOModuleManager.Instance.WriteIoValue(ioName, false);
  740. }
  741. #endregion
  742. #region Water Below
  743. /// <summary>
  744. /// Water Below On操作
  745. /// </summary>
  746. public bool WaterBelowOnAction(string cmd, object[] args)
  747. {
  748. return WaterBelowOn();
  749. }
  750. /// <summary>
  751. /// water Below Off操作
  752. /// </summary>
  753. public bool WaterBelowOffAction(string cmd, object[] args)
  754. {
  755. return WaterBelowOff();
  756. }
  757. /// <summary>
  758. /// Water Below On(不确认信号)
  759. /// </summary>
  760. /// <returns></returns>
  761. public bool WaterBelowOn()
  762. {
  763. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{WATER_BELOW}");
  764. return IOModuleManager.Instance.WriteIoValue(ioName, true);
  765. }
  766. /// <summary>
  767. /// Water Below Off(不确认信号)
  768. /// </summary>
  769. /// <returns></returns>
  770. public bool WaterBelowOff()
  771. {
  772. string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{WATER_BELOW}");
  773. return IOModuleManager.Instance.WriteIoValue(ioName, false);
  774. }
  775. #endregion
  776. /// <summary>
  777. /// Update IsWaferPresence 标志位
  778. /// </summary>
  779. /// <param name="cmd"></param>
  780. /// <param name="args"></param>
  781. /// <returns></returns>
  782. public bool UpdateIsWaferPresenceAction(string cmd, object[] args)
  783. {
  784. _isWaferPresence = (bool)args[0];
  785. return true;
  786. }
  787. /// <summary>
  788. /// 判定运行状态
  789. /// </summary>
  790. /// <returns></returns>
  791. private bool JudgeRunningState(SrdCommonOperation operation)
  792. {
  793. if (_status == RState.Running)
  794. {
  795. EV.PostAlarmLog($"{Module}", eEvent.ERR_SRD, $"{Module} current execute {_currentOperation},cannot {operation}");
  796. return true;
  797. }
  798. return false;
  799. }
  800. /// <summary>
  801. /// ErrorOperation
  802. /// </summary>
  803. public void EnterErrorOperation()
  804. {
  805. //关闭风扇
  806. if (CommonData.N2On)
  807. {
  808. bool result = N2OffAction("", null);
  809. if (!result)
  810. {
  811. LOG.WriteLog(eEvent.ERR_SRD, Module, "EnterError: N2 Off is failed");
  812. }
  813. }
  814. //关闭WaterAbove
  815. if (CommonData.WaterOn)
  816. {
  817. bool result = WaterOff();
  818. if (!result)
  819. {
  820. LOG.WriteLog(eEvent.INFO_SRD, Module, "EnterError: Water Off is failed");
  821. }
  822. }
  823. //停电机
  824. JetAxisBase _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
  825. if (_rotationAxis != null && _rotationAxis.IsRun) _rotationAxis.StopPositionOperation();
  826. }
  827. #endregion
  828. /// <summary>
  829. /// Rotation InterLock
  830. /// </summary>
  831. /// <returns></returns>
  832. public bool RotationInterLock()
  833. {
  834. if (!CommonData.DoorClosed)
  835. {
  836. LOG.WriteLog(eEvent.ERR_SRD, Module, "Door is not closed. Rotation can not position");
  837. return false;
  838. }
  839. //Check Flippers
  840. if (CommonData.FlippersIn150 || CommonData.FlippersIn200) //|| _srdCommon.CommonData.FlippersIn100
  841. {
  842. LOG.WriteLog(eEvent.ERR_SRD, Module, "FlippersIn is on. Rotation can not position");
  843. return false;
  844. }
  845. if (!CommonData.Flipper1Out150Status || !CommonData.Flipper2Out150Status || !CommonData.Flipper3Out150Status
  846. || !CommonData.Flipper1Out200Status || !CommonData.Flipper2Out200Status || !CommonData.Flipper3Out200Status)
  847. //|| !_srdCommon.CommonData.Flipper1Out100Status || !_srdCommon.CommonData.Flipper2Out100Status || !_srdCommon.CommonData.Flipper3Out100Status
  848. {
  849. LOG.WriteLog(eEvent.ERR_SRD, Module, "Flippers are at In position. Rotation can not position");
  850. return false;
  851. }
  852. return true;
  853. }
  854. /// <summary>
  855. /// 定时器
  856. /// </summary>
  857. /// <returns></returns>
  858. public bool OnTimer()
  859. {
  860. if (_status == RState.Running)
  861. {
  862. if (_currentOperation != SrdCommonOperation.None)
  863. {
  864. IRoutine routine = GetCurrentRoutine(_currentOperation);
  865. if (routine != null)
  866. {
  867. CheckRoutineState(routine, _currentOperation);
  868. }
  869. else
  870. {
  871. EndOperation();
  872. }
  873. }
  874. }
  875. //将公有的数据赋值于对象的数值
  876. if (_totalSRDDevice == null)
  877. {
  878. _totalSRDDevice = DEVICE.GetDevice<TotalSRDDevice>("SRD");
  879. }
  880. if (_totalSRDDevice != null)
  881. {
  882. CommonData.FluidContainment = _totalSRDDevice.FluidContainment;
  883. CommonData.WaterPressure = _totalSRDDevice.WaterPressure;
  884. }
  885. return true;
  886. }
  887. /// <summary>
  888. /// 获取当前操作对应的Routine
  889. /// </summary>
  890. /// <param name="currentOperation"></param>
  891. /// <returns></returns>
  892. private IRoutine GetCurrentRoutine(SrdCommonOperation currentOperation)
  893. {
  894. switch (currentOperation)
  895. {
  896. case SrdCommonOperation.DoorClose:
  897. case SrdCommonOperation.DoorOpen:
  898. return _doorCloseRoutine;
  899. case SrdCommonOperation.ChuckVacuumOn:
  900. case SrdCommonOperation.ChuckVacuumOff:
  901. return _chuckVacuumRoutine;
  902. case SrdCommonOperation.LiftUpOn:
  903. case SrdCommonOperation.LiftUpOff:
  904. return _liftUpRoutine;
  905. case SrdCommonOperation.FlippersIn:
  906. case SrdCommonOperation.FlippersOut:
  907. return _flipperRoutine;
  908. case SrdCommonOperation.ChuckATMClick:
  909. return _chuckATMRoutine;
  910. default:
  911. return null;
  912. }
  913. }
  914. /// <summary>
  915. /// 检验Routine状态
  916. /// </summary>
  917. /// <param name="routine"></param>
  918. /// <param name="currentOperation"></param>
  919. private void CheckRoutineState(IRoutine routine, SrdCommonOperation currentOperation)
  920. {
  921. RState state = routine.Monitor();
  922. if (state == RState.End)
  923. {
  924. EndOperation();
  925. }
  926. else if (state == RState.Failed || state == RState.Timeout)
  927. {
  928. LOG.WriteLog(eEvent.ERR_SRD, $"{Module}", $"{currentOperation} error");
  929. EndOperation();
  930. }
  931. }
  932. /// <summary>
  933. /// 结束操作
  934. /// </summary>
  935. private void EndOperation()
  936. {
  937. _status = RState.End;
  938. _currentOperation = SrdCommonOperation.None;
  939. }
  940. #region 设备接口
  941. /// <summary>
  942. /// 监控
  943. /// </summary>
  944. public void Monitor()
  945. {
  946. }
  947. public void Reset()
  948. {
  949. }
  950. public void Terminate()
  951. {
  952. }
  953. #endregion
  954. }
  955. }