WaferRobotPlace.cs 34 KB

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