CarrierUnload.cs 32 KB

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