CarrierLoad.cs 29 KB

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