WaferRobotPick.cs 34 KB

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