CarrierRobotPick.cs 35 KB

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