CarrierRobotPlace.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  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. SetRobotActionCommand,
  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. CheckBeforePlace((int)RoutineStep.CheckBeforePlace, _destination, _destinationSlot, _blade);
  203. if (ModuleHelper.IsBufferStocker(_destination))
  204. {
  205. Goto((int)RoutineStep.Goto, _destination, _destinationSlot, _blade, false, _timeout);
  206. SetBufferTargetPosition((int)RoutineStep.SetBufferTargetPosition, _destination, _timeout);
  207. SetBufferMoveTo((int)RoutineStep.SetBufferMoveTo, _destination, _timeout);
  208. CheckGotoFinish((int)RoutineStep.CheckGotoFinish, _destination, _timeout);
  209. }
  210. if (_destination == ModuleName.LP1 || _destination == ModuleName.LP2)
  211. {
  212. Goto((int)RoutineStep.Goto, _destination, _destinationSlot, _blade, false, _timeout);
  213. SaferDoorOpen((int)RoutineStep.DoorOpen, true, _timeout);
  214. CheckGotoFinish((int)RoutineStep.CheckGotoFinish, _destination, _timeout);
  215. }
  216. if (_cassetteRobotModule.TrigActionCommand != null)
  217. SetRobotActionCommand((int)RoutineStep.SetRobotActionCommand, _destination, _timeout);
  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. PlaceEndInfo();
  232. return Result.FAIL;
  233. }
  234. _cassetteRobotModule.ResetRobotActionCommand();
  235. PlaceEndInfo();
  236. Notify("Finished");
  237. return Result.DONE;
  238. }
  239. private void PlaceEndInfo()
  240. {
  241. (Singleton<EquipmentManager>.Instance.Modules[_destination] as ITransferTarget)?.NoteTransferStop(ModuleHelper.Converter(_cassetteRobotModule.Module), _blade, _destinationSlot, EnumTransferType.Place);
  242. var stockerModule = Singleton<EquipmentManager>.Instance.Modules[_destination] as StockerModule;
  243. var stockerFoupInfo = CarrierManager.Instance.GetCarrier(_destination);
  244. stockerFoupInfo.UICarrierStatusEnum = CarrierStatus.READY;
  245. Singleton<EquipmentManager>.Instance.SetVisibility(stockerFoupInfo, true);
  246. var carrierRobotFoupInfo = CarrierManager.Instance.GetCarrier(ModuleName.CarrierRobot);
  247. Singleton<EquipmentManager>.Instance.SetVisibility(carrierRobotFoupInfo, false);
  248. }
  249. private void SetRobotActionCommand(int id, ModuleName source, int timeout)
  250. {
  251. _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
  252. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  253. {
  254. Notify($"Set robot action command target position {source}");
  255. _cassetteRobotModule.SetRobotActionCommand(source, EnumTransferType.Place);
  256. return true;
  257. }, () =>
  258. {
  259. return _cassetteRobotModule.CheckRobotActionCommand(source, EnumTransferType.Place);
  260. }, timeout * 1000);
  261. if (ret.Item1)
  262. {
  263. if (ret.Item2 == Result.FAIL)
  264. {
  265. _cassetteRobotModule.PlaceCassetteTimeoutAlarm.Set($"place to {source} failed for robot action command interlock");
  266. throw (new RoutineFaildException());
  267. }
  268. else if (ret.Item2 == Result.TIMEOUT) //timeout
  269. {
  270. _cassetteRobotModule.PlaceCassetteTimeoutAlarm.Set($"timeout over {timeout} seconds");
  271. throw (new RoutineFaildException());
  272. }
  273. else
  274. throw (new RoutineBreakException());
  275. }
  276. }
  277. private void SetBufferTargetPosition(int id, ModuleName source, int timeout)
  278. {
  279. _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
  280. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  281. {
  282. Notify($"Set buffer target position {source}");
  283. _cassetteRobotModule.SetBufferTargetPosition(source.ToString());
  284. return true;
  285. }, () =>
  286. {
  287. return _cassetteRobotModule.CheckBufferTargetPosition(source.ToString());
  288. }, timeout * 1000);
  289. if (ret.Item1)
  290. {
  291. if (ret.Item2 == Result.FAIL)
  292. {
  293. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {source} failed for set buffer target position");
  294. throw (new RoutineFaildException());
  295. }
  296. else if (ret.Item2 == Result.TIMEOUT) //timeout
  297. {
  298. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"timeout over {timeout} seconds");
  299. throw (new RoutineFaildException());
  300. }
  301. else
  302. throw (new RoutineBreakException());
  303. }
  304. }
  305. private void SetBufferMoveTo(int id, ModuleName target, int timeout)
  306. {
  307. _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
  308. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  309. {
  310. Notify($"Set buffer move to {target}");
  311. _cassetteRobotModule.SetBufferMoveTo();
  312. return true;
  313. }, () =>
  314. {
  315. return _cassetteRobotModule.BufferDevice.IsReady && _cassetteRobotModule.BufferDevice.IsInPosition;
  316. }, timeout * 1000);
  317. if (ret.Item1)
  318. {
  319. if (ret.Item2 == Result.FAIL)
  320. {
  321. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
  322. throw (new RoutineFaildException());
  323. }
  324. else if (ret.Item2 == Result.TIMEOUT) //timeout
  325. {
  326. _cassetteRobotModule.PlaceCassetteTimeoutAlarm.Set($"timeout over {timeout} seconds");
  327. throw (new RoutineFaildException());
  328. }
  329. else
  330. throw (new RoutineBreakException());
  331. }
  332. }
  333. private void Place(int id, ModuleName target, int slot, Hand hand, int timeout)
  334. {
  335. _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
  336. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  337. {
  338. Notify($"Send place to {target} command to robot device");
  339. string reason;
  340. (Singleton<EquipmentManager>.Instance.Modules[target] as ITransferTarget)?.NoteTransferStart(ModuleHelper.Converter(_cassetteRobotModule.Module), hand, slot, EnumTransferType.Place);
  341. if (!_cassetteRobotModule.RobotPlace(target, slot, hand, out reason))
  342. {
  343. //_cassetteRobotModule.PlaceCassetteFailAlarm.Description = reason;
  344. _cassetteRobotModule.PlaceCassetteFailAlarm.Set(reason);
  345. return false;
  346. }
  347. return true;
  348. }, () =>
  349. {
  350. if (_cassetteRobotModule.CarrierRobotDevice.IsReady() && !_cassetteRobotModule.CarrierRobotDevice.IsError)
  351. {
  352. return true;
  353. }
  354. return false;
  355. }, timeout * 1000);
  356. if (ret.Item1)
  357. {
  358. if (ret.Item2 == Result.FAIL)
  359. {
  360. //_cassetteRobotModule.PlaceCassetteFailAlarm.Description = $"{_cassetteRobotModule.CassetteRobotDevice.ErrorCode}";
  361. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
  362. throw (new RoutineFaildException());
  363. }
  364. else if (ret.Item2 == Result.TIMEOUT) //timeout
  365. {
  366. //_cassetteRobotModule.PlaceCassetteTimeoutAlarm.Description = $"timeout over {timeout} seconds";
  367. _cassetteRobotModule.PlaceCassetteTimeoutAlarm.Set($"timeout over {timeout} seconds");
  368. throw (new RoutineFaildException());
  369. }
  370. else
  371. throw (new RoutineBreakException());
  372. }
  373. }
  374. private void RobotRequestCassettePresent(int id, Hand hand, int timeout)
  375. {
  376. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  377. {
  378. Notify("Request cassette present");
  379. if (!_cassetteRobotModule.RequestCassettePresent(hand, out string reason))
  380. {
  381. //_cassetteRobotModule.RequestCassettePresentFailAlarm.Description = reason;
  382. _cassetteRobotModule.RequestCassettePresentFailAlarm.Set(reason);
  383. return false;
  384. }
  385. return true;
  386. }, () =>
  387. {
  388. if (_cassetteRobotModule.CarrierRobotDevice.IsReady() && !_cassetteRobotModule.CarrierRobotDevice.IsError)
  389. {
  390. return true;
  391. }
  392. return false;
  393. }, timeout * 1000);
  394. if (ret.Item1)
  395. {
  396. if (ret.Item2 == Result.FAIL)
  397. {
  398. throw (new RoutineFaildException());
  399. }
  400. else if (ret.Item2 == Result.TIMEOUT) //timeout
  401. {
  402. //_cassetteRobotModule.RequestCassettePresentTimeoutAlarm.Description = $"timeout over {timeout} seconds";
  403. _cassetteRobotModule.RequestCassettePresentTimeoutAlarm.Set($"timeout over {timeout} seconds");
  404. throw (new RoutineFaildException());
  405. }
  406. else
  407. throw (new RoutineBreakException());
  408. }
  409. }
  410. private void CheckCassetteInfoByRobotSensor(int id, Hand hand, bool isAfterPick)
  411. {
  412. Tuple<bool, Result> ret = Execute(id, () =>
  413. {
  414. Notify($"Check cassette info by robot RQ present");
  415. if (SC.GetValue<bool>("System.IsSimulatorMode"))
  416. return true;
  417. if (hand == Hand.Blade1 || hand == Hand.Both)
  418. {
  419. if (!isAfterPick && _cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade1)
  420. {
  421. //_cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Description = "Cassette Robot sensor found cassette on blade 1";
  422. _cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Set("Cassette Robot sensor found cassette on blade 1");
  423. return false;
  424. }
  425. if (isAfterPick && !_cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade1)
  426. {
  427. //_cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Description = "Cassette Robot sensor no cassette on blade 1";
  428. _cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Set("Cassette Robot sensor no cassette on blade 1");
  429. return false;
  430. }
  431. }
  432. if (hand == Hand.Blade2 || hand == Hand.Both)
  433. {
  434. if (!isAfterPick && _cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade2)
  435. {
  436. //_cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Description = "Cassette Robot sensor found cassette on blade 2";
  437. _cassetteRobotModule.RobotSensorFoundCassetteOnBladeAfterPlaceAlarm.Set("Cassette Robot sensor found cassette on blade 2");
  438. return false;
  439. }
  440. if (isAfterPick && !_cassetteRobotModule.CarrierRobotDevice.IsWaferPresenceOnBlade2)
  441. {
  442. //_cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Description = "Cassette Robot sensor no cassette on blade 2";
  443. _cassetteRobotModule.RobotSensorNotFoundCassetteOnBladeAfterPickAlarm.Set("Cassette Robot sensor no cassette on blade 2");
  444. return false;
  445. }
  446. }
  447. return true;
  448. });
  449. if (ret.Item1)
  450. {
  451. if (ret.Item2 == Result.FAIL)
  452. {
  453. //_cassetteRobotModule.CheckCassetteInformationFailAlarm.Description = $"check cassette info failed.";
  454. _cassetteRobotModule.CheckCassetteInformationFailAlarm.Set($"check cassette info failed.");
  455. throw (new RoutineFaildException());
  456. }
  457. else
  458. throw (new RoutineBreakException());
  459. }
  460. }
  461. private void CheckBeforePlace(int id, ModuleName target, int slot, Hand blade)
  462. {
  463. Tuple<bool, Result> ret = Execute(id, () =>
  464. {
  465. Notify($"Check place to {target} condition");
  466. string reason = string.Empty;
  467. if (_cassetteRobotModule.CarrierRobotDevice.IsError)
  468. {
  469. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
  470. return false;
  471. }
  472. if (!_cassetteRobotModule.CarrierRobotDevice.IsReady())
  473. {
  474. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for robot isn't Ready");
  475. return false;
  476. }
  477. if (!CarrierManager.Instance.CheckNoCarrier(_destination, 0))
  478. {
  479. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {_destination} failed for pod is present");
  480. return false;
  481. }
  482. if (blade == Hand.Blade1)
  483. {
  484. if (!CarrierManager.Instance.CheckNoCarrier(target, 0))
  485. {
  486. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for {target} has carrier");
  487. return false;
  488. }
  489. if (!CarrierManager.Instance.CheckHasCarrier(Module, 0))
  490. {
  491. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for blade no carrier");
  492. return false;
  493. }
  494. }
  495. else if (blade == Hand.Blade2)
  496. {
  497. if (!CarrierManager.Instance.CheckNoCarrier(target, 0))
  498. {
  499. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for {target} has carrier");
  500. return false;
  501. }
  502. if (!CarrierManager.Instance.CheckHasCarrier(Module, 0))
  503. {
  504. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for blade no carrier");
  505. return false;
  506. }
  507. }
  508. else
  509. {
  510. if (!CarrierManager.Instance.CheckNoCarrier(target, 0))
  511. {
  512. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for {target} has carrier");
  513. return false;
  514. }
  515. if (!CarrierManager.Instance.CheckHasCarrier(Module, 0))
  516. {
  517. _cassetteRobotModule.PlaceCassetteFailAlarm.Set($"place to {target} failed for blade no carrier");
  518. return false;
  519. }
  520. }
  521. return true;
  522. });
  523. if (ret.Item1)
  524. {
  525. if (ret.Item2 == Result.FAIL)
  526. {
  527. throw (new RoutineFaildException());
  528. }
  529. }
  530. _needStartCheck = false;
  531. }
  532. private void Goto(int id, ModuleName target, int slot, Hand hand, bool isPickReady, int timeout)
  533. {
  534. _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
  535. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  536. {
  537. Notify($"Send goto to {target} command to robot device");
  538. string reason;
  539. _cassetteRobotModule.RobotGoto(target, slot, hand, isPickReady, out reason);
  540. return true;
  541. }, () =>
  542. {
  543. return true;
  544. }, timeout * 1000);
  545. if (ret.Item1)
  546. {
  547. if (ret.Item2 == Result.FAIL)
  548. {
  549. _cassetteRobotModule.GotoFailAlarm.Set($"goto to {target} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
  550. throw (new RoutineFaildException());
  551. }
  552. else if (ret.Item2 == Result.TIMEOUT) //timeout
  553. {
  554. _cassetteRobotModule.GotoTimeoutAlarm.Set($"timeout over {timeout} seconds");
  555. throw (new RoutineFaildException());
  556. }
  557. else
  558. throw (new RoutineBreakException());
  559. }
  560. }
  561. private void CheckGotoFinish(int id, ModuleName target, int timeout)
  562. {
  563. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  564. {
  565. Notify($"Check goto to {target} command finish");
  566. return true;
  567. }, () =>
  568. {
  569. if (_cassetteRobotModule.CarrierRobotDevice.IsError)
  570. return null;
  571. if (_cassetteRobotModule.CarrierRobotDevice.IsReady() && !_cassetteRobotModule.CarrierRobotDevice.IsError)
  572. {
  573. return true;
  574. }
  575. return false;
  576. }, timeout * 1000);
  577. if (ret.Item1)
  578. {
  579. if (ret.Item2 == Result.FAIL)
  580. {
  581. _cassetteRobotModule.GotoFailAlarm.Set($"goto to {target} failed for robot error, error code={_cassetteRobotModule.CarrierRobotDevice.ErrorCode}");
  582. throw (new RoutineFaildException());
  583. }
  584. else if (ret.Item2 == Result.TIMEOUT) //timeout
  585. {
  586. _cassetteRobotModule.GotoTimeoutAlarm.Set($"timeout over {timeout} seconds");
  587. throw (new RoutineFaildException());
  588. }
  589. else
  590. throw (new RoutineBreakException());
  591. }
  592. }
  593. private void SaferDoorOpen(int id, bool isOpen, int timeout)
  594. {
  595. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  596. {
  597. Notify($"Shutter Door {(isOpen ? "Open" : "Close")}");
  598. if (isOpen)
  599. _cassetteRobotModule.DoorDevice.Open();
  600. else
  601. _cassetteRobotModule.DoorDevice.Close();
  602. if (isOpen)
  603. (Singleton<EquipmentManager>.Instance.Modules[_destination] as LoadPortModule)?.LPDevice.Unclamp(out _);
  604. return true;
  605. }, () =>
  606. {
  607. return isOpen ? _cassetteRobotModule.DoorDevice.OpenCloseStatus == Devices.DeviceStatus.Open && (Singleton<EquipmentManager>.Instance.Modules[_destination] as LoadPortModule).IsReleased : _cassetteRobotModule.DoorDevice.OpenCloseStatus == Devices.DeviceStatus.Close;
  608. }, timeout * 1000);
  609. if (ret.Item1)
  610. {
  611. if (ret.Item2 == Result.FAIL)
  612. {
  613. throw new RoutineFaildException();
  614. }
  615. else if (ret.Item2 == Result.TIMEOUT) //timeout
  616. {
  617. if (isOpen)
  618. _cassetteRobotModule.ShutterOpenTimeoutAlarm.Set($"timeout over {timeout} seconds");
  619. else
  620. _cassetteRobotModule.ShutterCloseTimeoutAlarm.Set($"timeout over {timeout} seconds");
  621. throw (new RoutineFaildException());
  622. }
  623. else
  624. throw new RoutineBreakException();
  625. }
  626. }
  627. }
  628. }