CarrierRobotPick.cs 36 KB

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