PMPrepareTransferRoutine.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. using System;
  2. using Aitex.Core.Common;
  3. using Aitex.Core.RT.Routine;
  4. using Aitex.Core.RT.SCCore;
  5. using MECF.Framework.Common.Equipment;
  6. using MECF.Framework.Common.Schedulers;
  7. using MECF.Framework.Common.SubstrateTrackings;
  8. using JetVirgoPM.Devices;
  9. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.PMs;
  10. using Aitex.Sorter.Common;
  11. namespace JetVirgoPM.PMs.Routines
  12. {
  13. class PMPrepareTransferRoutine : PMRoutineBase, IStepRoutine
  14. {
  15. enum RoutineStep
  16. {
  17. LiftUpDown,
  18. Vent,
  19. VentDelay,
  20. SetGuidePin,
  21. CheckCoolantTemp1,
  22. CheckCoolantTemp2,
  23. CheckTemp1,
  24. CheckTemp2,
  25. CheckLETemp,
  26. SetSlitDoor,
  27. SlitDoorDelay,
  28. PrepareTransferPlace,
  29. PrepareTransferPick,
  30. kEnd
  31. }
  32. private EnumTransferType _TransferType;
  33. private EnumDualPM _pos;
  34. private int _timeout;
  35. private readonly VentRoutine _ventRoutine;
  36. private WaferSize _ws;
  37. private double _temp;
  38. private double _tolerance;
  39. private double _Chiller1OffsetTemp = 0.0f;
  40. private double _Chiller2OffsetTemp = 0.0f;
  41. private double _TargetTemp1 = 0.0f;
  42. private double _TargetTemp2 = 0.0f;
  43. private bool _enableCheckTemp = false;
  44. private int _checkChamberTempTimeout = 60;
  45. private bool _isATMMode;
  46. public bool _Chamber1Disabled;
  47. public bool _Chamber2Disabled;
  48. private bool _enableChiller1;
  49. private bool _enableChiller2;
  50. private bool _enableLE1;
  51. private bool _enableLE2;
  52. private bool _isVented = false;
  53. public bool GuidePinInstalled;
  54. public PMPrepareTransferRoutine(JetDualPM chamber, VentRoutine _vRoutine) : base(chamber)
  55. {
  56. Name = "PrepareTransfer";
  57. _ventRoutine = _vRoutine;
  58. }
  59. public RState Init(EnumTransferType type, EnumDualPM pos, WaferSize size, double temp1, double temp2, bool EnableCheckTemp)
  60. {
  61. if (type == EnumTransferType.Place)
  62. {
  63. Name = $"Prepare Place {_ws}";
  64. }
  65. else if (type == EnumTransferType.Pick)
  66. {
  67. size = WaferManager.Instance.GetWafer(_chamber.Module, pos == EnumDualPM.Left ? 0 : 1).Size;
  68. Name = $"Prepare Pick {_ws}";
  69. }
  70. _TargetTemp1 = temp1;
  71. _TargetTemp2 = temp2;
  72. _enableCheckTemp = EnableCheckTemp;
  73. _pos = pos;
  74. _TransferType = type;
  75. _ws = size;
  76. return RState.End;
  77. }
  78. public RState Init(EnumTransferType type, int[] slot, double temp1, double temp2, bool EnableCheckTemp, int handSlot = -1, EnumDualPM autoPos= EnumDualPM.None)
  79. {
  80. EnumDualPM pos = (slot.Length > 1) ? EnumDualPM.Both : (slot[0] == 0) ? EnumDualPM.Left : EnumDualPM.Right;
  81. if(autoPos != EnumDualPM.None)
  82. {
  83. pos = autoPos;
  84. }
  85. if (SC.IsDoubleFork) pos = EnumDualPM.Both;
  86. WaferSize ws = WaferSize.WS0;
  87. if(handSlot != -1 && type == EnumTransferType.Place)
  88. {
  89. Hand hand = (Hand)handSlot;
  90. if (hand == Hand.Both)
  91. {
  92. ws = WaferManager.Instance.GetWafer(ModuleName.TMRobot, (int)Hand.Blade1).Size;
  93. }
  94. else
  95. {
  96. ws = WaferManager.Instance.GetWafer(ModuleName.TMRobot, (int)hand).Size;
  97. }
  98. }
  99. else if (type == EnumTransferType.Pick)
  100. {
  101. if(pos == EnumDualPM.Left || pos == EnumDualPM.Both)
  102. {
  103. ws = WaferManager.Instance.GetWafer(_chamber.Module, (int)EnumDualPM.Left - 1).Size;
  104. }
  105. else if(pos == EnumDualPM.Right)
  106. {
  107. ws = WaferManager.Instance.GetWafer(_chamber.Module, (int)EnumDualPM.Right - 1).Size;
  108. }
  109. }
  110. _TargetTemp1 = temp1;
  111. _TargetTemp2 = temp2;
  112. _enableCheckTemp = EnableCheckTemp;
  113. return Init(type, pos, ws, temp1, temp2, EnableCheckTemp);
  114. }
  115. public RState Start(params object[] objs)
  116. {
  117. Reset();
  118. _timeout = SC.GetValue<int>($"{Module}.PrepareTransferTimeout");
  119. _Chamber1Disabled = SC.GetValue<bool>($"System.SetUp.{Module}Chamber1Disabled.IsInstalled");
  120. _Chamber2Disabled = SC.GetValue<bool>($"System.SetUp.{Module}Chamber2Disabled.IsInstalled");
  121. _enableChiller1 = SC.GetValue<bool>($"{Module}.Chiller1.EnableChiller");
  122. _enableChiller2 = SC.GetValue<bool>($"{Module}.Chiller2.EnableChiller");
  123. GuidePinInstalled = SC.GetValue<bool>($"{Module}.GuidePin.IsInstalled");
  124. if(GuidePinInstalled && _ws == WaferSize.WS0)
  125. {
  126. Stop($"GuidePin 开启后,检查到Wafer size is {_ws.ToString()}");
  127. return RState.Failed;
  128. }
  129. _checkChamberTempTimeout = SC.GetValue<int>($"{Module}.CheckChamberTempTimeout");
  130. _temp = SC.GetValue<double>($"{Module}.ChamberBaseTemperatureThreshold");
  131. _tolerance = SC.GetValue<double>($"System.MaxTemperatureToleranceToTarget");
  132. _Chiller1OffsetTemp = SC.GetValue<double>($"{Module}.Chiller1.ChillerTemperatureOffset");
  133. _Chiller2OffsetTemp = SC.GetValue<double>($"{Module}.Chiller2.ChillerTemperatureOffset");
  134. if (CheckAlreadyReadyForTransfer())
  135. {
  136. return RState.End;
  137. }
  138. _isATMMode = SC.IsATMMode;
  139. if (_isATMMode && !_chamber.CheckAtm())
  140. {
  141. Stop($"Running in ATMmode,{_chamber.DeviceID} not in atmos now!");
  142. return RState.Failed;
  143. }
  144. Notify($"开始, 准备 {(_TransferType == EnumTransferType.Place ? "放" : _TransferType == EnumTransferType.Pick ? "取" : "动作未知")}{_ws} 寸片, ");
  145. _enableLE1 = true;
  146. _enableLE2 = true;
  147. return Runner.Start(_chamber.Module.ToString(), Name);
  148. }
  149. public RState Monitor()
  150. {
  151. Runner.Run(RoutineStep.Vent, Vent, CheckVent)
  152. .Run(RoutineStep.CheckCoolantTemp1, SetCoolant1Temp, CheckCoolant1Temp, _checkChamberTempTimeout * 1000)
  153. .Run(RoutineStep.CheckCoolantTemp2, SetCoolant2Temp, CheckCoolant2Temp, _checkChamberTempTimeout * 1000)
  154. .Run(RoutineStep.CheckLETemp, SetLETemp, CheckLETemp, _checkChamberTempTimeout * 1000)
  155. .Run(RoutineStep.CheckTemp1, SetLETemp1, CheckLETemp1, _checkChamberTempTimeout * 1000)
  156. .Run(RoutineStep.CheckTemp2, SetLETemp2, CheckLETemp2, _checkChamberTempTimeout * 1000)
  157. .Run(RoutineStep.PrepareTransferPlace, PMPreparePlace, CheckPMPreparePlace, _timeout * 1000)
  158. .Run(RoutineStep.PrepareTransferPick, PMPreparePick, CheckPMPreparePick, _timeout * 1000)
  159. .End(RoutineStep.kEnd, EndFunc, _delay_0s);
  160. return Runner.Status;
  161. }
  162. public override void Abort()
  163. {
  164. }
  165. bool Vent()
  166. {
  167. _isVented = SC.IsATMMode || _chamber.CheckSlitDoor1Open() || _chamber.CheckSlitDoor2Open();
  168. if (!_isVented)
  169. {
  170. var status = _ventRoutine.Start();
  171. _isVented = status == RState.End;
  172. if (!_isVented) return status == RState.Running;
  173. }
  174. return _isVented;
  175. }
  176. bool CheckVent()
  177. {
  178. if (_isVented) return true;
  179. var status = _ventRoutine.Monitor();
  180. if (status == RState.End)
  181. return true;
  182. else if (status == RState.Failed || status == RState.Timeout)
  183. {
  184. Runner.Stop($"Vent failed.");
  185. return true;
  186. }
  187. return false;
  188. }
  189. bool SetCoolant1Temp()
  190. {
  191. if (_TransferType == EnumTransferType.Place && !SC.IsATMMode && _enableCheckTemp && !_Chamber1Disabled && _TargetTemp1 > 0 && _enableChiller1)
  192. {
  193. _enableLE1 = false;
  194. return SetCoolant1Temp(_TargetTemp1, _Chiller1OffsetTemp, _tolerance);
  195. }
  196. return true;
  197. }
  198. bool CheckCoolant1Temp()
  199. {
  200. if (_TransferType == EnumTransferType.Place && !SC.IsATMMode && _enableCheckTemp && !_Chamber1Disabled && _TargetTemp1 > 0 && _enableChiller1)
  201. {
  202. return CheckCoolant1Temp(_TargetTemp1, _Chiller1OffsetTemp, _tolerance);
  203. }
  204. return true;
  205. }
  206. bool SetCoolant2Temp()
  207. {
  208. if(_TransferType == EnumTransferType.Place && !SC.IsATMMode && _enableCheckTemp && !_Chamber2Disabled && _TargetTemp2 > 0 && _enableChiller2)
  209. {
  210. _enableLE2 = false;
  211. return SetCoolant2Temp(_TargetTemp2, _Chiller2OffsetTemp, _tolerance);
  212. }
  213. return true;
  214. }
  215. bool CheckCoolant2Temp()
  216. {
  217. if (_TransferType == EnumTransferType.Place && !SC.IsATMMode && _enableCheckTemp && !_Chamber2Disabled && _TargetTemp2 > 0 && _enableChiller2)
  218. {
  219. return CheckCoolant2Temp(_TargetTemp2, _Chiller2OffsetTemp, _tolerance);
  220. }
  221. return true;
  222. }
  223. bool SetLETemp()
  224. {
  225. if(_TransferType == EnumTransferType.Place && !SC.IsATMMode && (_enableLE1 && !_Chamber1Disabled && _TargetTemp1 > 0) && (_enableLE2 && !_Chamber2Disabled && _TargetTemp2 > 0))
  226. {
  227. return SetLETemp(_TargetTemp1, _TargetTemp2, _tolerance, _enableLE1, _enableLE2);
  228. }
  229. return true;
  230. }
  231. bool CheckLETemp()
  232. {
  233. if (_TransferType == EnumTransferType.Place && !SC.IsATMMode && (_enableLE1 && !_Chamber1Disabled && _TargetTemp1 > 0) && (_enableLE2 && !_Chamber2Disabled && _TargetTemp2 > 0))
  234. {
  235. return CheckLETemp(_TargetTemp1, _TargetTemp2, _tolerance, _enableLE1, _enableLE2);
  236. }
  237. return true;
  238. }
  239. bool SetLETemp1()
  240. {
  241. if (_TransferType == EnumTransferType.Place && !SC.IsATMMode && _enableLE1 && !_Chamber1Disabled && _TargetTemp1 > 0)
  242. {
  243. return SetLETemp(_TargetTemp1, 0, _tolerance, _enableLE1, false);
  244. }
  245. return true;
  246. }
  247. bool CheckLETemp1()
  248. {
  249. if (_TransferType == EnumTransferType.Place && !SC.IsATMMode && _enableLE1 && !_Chamber1Disabled && _TargetTemp1 > 0)
  250. {
  251. return CheckLETemp(_TargetTemp1, 0, _tolerance, _enableLE1, false);
  252. }
  253. return true;
  254. }
  255. bool SetLETemp2()
  256. {
  257. if (_TransferType == EnumTransferType.Place && !SC.IsATMMode && _enableLE2 && !_Chamber2Disabled && _TargetTemp2 > 0)
  258. {
  259. return SetLETemp(0, _TargetTemp2, _tolerance, false, _enableLE2);
  260. }
  261. return true;
  262. }
  263. bool CheckLETemp2()
  264. {
  265. if (_TransferType == EnumTransferType.Place && !SC.IsATMMode && _enableLE2 && !_Chamber2Disabled && _TargetTemp2 > 0)
  266. {
  267. return CheckLETemp(0, _TargetTemp2, _tolerance, false, _enableLE2);
  268. }
  269. return true;
  270. }
  271. bool CheckAlreadyReadyForTransfer()
  272. {
  273. if (_pos == EnumDualPM.Left)
  274. {
  275. if (_TransferType == EnumTransferType.Pick)
  276. {
  277. if (!_chamber.CheckSlitDoor1Open())
  278. {
  279. return false;
  280. }
  281. if (!_chamber.CheckLift1Up())
  282. {
  283. return false;
  284. }
  285. return _chamber.CheckSlitDoor1Open() && _chamber.CheckLift1Up();
  286. }
  287. else if (_TransferType == EnumTransferType.Place)
  288. {
  289. if (!_chamber.CheckSlitDoor1Open())
  290. {
  291. return false;
  292. }
  293. if (!_chamber.CheckLift1Down())
  294. {
  295. return false;
  296. }
  297. return _chamber.CheckSlitDoor1Open() && _chamber.CheckLift1Down();
  298. }
  299. }
  300. if (_pos == EnumDualPM.Right)
  301. {
  302. if (_TransferType == EnumTransferType.Pick)
  303. {
  304. if (!_chamber.CheckSlitDoor2Open())
  305. {
  306. return false;
  307. }
  308. if (!_chamber.CheckLift2Up())
  309. {
  310. return false;
  311. }
  312. return _chamber.CheckSlitDoor2Open() && _chamber.CheckLift2Up();
  313. }
  314. else if (_TransferType == EnumTransferType.Place)
  315. {
  316. if (!_chamber.CheckSlitDoor2Open())
  317. {
  318. return false;
  319. }
  320. if (!_chamber.CheckLift2Down())
  321. {
  322. return false;
  323. }
  324. return _chamber.CheckSlitDoor2Open() && _chamber.CheckLift2Down();
  325. }
  326. }
  327. if (_pos == EnumDualPM.Both)
  328. {
  329. bool checkSlitDoorBothResult = _chamber.CheckSlitDoor1Open() && _chamber.CheckSlitDoor2Open();
  330. if (!checkSlitDoorBothResult)
  331. {
  332. return checkSlitDoorBothResult;
  333. }
  334. if (_TransferType == EnumTransferType.Pick)
  335. {
  336. return _chamber.CheckLift1Up() && _chamber.CheckLift2Up();
  337. }
  338. else if (_TransferType == EnumTransferType.Place)
  339. {
  340. return _chamber.CheckLift1Down() && _chamber.CheckLift2Down();
  341. }
  342. }
  343. return false;
  344. }
  345. bool PMPreparePlace()
  346. {
  347. if(_TransferType == EnumTransferType.Place)
  348. {
  349. return SetLiftPinAndSlitDoorAndGuidePin(false, _ws, true, GuidePinInstalled);
  350. }
  351. return true;
  352. }
  353. bool CheckPMPreparePlace()
  354. {
  355. if (_TransferType == EnumTransferType.Place)
  356. {
  357. return CheckLiftPinAndSlitDoorAndGuidePin(false, _ws, true, GuidePinInstalled);
  358. }
  359. return true;
  360. }
  361. bool SetLiftPinAndSlitDoorAndGuidePin(bool isUp, WaferSize ws, bool isOpen, bool _guidePinInstalled)
  362. {
  363. Notify($"设置 {_chamber.Name}{_pos} liftPin {(isUp ? "升" : "降")}, 设置 {ws} Pin 升, 设置 {_chamber.Name}{_pos} SlitDoor {(isOpen ? "开" : "关")}");
  364. if (_pos == EnumDualPM.Left || _pos == EnumDualPM.Both)
  365. {
  366. if (!_chamber.SetLiftPin1(isUp ? MovementPosition.Up : MovementPosition.Down, out string reason))
  367. {
  368. Stop(reason);
  369. return false;
  370. }
  371. if (GuidePinInstalled)
  372. {
  373. _chamber.PrepareGuidePinForPlaceLeft(ws);
  374. }
  375. _chamber.SetSlitDoor1(isOpen, out string reason1);
  376. }
  377. if (_pos == EnumDualPM.Right || _pos == EnumDualPM.Both)
  378. {
  379. if (!_chamber.SetLiftPin2(isUp ? MovementPosition.Up : MovementPosition.Down, out string reason))
  380. {
  381. Stop(reason);
  382. return false;
  383. }
  384. if (GuidePinInstalled)
  385. {
  386. _chamber.PrepareGuidePinForPlaceRight(ws);
  387. }
  388. _chamber.SetSlitDoor2(isOpen, out string reason2);
  389. }
  390. return true;
  391. }
  392. bool CheckLiftPinAndSlitDoorAndGuidePin(bool isUp, WaferSize ws, bool isOpen, bool _guidePinInstalled)
  393. {
  394. bool Check1()
  395. {
  396. bool res1 = isUp ? _chamber.CheckLift1Up() : _chamber.CheckLift1Down();
  397. bool res2 = isOpen ? _chamber.CheckSlitDoor1Open() : _chamber.CheckSlitDoor1Close();
  398. bool res3 = _guidePinInstalled ? _chamber.CheckGuidePinIsReadyForTransferLeft(ws) : true;
  399. return res1 && res2 && res3;
  400. }
  401. bool Check2()
  402. {
  403. bool res1 = isUp ? _chamber.CheckLift2Up() : _chamber.CheckLift2Down();
  404. bool res2 = isOpen ? _chamber.CheckSlitDoor2Open() : _chamber.CheckSlitDoor2Close();
  405. bool res3 = _guidePinInstalled ? _chamber.CheckGuidePinIsReadyForTransferRight(ws) : true;
  406. return res1 && res2 && res3;
  407. }
  408. return ((_pos != EnumDualPM.Left && _pos != EnumDualPM.Both) || Check1()) && ((_pos != EnumDualPM.Right && _pos != EnumDualPM.Both) || Check2());
  409. }
  410. bool PMPreparePick()
  411. {
  412. if (_TransferType == EnumTransferType.Pick)
  413. {
  414. return SetLiftPinAndSlitDoorAndGuidePin(true, _ws, true, false);
  415. }
  416. return true;
  417. }
  418. bool CheckPMPreparePick()
  419. {
  420. if (_TransferType == EnumTransferType.Pick)
  421. {
  422. return CheckLiftPinAndSlitDoorAndGuidePin(true, _ws, true, false);
  423. }
  424. return true;
  425. }
  426. }
  427. }