CarrierRobotPlace.cs 36 KB

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