WaferRobotPlace.cs 30 KB

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