CarrierRobotPlace.cs 31 KB

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