WaferRobotPlace.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. using Aitex.Core.RT.Routine;
  2. using Aitex.Core.RT.SCCore;
  3. using Aitex.Core.Util;
  4. using Aitex.Sorter.Common;
  5. using DocumentFormat.OpenXml.Bibliography;
  6. using MECF.Framework.Common.Equipment;
  7. using MECF.Framework.Common.Schedulers;
  8. using MECF.Framework.Common.SubstrateTrackings;
  9. using MECF.Framework.RT.EquipmentLibrary.LogicUnits;
  10. using System;
  11. using System.Collections.Generic;
  12. using FurnaceRT.Equipments.FIMSs;
  13. using FurnaceRT.Equipments.PMs;
  14. using FurnaceRT.Equipments.Stockers;
  15. using FurnaceRT.Equipments.Systems;
  16. namespace FurnaceRT.Equipments.WaferRobots
  17. {
  18. public class WaferRobotPlace : ModuleRoutine, IRoutine
  19. {
  20. enum RoutineStep
  21. {
  22. Place,
  23. RobotRequestWaferPresent,
  24. CheckWaferInfoByRobotSensor,
  25. CheckBeforePlace,
  26. SetRobotActionCommand,
  27. }
  28. private ModuleName _destination;
  29. private int _destinationSlot;
  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 WaferRobotPlace(WaferRobotModule waferRobotModule)
  42. {
  43. _waferRobotModule = waferRobotModule;
  44. Module = waferRobotModule.Module;
  45. Name = "Place";
  46. }
  47. public void Init(ModuleName destination, int destinationSlot, Hand blade, bool isHasAlarm)
  48. {
  49. _destination = destination;
  50. _destinationSlot = destinationSlot;
  51. _blade = blade;
  52. var para = new List<object> { _destination, _destinationSlot, _blade, true };
  53. _waferRobotModule.PlaceWaferFailAlarm.RetryMessage = (int)WaferRobotModule.MSG.PlaceRetry;
  54. _waferRobotModule.PlaceWaferFailAlarm.RetryMessageParas = para.ToArray();
  55. _waferRobotModule.PlaceWaferTimeoutAlarm.RetryMessage = (int)WaferRobotModule.MSG.PlaceRetry;
  56. _waferRobotModule.PlaceWaferTimeoutAlarm.RetryMessageParas = para.ToArray();
  57. _waferRobotModule.RequestWaferPresentFailAlarm.RetryMessage = (int)WaferRobotModule.MSG.PlaceRetry;
  58. _waferRobotModule.RequestWaferPresentFailAlarm.RetryMessageParas = para.ToArray();
  59. _waferRobotModule.RequestWaferPresentTimeoutAlarm.RetryMessage = (int)WaferRobotModule.MSG.PlaceRetry;
  60. _waferRobotModule.RequestWaferPresentTimeoutAlarm.RetryMessageParas = para.ToArray();
  61. _waferRobotModule.RobotHasError.RetryMessage = (int)WaferRobotModule.MSG.PlaceRetry;
  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}.PlaceTimeout");
  87. var isSimulateMode = SC.GetValue<bool>("System.IsSimulatorMode");
  88. if (_needStartCheck)
  89. {
  90. if (_blade == Hand.Blade1)
  91. {
  92. if (isSimulateMode)
  93. {
  94. if (!WaferManager.Instance.CheckHasWafer(ModuleName.WaferRobot, 2))
  95. {
  96. //_waferRobotModule.BladeWaferNotPresentWarning.Description = $"{ModuleName.WaferRobot} {_blade} wafer not present";
  97. _waferRobotModule.BladeWaferNotPresentWarning.Set($"{ModuleName.WaferRobot} {_blade} wafer not present");
  98. return Result.FAIL;
  99. }
  100. }
  101. else
  102. {
  103. if (!_waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade3 || !WaferManager.Instance.CheckHasWafer(ModuleName.WaferRobot, 2))
  104. {
  105. //_waferRobotModule.BladeWaferNotPresentWarning.Description = $"{ModuleName.WaferRobot} {_blade} wafer not present";
  106. _waferRobotModule.BladeWaferNotPresentWarning.Set($"{ModuleName.WaferRobot} {_blade} wafer not present");
  107. return Result.FAIL;
  108. }
  109. }
  110. if (!WaferManager.Instance.CheckNoWafer(_destination, _destinationSlot))
  111. {
  112. //_waferRobotModule.TargetWaferPresentWarning.Description = $"{_destination} {_destinationSlot + 1} wafer present";
  113. _waferRobotModule.TargetWaferPresentWarning.Set($"{_destination} {_destinationSlot + 1} wafer present");
  114. return Result.FAIL;
  115. }
  116. }
  117. else if (_blade == Hand.Blade2)
  118. {
  119. if (isSimulateMode)
  120. {
  121. if (!WaferManager.Instance.CheckHasWafer(ModuleName.WaferRobot, 1) ||
  122. !WaferManager.Instance.CheckHasWafer(ModuleName.WaferRobot, 2) ||
  123. !WaferManager.Instance.CheckHasWafer(ModuleName.WaferRobot, 3) ||
  124. !WaferManager.Instance.CheckHasWafer(ModuleName.WaferRobot, 4))
  125. {
  126. //_waferRobotModule.BladeWaferNotPresentWarning.Description = $"{ModuleName.WaferRobot} {_blade} wafer not present";
  127. _waferRobotModule.BladeWaferNotPresentWarning.Set($"{ModuleName.WaferRobot} {_blade} wafer not present");
  128. return Result.FAIL;
  129. }
  130. }
  131. else
  132. {
  133. if (!_waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade2 ||
  134. !WaferManager.Instance.CheckHasWafer(ModuleName.WaferRobot, 1) ||
  135. !WaferManager.Instance.CheckHasWafer(ModuleName.WaferRobot, 2) ||
  136. !WaferManager.Instance.CheckHasWafer(ModuleName.WaferRobot, 3) ||
  137. !WaferManager.Instance.CheckHasWafer(ModuleName.WaferRobot, 4))
  138. {
  139. //_waferRobotModule.BladeWaferNotPresentWarning.Description = $"{ModuleName.WaferRobot} {_blade} wafer not present";
  140. _waferRobotModule.BladeWaferNotPresentWarning.Set($"{ModuleName.WaferRobot} {_blade} wafer not present");
  141. return Result.FAIL;
  142. }
  143. }
  144. if (!WaferManager.Instance.CheckNoWafer(_destination, _destinationSlot))
  145. {
  146. //_waferRobotModule.TargetWaferPresentWarning.Description = $"{_destination} {_destinationSlot + 1} wafer present";
  147. _waferRobotModule.TargetWaferPresentWarning.Set($"{_destination} {_destinationSlot + 1} wafer present");
  148. return Result.FAIL;
  149. }
  150. if (!WaferManager.Instance.CheckNoWafer(_destination, _destinationSlot + 1))
  151. {
  152. //_waferRobotModule.TargetWaferPresentWarning.Description = $"{_destination} {_destinationSlot + 2} wafer present";
  153. _waferRobotModule.TargetWaferPresentWarning.Set($"{_destination} {_destinationSlot + 2} wafer present");
  154. return Result.FAIL;
  155. }
  156. if (!WaferManager.Instance.CheckNoWafer(_destination, _destinationSlot + 2))
  157. {
  158. //_waferRobotModule.TargetWaferPresentWarning.Description = $"{_destination} {_destinationSlot + 3} wafer present";
  159. _waferRobotModule.TargetWaferPresentWarning.Set($"{_destination} {_destinationSlot + 3} wafer present");
  160. return Result.FAIL;
  161. }
  162. if (!WaferManager.Instance.CheckNoWafer(_destination, _destinationSlot + 3))
  163. {
  164. //_waferRobotModule.TargetWaferPresentWarning.Description = $"{_destination} {_destinationSlot + 4} wafer present";
  165. _waferRobotModule.TargetWaferPresentWarning.Set($"{_destination} {_destinationSlot + 4} wafer present");
  166. return Result.FAIL;
  167. }
  168. }
  169. else if (_blade == Hand.Both)
  170. {
  171. if (isSimulateMode)
  172. {
  173. if (!WaferManager.Instance.CheckHasWafer(ModuleName.WaferRobot, 0) ||
  174. !WaferManager.Instance.CheckHasWafer(ModuleName.WaferRobot, 1) ||
  175. !WaferManager.Instance.CheckHasWafer(ModuleName.WaferRobot, 2) ||
  176. !WaferManager.Instance.CheckHasWafer(ModuleName.WaferRobot, 3) ||
  177. !WaferManager.Instance.CheckHasWafer(ModuleName.WaferRobot, 4))
  178. {
  179. //_waferRobotModule.BladeWaferNotPresentWarning.Description = $"{ModuleName.WaferRobot} {_blade} wafer not present";
  180. _waferRobotModule.BladeWaferNotPresentWarning.Set($"{ModuleName.WaferRobot} {_blade} wafer not 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.CheckHasWafer(ModuleName.WaferRobot, 0) ||
  192. !WaferManager.Instance.CheckHasWafer(ModuleName.WaferRobot, 1) ||
  193. !WaferManager.Instance.CheckHasWafer(ModuleName.WaferRobot, 2) ||
  194. !WaferManager.Instance.CheckHasWafer(ModuleName.WaferRobot, 3) ||
  195. !WaferManager.Instance.CheckHasWafer(ModuleName.WaferRobot, 4))
  196. {
  197. //_waferRobotModule.BladeWaferNotPresentWarning.Description = $"{ModuleName.WaferRobot} {_blade} wafer not present";
  198. _waferRobotModule.BladeWaferNotPresentWarning.Set($"{ModuleName.WaferRobot} {_blade} wafer not present");
  199. return Result.FAIL;
  200. }
  201. }
  202. if (!WaferManager.Instance.CheckNoWafer(_destination, _destinationSlot))
  203. {
  204. //_waferRobotModule.TargetWaferPresentWarning.Description = $"{_destination} {_destinationSlot + 1} wafer present";
  205. _waferRobotModule.TargetWaferPresentWarning.Set($"{_destination} {_destinationSlot + 1} wafer present");
  206. return Result.FAIL;
  207. }
  208. if (!WaferManager.Instance.CheckNoWafer(_destination, _destinationSlot + 1))
  209. {
  210. //_waferRobotModule.TargetWaferPresentWarning.Description = $"{_destination} {_destinationSlot + 2} wafer present";
  211. _waferRobotModule.TargetWaferPresentWarning.Set($"{_destination} {_destinationSlot + 2} wafer present");
  212. return Result.FAIL;
  213. }
  214. if (!WaferManager.Instance.CheckNoWafer(_destination, _destinationSlot + 2))
  215. {
  216. //_waferRobotModule.TargetWaferPresentWarning.Description = $"{_destination} {_destinationSlot + 3} wafer present";
  217. _waferRobotModule.TargetWaferPresentWarning.Set($"{_destination} {_destinationSlot + 3} wafer present");
  218. return Result.FAIL;
  219. }
  220. if (!WaferManager.Instance.CheckNoWafer(_destination, _destinationSlot + 3))
  221. {
  222. //_waferRobotModule.TargetWaferPresentWarning.Description = $"{_destination} {_destinationSlot + 4} wafer present";
  223. _waferRobotModule.TargetWaferPresentWarning.Set($"{_destination} {_destinationSlot + 4} wafer present");
  224. return Result.FAIL;
  225. }
  226. if (!WaferManager.Instance.CheckNoWafer(_destination, _destinationSlot + 4))
  227. {
  228. //_waferRobotModule.TargetWaferPresentWarning.Description = $"{_destination} {_destinationSlot + 5} wafer present";
  229. _waferRobotModule.TargetWaferPresentWarning.Set($"{_destination} {_destinationSlot + 5} wafer present");
  230. return Result.FAIL;
  231. }
  232. }
  233. if (ModuleHelper.IsPm(_destination))
  234. {
  235. var pmModule = Singleton<EquipmentManager>.Instance.Modules[_destination] as PMModule;
  236. if (pmModule != null && !pmModule.CheckReadyForTransfer(ModuleHelper.Converter(_waferRobotModule.Module), _blade, _destinationSlot, EnumTransferType.Place, out string reason))
  237. {
  238. //_waferRobotModule.PlaceWaferFailAlarm.Description = reason;
  239. _waferRobotModule.PlaceWaferFailAlarm.Set(reason);
  240. return Result.FAIL;
  241. }
  242. }
  243. if (_destination == ModuleName.FIMS1 || _destination == ModuleName.FIMS2)
  244. {
  245. var fims = Singleton<EquipmentManager>.Instance.Modules[_destination] as FIMSModule;
  246. if (fims != null && !fims.CheckReadyForTransfer(ModuleHelper.Converter(Module), _blade, _destinationSlot, EnumTransferType.Place, out string reason))
  247. {
  248. //_waferRobotModule.PlaceWaferFailAlarm.Description = reason;
  249. _waferRobotModule.PlaceWaferFailAlarm.Set(reason);
  250. return Result.FAIL;
  251. }
  252. }
  253. }
  254. Notify($"Start");
  255. return Result.RUN;
  256. }
  257. public void Abort()
  258. {
  259. _waferRobotModule.ResetRobotActionCommand();
  260. _waferRobotModule.Stop();
  261. (Singleton<EquipmentManager>.Instance.Modules[_destination] as ITransferTarget)?.NoteTransferStop(ModuleHelper.Converter(_waferRobotModule.Module), _blade, _destinationSlot, EnumTransferType.Place);
  262. }
  263. public override Result Monitor()
  264. {
  265. try
  266. {
  267. PauseRountine(_waferRobotModule.WaferRobotDevice.IsPause);
  268. if (_waferRobotModule.WaferRobotDevice.IsPause)
  269. return Result.RUN;
  270. CheckBeforePlace((int)RoutineStep.CheckBeforePlace, _destination, _destinationSlot, _blade);
  271. if (_waferRobotModule.TrigActionCommand != null)
  272. SetRobotActionCommand((int)RoutineStep.SetRobotActionCommand, _destination, _timeout);
  273. Place((int)RoutineStep.Place, _destination, _destinationSlot, _blade, _timeout);
  274. //RobotRequestWaferPresent((int)RoutineStep.RobotRequestWaferPresent, _blade, _timeout);
  275. CheckWaferInfoByRobotSensor((int)RoutineStep.CheckWaferInfoByRobotSensor, _blade, false);
  276. }
  277. catch (RoutineBreakException)
  278. {
  279. return Result.RUN;
  280. }
  281. catch (RoutineFaildException ex)
  282. {
  283. _waferRobotModule.ResetRobotActionCommand();
  284. (Singleton<EquipmentManager>.Instance.Modules[_destination] as ITransferTarget)?.NoteTransferStop(ModuleHelper.Converter(_waferRobotModule.Module), _blade, _destinationSlot, EnumTransferType.Place);
  285. return Result.FAIL;
  286. }
  287. _waferRobotModule.ResetRobotActionCommand();
  288. (Singleton<EquipmentManager>.Instance.Modules[_destination] as ITransferTarget)?.NoteTransferStop(ModuleHelper.Converter(_waferRobotModule.Module), _blade, _destinationSlot, EnumTransferType.Place);
  289. Notify("Finished");
  290. return Result.DONE;
  291. }
  292. private void CheckBeforePlace(int id, ModuleName target, int slot, Hand blade)
  293. {
  294. Tuple<bool, Result> ret = Execute(id, () =>
  295. {
  296. Notify("Check place condition");
  297. string reason = string.Empty;
  298. if (_waferRobotModule.WaferRobotDevice.IsError)
  299. {
  300. //_waferRobotModule.PlaceWaferFailAlarm.Description = $"place to {target} failed for robot error, error code={_waferRobotModule.WaferRobotDevice.ErrorCode}";
  301. _waferRobotModule.PlaceWaferFailAlarm.Set($"place to {target} failed for robot error, error code={_waferRobotModule.WaferRobotDevice.ErrorCode}");
  302. return false;
  303. }
  304. if (!_waferRobotModule.WaferRobotDevice.IsReady(out reason))
  305. {
  306. //_waferRobotModule.PlaceWaferFailAlarm.Description = $"place to {target} failed for robot isn't Ready";
  307. _waferRobotModule.PlaceWaferFailAlarm.Set($"place to {target} failed for robot isn't Ready {reason}");
  308. return false;
  309. }
  310. if (ModuleHelper.IsPm(_destination))
  311. {
  312. var pmModule = Singleton<EquipmentManager>.Instance.Modules[_destination] as PMModule;
  313. if (pmModule != null && !pmModule.CheckReadyForTransfer(ModuleHelper.Converter(_waferRobotModule.Module), _blade, slot, EnumTransferType.Place, out reason))
  314. {
  315. //_waferRobotModule.PlaceWaferFailAlarm.Description = reason;
  316. _waferRobotModule.PlaceWaferFailAlarm.Set(reason);
  317. return false;
  318. }
  319. }
  320. if (target == ModuleName.FIMS1 || target == ModuleName.FIMS2)
  321. {
  322. var fims = Singleton<EquipmentManager>.Instance.Modules[_destination] as FIMSModule;
  323. if (fims != null && !fims.CheckReadyForTransfer(ModuleHelper.Converter(Module), _blade, slot, EnumTransferType.Place, out reason))
  324. {
  325. //_waferRobotModule.PlaceWaferFailAlarm.Description = reason;
  326. _waferRobotModule.PlaceWaferFailAlarm.Set(reason);
  327. return false;
  328. }
  329. }
  330. if (blade == Hand.Blade1)
  331. {
  332. if (!WaferManager.Instance.CheckNoWafer(target, slot))
  333. {
  334. //_waferRobotModule.PlaceWaferFailAlarm.Description = $"place to {target} failed for {target} has wafer";
  335. _waferRobotModule.PlaceWaferFailAlarm.Set($"place to {target} failed for {target} has wafer");
  336. return false;
  337. }
  338. if (!WaferManager.Instance.CheckHasWafer(Module, 2))
  339. {
  340. //_waferRobotModule.PlaceWaferFailAlarm.Description = $"place to {target} failed for blade no wafer";
  341. _waferRobotModule.PlaceWaferFailAlarm.Set($"place to {target} failed for blade no wafer");
  342. return false;
  343. }
  344. }
  345. else if (blade == Hand.Blade2)
  346. {
  347. if (!WaferManager.Instance.CheckNoWafer(target, slot))
  348. {
  349. //_waferRobotModule.PlaceWaferFailAlarm.Description = $"place to {target} failed for {target} has wafer";
  350. _waferRobotModule.PlaceWaferFailAlarm.Set($"place to {target} failed for {target} has wafer");
  351. return false;
  352. }
  353. if (!WaferManager.Instance.CheckHasWafer(Module, 1))
  354. {
  355. //_waferRobotModule.PlaceWaferFailAlarm.Description = $"place to {target} failed for blade no wafer";
  356. _waferRobotModule.PlaceWaferFailAlarm.Set($"place to {target} failed for blade no wafer");
  357. return false;
  358. }
  359. }
  360. else
  361. {
  362. for (int i = 0; i < 5; i++)
  363. {
  364. if (!WaferManager.Instance.CheckNoWafer(target, slot + i))
  365. {
  366. //_waferRobotModule.PlaceWaferFailAlarm.Description = $"place to {target} failed for {target} has wafer";
  367. _waferRobotModule.PlaceWaferFailAlarm.Set($"place to {target} failed for {target} has wafer");
  368. return false;
  369. }
  370. if (!WaferManager.Instance.CheckHasWafer(Module, i))
  371. {
  372. //_waferRobotModule.PlaceWaferFailAlarm.Description = $"place to {target} failed for blade no wafer";
  373. _waferRobotModule.PlaceWaferFailAlarm.Set($"place to {target} failed for blade no wafer");
  374. return false;
  375. }
  376. }
  377. }
  378. return true;
  379. });
  380. if (ret.Item1)
  381. {
  382. if (ret.Item2 == Result.FAIL)
  383. {
  384. throw (new RoutineFaildException());
  385. }
  386. }
  387. _needStartCheck = false;
  388. }
  389. private void Place(int id, ModuleName target, int slot, Hand hand, int timeout)
  390. {
  391. _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
  392. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  393. {
  394. Notify("send place command to device");
  395. string reason;
  396. (Singleton<EquipmentManager>.Instance.Modules[target] as ITransferTarget)?.NoteTransferStart(ModuleHelper.Converter(_waferRobotModule.Module), hand, slot, EnumTransferType.Place);
  397. if (!_waferRobotModule.RobotPlace(target, slot, hand, out reason))
  398. {
  399. //_waferRobotModule.PlaceWaferFailAlarm.Description = reason;
  400. _waferRobotModule.PlaceWaferFailAlarm.Set(reason);
  401. return false;
  402. }
  403. return true;
  404. }, () =>
  405. {
  406. if (_waferRobotModule.WaferRobotDevice.IsReady() && !_waferRobotModule.WaferRobotDevice.IsError)
  407. {
  408. return true;
  409. }
  410. return false;
  411. }, timeout * 1000);
  412. if (ret.Item1)
  413. {
  414. if (ret.Item2 == Result.FAIL)
  415. {
  416. //_waferRobotModule.PlaceWaferFailAlarm.Description = $"{_waferRobotModule.WaferRobotDevice.ErrorCode}";
  417. _waferRobotModule.PlaceWaferFailAlarm.Set($"place to {target} failed for robot error, error code={_waferRobotModule.WaferRobotDevice.ErrorCode}");
  418. throw (new RoutineFaildException());
  419. }
  420. else if (ret.Item2 == Result.TIMEOUT) //timeout
  421. {
  422. //_waferRobotModule.PlaceWaferTimeoutAlarm.Description = $"timeout over {timeout} seconds";
  423. _waferRobotModule.PlaceWaferTimeoutAlarm.Set($"timeout over {timeout} seconds");
  424. throw (new RoutineFaildException());
  425. }
  426. else
  427. throw (new RoutineBreakException());
  428. }
  429. }
  430. private void RobotRequestWaferPresent(int id, Hand hand, int timeout)
  431. {
  432. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  433. {
  434. Notify("request wafer present");
  435. if (!_waferRobotModule.RequestWaferPresent(hand, out string reason))
  436. {
  437. //_waferRobotModule.RequestWaferPresentFailAlarm.Description = reason;
  438. _waferRobotModule.RequestWaferPresentFailAlarm.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. throw (new RoutineFaildException());
  455. }
  456. else if (ret.Item2 == Result.TIMEOUT) //timeout
  457. {
  458. //_waferRobotModule.RequestWaferPresentTimeoutAlarm.Description = $"timeout over {timeout} seconds";
  459. _waferRobotModule.RequestWaferPresentTimeoutAlarm.Set($"timeout over {timeout} seconds");
  460. throw (new RoutineFaildException());
  461. }
  462. else
  463. throw (new RoutineBreakException());
  464. }
  465. }
  466. private void CheckWaferInfoByRobotSensor(int id, Hand hand, bool isAfterPick)
  467. {
  468. Tuple<bool, Result> ret = Execute(id, () =>
  469. {
  470. Notify($"check wafer info by robot RQ present");
  471. if (SC.GetValue<bool>("System.IsSimulatorMode"))
  472. return true;
  473. if (hand == Hand.Blade1 || hand == Hand.Both)
  474. {
  475. if (!isAfterPick && _waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade3)
  476. {
  477. _waferRobotModule.RobotSensorFoundWaferOnBladeAfterPlaceAlarm.Set("Wafer Robot sensor found wafer on blade 3");
  478. return false;
  479. }
  480. if (isAfterPick && !_waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade3)
  481. {
  482. _waferRobotModule.RobotSensorNotFoundWaferOnBladeAfterPickAlarm.Set("Wafer Robot sensor no wafer on blade 3");
  483. return false;
  484. }
  485. }
  486. if (hand == Hand.Blade2 || hand == Hand.Both)
  487. {
  488. if (!isAfterPick && _waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade1)
  489. {
  490. _waferRobotModule.RobotSensorFoundWaferOnBladeAfterPlaceAlarm.Set("Wafer Robot sensor found wafer on blade 1");
  491. return false;
  492. }
  493. if (isAfterPick && !_waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade1)
  494. {
  495. _waferRobotModule.RobotSensorNotFoundWaferOnBladeAfterPickAlarm.Set("Wafer Robot sensor no wafer on blade 1");
  496. return false;
  497. }
  498. if (!isAfterPick && _waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade2)
  499. {
  500. _waferRobotModule.RobotSensorFoundWaferOnBladeAfterPlaceAlarm.Set("Wafer Robot sensor found wafer on blade 2");
  501. return false;
  502. }
  503. if (isAfterPick && !_waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade2)
  504. {
  505. _waferRobotModule.RobotSensorNotFoundWaferOnBladeAfterPickAlarm.Set("Wafer Robot sensor no wafer on blade 2");
  506. return false;
  507. }
  508. if (!isAfterPick && _waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade4)
  509. {
  510. _waferRobotModule.RobotSensorFoundWaferOnBladeAfterPlaceAlarm.Set("Wafer Robot sensor found wafer on blade 4");
  511. return false;
  512. }
  513. if (isAfterPick && !_waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade4)
  514. {
  515. _waferRobotModule.RobotSensorNotFoundWaferOnBladeAfterPickAlarm.Set("Wafer Robot sensor no wafer on blade 4");
  516. return false;
  517. }
  518. if (!isAfterPick && _waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade5)
  519. {
  520. _waferRobotModule.RobotSensorFoundWaferOnBladeAfterPlaceAlarm.Set("Wafer Robot sensor found wafer on blade 5");
  521. return false;
  522. }
  523. if (isAfterPick && !_waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade5)
  524. {
  525. _waferRobotModule.RobotSensorNotFoundWaferOnBladeAfterPickAlarm.Set("Wafer Robot sensor no wafer on blade 5");
  526. return false;
  527. }
  528. }
  529. return true;
  530. });
  531. if (ret.Item1)
  532. {
  533. if (ret.Item2 == Result.FAIL)
  534. {
  535. _waferRobotModule.CheckWaferInformationFailAlarm.Set();
  536. throw (new RoutineFaildException());
  537. }
  538. else
  539. throw (new RoutineBreakException());
  540. }
  541. }
  542. private void SetRobotActionCommand(int id, ModuleName source, int timeout)
  543. {
  544. _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
  545. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  546. {
  547. Notify($"Set robot action command target position {source}");
  548. _waferRobotModule.SetRobotActionCommand(source, EnumTransferType.Place);
  549. return true;
  550. }, () =>
  551. {
  552. return _waferRobotModule.CheckRobotActionCommand(source, EnumTransferType.Place);
  553. }, timeout * 1000);
  554. if (ret.Item1)
  555. {
  556. if (ret.Item2 == Result.FAIL)
  557. {
  558. _waferRobotModule.PlaceWaferFailAlarm.Set($"place to {source} failed for robot action command interlock");
  559. throw (new RoutineFaildException());
  560. }
  561. else if (ret.Item2 == Result.TIMEOUT) //timeout
  562. {
  563. _waferRobotModule.PlaceWaferTimeoutAlarm.Set($"timeout over {timeout} seconds");
  564. throw (new RoutineFaildException());
  565. }
  566. else
  567. throw (new RoutineBreakException());
  568. }
  569. }
  570. }
  571. }