CarrierRobotPick.cs 35 KB

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