CarrierLoad.cs 35 KB

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