CarrierRobotPlace.cs 34 KB

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