WaferRobotPick.cs 31 KB

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