WaferRobotPlace.cs 36 KB

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