CarrierLoad.cs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789
  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. CheckGotoFinish((int)RoutineStep.CheckGotoFinish, _source, _timeout);
  234. if (_cassetteRobotModule.TrigActionCommand != null)
  235. SetRobotActionCommand((int)RoutineStep.SetRobotActionCommand, _source, _timeout);
  236. Pick((int)RoutineStep.Pick, _source, _sourceSlot, _blade, _carrierType, _currentCarrierId, _destinationStocker, _timeout);
  237. if (_source == ModuleName.LP1 || _source == ModuleName.LP2)
  238. {
  239. SetLPUnload((int)RoutineStep.SetLPUnload, _source, _timeout);
  240. SaferDoorOpen((int)RoutineStep.DoorClose, false, _timeout);
  241. }
  242. RobotRequestCassettePresent((int)RoutineStep.RobotRequestCassettePresent, _blade, _timeout);
  243. CheckCassetteInfoByRobotSensor((int)RoutineStep.CheckCassetteInfoByRobotSensor, _blade, true);
  244. }
  245. catch (RoutineBreakException)
  246. {
  247. return Result.RUN;
  248. }
  249. catch (RoutineFaildException ex)
  250. {
  251. _cassetteRobotModule.ResetRobotActionCommand();
  252. (Singleton<EquipmentManager>.Instance.Modules[_source] as ITransferTarget)?.NoteTransferStop(ModuleHelper.Converter(_cassetteRobotModule.Module), _blade, _sourceSlot, EnumTransferType.Pick);
  253. return Result.FAIL;
  254. }
  255. _cassetteRobotModule.ResetRobotActionCommand();
  256. (Singleton<EquipmentManager>.Instance.Modules[_source] as ITransferTarget)?.NoteTransferStop(ModuleHelper.Converter(_cassetteRobotModule.Module), _blade, _sourceSlot, EnumTransferType.Pick);
  257. Notify("Finished");
  258. return Result.DONE;
  259. }
  260. private void SetRobotActionCommand(int id, ModuleName source, int timeout)
  261. {
  262. _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
  263. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  264. {
  265. Notify($"Set robot action command target position {source}");
  266. _cassetteRobotModule.SetRobotActionCommand(source, EnumTransferType.Pick);
  267. return true;
  268. }, () =>
  269. {
  270. return _cassetteRobotModule.CheckRobotActionCommand(source, EnumTransferType.Pick);
  271. }, timeout * 1000);
  272. if (ret.Item1)
  273. {
  274. if (ret.Item2 == Result.FAIL)
  275. {
  276. _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {source} failed for robot action command interlock");
  277. throw (new RoutineFaildException());
  278. }
  279. else if (ret.Item2 == Result.TIMEOUT) //timeout
  280. {
  281. _cassetteRobotModule.PickCassetteTimeoutAlarm.Set($"timeout over {timeout} seconds");
  282. throw (new RoutineFaildException());
  283. }
  284. else
  285. throw (new RoutineBreakException());
  286. }
  287. }
  288. private void SetLPLoad(int id, ModuleName source, int timeout)
  289. {
  290. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  291. {
  292. Notify($"Set {source} load");
  293. var lp = Singleton<EquipmentManager>.Instance.Modules[source] as LoadPortModule;
  294. if (lp != null)
  295. lp.LPDevice.Load(out string reason);
  296. return true;
  297. }, () =>
  298. {
  299. return true;
  300. }, timeout * 1000);
  301. if (ret.Item1)
  302. {
  303. if (ret.Item2 == Result.FAIL)
  304. {
  305. throw (new RoutineFaildException());
  306. }
  307. else if (ret.Item2 == Result.TIMEOUT) //timeout
  308. {
  309. throw (new RoutineFaildException());
  310. }
  311. else
  312. throw (new RoutineBreakException());
  313. }
  314. }
  315. private void SetLPUnload(int id, ModuleName source, int timeout)
  316. {
  317. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  318. {
  319. Notify($"Set {source} unload");
  320. var lp = Singleton<EquipmentManager>.Instance.Modules[source] as LoadPortModule;
  321. if (lp != null)
  322. lp.LPDevice.Unload(out string reason);
  323. return true;
  324. }, () =>
  325. {
  326. return true;
  327. }, timeout * 1000);
  328. if (ret.Item1)
  329. {
  330. if (ret.Item2 == Result.FAIL)
  331. {
  332. throw (new RoutineFaildException());
  333. }
  334. else if (ret.Item2 == Result.TIMEOUT) //timeout
  335. {
  336. throw (new RoutineFaildException());
  337. }
  338. else
  339. throw (new RoutineBreakException());
  340. }
  341. }
  342. private void ReadCarrierID(int id, int timeout)
  343. {
  344. _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
  345. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  346. {
  347. Notify($"Read carrier ID");
  348. string reason;
  349. return true;
  350. }, () =>
  351. {
  352. _readCarrierId = "123";//Carrier ID reader读取到的值
  353. _currentCarrierId = "123";//Carrier ID reader读取到的值
  354. return true;
  355. }, timeout * 1000);
  356. if (ret.Item1)
  357. {
  358. if (ret.Item2 == Result.FAIL)
  359. {
  360. throw (new RoutineFaildException());
  361. }
  362. else if (ret.Item2 == Result.TIMEOUT) //timeout
  363. {
  364. //_cassetteRobotModule.SetStageValveTimeout.Description = $"timeout over {timeout} seconds";
  365. _cassetteRobotModule.SetStageValveTimeout.Set($"timeout over {timeout} seconds");
  366. throw (new RoutineFaildException());
  367. }
  368. else
  369. throw (new RoutineBreakException());
  370. }
  371. }
  372. private void Pick(int id, ModuleName source, int slot, Hand hand, CarrierType carrierType, string lotId, ModuleName carrierInternalModuleName, int timeout)
  373. {
  374. _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
  375. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  376. {
  377. Notify($"Send pick from {source} command to robot device");
  378. string reason;
  379. if (!CarrierManager.Instance.CheckNoCarrier(source.ToString(), 0))
  380. CarrierManager.Instance.DeleteCarrier(source.ToString());//要保留
  381. CarrierManager.Instance.CreateCarrier(source.ToString(), carrierType, carrierInternalModuleName.ToString());
  382. CarrierManager.Instance.GetCarrier(source.ToString(), 0).IsMapOK = false;
  383. CarrierManager.Instance.GetCarrier(source.ToString(), 0).IsMapped = false;
  384. (Singleton<EquipmentManager>.Instance.Modules[source] as ITransferTarget)?.NoteTransferStart(ModuleHelper.Converter(_cassetteRobotModule.Module), hand, slot, EnumTransferType.Pick);
  385. if (!_cassetteRobotModule.RobotPick(source, slot, hand, out reason))
  386. {
  387. //_cassetteRobotModule.PickCassetteFailAlarm.Description = reason;
  388. _cassetteRobotModule.PickCassetteFailAlarm.Set(reason);
  389. return false;
  390. }
  391. return true;
  392. }, () =>
  393. {
  394. if (_cassetteRobotModule.CarrierRobotDevice.IsReady() && !_cassetteRobotModule.CarrierRobotDevice.IsError)
  395. {
  396. var lp = Singleton<EquipmentManager>.Instance.Modules[_source] as LoadPortModule;
  397. var readCarrierId = lp != null ? lp.CarrierId : lotId;
  398. CarrierManager.Instance.UpdateCarrierId(ModuleName.CarrierRobot.ToString(), readCarrierId);
  399. return true;
  400. }
  401. return false;
  402. }, timeout * 1000);
  403. if (ret.Item1)
  404. {
  405. if (ret.Item2 == Result.FAIL)
  406. {
  407. //_cassetteRobotModule.PickCassetteFailAlarm.Description = $"{_cassetteRobotModule.CassetteRobotDevice.ErrorCode}";
  408. _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {source} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
  409. throw (new RoutineFaildException());
  410. }
  411. else if (ret.Item2 == Result.TIMEOUT) //timeout
  412. {
  413. //_cassetteRobotModule.PickCassetteTimeoutAlarm.Description = $"timeout over {timeout} seconds";
  414. _cassetteRobotModule.PickCassetteTimeoutAlarm.Set($"timeout over {timeout} seconds");
  415. throw (new RoutineFaildException());
  416. }
  417. else
  418. throw (new RoutineBreakException());
  419. }
  420. }
  421. private void RobotRequestCassettePresent(int id, Hand hand, int timeout)
  422. {
  423. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  424. {
  425. Notify("Request cassette present");
  426. if (!_cassetteRobotModule.RequestCassettePresent(hand, out string reason))
  427. {
  428. //_cassetteRobotModule.RequestCassettePresentFailAlarm.Description = reason;
  429. _cassetteRobotModule.RequestCassettePresentFailAlarm.Set(reason);
  430. return false;
  431. }
  432. return true;
  433. }, () =>
  434. {
  435. if (_cassetteRobotModule.CarrierRobotDevice.IsReady() && !_cassetteRobotModule.CarrierRobotDevice.IsError)
  436. {
  437. return true;
  438. }
  439. return false;
  440. }, timeout * 1000);
  441. if (ret.Item1)
  442. {
  443. if (ret.Item2 == Result.FAIL)
  444. {
  445. throw (new RoutineFaildException());
  446. }
  447. else if (ret.Item2 == Result.TIMEOUT) //timeout
  448. {
  449. //_cassetteRobotModule.RequestCassettePresentTimeoutAlarm.Description = $"timeout over {timeout} seconds";
  450. _cassetteRobotModule.RequestCassettePresentTimeoutAlarm.Set($"timeout over {timeout} seconds");
  451. throw (new RoutineFaildException());
  452. }
  453. else
  454. throw (new RoutineBreakException());
  455. }
  456. }
  457. private void CheckCassetteInfoByRobotSensor(int id, Hand hand, bool isAfterPick)
  458. {
  459. Tuple<bool, Result> ret = Execute(id, () =>
  460. {
  461. Notify($"Check cassette info by robot RQ present");
  462. if (SC.GetValue<bool>("System.IsSimulatorMode"))
  463. return true;
  464. if (hand == Hand.Blade1 || hand == Hand.Both)
  465. {
  466. if (!isAfterPick && _cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade1)
  467. {
  468. //_cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Description = "Cassette Robot sensor found cassette on blade 1";
  469. _cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Set("Cassette Robot sensor found cassette on blade 1");
  470. return false;
  471. }
  472. if (isAfterPick && !_cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade1)
  473. {
  474. //_cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Description = "Cassette Robot sensor no cassette on blade 1";
  475. _cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Set("Cassette Robot sensor no cassette on blade 1");
  476. return false;
  477. }
  478. }
  479. if (hand == Hand.Blade2 || hand == Hand.Both)
  480. {
  481. if (!isAfterPick && _cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade2)
  482. {
  483. //_cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Description = "Cassette Robot sensor found cassette on blade 2";
  484. _cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Set("Cassette Robot sensor found cassette on blade 2");
  485. return false;
  486. }
  487. if (isAfterPick && !_cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade2)
  488. {
  489. //_cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Description = "Cassette Robot sensor no cassette on blade 2";
  490. _cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Set("Cassette Robot sensor no cassette on blade 2");
  491. return false;
  492. }
  493. }
  494. return true;
  495. });
  496. if (ret.Item1)
  497. {
  498. if (ret.Item2 == Result.FAIL)
  499. {
  500. //_cassetteRobotModule.CheckCassetteInformationFailAlarm.Description = $"check cassette info failed.";
  501. _cassetteRobotModule.CheckCassetteInformationFailAlarm.Set($"check cassette info failed.");
  502. throw (new RoutineFaildException());
  503. }
  504. else
  505. throw (new RoutineBreakException());
  506. }
  507. }
  508. private void CheckBeforePick(int id, ModuleName source, int slot, Hand blade)
  509. {
  510. Tuple<bool, Result> ret = Execute(id, () =>
  511. {
  512. Notify($"Check pick from {source} condition");
  513. string reason = string.Empty;
  514. if (_cassetteRobotModule.CarrierRobotDevice.IsError)
  515. {
  516. _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {source} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
  517. return false;
  518. }
  519. if (!_cassetteRobotModule.CarrierRobotDevice.IsReady())
  520. {
  521. _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {source} failed for robot isn't Ready");
  522. return false;
  523. }
  524. if (!CarrierManager.Instance.CheckHasCarrier(_source, 0))
  525. {
  526. _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {_source} failed for pod is not present");
  527. return false;
  528. }
  529. if (blade == Hand.Blade1)
  530. {
  531. if (!CarrierManager.Instance.CheckHasCarrier(source, 0))
  532. {
  533. _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {source} failed for {source} no carrrier");
  534. return false;
  535. }
  536. if (!CarrierManager.Instance.CheckNoCarrier(Module, 0))
  537. {
  538. _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {source} failed for blade has carrier");
  539. return false;
  540. }
  541. }
  542. else if (blade == Hand.Blade2)
  543. {
  544. if (!CarrierManager.Instance.CheckHasCarrier(source, 0))
  545. {
  546. _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {source} failed for {source} no carrier");
  547. return false;
  548. }
  549. if (!CarrierManager.Instance.CheckNoCarrier(Module, 0))
  550. {
  551. _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {source} failed for blade has carrier");
  552. return false;
  553. }
  554. }
  555. else
  556. {
  557. if (!CarrierManager.Instance.CheckHasCarrier(source, 0))
  558. {
  559. _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {source} failed for {source} no carrier");
  560. return false;
  561. }
  562. if (!CarrierManager.Instance.CheckNoCarrier(Module, 0))
  563. {
  564. _cassetteRobotModule.PickCassetteFailAlarm.Set($"pick from {source} failed for blade has carrier");
  565. return false;
  566. }
  567. }
  568. return true;
  569. });
  570. if (ret.Item1)
  571. {
  572. if (ret.Item2 == Result.FAIL)
  573. {
  574. throw (new RoutineFaildException());
  575. }
  576. }
  577. _needStartCheck = false;
  578. }
  579. private void CheckCarrierID(int id)
  580. {
  581. Tuple<bool, Result> ret = Execute(id, () =>
  582. {
  583. Notify($"Check carrier ID");
  584. string reason = string.Empty;
  585. if (_readCarrierId != _reservedCarrierId)
  586. {
  587. _cassetteRobotModule.CheckCarrierIDFailAlarm.Set($"read id={_readCarrierId}, reserved id={_reservedCarrierId}, mismatch");
  588. return false;
  589. }
  590. return true;
  591. });
  592. if (ret.Item1)
  593. {
  594. if (ret.Item2 == Result.FAIL)
  595. {
  596. throw (new RoutineFaildException());
  597. }
  598. }
  599. _needStartCheck = false;
  600. }
  601. private void Goto(int id, ModuleName target, int slot, Hand hand, bool isPickReady, int timeout)
  602. {
  603. _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
  604. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  605. {
  606. Notify($"Send goto to {target} command to robot device");
  607. string reason;
  608. _cassetteRobotModule.RobotGoto(target, slot, hand, isPickReady, out reason);
  609. return true;
  610. }, () =>
  611. {
  612. return true;
  613. }, timeout * 1000);
  614. if (ret.Item1)
  615. {
  616. if (ret.Item2 == Result.FAIL)
  617. {
  618. _cassetteRobotModule.GotoFailAlarm.Set($"goto to {target} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
  619. throw (new RoutineFaildException());
  620. }
  621. else if (ret.Item2 == Result.TIMEOUT) //timeout
  622. {
  623. _cassetteRobotModule.GotoTimeoutAlarm.Set($"timeout over {timeout} seconds");
  624. throw (new RoutineFaildException());
  625. }
  626. else
  627. throw (new RoutineBreakException());
  628. }
  629. }
  630. private void CheckGotoFinish(int id, ModuleName target, int timeout)
  631. {
  632. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  633. {
  634. Notify($"Check goto to {target} command finish");
  635. return true;
  636. }, () =>
  637. {
  638. if (_cassetteRobotModule.CarrierRobotDevice.IsError)
  639. return null;
  640. if (_cassetteRobotModule.CarrierRobotDevice.IsReady() && !_cassetteRobotModule.CarrierRobotDevice.IsError)
  641. {
  642. return true;
  643. }
  644. return false;
  645. }, timeout * 1000);
  646. if (ret.Item1)
  647. {
  648. if (ret.Item2 == Result.FAIL)
  649. {
  650. _cassetteRobotModule.GotoFailAlarm.Set($"goto to {target} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
  651. throw (new RoutineFaildException());
  652. }
  653. else if (ret.Item2 == Result.TIMEOUT) //timeout
  654. {
  655. _cassetteRobotModule.GotoTimeoutAlarm.Set($"timeout over {timeout} seconds");
  656. throw (new RoutineFaildException());
  657. }
  658. else
  659. throw (new RoutineBreakException());
  660. }
  661. }
  662. private void SaferDoorOpen(int id, bool isOpen, int timeout)
  663. {
  664. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  665. {
  666. Notify($"Shutter Door {(isOpen ? "Open" : "Close")}");
  667. if (isOpen)
  668. _cassetteRobotModule.DoorDevice.Open();
  669. else
  670. _cassetteRobotModule.DoorDevice.Close();
  671. if (isOpen)
  672. (Singleton<EquipmentManager>.Instance.Modules[_source] as LoadPortModule)?.LPDevice.Unclamp(out _);
  673. return true;
  674. }, () =>
  675. {
  676. return isOpen ? _cassetteRobotModule.DoorDevice.OpenCloseStatus == Devices.DeviceStatus.Open && (Singleton<EquipmentManager>.Instance.Modules[_source] as LoadPortModule).IsReleased : _cassetteRobotModule.DoorDevice.OpenCloseStatus == Devices.DeviceStatus.Close;
  677. }, timeout * 1000);
  678. if (ret.Item1)
  679. {
  680. if (ret.Item2 == Result.FAIL)
  681. {
  682. throw new RoutineFaildException();
  683. }
  684. else if (ret.Item2 == Result.TIMEOUT) //timeout
  685. {
  686. if (isOpen)
  687. _cassetteRobotModule.ShutterOpenTimeoutAlarm.Set($"timeout over {timeout} seconds");
  688. else
  689. _cassetteRobotModule.ShutterCloseTimeoutAlarm.Set($"timeout over {timeout} seconds");
  690. throw (new RoutineFaildException());
  691. }
  692. else
  693. throw new RoutineBreakException();
  694. }
  695. }
  696. }
  697. }