CarrierUnload.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. using Aitex.Core.RT.Routine;
  2. using Aitex.Core.RT.SCCore;
  3. using Aitex.Core.Util;
  4. using Aitex.Sorter.Common;
  5. using MECF.Framework.Common.Equipment;
  6. using MECF.Framework.Common.Schedulers;
  7. using MECF.Framework.Common.SubstrateTrackings;
  8. using MECF.Framework.RT.EquipmentLibrary.LogicUnits;
  9. using System;
  10. using System.Collections.Generic;
  11. using FurnaceRT.Equipments.FIMSs;
  12. using FurnaceRT.Equipments.LPs;
  13. using FurnaceRT.Equipments.Stockers;
  14. using FurnaceRT.Equipments.Systems;
  15. using static FurnaceRT.Equipments.FIMSs.FIMSModule;
  16. namespace FurnaceRT.Equipments.CarrierRobots
  17. {
  18. public class CarrierUnload : ModuleRoutine, IRoutine
  19. {
  20. enum RoutineStep
  21. {
  22. Place,
  23. DoorOpen,
  24. DoorClose,
  25. RobotRequestCassettePresent,
  26. CheckCassetteInfoByRobotSensor,
  27. SetStageLock,
  28. SetStageUnlock,
  29. CheckBeforePlace,
  30. SetRobotActionCommand,
  31. Goto,
  32. CheckGotoFinish,
  33. }
  34. private CarrierRobotModule _cassetteRobotModule;
  35. private ModuleName _destination;
  36. private int _destinationSlot;
  37. private Hand _blade;
  38. private int _timeout = 0;
  39. private RD_TRIG _holdTrig = new RD_TRIG();
  40. private R_TRIG _emergencyStopTrig = new R_TRIG();
  41. private R_TRIG _pauseTrig = new R_TRIG();
  42. private R_TRIG _resumeTrig = new R_TRIG();
  43. private RoutineStep _routineStep;
  44. private double _durationTime = 0;
  45. private bool _isHasAlarm = false;
  46. private bool _needStartCheck = true;
  47. public CarrierUnload(CarrierRobotModule cassetteModule)
  48. {
  49. _cassetteRobotModule = cassetteModule;
  50. Module = cassetteModule.Module;
  51. Name = "Unload";
  52. }
  53. public void Init(ModuleName destination, int destinationSlot, Hand blade, bool isHasAlarm)
  54. {
  55. _destination = destination;
  56. _destinationSlot = destinationSlot;
  57. _blade = blade;
  58. var para = new List<object> { _destination, _destinationSlot, _blade, true };
  59. _cassetteRobotModule.PlaceCassetteFailAlarm.RetryMessage = (int)CarrierRobotModule.MSG.UnloadRetry;
  60. _cassetteRobotModule.PlaceCassetteFailAlarm.RetryMessageParas = para.ToArray();
  61. _cassetteRobotModule.PlaceCassetteTimeoutAlarm.RetryMessage = (int)CarrierRobotModule.MSG.UnloadRetry;
  62. _cassetteRobotModule.PlaceCassetteTimeoutAlarm.RetryMessageParas = para.ToArray();
  63. _cassetteRobotModule.RequestCassettePresentFailAlarm.RetryMessage = (int)CarrierRobotModule.MSG.UnloadRetry;
  64. _cassetteRobotModule.RequestCassettePresentFailAlarm.RetryMessageParas = para.ToArray();
  65. _cassetteRobotModule.RequestCassettePresentTimeoutAlarm.RetryMessage = (int)CarrierRobotModule.MSG.UnloadRetry;
  66. _cassetteRobotModule.RequestCassettePresentTimeoutAlarm.RetryMessageParas = para.ToArray();
  67. _cassetteRobotModule.RobotHasError.RetryMessage = (int)CarrierRobotModule.MSG.UnloadRetry;
  68. _cassetteRobotModule.RobotHasError.RetryMessageParas = para.ToArray();
  69. _cassetteRobotModule.ShutterOpenTimeoutAlarm.RetryMessage = (int)CarrierRobotModule.MSG.UnloadRetry;
  70. _cassetteRobotModule.ShutterOpenTimeoutAlarm.RetryMessageParas = para.ToArray();
  71. _cassetteRobotModule.ShutterCloseTimeoutAlarm.RetryMessage = (int)CarrierRobotModule.MSG.UnloadRetry;
  72. _cassetteRobotModule.ShutterCloseTimeoutAlarm.RetryMessageParas = para.ToArray();
  73. _isHasAlarm = isHasAlarm;
  74. if (!_isHasAlarm)
  75. _needStartCheck = true;
  76. }
  77. public Result Start(params object[] objs)
  78. {
  79. // 抛出过alarm就不reset
  80. if (!_isHasAlarm)
  81. {
  82. Reset();
  83. }
  84. else
  85. {
  86. _historySteps.Remove((int)_routineStep);
  87. _isHasAlarm = false;
  88. ResetState();
  89. }
  90. _holdTrig.RST = true;
  91. _emergencyStopTrig.RST = true;
  92. _pauseTrig.RST = true;
  93. _resumeTrig.RST = true;
  94. _timeout = SC.GetValue<int>($"{Module}.MotionTimeout");
  95. if (_needStartCheck)
  96. {
  97. if (!Singleton<EquipmentManager>.Instance.Modules.ContainsKey(_destination))
  98. {
  99. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {_destination} failed for not install");
  100. return Result.FAIL;
  101. }
  102. if (ModuleHelper.IsLoadPort(_destination))
  103. {
  104. var lpModule = Singleton<EquipmentManager>.Instance.Modules[_destination] as LoadPortModule;
  105. if (lpModule == null)
  106. {
  107. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {_destination} failed for not install");
  108. return Result.FAIL;
  109. }
  110. if (lpModule != null && !lpModule.CheckReadyForTransfer(ModuleHelper.Converter(Module), _blade, _destinationSlot, EnumTransferType.Place, out string reason))
  111. {
  112. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {_destination} failed for {reason}");
  113. return Result.FAIL;
  114. }
  115. }
  116. else if (_destination == ModuleName.FIMS1 || _destination == ModuleName.FIMS2)
  117. {
  118. var fims = Singleton<EquipmentManager>.Instance.Modules[_destination] as FIMSModule;
  119. if (fims == null)
  120. {
  121. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {_destination} failed for not install");
  122. return Result.FAIL;
  123. }
  124. if (fims != null && !fims.CheckReadyForTransfer(ModuleHelper.Converter(Module), _blade, _destinationSlot, EnumTransferType.Place, out string reason))
  125. {
  126. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {_destination} failed for {reason}");
  127. return Result.FAIL;
  128. }
  129. if (!SC.GetValue<bool>("System.IsSimulatorMode"))
  130. {
  131. if (fims != null && fims.IsFoupExist)
  132. {
  133. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {_destination} failed for carrier is present");
  134. return Result.FAIL;
  135. }
  136. }
  137. }
  138. else
  139. {
  140. var stockerModule = Singleton<EquipmentManager>.Instance.Modules[_destination] as StockerModule;
  141. if (stockerModule == null)
  142. {
  143. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {_destination} failed for not install");
  144. return Result.FAIL;
  145. }
  146. if (!SC.GetValue<bool>("System.IsSimulatorMode"))
  147. {
  148. if (stockerModule != null && stockerModule.IsFoupPresent)
  149. {
  150. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {_destination} failed for carrier is present");
  151. return Result.FAIL;
  152. }
  153. }
  154. }
  155. if (SC.GetValue<bool>("System.IsSimulatorMode"))
  156. {
  157. if (!CarrierManager.Instance.CheckHasCarrier(ModuleName.CarrierRobot, 0))
  158. {
  159. _cassetteRobotModule.BladeCassetteNotPresentWarning.Set($"{ModuleName.CarrierRobot} cassette not present");
  160. return Result.FAIL;
  161. }
  162. }
  163. else
  164. {
  165. if (!_cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade1 || !CarrierManager.Instance.CheckHasCarrier(ModuleName.CarrierRobot, 0))
  166. {
  167. _cassetteRobotModule.BladeCassetteNotPresentWarning.Set($"{ModuleName.CarrierRobot} cassette not present");
  168. return Result.FAIL;
  169. }
  170. }
  171. if (!CarrierManager.Instance.CheckNoCarrier(_destination, 0))
  172. {
  173. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {_destination} failed for carrier is present");
  174. return Result.FAIL;
  175. }
  176. }
  177. Notify($"Start");
  178. return Result.RUN;
  179. }
  180. public void Abort()
  181. {
  182. _cassetteRobotModule.ResetRobotActionCommand();
  183. _cassetteRobotModule.Stop();
  184. (Singleton<EquipmentManager>.Instance.Modules[_destination] as ITransferTarget)?.NoteTransferStop(ModuleHelper.Converter(_cassetteRobotModule.Module), _blade, _destinationSlot, EnumTransferType.Place);
  185. }
  186. public override Result Monitor()
  187. {
  188. try
  189. {
  190. PauseRountine(_cassetteRobotModule.CarrierRobotDevice.IsPause);
  191. if (_cassetteRobotModule.CarrierRobotDevice.IsPause)
  192. return Result.RUN;
  193. CheckBeforePlace((int)RoutineStep.CheckBeforePlace, _destination, _destinationSlot, _blade);
  194. Goto((int)RoutineStep.Goto, _destination, _destinationSlot, _blade, true, _timeout);
  195. if (_destination == ModuleName.LP1 || _destination == ModuleName.LP2)
  196. SaferDoorOpen((int)RoutineStep.DoorOpen, true, _timeout);
  197. CheckGotoFinish((int)RoutineStep.CheckGotoFinish, _destination, _timeout);
  198. if (_cassetteRobotModule.TrigActionCommand != null)
  199. SetRobotActionCommand((int)RoutineStep.SetRobotActionCommand, _destination, _timeout);
  200. Place((int)RoutineStep.Place, _destination, _destinationSlot, _blade, _timeout);
  201. if (_destination == ModuleName.LP1 || _destination == ModuleName.LP2)
  202. SaferDoorOpen((int)RoutineStep.DoorClose, false, _timeout);
  203. RobotRequestCassettePresent((int)RoutineStep.RobotRequestCassettePresent, _blade, _timeout);
  204. CheckCassetteInfoByRobotSensor((int)RoutineStep.CheckCassetteInfoByRobotSensor, _blade, false);
  205. }
  206. catch (RoutineBreakException)
  207. {
  208. return Result.RUN;
  209. }
  210. catch (RoutineFaildException ex)
  211. {
  212. _cassetteRobotModule.ResetRobotActionCommand();
  213. (Singleton<EquipmentManager>.Instance.Modules[_destination] as ITransferTarget)?.NoteTransferStop(ModuleHelper.Converter(_cassetteRobotModule.Module), _blade, _destinationSlot, EnumTransferType.Place);
  214. return Result.FAIL;
  215. }
  216. if (SC.GetValue<bool>("System.IsSimulatorMode"))
  217. CarrierManager.Instance.DeleteCarrier(_destination.ToString());
  218. _cassetteRobotModule.ResetRobotActionCommand();
  219. (Singleton<EquipmentManager>.Instance.Modules[_destination] as ITransferTarget)?.NoteTransferStop(ModuleHelper.Converter(_cassetteRobotModule.Module), _blade, _destinationSlot, EnumTransferType.Place);
  220. Notify("Finished");
  221. return Result.DONE;
  222. }
  223. private void SetRobotActionCommand(int id, ModuleName source, int timeout)
  224. {
  225. _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
  226. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  227. {
  228. Notify($"Set robot action command target position {source}");
  229. _cassetteRobotModule.SetRobotActionCommand(source, EnumTransferType.Place);
  230. return true;
  231. }, () =>
  232. {
  233. return _cassetteRobotModule.CheckRobotActionCommand(source, EnumTransferType.Place);
  234. }, timeout * 1000);
  235. if (ret.Item1)
  236. {
  237. if (ret.Item2 == Result.FAIL)
  238. {
  239. _cassetteRobotModule.PlaceCassetteTimeoutAlarm.Set($"place to {source} failed for robot action command interlock");
  240. throw (new RoutineFaildException());
  241. }
  242. else if (ret.Item2 == Result.TIMEOUT) //timeout
  243. {
  244. _cassetteRobotModule.PlaceCassetteTimeoutAlarm.Set($"timeout over {timeout} seconds");
  245. throw (new RoutineFaildException());
  246. }
  247. else
  248. throw (new RoutineBreakException());
  249. }
  250. }
  251. private void Place(int id, ModuleName target, int slot, Hand hand, int timeout)
  252. {
  253. _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
  254. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  255. {
  256. Notify($"Send place to {target} command to robot device");
  257. string reason;
  258. (Singleton<EquipmentManager>.Instance.Modules[target] as ITransferTarget)?.NoteTransferStart(ModuleHelper.Converter(_cassetteRobotModule.Module), hand, slot, EnumTransferType.Place);
  259. if (!_cassetteRobotModule.RobotPlace(target, slot, hand, out reason))
  260. {
  261. //_cassetteRobotModule.PlaceCassetteFailAlarm.Description = reason;
  262. _cassetteRobotModule.PlaceCassetteFailAlarm.Set(reason);
  263. return false;
  264. }
  265. return true;
  266. }, () =>
  267. {
  268. if (_cassetteRobotModule.CarrierRobotDevice.IsReady() && !_cassetteRobotModule.CarrierRobotDevice.IsError)
  269. {
  270. return true;
  271. }
  272. return false;
  273. }, timeout * 1000);
  274. if (ret.Item1)
  275. {
  276. if (ret.Item2 == Result.FAIL)
  277. {
  278. //_cassetteRobotModule.PlaceCassetteFailAlarm.Description = $"{_cassetteRobotModule.CassetteRobotDevice.ErrorCode}";
  279. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
  280. throw (new RoutineFaildException());
  281. }
  282. else if (ret.Item2 == Result.TIMEOUT) //timeout
  283. {
  284. //_cassetteRobotModule.PlaceCassetteTimeoutAlarm.Description = $"timeout over {timeout} seconds";
  285. _cassetteRobotModule.PlaceCassetteTimeoutAlarm.Set($"timeout over {timeout} seconds");
  286. throw (new RoutineFaildException());
  287. }
  288. else
  289. throw (new RoutineBreakException());
  290. }
  291. }
  292. private void RobotRequestCassettePresent(int id, Hand hand, int timeout)
  293. {
  294. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  295. {
  296. Notify("Request cassette present");
  297. if (!_cassetteRobotModule.RequestCassettePresent(hand, out string reason))
  298. {
  299. //_cassetteRobotModule.RequestCassettePresentFailAlarm.Description = reason;
  300. _cassetteRobotModule.RequestCassettePresentFailAlarm.Set(reason);
  301. return false;
  302. }
  303. return true;
  304. }, () =>
  305. {
  306. if (_cassetteRobotModule.CarrierRobotDevice.IsReady() && !_cassetteRobotModule.CarrierRobotDevice.IsError)
  307. {
  308. return true;
  309. }
  310. return false;
  311. }, timeout * 1000);
  312. if (ret.Item1)
  313. {
  314. if (ret.Item2 == Result.FAIL)
  315. {
  316. throw (new RoutineFaildException());
  317. }
  318. else if (ret.Item2 == Result.TIMEOUT) //timeout
  319. {
  320. //_cassetteRobotModule.RequestCassettePresentTimeoutAlarm.Description = $"timeout over {timeout} seconds";
  321. _cassetteRobotModule.RequestCassettePresentTimeoutAlarm.Set($"timeout over {timeout} seconds");
  322. throw (new RoutineFaildException());
  323. }
  324. else
  325. throw (new RoutineBreakException());
  326. }
  327. }
  328. private void CheckCassetteInfoByRobotSensor(int id, Hand hand, bool isAfterPick)
  329. {
  330. Tuple<bool, Result> ret = Execute(id, () =>
  331. {
  332. Notify($"Check cassette info by robot RQ present");
  333. if (SC.GetValue<bool>("System.IsSimulatorMode"))
  334. return true;
  335. if (hand == Hand.Blade1 || hand == Hand.Both)
  336. {
  337. if (!isAfterPick && _cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade1)
  338. {
  339. //_cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Description = "Cassette Robot sensor found cassette on blade 1";
  340. _cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Set("Cassette Robot sensor found cassette on blade 1");
  341. return false;
  342. }
  343. if (isAfterPick && !_cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade1)
  344. {
  345. //_cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Description = "Cassette Robot sensor no cassette on blade 1";
  346. _cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Set("Cassette Robot sensor no cassette on blade 1");
  347. return false;
  348. }
  349. }
  350. if (hand == Hand.Blade2 || hand == Hand.Both)
  351. {
  352. if (!isAfterPick && _cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade2)
  353. {
  354. //_cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Description = "Cassette Robot sensor found cassette on blade 2";
  355. _cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Set("Cassette Robot sensor found cassette on blade 2");
  356. return false;
  357. }
  358. if (isAfterPick && !_cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade2)
  359. {
  360. //_cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Description = "Cassette Robot sensor no cassette on blade 2";
  361. _cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Set("Cassette Robot sensor no cassette on blade 2");
  362. return false;
  363. }
  364. }
  365. return true;
  366. });
  367. if (ret.Item1)
  368. {
  369. if (ret.Item2 == Result.FAIL)
  370. {
  371. //_cassetteRobotModule.CheckCassetteInformationFailAlarm.Description = $"check cassette info failed.";
  372. _cassetteRobotModule.CheckCassetteInformationFailAlarm.Set($"check cassette info failed.");
  373. throw (new RoutineFaildException());
  374. }
  375. else
  376. throw (new RoutineBreakException());
  377. }
  378. }
  379. private void CheckBeforePlace(int id, ModuleName target, int slot, Hand blade)
  380. {
  381. Tuple<bool, Result> ret = Execute(id, () =>
  382. {
  383. Notify($"Check place to {target} condition");
  384. string reason = string.Empty;
  385. if (_cassetteRobotModule.CarrierRobotDevice.IsError)
  386. {
  387. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
  388. return false;
  389. }
  390. if (!_cassetteRobotModule.CarrierRobotDevice.IsReady())
  391. {
  392. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for robot isn't Ready");
  393. return false;
  394. }
  395. if (!CarrierManager.Instance.CheckNoCarrier(_destination, 0))
  396. {
  397. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {_destination} failed for pod is present");
  398. return false;
  399. }
  400. if (blade == Hand.Blade1)
  401. {
  402. if (!CarrierManager.Instance.CheckNoCarrier(target, 0))
  403. {
  404. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for {target} has carrier");
  405. return false;
  406. }
  407. if (!CarrierManager.Instance.CheckHasCarrier(Module, 0))
  408. {
  409. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for blade no carrier");
  410. return false;
  411. }
  412. }
  413. else if (blade == Hand.Blade2)
  414. {
  415. if (!CarrierManager.Instance.CheckNoCarrier(target, 0))
  416. {
  417. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for {target} has carrier");
  418. return false;
  419. }
  420. if (!CarrierManager.Instance.CheckHasCarrier(Module, 0))
  421. {
  422. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for blade no carrier");
  423. return false;
  424. }
  425. }
  426. else
  427. {
  428. if (!CarrierManager.Instance.CheckNoCarrier(target, 0))
  429. {
  430. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for {target} has carrier");
  431. return false;
  432. }
  433. if (!CarrierManager.Instance.CheckHasCarrier(Module, 0))
  434. {
  435. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for blade no carrier");
  436. return false;
  437. }
  438. }
  439. return true;
  440. });
  441. if (ret.Item1)
  442. {
  443. if (ret.Item2 == Result.FAIL)
  444. {
  445. throw (new RoutineFaildException());
  446. }
  447. }
  448. _needStartCheck = false;
  449. }
  450. private void Goto(int id, ModuleName target, int slot, Hand hand, bool isPickReady, int timeout)
  451. {
  452. _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
  453. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  454. {
  455. Notify($"Send goto to {target} command to robot device");
  456. string reason;
  457. _cassetteRobotModule.RobotGoto(target, slot, hand, isPickReady, out reason);
  458. return true;
  459. }, () =>
  460. {
  461. return true;
  462. }, timeout * 1000);
  463. if (ret.Item1)
  464. {
  465. if (ret.Item2 == Result.FAIL)
  466. {
  467. _cassetteRobotModule.GotoFailAlarm.Set($"goto to {target} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
  468. throw (new RoutineFaildException());
  469. }
  470. else if (ret.Item2 == Result.TIMEOUT) //timeout
  471. {
  472. _cassetteRobotModule.GotoTimeoutAlarm.Set($"timeout over {timeout} seconds");
  473. throw (new RoutineFaildException());
  474. }
  475. else
  476. throw (new RoutineBreakException());
  477. }
  478. }
  479. private void CheckGotoFinish(int id, ModuleName target, int timeout)
  480. {
  481. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  482. {
  483. Notify($"Check goto to {target} command finish");
  484. return true;
  485. }, () =>
  486. {
  487. if (_cassetteRobotModule.CarrierRobotDevice.IsError)
  488. return null;
  489. if (_cassetteRobotModule.CarrierRobotDevice.IsReady() && !_cassetteRobotModule.CarrierRobotDevice.IsError)
  490. {
  491. return true;
  492. }
  493. return false;
  494. }, timeout * 1000);
  495. if (ret.Item1)
  496. {
  497. if (ret.Item2 == Result.FAIL)
  498. {
  499. _cassetteRobotModule.GotoFailAlarm.Set($"goto to {target} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
  500. throw (new RoutineFaildException());
  501. }
  502. else if (ret.Item2 == Result.TIMEOUT) //timeout
  503. {
  504. _cassetteRobotModule.GotoTimeoutAlarm.Set($"timeout over {timeout} seconds");
  505. throw (new RoutineFaildException());
  506. }
  507. else
  508. throw (new RoutineBreakException());
  509. }
  510. }
  511. private void SaferDoorOpen(int id, bool isOpen, int timeout)
  512. {
  513. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  514. {
  515. Notify($"Shutter Door {(isOpen ? "Open" : "Close")}");
  516. if (isOpen)
  517. _cassetteRobotModule.DoorDevice.Open();
  518. else
  519. _cassetteRobotModule.DoorDevice.Close();
  520. if (isOpen)
  521. (Singleton<EquipmentManager>.Instance.Modules[_destination] as LoadPortModule)?.LPDevice.Unclamp(out _);
  522. return true;
  523. }, () =>
  524. {
  525. return isOpen ? _cassetteRobotModule.DoorDevice.OpenCloseStatus == Devices.DeviceStatus.Open && (Singleton<EquipmentManager>.Instance.Modules[_destination] as LoadPortModule).IsReleased : _cassetteRobotModule.DoorDevice.OpenCloseStatus == Devices.DeviceStatus.Close;
  526. }, timeout * 1000);
  527. if (ret.Item1)
  528. {
  529. if (ret.Item2 == Result.FAIL)
  530. {
  531. throw new RoutineFaildException();
  532. }
  533. else if (ret.Item2 == Result.TIMEOUT) //timeout
  534. {
  535. if (isOpen)
  536. _cassetteRobotModule.ShutterOpenTimeoutAlarm.Set($"timeout over {timeout} seconds");
  537. else
  538. _cassetteRobotModule.ShutterCloseTimeoutAlarm.Set($"timeout over {timeout} seconds");
  539. throw (new RoutineFaildException());
  540. }
  541. else
  542. throw new RoutineBreakException();
  543. }
  544. }
  545. }
  546. }