CarrierUnload.cs 30 KB

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