CarrierRobotPick.cs 32 KB

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