CarrierLoad.cs 35 KB

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