CarrierRobotPlace.cs 34 KB

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