CarrierUnload.cs 30 KB

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