CarrierRobotPlace.cs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  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. if (!ModuleHelper.IsLoadPort1And2(_destination))
  418. return true;
  419. if (_cassetteRobotModule.SensorFTRHomeCX != null && _cassetteRobotModule.SensorFTRHomeCX.Value)
  420. return true;
  421. }
  422. return false;
  423. }, timeout * 1000);
  424. if (ret.Item1)
  425. {
  426. if (ret.Item2 == Result.FAIL)
  427. {
  428. //_cassetteRobotModule.PlaceCassetteFailAlarm.Description = $"{_cassetteRobotModule.CassetteRobotDevice.ErrorCode}";
  429. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
  430. throw (new RoutineFaildException());
  431. }
  432. else if (ret.Item2 == Result.TIMEOUT) //timeout
  433. {
  434. //_cassetteRobotModule.PlaceCassetteTimeoutAlarm.Description = $"timeout over {timeout} seconds";
  435. _cassetteRobotModule.PlaceCassetteTimeoutAlarm.Set($"timeout over {timeout} seconds");
  436. throw (new RoutineFaildException());
  437. }
  438. else
  439. throw (new RoutineBreakException());
  440. }
  441. }
  442. private void RobotRequestCassettePresent(int id, Hand hand, int timeout)
  443. {
  444. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  445. {
  446. Notify("Request cassette present");
  447. if (!_cassetteRobotModule.RequestCassettePresent(hand, out string reason))
  448. {
  449. //_cassetteRobotModule.RequestCassettePresentFailAlarm.Description = reason;
  450. _cassetteRobotModule.RequestCassettePresentFailAlarm.Set(reason);
  451. return false;
  452. }
  453. return true;
  454. }, () =>
  455. {
  456. if (_cassetteRobotModule.CarrierRobotDevice.IsReady() && !_cassetteRobotModule.CarrierRobotDevice.IsError)
  457. {
  458. return true;
  459. }
  460. return false;
  461. }, timeout * 1000);
  462. if (ret.Item1)
  463. {
  464. if (ret.Item2 == Result.FAIL)
  465. {
  466. throw (new RoutineFaildException());
  467. }
  468. else if (ret.Item2 == Result.TIMEOUT) //timeout
  469. {
  470. //_cassetteRobotModule.RequestCassettePresentTimeoutAlarm.Description = $"timeout over {timeout} seconds";
  471. _cassetteRobotModule.RequestCassettePresentTimeoutAlarm.Set($"timeout over {timeout} seconds");
  472. throw (new RoutineFaildException());
  473. }
  474. else
  475. throw (new RoutineBreakException());
  476. }
  477. }
  478. private void CheckCassetteInfoByRobotSensor(int id, Hand hand, bool isAfterPick)
  479. {
  480. Tuple<bool, Result> ret = Execute(id, () =>
  481. {
  482. Notify($"Check cassette info by robot RQ present");
  483. if (SC.GetValue<bool>("System.IsSimulatorMode"))
  484. return true;
  485. if (hand == Hand.Blade1 || hand == Hand.Both)
  486. {
  487. if (!isAfterPick && _cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade1)
  488. {
  489. //_cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Description = "Cassette Robot sensor found cassette on blade 1";
  490. _cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Set("Cassette Robot sensor found cassette on blade 1");
  491. return false;
  492. }
  493. if (isAfterPick && !_cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade1)
  494. {
  495. //_cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Description = "Cassette Robot sensor no cassette on blade 1";
  496. _cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Set("Cassette Robot sensor no cassette on blade 1");
  497. return false;
  498. }
  499. }
  500. if (hand == Hand.Blade2 || hand == Hand.Both)
  501. {
  502. if (!isAfterPick && _cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade2)
  503. {
  504. //_cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Description = "Cassette Robot sensor found cassette on blade 2";
  505. _cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Set("Cassette Robot sensor found cassette on blade 2");
  506. return false;
  507. }
  508. if (isAfterPick && !_cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade2)
  509. {
  510. //_cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Description = "Cassette Robot sensor no cassette on blade 2";
  511. _cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Set("Cassette Robot sensor no cassette on blade 2");
  512. return false;
  513. }
  514. }
  515. return true;
  516. });
  517. if (ret.Item1)
  518. {
  519. if (ret.Item2 == Result.FAIL)
  520. {
  521. //_cassetteRobotModule.CheckCassetteInformationFailAlarm.Description = $"check cassette info failed.";
  522. _cassetteRobotModule.CheckCassetteInformationFailAlarm.Set($"check cassette info failed.");
  523. throw (new RoutineFaildException());
  524. }
  525. else
  526. throw (new RoutineBreakException());
  527. }
  528. }
  529. private void CheckBeforePlace(int id, ModuleName target, int slot, Hand blade)
  530. {
  531. Tuple<bool, Result> ret = Execute(id, () =>
  532. {
  533. Notify($"Check place to {target} condition");
  534. string reason = string.Empty;
  535. if (_cassetteRobotModule.CarrierRobotDevice.IsError)
  536. {
  537. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
  538. return false;
  539. }
  540. if (!_cassetteRobotModule.CarrierRobotDevice.IsReady())
  541. {
  542. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for robot isn't Ready");
  543. return false;
  544. }
  545. if (!CarrierManager.Instance.CheckNoCarrier(_destination, 0))
  546. {
  547. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {_destination} failed for pod is present");
  548. return false;
  549. }
  550. if (blade == Hand.Blade1)
  551. {
  552. if (!CarrierManager.Instance.CheckNoCarrier(target, 0))
  553. {
  554. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for {target} has carrier");
  555. return false;
  556. }
  557. if (!CarrierManager.Instance.CheckHasCarrier(Module, 0))
  558. {
  559. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for blade no carrier");
  560. return false;
  561. }
  562. }
  563. else if (blade == Hand.Blade2)
  564. {
  565. if (!CarrierManager.Instance.CheckNoCarrier(target, 0))
  566. {
  567. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for {target} has carrier");
  568. return false;
  569. }
  570. if (!CarrierManager.Instance.CheckHasCarrier(Module, 0))
  571. {
  572. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for blade no carrier");
  573. return false;
  574. }
  575. }
  576. else
  577. {
  578. if (!CarrierManager.Instance.CheckNoCarrier(target, 0))
  579. {
  580. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for {target} has carrier");
  581. return false;
  582. }
  583. if (!CarrierManager.Instance.CheckHasCarrier(Module, 0))
  584. {
  585. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for blade no carrier");
  586. return false;
  587. }
  588. }
  589. return true;
  590. });
  591. if (ret.Item1)
  592. {
  593. if (ret.Item2 == Result.FAIL)
  594. {
  595. throw (new RoutineFaildException());
  596. }
  597. }
  598. _needStartCheck = false;
  599. }
  600. private void Goto(int id, ModuleName target, int slot, Hand hand, bool isPickReady, int timeout)
  601. {
  602. _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
  603. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  604. {
  605. Notify($"Send goto to {target} command to robot device");
  606. string reason;
  607. _cassetteRobotModule.RobotGoto(target, slot, hand, isPickReady, out reason);
  608. return true;
  609. }, () =>
  610. {
  611. return true;
  612. }, timeout * 1000);
  613. if (ret.Item1)
  614. {
  615. if (ret.Item2 == Result.FAIL)
  616. {
  617. _cassetteRobotModule.GotoFailAlarm.Set($"goto to {target} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
  618. throw (new RoutineFaildException());
  619. }
  620. else if (ret.Item2 == Result.TIMEOUT) //timeout
  621. {
  622. _cassetteRobotModule.GotoTimeoutAlarm.Set($"timeout over {timeout} seconds");
  623. throw (new RoutineFaildException());
  624. }
  625. else
  626. throw (new RoutineBreakException());
  627. }
  628. }
  629. private void CheckGotoFinish(int id, ModuleName target, int timeout)
  630. {
  631. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  632. {
  633. Notify($"Check goto to {target} command finish");
  634. return true;
  635. }, () =>
  636. {
  637. if (_cassetteRobotModule.CarrierRobotDevice.IsError)
  638. return null;
  639. if (_cassetteRobotModule.CarrierRobotDevice.IsReady() && !_cassetteRobotModule.CarrierRobotDevice.IsError)
  640. {
  641. return true;
  642. }
  643. return false;
  644. }, timeout * 1000);
  645. if (ret.Item1)
  646. {
  647. if (ret.Item2 == Result.FAIL)
  648. {
  649. _cassetteRobotModule.GotoFailAlarm.Set($"goto to {target} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
  650. throw (new RoutineFaildException());
  651. }
  652. else if (ret.Item2 == Result.TIMEOUT) //timeout
  653. {
  654. _cassetteRobotModule.GotoTimeoutAlarm.Set($"timeout over {timeout} seconds");
  655. throw (new RoutineFaildException());
  656. }
  657. else
  658. throw (new RoutineBreakException());
  659. }
  660. }
  661. private void SaferDoorOpen(int id, bool isOpen, int timeout)
  662. {
  663. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  664. {
  665. Notify($"Shutter Door {(isOpen ? "Open" : "Close")}");
  666. if (isOpen)
  667. _cassetteRobotModule.DoorDevice.Open();
  668. else
  669. _cassetteRobotModule.DoorDevice.Close();
  670. if (isOpen)
  671. (Singleton<EquipmentManager>.Instance.Modules[_destination] as LoadPortModule)?.LPDevice.Unclamp(out _);
  672. return true;
  673. }, () =>
  674. {
  675. return isOpen ? _cassetteRobotModule.DoorDevice.OpenCloseStatus == Devices.DeviceStatus.Open && (Singleton<EquipmentManager>.Instance.Modules[_destination] as LoadPortModule).IsReleased : _cassetteRobotModule.DoorDevice.OpenCloseStatus == Devices.DeviceStatus.Close;
  676. }, timeout * 1000);
  677. if (ret.Item1)
  678. {
  679. if (ret.Item2 == Result.FAIL)
  680. {
  681. throw new RoutineFaildException();
  682. }
  683. else if (ret.Item2 == Result.TIMEOUT) //timeout
  684. {
  685. if (isOpen)
  686. _cassetteRobotModule.ShutterOpenTimeoutAlarm.Set($"timeout over {timeout} seconds");
  687. else
  688. _cassetteRobotModule.ShutterCloseTimeoutAlarm.Set($"timeout over {timeout} seconds");
  689. throw (new RoutineFaildException());
  690. }
  691. else
  692. throw new RoutineBreakException();
  693. }
  694. }
  695. }
  696. }