WaferRobotPlace.cs 34 KB

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