WaferRobotPick.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. using Aitex.Core.RT.Routine;
  2. using Aitex.Core.RT.SCCore;
  3. using Aitex.Core.Util;
  4. using Aitex.Sorter.Common;
  5. using MECF.Framework.Common.Equipment;
  6. using MECF.Framework.Common.Schedulers;
  7. using MECF.Framework.Common.SubstrateTrackings;
  8. using MECF.Framework.RT.EquipmentLibrary.LogicUnits;
  9. using System;
  10. using System.Collections.Generic;
  11. using FurnaceRT.Equipments.FIMSs;
  12. using FurnaceRT.Equipments.PMs;
  13. using FurnaceRT.Equipments.Stockers;
  14. using FurnaceRT.Equipments.Systems;
  15. namespace FurnaceRT.Equipments.WaferRobots
  16. {
  17. public class WaferRobotPick : ModuleRoutine, IRoutine
  18. {
  19. enum RoutineStep
  20. {
  21. Pick,
  22. RobotRequestWaferPresent,
  23. CheckCassetteInfoByRobotSensor,
  24. CheckBeforePick,
  25. }
  26. private ModuleName _source;
  27. private int _sourceSlot;
  28. private Hand _blade;
  29. private WaferRobotModule _waferRobotModule;
  30. private int _timeout = 0;
  31. private RD_TRIG _holdTrig = new RD_TRIG();
  32. private R_TRIG _emergencyStopTrig = new R_TRIG();
  33. private R_TRIG _pauseTrig = new R_TRIG();
  34. private R_TRIG _resumeTrig = new R_TRIG();
  35. private RoutineStep _routineStep;
  36. private double _durationTime = 0;
  37. private bool _isHasAlarm = false;
  38. private bool _needStartCheck = true;
  39. public WaferRobotPick(WaferRobotModule waferRobotModule)
  40. {
  41. _waferRobotModule = waferRobotModule;
  42. Module = waferRobotModule.Module;
  43. Name = "Pick";
  44. }
  45. public void Init(ModuleName source, int sourceSlot, Hand blade, bool isHasAlarm)
  46. {
  47. _source = source;
  48. _sourceSlot = sourceSlot;
  49. _blade = blade;
  50. var para = new List<object> { _source, _sourceSlot, _blade, true };//增加参数true,表示执行过程中有alarm
  51. _waferRobotModule.PickWaferFailAlarm.RetryMessage = (int)WaferRobotModule.MSG.PickRetry;
  52. _waferRobotModule.PickWaferFailAlarm.RetryMessageParas = para.ToArray();
  53. _waferRobotModule.PickWaferTimeoutAlarm.RetryMessage = (int)WaferRobotModule.MSG.PickRetry;
  54. _waferRobotModule.PickWaferTimeoutAlarm.RetryMessageParas = para.ToArray();
  55. _waferRobotModule.RequestWaferPresentFailAlarm.RetryMessage = (int)WaferRobotModule.MSG.PickRetry;
  56. _waferRobotModule.RequestWaferPresentFailAlarm.RetryMessageParas = para.ToArray();
  57. _waferRobotModule.RequestWaferPresentTimeoutAlarm.RetryMessage = (int)WaferRobotModule.MSG.PickRetry;
  58. _waferRobotModule.RequestWaferPresentTimeoutAlarm.RetryMessageParas = para.ToArray();
  59. _waferRobotModule.RobotHasError.RetryMessage = (int)WaferRobotModule.MSG.PickRetry;
  60. _waferRobotModule.RobotHasError.RetryMessageParas = para.ToArray();
  61. _isHasAlarm = isHasAlarm;
  62. if (!_isHasAlarm)
  63. _needStartCheck = true;
  64. }
  65. public Result Start(params object[] objs)
  66. {
  67. // 抛出过alarm就不reset
  68. if (!_isHasAlarm)
  69. {
  70. Reset();
  71. }
  72. else
  73. {
  74. List<int> stepLst = new List<int>(Steps.ToArray());
  75. stepLst.Remove((int)_routineStep);
  76. Steps = new Stack<int>(stepLst);
  77. _isHasAlarm = false;
  78. ResetState();
  79. }
  80. _holdTrig.RST = true;
  81. _emergencyStopTrig.RST = true;
  82. _pauseTrig.RST = true;
  83. _resumeTrig.RST = true;
  84. _timeout = SC.GetValue<int>($"{Module}.PickTimeout");
  85. if (_needStartCheck)
  86. {
  87. if (_blade == Hand.Blade1)
  88. {
  89. if (SC.GetValue<bool>("System.IsSimulatorMode"))
  90. {
  91. if (!WaferManager.Instance.CheckNoWafer(ModuleName.WaferRobot, 2))
  92. {
  93. //_waferRobotModule.BladeWaferPresentWarning.Description = $"{ModuleName.WaferRobot} {_blade} wafer present";
  94. _waferRobotModule.BladeWaferPresentWarning.Set($"{ModuleName.WaferRobot} {_blade} wafer present");
  95. return Result.FAIL;
  96. }
  97. }
  98. else
  99. {
  100. if (_waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade3 || !WaferManager.Instance.CheckNoWafer(ModuleName.WaferRobot, 2))
  101. {
  102. //_waferRobotModule.BladeWaferPresentWarning.Description = $"{ModuleName.WaferRobot} {_blade} wafer present";
  103. _waferRobotModule.BladeWaferPresentWarning.Set($"{ModuleName.WaferRobot} {_blade} wafer present");
  104. return Result.FAIL;
  105. }
  106. }
  107. if (!WaferManager.Instance.CheckHasWafer(_source, _sourceSlot))
  108. {
  109. //_waferRobotModule.TargetWaferNotPresentWarning.Description = $"{_source} {_sourceSlot + 1} wafer not present";
  110. _waferRobotModule.TargetWaferNotPresentWarning.Set($"{_source} {_sourceSlot + 1} wafer not present");
  111. return Result.FAIL;
  112. }
  113. }
  114. else if (_blade == Hand.Blade2)
  115. {
  116. if (SC.GetValue<bool>("System.IsSimulatorMode"))
  117. {
  118. if (!WaferManager.Instance.CheckNoWafer(ModuleName.WaferRobot, 1) ||
  119. !WaferManager.Instance.CheckNoWafer(ModuleName.WaferRobot, 2) ||
  120. !WaferManager.Instance.CheckNoWafer(ModuleName.WaferRobot, 3) ||
  121. !WaferManager.Instance.CheckNoWafer(ModuleName.WaferRobot, 4))
  122. {
  123. //_waferRobotModule.BladeWaferPresentWarning.Description = $"{ModuleName.WaferRobot} {_blade} wafer present";
  124. _waferRobotModule.BladeWaferPresentWarning.Set($"{ModuleName.WaferRobot} {_blade} wafer present");
  125. return Result.FAIL;
  126. }
  127. }
  128. else
  129. {
  130. if (_waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade2 ||
  131. !WaferManager.Instance.CheckNoWafer(ModuleName.WaferRobot, 1) ||
  132. !WaferManager.Instance.CheckNoWafer(ModuleName.WaferRobot, 2) ||
  133. !WaferManager.Instance.CheckNoWafer(ModuleName.WaferRobot, 3) ||
  134. !WaferManager.Instance.CheckNoWafer(ModuleName.WaferRobot, 4))
  135. {
  136. //_waferRobotModule.BladeWaferPresentWarning.Description = $"{ModuleName.WaferRobot} {_blade} wafer present";
  137. _waferRobotModule.BladeWaferPresentWarning.Set($"{ModuleName.WaferRobot} {_blade} wafer present");
  138. return Result.FAIL;
  139. }
  140. }
  141. if (!WaferManager.Instance.CheckHasWafer(_source, _sourceSlot))
  142. {
  143. //_waferRobotModule.TargetWaferNotPresentWarning.Description = $"{_source} {_sourceSlot + 1} wafer not present";
  144. _waferRobotModule.TargetWaferNotPresentWarning.Set($"{_source} {_sourceSlot + 1} wafer not present");
  145. return Result.FAIL;
  146. }
  147. if (!WaferManager.Instance.CheckHasWafer(_source, _sourceSlot + 1))
  148. {
  149. //_waferRobotModule.TargetWaferNotPresentWarning.Description = $"{_source} {_sourceSlot + 2} wafer not present";
  150. _waferRobotModule.TargetWaferNotPresentWarning.Set($"{_source} {_sourceSlot + 2} wafer not present");
  151. return Result.FAIL;
  152. }
  153. if (!WaferManager.Instance.CheckHasWafer(_source, _sourceSlot + 2))
  154. {
  155. //_waferRobotModule.TargetWaferNotPresentWarning.Description = $"{_source} {_sourceSlot + 3} wafer not present";
  156. _waferRobotModule.TargetWaferNotPresentWarning.Set($"{_source} {_sourceSlot + 3} wafer not present");
  157. return Result.FAIL;
  158. }
  159. if (!WaferManager.Instance.CheckHasWafer(_source, _sourceSlot + 3))
  160. {
  161. //_waferRobotModule.TargetWaferNotPresentWarning.Description = $"{_source} {_sourceSlot + 4} wafer not present";
  162. _waferRobotModule.TargetWaferNotPresentWarning.Set($"{_source} {_sourceSlot + 4} wafer not present");
  163. return Result.FAIL;
  164. }
  165. }
  166. else if (_blade == Hand.Both)
  167. {
  168. if (SC.GetValue<bool>("System.IsSimulatorMode"))
  169. {
  170. if (!WaferManager.Instance.CheckNoWafer(ModuleName.WaferRobot, 0) ||
  171. !WaferManager.Instance.CheckNoWafer(ModuleName.WaferRobot, 1) ||
  172. !WaferManager.Instance.CheckNoWafer(ModuleName.WaferRobot, 2) ||
  173. !WaferManager.Instance.CheckNoWafer(ModuleName.WaferRobot, 3) ||
  174. !WaferManager.Instance.CheckNoWafer(ModuleName.WaferRobot, 4))
  175. {
  176. //_waferRobotModule.BladeWaferPresentWarning.Description = $"{ModuleName.WaferRobot} {_blade} wafer present";
  177. _waferRobotModule.BladeWaferPresentWarning.Set($"{ModuleName.WaferRobot} {_blade} wafer present");
  178. return Result.FAIL;
  179. }
  180. }
  181. else
  182. {
  183. if (_waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade1 ||
  184. _waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade2 ||
  185. _waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade3 ||
  186. _waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade4 ||
  187. _waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade5 ||
  188. !WaferManager.Instance.CheckNoWafer(ModuleName.WaferRobot, 0) ||
  189. !WaferManager.Instance.CheckNoWafer(ModuleName.WaferRobot, 1) ||
  190. !WaferManager.Instance.CheckNoWafer(ModuleName.WaferRobot, 2) ||
  191. !WaferManager.Instance.CheckNoWafer(ModuleName.WaferRobot, 3) ||
  192. !WaferManager.Instance.CheckNoWafer(ModuleName.WaferRobot, 4))
  193. {
  194. //_waferRobotModule.BladeWaferPresentWarning.Description = $"{ModuleName.WaferRobot} {_blade} wafer present";
  195. _waferRobotModule.BladeWaferPresentWarning.Set($"{ModuleName.WaferRobot} {_blade} wafer present");
  196. return Result.FAIL;
  197. }
  198. }
  199. if (!WaferManager.Instance.CheckHasWafer(_source, _sourceSlot))
  200. {
  201. //_waferRobotModule.TargetWaferNotPresentWarning.Description = $"{_source} {_sourceSlot + 1} wafer not present";
  202. _waferRobotModule.TargetWaferNotPresentWarning.Set($"{_source} {_sourceSlot + 1} wafer not present");
  203. return Result.FAIL;
  204. }
  205. if (!WaferManager.Instance.CheckHasWafer(_source, _sourceSlot + 1))
  206. {
  207. //_waferRobotModule.TargetWaferNotPresentWarning.Description = $"{_source} {_sourceSlot + 2} wafer not present";
  208. _waferRobotModule.TargetWaferNotPresentWarning.Set($"{_source} {_sourceSlot + 2} wafer not present");
  209. return Result.FAIL;
  210. }
  211. if (!WaferManager.Instance.CheckHasWafer(_source, _sourceSlot + 2))
  212. {
  213. //_waferRobotModule.TargetWaferNotPresentWarning.Description = $"{_source} {_sourceSlot + 3} wafer not present";
  214. _waferRobotModule.TargetWaferNotPresentWarning.Set($"{_source} {_sourceSlot + 3} wafer not present");
  215. return Result.FAIL;
  216. }
  217. if (!WaferManager.Instance.CheckHasWafer(_source, _sourceSlot + 3))
  218. {
  219. //_waferRobotModule.TargetWaferNotPresentWarning.Description = $"{_source} {_sourceSlot + 4} wafer not present";
  220. _waferRobotModule.TargetWaferNotPresentWarning.Set($"{_source} {_sourceSlot + 4} wafer not present");
  221. return Result.FAIL;
  222. }
  223. if (!WaferManager.Instance.CheckHasWafer(_source, _sourceSlot + 4))
  224. {
  225. //_waferRobotModule.TargetWaferNotPresentWarning.Description = $"{_source} {_sourceSlot + 5} wafer not present";
  226. _waferRobotModule.TargetWaferNotPresentWarning.Set($"{_source} {_sourceSlot + 5} wafer not present");
  227. return Result.FAIL;
  228. }
  229. }
  230. if (ModuleHelper.IsPm(_source))
  231. {
  232. var pmModule = Singleton<EquipmentManager>.Instance.Modules[_source] as PMModule;
  233. if (pmModule != null && !pmModule.CheckReadyForTransfer(ModuleHelper.Converter(_waferRobotModule.Module), _blade, _sourceSlot, EnumTransferType.Pick, out string reason))
  234. {
  235. //_waferRobotModule.PickWaferFailAlarm.Description = reason;
  236. _waferRobotModule.PickWaferFailAlarm.Set(reason);
  237. return Result.FAIL;
  238. }
  239. }
  240. if (_source == ModuleName.FIMS1 || _source == ModuleName.FIMS2)
  241. {
  242. var fims = Singleton<EquipmentManager>.Instance.Modules[_source] as FIMSModule;
  243. if (fims != null && !fims.CheckReadyForTransfer(ModuleHelper.Converter(Module), _blade, _sourceSlot, EnumTransferType.Pick, out string reason))
  244. {
  245. //_waferRobotModule.PickWaferFailAlarm.Description = reason;
  246. _waferRobotModule.PickWaferFailAlarm.Set(reason);
  247. return Result.FAIL;
  248. }
  249. }
  250. }
  251. Notify($"Start");
  252. return Result.RUN;
  253. }
  254. public void Abort()
  255. {
  256. _waferRobotModule.Stop();
  257. (Singleton<EquipmentManager>.Instance.Modules[_source] as ITransferTarget)?.NoteTransferStop(ModuleHelper.Converter(_waferRobotModule.Module), _blade, _sourceSlot, EnumTransferType.Pick);
  258. }
  259. public override Result Monitor()
  260. {
  261. try
  262. {
  263. PauseRountine(_waferRobotModule.WaferRobotDevice.IsPause);
  264. if (_waferRobotModule.WaferRobotDevice.IsPause)
  265. return Result.RUN;
  266. CheckBeforePick((int)RoutineStep.CheckBeforePick, _source, _sourceSlot, _blade);
  267. Pick((int)RoutineStep.Pick, _source, _sourceSlot, _blade, _timeout);
  268. //RobotRequestWaferPresent((int)RoutineStep.RobotRequestWaferPresent, _blade, _timeout);
  269. CheckWaferInfoByRobotSensor((int)RoutineStep.CheckCassetteInfoByRobotSensor, _blade, true);
  270. }
  271. catch (RoutineBreakException)
  272. {
  273. return Result.RUN;
  274. }
  275. catch (RoutineFaildException ex)
  276. {
  277. (Singleton<EquipmentManager>.Instance.Modules[_source] as ITransferTarget)?.NoteTransferStop(ModuleHelper.Converter(_waferRobotModule.Module), _blade, _sourceSlot, EnumTransferType.Pick);
  278. return Result.FAIL;
  279. }
  280. (Singleton<EquipmentManager>.Instance.Modules[_source] as ITransferTarget)?.NoteTransferStop(ModuleHelper.Converter(_waferRobotModule.Module), _blade, _sourceSlot, EnumTransferType.Pick);
  281. Notify("Finished");
  282. return Result.DONE;
  283. }
  284. private void CheckBeforePick(int id, ModuleName source, int slot, Hand blade)
  285. {
  286. Tuple<bool, Result> ret = Execute(id, () =>
  287. {
  288. Notify("Check pick condition");
  289. string reason = string.Empty;
  290. if (_waferRobotModule.WaferRobotDevice.IsError)
  291. {
  292. //_waferRobotModule.PickWaferFailAlarm.Description = $"pick from {source} failed for robot error, error code={_waferRobotModule.WaferRobotDevice.ErrorCode}";
  293. _waferRobotModule.PickWaferFailAlarm.Set($"pick from {source} failed for robot error, error code={_waferRobotModule.WaferRobotDevice.ErrorCode}");
  294. return false;
  295. }
  296. if (!_waferRobotModule.WaferRobotDevice.IsReady(out reason))
  297. {
  298. //_waferRobotModule.PickWaferFailAlarm.Description = $"pick from {source} failed for robot isn't Ready";
  299. _waferRobotModule.PickWaferFailAlarm.Set($"pick from {source} failed for robot isn't Ready {reason}");
  300. return false;
  301. }
  302. if (ModuleHelper.IsPm(_source))
  303. {
  304. var pmModule = Singleton<EquipmentManager>.Instance.Modules[_source] as PMModule;
  305. if (pmModule != null && !pmModule.CheckReadyForTransfer(ModuleHelper.Converter(_waferRobotModule.Module), _blade, _sourceSlot, EnumTransferType.Pick, out reason))
  306. {
  307. //_waferRobotModule.PickWaferFailAlarm.Description = reason;
  308. _waferRobotModule.PickWaferFailAlarm.Set(reason);
  309. return false;
  310. }
  311. }
  312. if (source == ModuleName.FIMS1 || source == ModuleName.FIMS2)
  313. {
  314. var fims = Singleton<EquipmentManager>.Instance.Modules[source] as FIMSModule;
  315. if (fims != null && !fims.CheckReadyForTransfer(ModuleHelper.Converter(Module), _blade, slot, EnumTransferType.Pick, out reason))
  316. {
  317. //_waferRobotModule.PickWaferFailAlarm.Description = reason;
  318. _waferRobotModule.PickWaferFailAlarm.Set(reason);
  319. return false;
  320. }
  321. }
  322. if (blade == Hand.Blade1)
  323. {
  324. if (!WaferManager.Instance.CheckHasWafer(source, slot))
  325. {
  326. //_waferRobotModule.PickWaferFailAlarm.Description = $"pick from {source} failed for {source} no wafer";
  327. _waferRobotModule.PickWaferFailAlarm.Set($"pick from {source} failed for {source} no wafer");
  328. return false;
  329. }
  330. if (!WaferManager.Instance.CheckNoWafer(Module, 2))
  331. {
  332. //_waferRobotModule.PickWaferFailAlarm.Description = $"pick from {source} failed for blade has wafer";
  333. _waferRobotModule.PickWaferFailAlarm.Set($"pick from {source} failed for blade has wafer");
  334. return false;
  335. }
  336. }
  337. else if (blade == Hand.Blade2)
  338. {
  339. if (!WaferManager.Instance.CheckHasWafer(source, slot))
  340. {
  341. //_waferRobotModule.PickWaferFailAlarm.Description = $"pick from {source} failed for {source} no wafer";
  342. _waferRobotModule.PickWaferFailAlarm.Set($"pick from {source} failed for {source} no wafer");
  343. return false;
  344. }
  345. if (!WaferManager.Instance.CheckNoWafer(Module, 1))
  346. {
  347. //_waferRobotModule.PickWaferFailAlarm.Description = $"pick from {source} failed for blade has wafer";
  348. _waferRobotModule.PickWaferFailAlarm.Set($"pick from {source} failed for blade has wafer");
  349. return false;
  350. }
  351. }
  352. else
  353. {
  354. for (int i = 0; i < 5; i++)
  355. {
  356. if (!WaferManager.Instance.CheckHasWafer(source, slot + i))
  357. {
  358. //_waferRobotModule.PickWaferFailAlarm.Description = $"pick from {source} failed for {source} no wafer";
  359. _waferRobotModule.PickWaferFailAlarm.Set($"pick from {source} failed for {source} no wafer");
  360. return false;
  361. }
  362. if (!WaferManager.Instance.CheckNoWafer(Module, i))
  363. {
  364. //_waferRobotModule.PickWaferFailAlarm.Description = $"pick from {source} failed for blade has wafer";
  365. _waferRobotModule.PickWaferFailAlarm.Set($"pick from {source} failed for blade has wafer");
  366. return false;
  367. }
  368. }
  369. }
  370. return true;
  371. });
  372. if (ret.Item1)
  373. {
  374. if (ret.Item2 == Result.FAIL)
  375. {
  376. throw (new RoutineFaildException());
  377. }
  378. }
  379. _needStartCheck = false;
  380. }
  381. private void Pick(int id, ModuleName source, int slot, Hand hand, int timeout)
  382. {
  383. _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
  384. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  385. {
  386. Notify("Pick");
  387. string reason;
  388. (Singleton<EquipmentManager>.Instance.Modules[source] as ITransferTarget)?.NoteTransferStart(ModuleHelper.Converter(_waferRobotModule.Module), hand, slot, EnumTransferType.Pick);
  389. if (!_waferRobotModule.RobotPick(source, slot, hand, out reason))
  390. {
  391. //_waferRobotModule.PickWaferFailAlarm.Description = reason;
  392. _waferRobotModule.PickWaferFailAlarm.Set(reason);
  393. return false;
  394. }
  395. return true;
  396. }, () =>
  397. {
  398. if (_waferRobotModule.WaferRobotDevice.IsReady() && !_waferRobotModule.WaferRobotDevice.IsError)
  399. {
  400. return true;
  401. }
  402. return false;
  403. }, timeout * 1000);
  404. if (ret.Item1)
  405. {
  406. if (ret.Item2 == Result.FAIL)
  407. {
  408. //_waferRobotModule.PickWaferFailAlarm.Description = $"{_waferRobotModule.WaferRobotDevice.ErrorCode}";
  409. _waferRobotModule.PickWaferFailAlarm.Set($"pick from {source} failed for robot error, error code={_waferRobotModule.WaferRobotDevice.ErrorCode}");
  410. throw (new RoutineFaildException());
  411. }
  412. else if (ret.Item2 == Result.TIMEOUT) //timeout
  413. {
  414. //_waferRobotModule.PickWaferTimeoutAlarm.Description = $"timeout over {timeout} seconds";
  415. _waferRobotModule.PickWaferTimeoutAlarm.Set($"timeout over {timeout} seconds");
  416. throw (new RoutineFaildException());
  417. }
  418. else
  419. throw (new RoutineBreakException());
  420. }
  421. }
  422. private void RobotRequestWaferPresent(int id, Hand hand, int timeout)
  423. {
  424. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  425. {
  426. Notify("request wafer present");
  427. if (!_waferRobotModule.RequestWaferPresent(hand, out string reason))
  428. {
  429. //_waferRobotModule.RequestWaferPresentFailAlarm.Description = reason;
  430. _waferRobotModule.RequestWaferPresentFailAlarm.Set(reason);
  431. return false;
  432. }
  433. return true;
  434. }, () =>
  435. {
  436. if (_waferRobotModule.WaferRobotDevice.IsReady() && !_waferRobotModule.WaferRobotDevice.IsError)
  437. {
  438. return true;
  439. }
  440. return false;
  441. }, timeout * 1000);
  442. if (ret.Item1)
  443. {
  444. if (ret.Item2 == Result.FAIL)
  445. {
  446. throw (new RoutineFaildException());
  447. }
  448. else if (ret.Item2 == Result.TIMEOUT) //timeout
  449. {
  450. //_waferRobotModule.RequestWaferPresentTimeoutAlarm.Description = $"timeout over {timeout} seconds";
  451. _waferRobotModule.RequestWaferPresentTimeoutAlarm.Set($"timeout over {timeout} seconds");
  452. throw (new RoutineFaildException());
  453. }
  454. else
  455. throw (new RoutineBreakException());
  456. }
  457. }
  458. private void CheckWaferInfoByRobotSensor(int id, Hand hand, bool isAfterPick)
  459. {
  460. Tuple<bool, Result> ret = Execute(id, () =>
  461. {
  462. Notify($"check wafer info by robot RQ present");
  463. if (SC.GetValue<bool>("System.IsSimulatorMode"))
  464. return true;
  465. if (hand == Hand.Blade1 || hand == Hand.Both)
  466. {
  467. if (!isAfterPick && _waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade3)
  468. {
  469. _waferRobotModule.RobotSensorFoundWaferOnBladeAfterPlaceAlarm.Set("Wafer Robot sensor found wafer on blade 3");
  470. return false;
  471. }
  472. if (isAfterPick && !_waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade3)
  473. {
  474. _waferRobotModule.RobotSensorNotFoundWaferOnBladeAfterPickAlarm.Set("Wafer Robot sensor no wafer on blade 3");
  475. return false;
  476. }
  477. }
  478. if (hand == Hand.Blade2 || hand == Hand.Both)
  479. {
  480. if (!isAfterPick && _waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade1)
  481. {
  482. _waferRobotModule.RobotSensorFoundWaferOnBladeAfterPlaceAlarm.Set("Wafer Robot sensor found wafer on blade 1");
  483. return false;
  484. }
  485. if (isAfterPick && !_waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade1)
  486. {
  487. _waferRobotModule.RobotSensorNotFoundWaferOnBladeAfterPickAlarm.Set("Wafer Robot sensor no wafer on blade 1");
  488. return false;
  489. }
  490. if (!isAfterPick && _waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade2)
  491. {
  492. _waferRobotModule.RobotSensorFoundWaferOnBladeAfterPlaceAlarm.Set("Wafer Robot sensor found wafer on blade 2");
  493. return false;
  494. }
  495. if (isAfterPick && !_waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade2)
  496. {
  497. _waferRobotModule.RobotSensorNotFoundWaferOnBladeAfterPickAlarm.Set("Wafer Robot sensor no wafer on blade 2");
  498. return false;
  499. }
  500. if (!isAfterPick && _waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade4)
  501. {
  502. _waferRobotModule.RobotSensorFoundWaferOnBladeAfterPlaceAlarm.Set("Wafer Robot sensor found wafer on blade 4");
  503. return false;
  504. }
  505. if (isAfterPick && !_waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade4)
  506. {
  507. _waferRobotModule.RobotSensorNotFoundWaferOnBladeAfterPickAlarm.Set("Wafer Robot sensor no wafer on blade 4");
  508. return false;
  509. }
  510. if (!isAfterPick && _waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade5)
  511. {
  512. _waferRobotModule.RobotSensorFoundWaferOnBladeAfterPlaceAlarm.Set("Wafer Robot sensor found wafer on blade 5");
  513. return false;
  514. }
  515. if (isAfterPick && !_waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade5)
  516. {
  517. _waferRobotModule.RobotSensorNotFoundWaferOnBladeAfterPickAlarm.Set("Wafer Robot sensor no wafer on blade 5");
  518. return false;
  519. }
  520. }
  521. return true;
  522. });
  523. if (ret.Item1)
  524. {
  525. if (ret.Item2 == Result.FAIL)
  526. {
  527. _waferRobotModule.CheckWaferInformationFailAlarm.Set();
  528. throw (new RoutineFaildException());
  529. }
  530. else
  531. throw (new RoutineBreakException());
  532. }
  533. }
  534. }
  535. }