CarrierUnload.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  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. return true;
  253. }, () =>
  254. {
  255. int count = 0;
  256. while (count < 3)
  257. {
  258. if (_cassetteRobotModule.CarrierRobotDevice.IsReady() && !_cassetteRobotModule.CarrierRobotDevice.IsError)
  259. count++;
  260. }
  261. if (count == 3)
  262. return true;
  263. return false;
  264. }, timeout * 1000);
  265. if (ret.Item1)
  266. {
  267. if (ret.Item2 == Result.FAIL)
  268. {
  269. throw (new RoutineFaildException());
  270. }
  271. else if (ret.Item2 == Result.TIMEOUT) //timeout
  272. {
  273. throw (new RoutineFaildException());
  274. }
  275. else
  276. throw (new RoutineBreakException());
  277. }
  278. }
  279. private void SetRobotActionCommand(int id, ModuleName source, int timeout)
  280. {
  281. _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
  282. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  283. {
  284. Notify($"Set robot action command target position {source}");
  285. _cassetteRobotModule.SetRobotActionCommand(source, EnumTransferType.Place);
  286. return true;
  287. }, () =>
  288. {
  289. return _cassetteRobotModule.CheckRobotActionCommand(source, EnumTransferType.Place);
  290. }, timeout * 1000);
  291. if (ret.Item1)
  292. {
  293. if (ret.Item2 == Result.FAIL)
  294. {
  295. _cassetteRobotModule.PlaceCassetteTimeoutAlarm.Set($"place to {source} failed for robot action command interlock");
  296. throw (new RoutineFaildException());
  297. }
  298. else if (ret.Item2 == Result.TIMEOUT) //timeout
  299. {
  300. _cassetteRobotModule.PlaceCassetteTimeoutAlarm.Set($"timeout over {timeout} seconds");
  301. throw (new RoutineFaildException());
  302. }
  303. else
  304. throw (new RoutineBreakException());
  305. }
  306. }
  307. private void SetLPLoad(int id, ModuleName source, int timeout)
  308. {
  309. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  310. {
  311. Notify($"Set {source} load");
  312. var lp = Singleton<EquipmentManager>.Instance.Modules[source] as LoadPortModule;
  313. if (lp != null)
  314. lp.LPDevice.Load(out string reason);
  315. return true;
  316. }, () =>
  317. {
  318. return true;
  319. }, timeout * 1000);
  320. if (ret.Item1)
  321. {
  322. if (ret.Item2 == Result.FAIL)
  323. {
  324. throw (new RoutineFaildException());
  325. }
  326. else if (ret.Item2 == Result.TIMEOUT) //timeout
  327. {
  328. throw (new RoutineFaildException());
  329. }
  330. else
  331. throw (new RoutineBreakException());
  332. }
  333. }
  334. private void SetLPUnload(int id, ModuleName source, int timeout)
  335. {
  336. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  337. {
  338. Notify($"Set {source} unload");
  339. var lp = Singleton<EquipmentManager>.Instance.Modules[source] as LoadPortModule;
  340. if (lp != null)
  341. {
  342. var lpCarrierInfo = CarrierManager.Instance.GetCarrier(source, 0);
  343. if (lpCarrierInfo != null)
  344. {
  345. (Singleton<EquipmentManager>.Instance.Modules[ModuleName.PM1] as PMModule).CarrierOutEnd(lpCarrierInfo, source.ToString().Replace("LP", "").ToString());
  346. }
  347. lp.LPDevice.Unload(out string reason);
  348. }
  349. return true;
  350. }, () =>
  351. {
  352. return true;
  353. }, timeout * 1000);
  354. if (ret.Item1)
  355. {
  356. if (ret.Item2 == Result.FAIL)
  357. {
  358. throw (new RoutineFaildException());
  359. }
  360. else if (ret.Item2 == Result.TIMEOUT) //timeout
  361. {
  362. throw (new RoutineFaildException());
  363. }
  364. else
  365. throw (new RoutineBreakException());
  366. }
  367. }
  368. private void Place(int id, ModuleName target, int slot, Hand hand, int timeout)
  369. {
  370. _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
  371. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  372. {
  373. Notify($"Send place to {target} command to robot device");
  374. string reason;
  375. (Singleton<EquipmentManager>.Instance.Modules[target] as ITransferTarget)?.NoteTransferStart(ModuleHelper.Converter(_cassetteRobotModule.Module), hand, slot, EnumTransferType.Place);
  376. if (!_cassetteRobotModule.RobotPlace(target, slot, hand, out reason))
  377. {
  378. //_cassetteRobotModule.PlaceCassetteFailAlarm.Description = reason;
  379. _cassetteRobotModule.PlaceCassetteFailAlarm.Set(reason);
  380. return false;
  381. }
  382. return true;
  383. }, () =>
  384. {
  385. if (_cassetteRobotModule.CarrierRobotDevice.IsReady() && !_cassetteRobotModule.CarrierRobotDevice.IsError)
  386. {
  387. return true;
  388. }
  389. return false;
  390. }, timeout * 1000);
  391. if (ret.Item1)
  392. {
  393. if (ret.Item2 == Result.FAIL)
  394. {
  395. //_cassetteRobotModule.PlaceCassetteFailAlarm.Description = $"{_cassetteRobotModule.CassetteRobotDevice.ErrorCode}";
  396. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
  397. throw (new RoutineFaildException());
  398. }
  399. else if (ret.Item2 == Result.TIMEOUT) //timeout
  400. {
  401. //_cassetteRobotModule.PlaceCassetteTimeoutAlarm.Description = $"timeout over {timeout} seconds";
  402. _cassetteRobotModule.PlaceCassetteTimeoutAlarm.Set($"timeout over {timeout} seconds");
  403. throw (new RoutineFaildException());
  404. }
  405. else
  406. throw (new RoutineBreakException());
  407. }
  408. }
  409. private void RobotRequestCassettePresent(int id, Hand hand, int timeout)
  410. {
  411. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  412. {
  413. Notify("Request cassette present");
  414. if (!_cassetteRobotModule.RequestCassettePresent(hand, out string reason))
  415. {
  416. //_cassetteRobotModule.RequestCassettePresentFailAlarm.Description = reason;
  417. _cassetteRobotModule.RequestCassettePresentFailAlarm.Set(reason);
  418. return false;
  419. }
  420. return true;
  421. }, () =>
  422. {
  423. if (_cassetteRobotModule.CarrierRobotDevice.IsReady() && !_cassetteRobotModule.CarrierRobotDevice.IsError)
  424. {
  425. return true;
  426. }
  427. return false;
  428. }, timeout * 1000);
  429. if (ret.Item1)
  430. {
  431. if (ret.Item2 == Result.FAIL)
  432. {
  433. throw (new RoutineFaildException());
  434. }
  435. else if (ret.Item2 == Result.TIMEOUT) //timeout
  436. {
  437. //_cassetteRobotModule.RequestCassettePresentTimeoutAlarm.Description = $"timeout over {timeout} seconds";
  438. _cassetteRobotModule.RequestCassettePresentTimeoutAlarm.Set($"timeout over {timeout} seconds");
  439. throw (new RoutineFaildException());
  440. }
  441. else
  442. throw (new RoutineBreakException());
  443. }
  444. }
  445. private void CheckCassetteInfoByRobotSensor(int id, Hand hand, bool isAfterPick)
  446. {
  447. Tuple<bool, Result> ret = Execute(id, () =>
  448. {
  449. Notify($"Check cassette info by robot RQ present");
  450. if (SC.GetValue<bool>("System.IsSimulatorMode"))
  451. return true;
  452. if (hand == Hand.Blade1 || hand == Hand.Both)
  453. {
  454. if (!isAfterPick && _cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade1)
  455. {
  456. //_cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Description = "Cassette Robot sensor found cassette on blade 1";
  457. _cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Set("Cassette Robot sensor found cassette on blade 1");
  458. return false;
  459. }
  460. if (isAfterPick && !_cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade1)
  461. {
  462. //_cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Description = "Cassette Robot sensor no cassette on blade 1";
  463. _cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Set("Cassette Robot sensor no cassette on blade 1");
  464. return false;
  465. }
  466. }
  467. if (hand == Hand.Blade2 || hand == Hand.Both)
  468. {
  469. if (!isAfterPick && _cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade2)
  470. {
  471. //_cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Description = "Cassette Robot sensor found cassette on blade 2";
  472. _cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Set("Cassette Robot sensor found cassette on blade 2");
  473. return false;
  474. }
  475. if (isAfterPick && !_cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade2)
  476. {
  477. //_cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Description = "Cassette Robot sensor no cassette on blade 2";
  478. _cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Set("Cassette Robot sensor no cassette on blade 2");
  479. return false;
  480. }
  481. }
  482. return true;
  483. });
  484. if (ret.Item1)
  485. {
  486. if (ret.Item2 == Result.FAIL)
  487. {
  488. //_cassetteRobotModule.CheckCassetteInformationFailAlarm.Description = $"check cassette info failed.";
  489. _cassetteRobotModule.CheckCassetteInformationFailAlarm.Set($"check cassette info failed.");
  490. throw (new RoutineFaildException());
  491. }
  492. else
  493. throw (new RoutineBreakException());
  494. }
  495. }
  496. private void CheckBeforePlace(int id, ModuleName target, int slot, Hand blade)
  497. {
  498. Tuple<bool, Result> ret = Execute(id, () =>
  499. {
  500. Notify($"Check place to {target} condition");
  501. string reason = string.Empty;
  502. if (_cassetteRobotModule.CarrierRobotDevice.IsError)
  503. {
  504. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
  505. return false;
  506. }
  507. if (!_cassetteRobotModule.CarrierRobotDevice.IsReady())
  508. {
  509. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for robot isn't Ready");
  510. return false;
  511. }
  512. if (!CarrierManager.Instance.CheckNoCarrier(_destination, 0))
  513. {
  514. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {_destination} failed for pod is present");
  515. return false;
  516. }
  517. if (blade == Hand.Blade1)
  518. {
  519. if (!CarrierManager.Instance.CheckNoCarrier(target, 0))
  520. {
  521. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for {target} has carrier");
  522. return false;
  523. }
  524. if (!CarrierManager.Instance.CheckHasCarrier(Module, 0))
  525. {
  526. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for blade no carrier");
  527. return false;
  528. }
  529. }
  530. else if (blade == Hand.Blade2)
  531. {
  532. if (!CarrierManager.Instance.CheckNoCarrier(target, 0))
  533. {
  534. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for {target} has carrier");
  535. return false;
  536. }
  537. if (!CarrierManager.Instance.CheckHasCarrier(Module, 0))
  538. {
  539. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for blade no carrier");
  540. return false;
  541. }
  542. }
  543. else
  544. {
  545. if (!CarrierManager.Instance.CheckNoCarrier(target, 0))
  546. {
  547. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for {target} has carrier");
  548. return false;
  549. }
  550. if (!CarrierManager.Instance.CheckHasCarrier(Module, 0))
  551. {
  552. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for blade no carrier");
  553. return false;
  554. }
  555. }
  556. return true;
  557. });
  558. if (ret.Item1)
  559. {
  560. if (ret.Item2 == Result.FAIL)
  561. {
  562. throw (new RoutineFaildException());
  563. }
  564. }
  565. _needStartCheck = false;
  566. }
  567. private void Goto(int id, ModuleName target, int slot, Hand hand, bool isPickReady, int timeout)
  568. {
  569. _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
  570. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  571. {
  572. Notify($"Send goto to {target} command to robot device");
  573. string reason;
  574. _cassetteRobotModule.RobotGoto(target, slot, hand, isPickReady, out reason);
  575. return true;
  576. }, () =>
  577. {
  578. return true;
  579. }, timeout * 1000);
  580. if (ret.Item1)
  581. {
  582. if (ret.Item2 == Result.FAIL)
  583. {
  584. _cassetteRobotModule.GotoFailAlarm.Set($"goto to {target} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
  585. throw (new RoutineFaildException());
  586. }
  587. else if (ret.Item2 == Result.TIMEOUT) //timeout
  588. {
  589. _cassetteRobotModule.GotoTimeoutAlarm.Set($"timeout over {timeout} seconds");
  590. throw (new RoutineFaildException());
  591. }
  592. else
  593. throw (new RoutineBreakException());
  594. }
  595. }
  596. private void CheckGotoFinish(int id, ModuleName target, int timeout)
  597. {
  598. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  599. {
  600. Notify($"Check goto to {target} command finish");
  601. return true;
  602. }, () =>
  603. {
  604. if (_cassetteRobotModule.CarrierRobotDevice.IsError)
  605. return null;
  606. if (_cassetteRobotModule.CarrierRobotDevice.IsReady() && !_cassetteRobotModule.CarrierRobotDevice.IsError)
  607. {
  608. return true;
  609. }
  610. return false;
  611. }, timeout * 1000);
  612. if (ret.Item1)
  613. {
  614. if (ret.Item2 == Result.FAIL)
  615. {
  616. _cassetteRobotModule.GotoFailAlarm.Set($"goto to {target} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
  617. throw (new RoutineFaildException());
  618. }
  619. else if (ret.Item2 == Result.TIMEOUT) //timeout
  620. {
  621. _cassetteRobotModule.GotoTimeoutAlarm.Set($"timeout over {timeout} seconds");
  622. throw (new RoutineFaildException());
  623. }
  624. else
  625. throw (new RoutineBreakException());
  626. }
  627. }
  628. private void SaferDoorOpen(int id, bool isOpen, int timeout)
  629. {
  630. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  631. {
  632. Notify($"Shutter Door {(isOpen ? "Open" : "Close")}");
  633. if (isOpen)
  634. _cassetteRobotModule.DoorDevice.Open();
  635. else
  636. _cassetteRobotModule.DoorDevice.Close();
  637. if (isOpen)
  638. (Singleton<EquipmentManager>.Instance.Modules[_destination] as LoadPortModule)?.LPDevice.Unclamp(out _);
  639. return true;
  640. }, () =>
  641. {
  642. return isOpen ? _cassetteRobotModule.DoorDevice.OpenCloseStatus == Devices.DeviceStatus.Open && (Singleton<EquipmentManager>.Instance.Modules[_destination] as LoadPortModule).IsReleased : _cassetteRobotModule.DoorDevice.OpenCloseStatus == Devices.DeviceStatus.Close;
  643. }, timeout * 1000);
  644. if (ret.Item1)
  645. {
  646. if (ret.Item2 == Result.FAIL)
  647. {
  648. throw new RoutineFaildException();
  649. }
  650. else if (ret.Item2 == Result.TIMEOUT) //timeout
  651. {
  652. if (isOpen)
  653. _cassetteRobotModule.ShutterOpenTimeoutAlarm.Set($"timeout over {timeout} seconds");
  654. else
  655. _cassetteRobotModule.ShutterCloseTimeoutAlarm.Set($"timeout over {timeout} seconds");
  656. throw (new RoutineFaildException());
  657. }
  658. else
  659. throw new RoutineBreakException();
  660. }
  661. }
  662. }
  663. }