CarrierRobotPlace.cs 33 KB

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