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