CarrierRobotPlace.cs 36 KB

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