WaferRobotPlace.cs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  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. if (fims != null&&fims.IsWaferOnRobot)
  254. {
  255. _waferRobotModule.PlaceWaferFailAlarm.Set($"The wafer on {Module} has shifted");
  256. }
  257. }
  258. }
  259. Notify($"Start");
  260. return Result.RUN;
  261. }
  262. public void Abort()
  263. {
  264. _waferRobotModule.ResetRobotActionCommand();
  265. _waferRobotModule.Stop();
  266. (Singleton<EquipmentManager>.Instance.Modules[_destination] as ITransferTarget)?.NoteTransferStop(ModuleHelper.Converter(_waferRobotModule.Module), _blade, _destinationSlot, EnumTransferType.Place);
  267. }
  268. public override Result Monitor()
  269. {
  270. try
  271. {
  272. PauseRountine(_waferRobotModule.WaferRobotDevice.IsPause);
  273. if (_waferRobotModule.WaferRobotDevice.IsPause)
  274. return Result.RUN;
  275. CheckBeforePlace((int)RoutineStep.CheckBeforePlace, _destination, _destinationSlot, _blade);
  276. if (_waferRobotModule.TrigActionCommand != null)
  277. SetRobotActionCommand((int)RoutineStep.SetRobotActionCommand, _destination, _timeout);
  278. Place((int)RoutineStep.Place, _destination, _destinationSlot, _blade, _timeout);
  279. //RobotRequestWaferPresent((int)RoutineStep.RobotRequestWaferPresent, _blade, _timeout);
  280. CheckWaferInfoByRobotSensor((int)RoutineStep.CheckWaferInfoByRobotSensor, _blade, false);
  281. }
  282. catch (RoutineBreakException)
  283. {
  284. return Result.RUN;
  285. }
  286. catch (RoutineFaildException ex)
  287. {
  288. _waferRobotModule.ResetRobotActionCommand();
  289. (Singleton<EquipmentManager>.Instance.Modules[_destination] as ITransferTarget)?.NoteTransferStop(ModuleHelper.Converter(_waferRobotModule.Module), _blade, _destinationSlot, EnumTransferType.Place);
  290. return Result.FAIL;
  291. }
  292. _waferRobotModule.ResetRobotActionCommand();
  293. (Singleton<EquipmentManager>.Instance.Modules[_destination] as ITransferTarget)?.NoteTransferStop(ModuleHelper.Converter(_waferRobotModule.Module), _blade, _destinationSlot, EnumTransferType.Place);
  294. Notify("Finished");
  295. return Result.DONE;
  296. }
  297. private void PlaceStartInfo(ModuleName moduleName)
  298. {
  299. if (ModuleHelper.IsFIMS(moduleName))
  300. {
  301. var fimsFoupInfo = CarrierManager.Instance.GetCarrier(_destination);
  302. fimsFoupInfo.UICarrierStatusEnum = CarrierStatus.WDCHRG;
  303. Singleton<EquipmentManager>.Instance.SetVisibility(fimsFoupInfo, true);
  304. Singleton<EquipmentManager>.Instance.SetUIWaferCount(fimsFoupInfo, moduleName, out var wafers);
  305. }
  306. if (ModuleHelper.IsPm(moduleName))
  307. {
  308. var fims1 = Singleton<EquipmentManager>.Instance.Modules[ModuleName.FIMS1] as FIMSModule;
  309. var fims2 = Singleton<EquipmentManager>.Instance.Modules[ModuleName.FIMS2] as FIMSModule;
  310. if (fims1 != null && fims1.CheckReadyForTransfer(ModuleName.WaferRobot, _blade, 0, EnumTransferType.Pick, out string reason))
  311. {
  312. var fims1FoupInfo = CarrierManager.Instance.GetCarrier(ModuleName.FIMS1);
  313. fims1FoupInfo.UICarrierStatusEnum = CarrierStatus.WCHARG;
  314. Singleton<EquipmentManager>.Instance.SetUIWaferCount(fims1FoupInfo, ModuleName.FIMS1, out var wafers);
  315. if (wafers.All(a => a.IsEmpty))
  316. {
  317. fims1FoupInfo.UICarrierStatusEnum = CarrierStatus.ONBOAT;
  318. }
  319. Singleton<EquipmentManager>.Instance.SetVisibility(fims1FoupInfo, true);
  320. }
  321. if (fims2 != null && fims2.CheckReadyForTransfer(ModuleName.WaferRobot, _blade, 0, EnumTransferType.Pick, out reason))
  322. {
  323. var fims2FoupInfo = CarrierManager.Instance.GetCarrier(ModuleName.FIMS2);
  324. fims2FoupInfo.UICarrierStatusEnum = CarrierStatus.WCHARG;
  325. Singleton<EquipmentManager>.Instance.SetUIWaferCount(fims2FoupInfo, ModuleName.FIMS2, out var wafers);
  326. if (wafers.All(a => a.IsEmpty))
  327. {
  328. fims2FoupInfo.UICarrierStatusEnum = CarrierStatus.ONBOAT;
  329. }
  330. Singleton<EquipmentManager>.Instance.SetVisibility(fims2FoupInfo, true);
  331. }
  332. }
  333. }
  334. private void CheckBeforePlace(int id, ModuleName target, int slot, Hand blade)
  335. {
  336. Tuple<bool, Result> ret = Execute(id, () =>
  337. {
  338. Notify("Check place condition");
  339. string reason = string.Empty;
  340. if (_waferRobotModule.WaferRobotDevice.IsError)
  341. {
  342. //_waferRobotModule.PlaceWaferFailAlarm.Description = $"place to {target} failed for robot error, error code={_waferRobotModule.WaferRobotDevice.ErrorCode}";
  343. _waferRobotModule.PlaceWaferFailAlarm.Set($"place to {target} failed for robot error, error code={_waferRobotModule.WaferRobotDevice.ErrorCode}");
  344. return false;
  345. }
  346. if (!_waferRobotModule.WaferRobotDevice.IsReady(out reason))
  347. {
  348. //_waferRobotModule.PlaceWaferFailAlarm.Description = $"place to {target} failed for robot isn't Ready";
  349. _waferRobotModule.PlaceWaferFailAlarm.Set($"place to {target} failed for robot isn't Ready {reason}");
  350. return false;
  351. }
  352. if (ModuleHelper.IsPm(_destination))
  353. {
  354. var pmModule = Singleton<EquipmentManager>.Instance.Modules[_destination] as PMModule;
  355. if (pmModule != null && !pmModule.CheckReadyForTransfer(ModuleHelper.Converter(_waferRobotModule.Module), _blade, slot, EnumTransferType.Place, out reason))
  356. {
  357. //_waferRobotModule.PlaceWaferFailAlarm.Description = reason;
  358. _waferRobotModule.PlaceWaferFailAlarm.Set(reason);
  359. return false;
  360. }
  361. PlaceStartInfo(_destination);
  362. }
  363. if (target == ModuleName.FIMS1 || target == ModuleName.FIMS2)
  364. {
  365. var fims = Singleton<EquipmentManager>.Instance.Modules[_destination] as FIMSModule;
  366. if (fims != null && !fims.CheckReadyForTransfer(ModuleHelper.Converter(Module), _blade, slot, EnumTransferType.Place, out reason))
  367. {
  368. //_waferRobotModule.PlaceWaferFailAlarm.Description = reason;
  369. _waferRobotModule.PlaceWaferFailAlarm.Set(reason);
  370. return false;
  371. }
  372. PlaceStartInfo(target);
  373. }
  374. if (blade == Hand.Blade1)
  375. {
  376. if (!WaferManager.Instance.CheckNoWafer(target, slot))
  377. {
  378. //_waferRobotModule.PlaceWaferFailAlarm.Description = $"place to {target} failed for {target} has wafer";
  379. _waferRobotModule.PlaceWaferFailAlarm.Set($"place to {target} failed for {target} has wafer");
  380. return false;
  381. }
  382. if (!WaferManager.Instance.CheckHasWafer(Module, 2))
  383. {
  384. //_waferRobotModule.PlaceWaferFailAlarm.Description = $"place to {target} failed for blade no wafer";
  385. _waferRobotModule.PlaceWaferFailAlarm.Set($"place to {target} failed for blade no wafer");
  386. return false;
  387. }
  388. }
  389. else if (blade == Hand.Blade2)
  390. {
  391. if (!WaferManager.Instance.CheckNoWafer(target, slot))
  392. {
  393. //_waferRobotModule.PlaceWaferFailAlarm.Description = $"place to {target} failed for {target} has wafer";
  394. _waferRobotModule.PlaceWaferFailAlarm.Set($"place to {target} failed for {target} has wafer");
  395. return false;
  396. }
  397. if (!WaferManager.Instance.CheckHasWafer(Module, 1))
  398. {
  399. //_waferRobotModule.PlaceWaferFailAlarm.Description = $"place to {target} failed for blade no wafer";
  400. _waferRobotModule.PlaceWaferFailAlarm.Set($"place to {target} failed for blade no wafer");
  401. return false;
  402. }
  403. }
  404. else
  405. {
  406. for (int i = 0; i < 5; i++)
  407. {
  408. if (!WaferManager.Instance.CheckNoWafer(target, slot + i))
  409. {
  410. //_waferRobotModule.PlaceWaferFailAlarm.Description = $"place to {target} failed for {target} has wafer";
  411. _waferRobotModule.PlaceWaferFailAlarm.Set($"place to {target} failed for {target} has wafer");
  412. return false;
  413. }
  414. if (!WaferManager.Instance.CheckHasWafer(Module, i))
  415. {
  416. //_waferRobotModule.PlaceWaferFailAlarm.Description = $"place to {target} failed for blade no wafer";
  417. _waferRobotModule.PlaceWaferFailAlarm.Set($"place to {target} failed for blade no wafer");
  418. return false;
  419. }
  420. }
  421. }
  422. return true;
  423. });
  424. if (ret.Item1)
  425. {
  426. if (ret.Item2 == Result.FAIL)
  427. {
  428. throw (new RoutineFaildException());
  429. }
  430. }
  431. _needStartCheck = false;
  432. }
  433. private void Place(int id, ModuleName target, int slot, Hand hand, int timeout)
  434. {
  435. _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
  436. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  437. {
  438. Notify("send place command to device");
  439. string reason;
  440. (Singleton<EquipmentManager>.Instance.Modules[target] as ITransferTarget)?.NoteTransferStart(ModuleHelper.Converter(_waferRobotModule.Module), hand, slot, EnumTransferType.Place);
  441. if (!_waferRobotModule.RobotPlace(target, slot, hand, out reason))
  442. {
  443. //_waferRobotModule.PlaceWaferFailAlarm.Description = reason;
  444. _waferRobotModule.PlaceWaferFailAlarm.Set(reason);
  445. return false;
  446. }
  447. return true;
  448. }, () =>
  449. {
  450. if (_waferRobotModule.WaferRobotDevice.IsReady() && !_waferRobotModule.WaferRobotDevice.IsError)
  451. {
  452. return true;
  453. }
  454. return false;
  455. }, timeout * 1000);
  456. if (ret.Item1)
  457. {
  458. if (ret.Item2 == Result.FAIL)
  459. {
  460. //_waferRobotModule.PlaceWaferFailAlarm.Description = $"{_waferRobotModule.WaferRobotDevice.ErrorCode}";
  461. _waferRobotModule.PlaceWaferFailAlarm.Set($"place to {target} failed for robot error, error code={_waferRobotModule.WaferRobotDevice.ErrorCode}");
  462. throw (new RoutineFaildException());
  463. }
  464. else if (ret.Item2 == Result.TIMEOUT) //timeout
  465. {
  466. //_waferRobotModule.PlaceWaferTimeoutAlarm.Description = $"timeout over {timeout} seconds";
  467. _waferRobotModule.PlaceWaferTimeoutAlarm.Set($"timeout over {timeout} seconds");
  468. throw (new RoutineFaildException());
  469. }
  470. else
  471. throw (new RoutineBreakException());
  472. }
  473. }
  474. private void RobotRequestWaferPresent(int id, Hand hand, int timeout)
  475. {
  476. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  477. {
  478. Notify("request wafer present");
  479. if (!_waferRobotModule.RequestWaferPresent(hand, out string reason))
  480. {
  481. //_waferRobotModule.RequestWaferPresentFailAlarm.Description = reason;
  482. _waferRobotModule.RequestWaferPresentFailAlarm.Set(reason);
  483. return false;
  484. }
  485. return true;
  486. }, () =>
  487. {
  488. if (_waferRobotModule.WaferRobotDevice.IsReady() && !_waferRobotModule.WaferRobotDevice.IsError)
  489. {
  490. return true;
  491. }
  492. return false;
  493. }, timeout * 1000);
  494. if (ret.Item1)
  495. {
  496. if (ret.Item2 == Result.FAIL)
  497. {
  498. throw (new RoutineFaildException());
  499. }
  500. else if (ret.Item2 == Result.TIMEOUT) //timeout
  501. {
  502. //_waferRobotModule.RequestWaferPresentTimeoutAlarm.Description = $"timeout over {timeout} seconds";
  503. _waferRobotModule.RequestWaferPresentTimeoutAlarm.Set($"timeout over {timeout} seconds");
  504. throw (new RoutineFaildException());
  505. }
  506. else
  507. throw (new RoutineBreakException());
  508. }
  509. }
  510. private void CheckWaferInfoByRobotSensor(int id, Hand hand, bool isAfterPick)
  511. {
  512. Tuple<bool, Result> ret = Execute(id, () =>
  513. {
  514. Notify($"check wafer info by robot RQ present");
  515. if (SC.GetValue<bool>("System.IsSimulatorMode"))
  516. return true;
  517. if (hand == Hand.Blade1 || hand == Hand.Both)
  518. {
  519. if (!isAfterPick && _waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade3)
  520. {
  521. _waferRobotModule.RobotSensorFoundWaferOnBladeAfterPlaceAlarm.Set("Wafer Robot sensor found wafer on blade 3");
  522. return false;
  523. }
  524. if (isAfterPick && !_waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade3)
  525. {
  526. _waferRobotModule.RobotSensorNotFoundWaferOnBladeAfterPickAlarm.Set("Wafer Robot sensor no wafer on blade 3");
  527. return false;
  528. }
  529. }
  530. if (hand == Hand.Blade2 || hand == Hand.Both)
  531. {
  532. if (!isAfterPick && _waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade1)
  533. {
  534. _waferRobotModule.RobotSensorFoundWaferOnBladeAfterPlaceAlarm.Set("Wafer Robot sensor found wafer on blade 1");
  535. return false;
  536. }
  537. if (isAfterPick && !_waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade1)
  538. {
  539. _waferRobotModule.RobotSensorNotFoundWaferOnBladeAfterPickAlarm.Set("Wafer Robot sensor no wafer on blade 1");
  540. return false;
  541. }
  542. if (!isAfterPick && _waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade2)
  543. {
  544. _waferRobotModule.RobotSensorFoundWaferOnBladeAfterPlaceAlarm.Set("Wafer Robot sensor found wafer on blade 2");
  545. return false;
  546. }
  547. if (isAfterPick && !_waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade2)
  548. {
  549. _waferRobotModule.RobotSensorNotFoundWaferOnBladeAfterPickAlarm.Set("Wafer Robot sensor no wafer on blade 2");
  550. return false;
  551. }
  552. if (!isAfterPick && _waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade4)
  553. {
  554. _waferRobotModule.RobotSensorFoundWaferOnBladeAfterPlaceAlarm.Set("Wafer Robot sensor found wafer on blade 4");
  555. return false;
  556. }
  557. if (isAfterPick && !_waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade4)
  558. {
  559. _waferRobotModule.RobotSensorNotFoundWaferOnBladeAfterPickAlarm.Set("Wafer Robot sensor no wafer on blade 4");
  560. return false;
  561. }
  562. if (!isAfterPick && _waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade5)
  563. {
  564. _waferRobotModule.RobotSensorFoundWaferOnBladeAfterPlaceAlarm.Set("Wafer Robot sensor found wafer on blade 5");
  565. return false;
  566. }
  567. if (isAfterPick && !_waferRobotModule.WaferRobotDevice.IsWaferPresenceOnBlade5)
  568. {
  569. _waferRobotModule.RobotSensorNotFoundWaferOnBladeAfterPickAlarm.Set("Wafer Robot sensor no wafer on blade 5");
  570. return false;
  571. }
  572. }
  573. return true;
  574. });
  575. if (ret.Item1)
  576. {
  577. if (ret.Item2 == Result.FAIL)
  578. {
  579. _waferRobotModule.CheckWaferInformationFailAlarm.Set();
  580. throw (new RoutineFaildException());
  581. }
  582. else
  583. throw (new RoutineBreakException());
  584. }
  585. }
  586. private void SetRobotActionCommand(int id, ModuleName source, int timeout)
  587. {
  588. _routineStep = (RoutineStep)Enum.Parse(typeof(RoutineStep), id.ToString());
  589. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  590. {
  591. Notify($"Set robot action command target position {source}");
  592. _waferRobotModule.SetRobotActionCommand(source, EnumTransferType.Place);
  593. return true;
  594. }, () =>
  595. {
  596. return _waferRobotModule.CheckRobotActionCommand(source, EnumTransferType.Place);
  597. }, timeout * 1000);
  598. if (ret.Item1)
  599. {
  600. if (ret.Item2 == Result.FAIL)
  601. {
  602. _waferRobotModule.PlaceWaferFailAlarm.Set($"place to {source} failed for robot action command interlock");
  603. throw (new RoutineFaildException());
  604. }
  605. else if (ret.Item2 == Result.TIMEOUT) //timeout
  606. {
  607. _waferRobotModule.PlaceWaferTimeoutAlarm.Set($"timeout over {timeout} seconds");
  608. throw (new RoutineFaildException());
  609. }
  610. else
  611. throw (new RoutineBreakException());
  612. }
  613. }
  614. }
  615. }