PMRoutineBase.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. using System;
  2. using Aitex.Core.Equipment.SusceptorDefine;
  3. using Aitex.Core.RT.Event;
  4. using Aitex.Core.RT.Routine;
  5. using Aitex.Core.RT.SCCore;
  6. using MECF.Framework.Common.DBCore;
  7. using VirgoCommon;
  8. //using Virgo.Common;
  9. using VirgoRT.Devices;
  10. namespace VirgoRT.Modules.PMs
  11. {
  12. public enum MonitorStepState
  13. {
  14. Continue,
  15. Failed,
  16. Break,
  17. }
  18. class PMRoutineBase : ModuleRoutine
  19. {
  20. // ----------------------------Fields--------------------------
  21. //
  22. //private SCConfigItem scOpenGasValveTimeout = null;
  23. private int dOpenGasValveTimeout = 1; //1S
  24. //private SCConfigItem scCloseGasValveTimeout = null;
  25. public int dCloseGasValveTimeout = 2; //2s
  26. //private SCConfigItem scOpenCloseSlitValveTimeout = null;
  27. protected int valveOpenCloseTimeout = 2; //2s
  28. protected int _PressureTrip1 = 80;
  29. protected bool bUINotify;
  30. protected readonly JetPM _chamber;
  31. // --------------------------Properties------------------------
  32. //
  33. public string Display { get; set; }
  34. public string WaferID { get; set; }
  35. // Constructor
  36. protected PMRoutineBase(JetPM chamber)
  37. {
  38. this.Module = chamber.Module.ToString();
  39. _chamber = chamber;
  40. bUINotify = true;
  41. dOpenGasValveTimeout = SC.GetValue<int>($"{Module}.OpenGasValveTimeout");
  42. dCloseGasValveTimeout = SC.GetValue<int>($"{Module}.TimeLimitOfCloseGasValve");
  43. valveOpenCloseTimeout = SC.GetValue<int>($"{Module}.OpenCloseSlitValveTimeout");
  44. }
  45. public Result CheckLid()
  46. {
  47. if (!_chamber.IsLidClosed)
  48. {
  49. this.Stop("Chamber 盖子必须关");
  50. return Result.FAIL;
  51. }
  52. return Result.RUN;
  53. }
  54. protected Result CheckSlitDoor()
  55. {
  56. if (!_chamber.IsSlitDoorClosed)
  57. {
  58. Stop("传送门必须关");
  59. return Result.FAIL;
  60. }
  61. return Result.RUN;
  62. }
  63. protected Result CheckDryPump()
  64. {
  65. if (!_chamber.IsPumpRunning)
  66. {
  67. Stop("泵没有启动");
  68. return Result.FAIL;
  69. }
  70. if (_chamber.HasPumpError)
  71. {
  72. Stop("泵状态有错误");
  73. return Result.FAIL;
  74. }
  75. return Result.RUN;
  76. }
  77. public void CheckThrottleValveFullOpen(int id)
  78. {
  79. bool execute()
  80. {
  81. Notify("完全打开蝶阀");
  82. _chamber.FullOpenTV();
  83. return true;
  84. }
  85. bool? Check1()
  86. {
  87. if (_chamber.TVPosition >= 98)
  88. {
  89. Notify("蝶阀已经完全打开");
  90. return true;
  91. }
  92. return false;
  93. }
  94. Tuple<bool, Result> ret = ExecuteAndWait(id, execute, Check1, 20 * 1000);
  95. if (ret.Item1)
  96. {
  97. if (ret.Item2 == Result.FAIL)
  98. {
  99. Stop("无法打开蝶阀");
  100. throw new RoutineFaildException();
  101. }
  102. if (ret.Item2 == Result.TIMEOUT)
  103. {
  104. Stop("启动蝶阀超时");
  105. throw new RoutineFaildException();
  106. }
  107. throw new RoutineBreakException();
  108. }
  109. }
  110. protected Result CheckCDA()
  111. {
  112. if (!_chamber.IsCDA_OK)
  113. {
  114. Stop("CDA 压力信号不正确");
  115. return Result.FAIL;
  116. }
  117. return Result.RUN;
  118. }
  119. protected void CloseAllValve(int id, int time)
  120. {
  121. bool execute()
  122. {
  123. Notify("关闭所有的阀门");
  124. _chamber.CloseValves();
  125. return true;
  126. }
  127. Tuple<bool, Result> ret = ExecuteAndWait(id, execute, () => true, time * 1000);
  128. if (ret.Item1)
  129. {
  130. if (ret.Item2 == Result.FAIL)
  131. {
  132. throw new RoutineFaildException();
  133. }
  134. if (ret.Item2 == Result.TIMEOUT)
  135. {
  136. throw new RoutineFaildException();
  137. }
  138. throw new RoutineBreakException();
  139. }
  140. }
  141. protected void SetValve(int id, ValveType vlv, bool bOpen)
  142. {
  143. bool exec()
  144. {
  145. _chamber.SetValveOnOff(vlv, bOpen);
  146. Notify($"{(bOpen ? "打开" : "关闭")} {vlv} 阀");
  147. return true;
  148. }
  149. bool? Check1()
  150. {
  151. if (vlv == ValveType.FAST_PUMP && bOpen)
  152. return _chamber.IsFastPumpOpened;
  153. else if (vlv == ValveType.FAST_PUMP && !bOpen)
  154. return !_chamber.IsFastPumpOpened;
  155. else if (vlv == ValveType.SOFT_PUMP && bOpen)
  156. return _chamber.IsSoftPumpOpened;
  157. else if (vlv == ValveType.SOFT_PUMP && !bOpen)
  158. return !_chamber.IsSoftPumpOpened;
  159. else
  160. return true;
  161. }
  162. var res = ExecuteAndWait(id, exec, Check1, 500);
  163. if (res.Item1)
  164. {
  165. throw new RoutineBreakException();
  166. }
  167. }
  168. protected void CheckATM2(int id, bool on, int time)
  169. {
  170. bool? check()
  171. {
  172. //if (!_chamber.IsATM)
  173. //{
  174. // Notify("ATM is OFF");
  175. //}
  176. return on ? _chamber.IsATM : !_chamber.IsATM;
  177. }
  178. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  179. {
  180. Notify($"等待 ATM 信号 {(on ? "ON" : "OFF")}");
  181. return true;
  182. }, check, time * 1000);
  183. if (ret.Item1)
  184. {
  185. if (ret.Item2 == Result.FAIL || ret.Item2 == Result.TIMEOUT)
  186. {
  187. Stop($"ATM 信号仍然 {(_chamber.IsATM ? "ON" : "OFF")}");
  188. throw new RoutineFaildException();
  189. }
  190. throw new RoutineBreakException();
  191. }
  192. }
  193. protected void CheckPressure(int id, int targetPressure, bool morethan, int time)
  194. {
  195. bool? Check1()
  196. {
  197. bool res = morethan ? _chamber.ChamberPressure > targetPressure : _chamber.ChamberPressure < targetPressure;
  198. if (res)
  199. {
  200. Notify($"压力已经到达 {targetPressure:N} mTorr");
  201. }
  202. return res;
  203. }
  204. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  205. {
  206. Notify($"等待压力{(morethan ? "上升" : "下降")} 到 {targetPressure:N} mTorr");
  207. return true;
  208. }, Check1, time * 1000);
  209. if (ret.Item1)
  210. {
  211. if (ret.Item2 == Result.FAIL)
  212. {
  213. Stop($"当前压力 [{_chamber.ChamberPressure}], 无法到达 [{targetPressure}]");
  214. throw new RoutineFaildException();
  215. }
  216. if (ret.Item2 == Result.TIMEOUT)
  217. {
  218. Stop($"检测压力超时, 当前压力 [{_chamber.ChamberPressure*0.001:F2}] Torr");
  219. throw new RoutineFaildException();
  220. }
  221. throw new RoutineBreakException();
  222. }
  223. }
  224. protected void CheckForeline(int id, uint target, int time)
  225. {
  226. bool Func()
  227. {
  228. Notify($"Check foreline pressure, 目标 {target} mTorr");
  229. return true;
  230. }
  231. bool? Check1()
  232. {
  233. return _chamber.ForelinePressure < target;
  234. }
  235. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, time * 1000);
  236. if (ret.Item1)
  237. {
  238. if (ret.Item2 == Result.FAIL)
  239. {
  240. throw new RoutineFaildException();
  241. }
  242. if (ret.Item2 == Result.TIMEOUT)
  243. {
  244. Stop($"检查Foreline 压力超时, 当前Foreline 压力值 {_chamber.ForelinePressure}");
  245. throw new RoutineFaildException();
  246. }
  247. throw new RoutineBreakException();
  248. }
  249. }
  250. protected void CheckVAC(int id, double targetPressure, int time)
  251. {
  252. bool? Check1()
  253. {
  254. if (_chamber.ChamberPressure < targetPressure)
  255. {
  256. Notify($"Pump below [{targetPressure}]");
  257. return true;
  258. }
  259. return false;
  260. }
  261. Tuple<bool, Result> ret = ExecuteAndWait(id, () => true, Check1, time * 1000);
  262. if (ret.Item1)
  263. {
  264. if (ret.Item2 == Result.FAIL)
  265. {
  266. throw new RoutineFaildException();
  267. }
  268. if (ret.Item2 == Result.TIMEOUT) //timeout
  269. {
  270. //Warning($"Can not pump to base pressure {target} in {time} seconds");
  271. throw new RoutineFaildException();
  272. }
  273. throw new RoutineBreakException();
  274. }
  275. }
  276. protected void CheckVAC(int id, int time)
  277. {
  278. Tuple<bool, Result> ret = ExecuteAndWait(id, () => true, () => _chamber.IsVAC, time * 1000);
  279. if (ret.Item1)
  280. {
  281. if (ret.Item2 == Result.FAIL)
  282. {
  283. Stop("VAC真空信号 NOT ON");
  284. throw new RoutineFaildException();
  285. }
  286. if (Result.TIMEOUT == ret.Item2)
  287. {
  288. Stop($"VAC 真空信号超时, 当前压力 {_chamber.ChamberPressure}");
  289. throw new RoutineFaildException();
  290. }
  291. throw new RoutineBreakException();
  292. }
  293. }
  294. public void SetLiftPinUpDown(int id, bool isUp, int timeout)
  295. {
  296. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  297. {
  298. Notify($"设置 lift pin {_chamber.Name} " + (isUp ? "升" : "降"));
  299. if (!_chamber.SetLiftPin(isUp ? MovementPosition.Up : MovementPosition.Down, out string reason))
  300. {
  301. Stop(reason);
  302. return false;
  303. }
  304. return true;
  305. }, () => isUp ? _chamber.CheckLiftUp() : _chamber.CheckLiftDown(), timeout * 1000);
  306. if (ret.Item1)
  307. {
  308. if (ret.Item2 == Result.FAIL)
  309. {
  310. throw new RoutineFaildException();
  311. }
  312. else if (ret.Item2 == Result.TIMEOUT) //timeout
  313. {
  314. Stop($"无法 {(isUp ? "Up" : "Down")} lift pin in {timeout} seconds");
  315. throw new RoutineFaildException();
  316. }
  317. else
  318. throw new RoutineBreakException();
  319. }
  320. }
  321. protected void End(int id)
  322. {
  323. bool Func()
  324. {
  325. double duration_min = counter.GetElapseTime();
  326. TimeSpan ts = TimeSpan.FromMilliseconds(duration_min);
  327. string info = $"完成 in {ts.Minutes} minutes {ts.Seconds} seconds";
  328. Notify(info);
  329. //if (bUINotify)
  330. // EV.PostPopDialogMessage(EventLevel.Information, Name, $"{Module} {info} Finished");
  331. return true;
  332. }
  333. Tuple<bool, Result> ret = Execute(id, Func);
  334. }
  335. public virtual void Abort()
  336. {
  337. _chamber.GeneratorPowerOn(false);
  338. _chamber.GeneratorBiasPowerOn(false);
  339. _chamber.StopAllGases();
  340. //ProcessDataRecorder.UpdateStatus(RecipeRunGuid.ToString(), SusceptorStatus.Failed.ToString(), Module);
  341. }
  342. /// <summary>
  343. ///
  344. /// </summary>
  345. /// <param name="stepId"></param>
  346. /// <param name="delayTime">单位:秒</param>
  347. public void CloseValve(int stepId, float delayTime)
  348. {
  349. bool Func()
  350. {
  351. Notify("Vent End Close Vent Valve");
  352. _chamber.SetValveOnOff(ValveType.PURGE, false);
  353. _chamber.SetValveOnOff(ValveType.FAST_VENT, false);
  354. _chamber.SetValveOnOff(ValveType.PROCESS, false);
  355. //_chamber.OpenValve(ValveType.SOFT_PUMP, true);
  356. //_chamber.OpenValve(ValveType.FAST_PUMP, true);
  357. return true;
  358. }
  359. Tuple<bool, Result> ret = Delay(stepId, Func, delayTime * 1000);
  360. if (ret.Item1)
  361. {
  362. if (ret.Item2 == Result.FAIL)
  363. {
  364. throw new RoutineFaildException();
  365. }
  366. throw new RoutineBreakException();
  367. }
  368. }
  369. protected void StartLoop(int id, string name, int count, Action<string> notify, Action<string> error)
  370. {
  371. bool Func()
  372. {
  373. Notify($"{name} 循环 {LoopCounter + 1}");
  374. return true;
  375. }
  376. Tuple<bool, Result> ret = Loop(id, Func, count);
  377. if (ret.Item1)
  378. {
  379. if (ret.Item2 == Result.FAIL)
  380. throw new RoutineFaildException();
  381. }
  382. }
  383. protected void EndLoop(int id, Action<string> notify, Action<string> error)
  384. {
  385. Tuple<bool, Result> ret = EndLoop(id, () => true);
  386. if (ret.Item1)
  387. {
  388. if (ret.Item2 == Result.FAIL)
  389. throw new RoutineFaildException();
  390. throw new RoutineBreakException();
  391. }
  392. }
  393. protected void CyclePump(int id, int target, int timeLimit, bool isStopPumpOnceDone)
  394. {
  395. bool Func()
  396. {
  397. Notify($"Pumping to {target} mTorr");
  398. _chamber.SetValveOnOff(ValveType.PROCESS, false);
  399. _chamber.SetValveOnOff(ValveType.PURGE, false);
  400. _chamber.SetValveOnOff(ValveType.FAST_VENT, false);
  401. _chamber.SetValveOnOff(ValveType.FAST_PUMP, true);
  402. return true;
  403. }
  404. bool? Check1()
  405. {
  406. if (_chamber.ChamberPressure < target)
  407. {
  408. if (isStopPumpOnceDone)
  409. {
  410. _chamber.SetValveOnOff(ValveType.FAST_PUMP, false);
  411. }
  412. return true;
  413. }
  414. return true;
  415. }
  416. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, timeLimit * 1000);
  417. if (ret.Item1)
  418. {
  419. if (ret.Item2 == Result.FAIL)
  420. {
  421. throw new RoutineFaildException();
  422. }
  423. if (ret.Item2 == Result.TIMEOUT)
  424. {
  425. Stop($"Pump 压力无法到达 {target} in time {timeLimit}");
  426. throw new RoutineFaildException();
  427. }
  428. throw new RoutineBreakException();
  429. }
  430. }
  431. protected void CycleVent(int id, int target, int timeLimit, bool isStopVentOnceDone)
  432. {
  433. bool Func()
  434. {
  435. Notify($"Venting to {target} mTorr");
  436. _chamber.SetValveOnOff(ValveType.FAST_PUMP, false);
  437. _chamber.SetValveOnOff(ValveType.PROCESS, true);
  438. _chamber.SetValveOnOff(ValveType.PURGE, true);
  439. return true;
  440. }
  441. bool? Check1()
  442. {
  443. if (_chamber.ChamberPressurePressure > target)
  444. {
  445. if (isStopVentOnceDone)
  446. {
  447. _chamber.SetValveOnOff(ValveType.PROCESS, false);
  448. _chamber.SetValveOnOff(ValveType.PURGE, false);
  449. _chamber.SetValveOnOff(ValveType.FAST_VENT, false);
  450. }
  451. return true;
  452. }
  453. return false;
  454. }
  455. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, timeLimit * 1000);
  456. if (ret.Item1)
  457. {
  458. if (ret.Item2 == Result.FAIL)
  459. {
  460. throw new RoutineFaildException();
  461. }
  462. if (ret.Item2 == Result.TIMEOUT) //timeout
  463. {
  464. Stop($"Purge 压力无法到达 {target} in purge time {timeLimit}");
  465. if (isStopVentOnceDone)
  466. {
  467. _chamber.SetValveOnOff(ValveType.PROCESS, false);
  468. _chamber.SetValveOnOff(ValveType.PURGE, false);
  469. _chamber.SetValveOnOff(ValveType.FAST_VENT, false);
  470. }
  471. throw new RoutineFaildException();
  472. }
  473. throw new RoutineBreakException();
  474. }
  475. }
  476. protected void CheckSubstrateTemp(int id, double target, int time, double tolerance)
  477. {
  478. bool Func()
  479. {
  480. if (_chamber.SubstrateTempFB > target)
  481. {
  482. Notify($"当前温度{_chamber.SubstrateTempFB} ℃, 大于目标 {target.ToString()} ℃");
  483. //return true;
  484. }
  485. _chamber.HeatSubstrate(target);
  486. Notify($"检查底座温度值,当前温度{_chamber.SubstrateTempFB} ℃, 目标 {target.ToString()} ℃");
  487. return true;
  488. }
  489. bool? Check1()
  490. {
  491. if (Math.Abs( target) <= 0.1)
  492. return true;
  493. if (Math.Abs(_chamber.SubstrateTempFB - target) <= tolerance)
  494. return true;
  495. return false;
  496. }
  497. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, time * 1000);
  498. if (ret.Item1)
  499. {
  500. if (ret.Item2 == Result.FAIL)
  501. {
  502. throw new RoutineFaildException();
  503. }
  504. if (ret.Item2 == Result.TIMEOUT)
  505. {
  506. Stop($"检查底座温度超时, 当前底座温度值 {_chamber.SubstrateTempFB}");
  507. throw new RoutineFaildException();
  508. }
  509. throw new RoutineBreakException();
  510. }
  511. }
  512. protected void CheckCoolantTemp(int id, double target, double offset, int time, double tolerance)
  513. {
  514. bool Func()
  515. {
  516. if (_chamber.CoolantOutletTempFB > target)
  517. {
  518. Notify($"水冷当前温度{_chamber.CoolantOutletTempFB} ℃, 大于目标 {target.ToString()} ℃");
  519. //return true;
  520. }
  521. _chamber.HeatChiller(target, offset);
  522. Notify($"检查水冷温度值,当前温度{_chamber.CoolantOutletTempFB} ℃, 目标 {target.ToString()} ℃");
  523. return true;
  524. }
  525. bool? Check1()
  526. {
  527. if (!_chamber.CheckChillerStatus())
  528. return false;
  529. return Math.Abs(_chamber.CoolantOutletTempFB - target) <= tolerance;
  530. }
  531. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, time * 1000);
  532. if (ret.Item1)
  533. {
  534. if (ret.Item2 == Result.FAIL)
  535. {
  536. throw new RoutineFaildException();
  537. }
  538. if (ret.Item2 == Result.TIMEOUT)
  539. {
  540. if (!_chamber.CheckChillerStatus())
  541. {
  542. Stop($"Chiller not connected or in error");
  543. }
  544. else
  545. {
  546. Stop($"检查水冷温度超时, 当前水冷温度值 {_chamber.CoolantOutletTempFB}");
  547. }
  548. throw new RoutineFaildException();
  549. }
  550. throw new RoutineBreakException();
  551. }
  552. }
  553. protected void SetSlitDoor(int id, bool isOpen, int timeout)
  554. {
  555. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  556. {
  557. Notify($"设置传送门 {_chamber.Name} " + (isOpen ? "开" : "关"));
  558. _chamber.SetSlitDoor(isOpen, out _);
  559. return true;
  560. }, () => isOpen ? _chamber.CheckSlitDoorOpen() : _chamber.CheckSlitDoorClose(), timeout * 1000);
  561. if (ret.Item1)
  562. {
  563. if (ret.Item2 == Result.FAIL)
  564. {
  565. throw new RoutineFaildException();
  566. }
  567. else if (ret.Item2 == Result.TIMEOUT) //timeout
  568. {
  569. Stop($"无法 {(isOpen ? "开" : "关")} 传送门 in {timeout} seconds");
  570. throw new RoutineFaildException();
  571. }
  572. else
  573. throw new RoutineBreakException();
  574. }
  575. }
  576. }
  577. }