CarrierRobotPlace.cs 34 KB

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