CarrierLoad.cs 31 KB

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