WaferRobotPick.cs 35 KB

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