PMRoutineBase.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  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 OpenValve(int id, ValveType vlv, bool bOpen)
  142. {
  143. bool exec()
  144. {
  145. _chamber.OpenValve(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. public void CloseValve(int stepId, int timeVent)
  343. {
  344. bool Func()
  345. {
  346. Notify("Vent End Close Vent Valve");
  347. _chamber.OpenValve(ValveType.PURGE, false);
  348. _chamber.OpenValve(ValveType.FAST_VENT, false);
  349. _chamber.OpenValve(ValveType.PROCESS, false);
  350. //_chamber.OpenValve(ValveType.SOFT_PUMP, true);
  351. //_chamber.OpenValve(ValveType.FAST_PUMP, true);
  352. return true;
  353. }
  354. Tuple<bool, Result> ret = Delay(stepId, Func, timeVent * 1000);
  355. if (ret.Item1)
  356. {
  357. if (ret.Item2 == Result.FAIL)
  358. {
  359. throw new RoutineFaildException();
  360. }
  361. throw new RoutineBreakException();
  362. }
  363. }
  364. public void VentToPrecision(int stepId, int timeVent)
  365. {
  366. bool Func()
  367. {
  368. Notify("Vent to precision");
  369. _chamber.OpenValve(ValveType.SOFT_PUMP, false);
  370. _chamber.OpenValve(ValveType.PURGE, true);
  371. return true;
  372. }
  373. Tuple<bool, Result> ret = Delay(stepId, Func, timeVent * 1000);
  374. if (ret.Item1)
  375. {
  376. if (ret.Item2 == Result.FAIL)
  377. {
  378. throw new RoutineFaildException();
  379. }
  380. throw new RoutineBreakException();
  381. }
  382. }
  383. protected void StartLoop(int id, string name, int count, Action<string> notify, Action<string> error)
  384. {
  385. bool Func()
  386. {
  387. Notify($"{name} 循环 {LoopCounter + 1}");
  388. return true;
  389. }
  390. Tuple<bool, Result> ret = Loop(id, Func, count);
  391. if (ret.Item1)
  392. {
  393. if (ret.Item2 == Result.FAIL)
  394. throw new RoutineFaildException();
  395. }
  396. }
  397. protected void EndLoop(int id, Action<string> notify, Action<string> error)
  398. {
  399. Tuple<bool, Result> ret = EndLoop(id, () => true);
  400. if (ret.Item1)
  401. {
  402. if (ret.Item2 == Result.FAIL)
  403. throw new RoutineFaildException();
  404. throw new RoutineBreakException();
  405. }
  406. }
  407. protected void CyclePump(int id, int target, int timeLimit, bool isStopPumpOnceDone)
  408. {
  409. bool Func()
  410. {
  411. Notify($"Pumping to {target} mTorr");
  412. _chamber.OpenValve(ValveType.PROCESS, false);
  413. _chamber.OpenValve(ValveType.PURGE, false);
  414. _chamber.OpenValve(ValveType.FAST_VENT, false);
  415. _chamber.OpenValve(ValveType.FAST_PUMP, true);
  416. return true;
  417. }
  418. bool? Check1()
  419. {
  420. if (_chamber.ChamberPressure < target)
  421. {
  422. if (isStopPumpOnceDone)
  423. {
  424. _chamber.OpenValve(ValveType.FAST_PUMP, false);
  425. }
  426. return true;
  427. }
  428. return true;
  429. }
  430. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, timeLimit * 1000);
  431. if (ret.Item1)
  432. {
  433. if (ret.Item2 == Result.FAIL)
  434. {
  435. throw new RoutineFaildException();
  436. }
  437. if (ret.Item2 == Result.TIMEOUT)
  438. {
  439. Stop($"Pump 压力无法到达 {target} in time {timeLimit}");
  440. throw new RoutineFaildException();
  441. }
  442. throw new RoutineBreakException();
  443. }
  444. }
  445. protected void CycleVent(int id, int target, int timeLimit, bool isStopVentOnceDone)
  446. {
  447. bool Func()
  448. {
  449. Notify($"Venting to {target} mTorr");
  450. _chamber.OpenValve(ValveType.FAST_PUMP, false);
  451. _chamber.OpenValve(ValveType.PROCESS, true);
  452. _chamber.OpenValve(ValveType.PURGE, true);
  453. return true;
  454. }
  455. bool? Check1()
  456. {
  457. if (_chamber.ChamberPressurePressure > target)
  458. {
  459. if (isStopVentOnceDone)
  460. {
  461. _chamber.OpenValve(ValveType.PROCESS, false);
  462. _chamber.OpenValve(ValveType.PURGE, false);
  463. _chamber.OpenValve(ValveType.FAST_VENT, false);
  464. }
  465. return true;
  466. }
  467. return false;
  468. }
  469. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, timeLimit * 1000);
  470. if (ret.Item1)
  471. {
  472. if (ret.Item2 == Result.FAIL)
  473. {
  474. throw new RoutineFaildException();
  475. }
  476. if (ret.Item2 == Result.TIMEOUT) //timeout
  477. {
  478. Stop($"Purge 压力无法到达 {target} in purge time {timeLimit}");
  479. if (isStopVentOnceDone)
  480. {
  481. _chamber.OpenValve(ValveType.PROCESS, false);
  482. _chamber.OpenValve(ValveType.PURGE, false);
  483. _chamber.OpenValve(ValveType.FAST_VENT, false);
  484. }
  485. throw new RoutineFaildException();
  486. }
  487. throw new RoutineBreakException();
  488. }
  489. }
  490. protected void CheckSubstrateTemp(int id, double target, int time, double tolerance)
  491. {
  492. bool Func()
  493. {
  494. if (_chamber.SubstrateTempFB > target)
  495. {
  496. Notify($"当前温度{_chamber.SubstrateTempFB} ℃, 大于目标 {target.ToString()} ℃");
  497. //return true;
  498. }
  499. _chamber.HeatSubstrate(target);
  500. Notify($"检查底座温度值,当前温度{_chamber.SubstrateTempFB} ℃, 目标 {target.ToString()} ℃");
  501. return true;
  502. }
  503. bool? Check1()
  504. {
  505. if (Math.Abs(_chamber.SubstrateTempFB - target) <= tolerance) return true;
  506. else return false;
  507. }
  508. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, time * 1000);
  509. if (ret.Item1)
  510. {
  511. if (ret.Item2 == Result.FAIL)
  512. {
  513. throw new RoutineFaildException();
  514. }
  515. if (ret.Item2 == Result.TIMEOUT)
  516. {
  517. Stop($"检查底座温度超时, 当前底座温度值 {_chamber.SubstrateTempFB}");
  518. throw new RoutineFaildException();
  519. }
  520. throw new RoutineBreakException();
  521. }
  522. }
  523. protected void CheckCoolantTemp(int id, double target, double offset, int time, double tolerance)
  524. {
  525. bool Func()
  526. {
  527. if (_chamber.CoolantOutletTempFB > target)
  528. {
  529. Notify($"水冷当前温度{_chamber.CoolantOutletTempFB} ℃, 大于目标 {target.ToString()} ℃");
  530. //return true;
  531. }
  532. _chamber.HeatChiller(target, offset);
  533. Notify($"检查水冷温度值,当前温度{_chamber.CoolantOutletTempFB} ℃, 目标 {target.ToString()} ℃");
  534. return true;
  535. }
  536. bool? Check1()
  537. {
  538. if (!_chamber.CheckChillerStatus())
  539. return false;
  540. return Math.Abs(_chamber.CoolantOutletTempFB - target) <= tolerance;
  541. }
  542. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, time * 1000);
  543. if (ret.Item1)
  544. {
  545. if (ret.Item2 == Result.FAIL)
  546. {
  547. throw new RoutineFaildException();
  548. }
  549. if (ret.Item2 == Result.TIMEOUT)
  550. {
  551. if (!_chamber.CheckChillerStatus())
  552. {
  553. Stop($"Chiller not connected or in error");
  554. }
  555. else
  556. {
  557. Stop($"检查水冷温度超时, 当前水冷温度值 {_chamber.CoolantOutletTempFB}");
  558. }
  559. throw new RoutineFaildException();
  560. }
  561. throw new RoutineBreakException();
  562. }
  563. }
  564. protected void SetSlitDoor(int id, bool isOpen, int timeout)
  565. {
  566. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  567. {
  568. Notify($"设置传送门 {_chamber.Name} " + (isOpen ? "开" : "关"));
  569. _chamber.SetSlitDoor(isOpen, out _);
  570. return true;
  571. }, () => isOpen ? _chamber.CheckSlitDoorOpen() : _chamber.CheckSlitDoorClose(), timeout * 1000);
  572. if (ret.Item1)
  573. {
  574. if (ret.Item2 == Result.FAIL)
  575. {
  576. throw new RoutineFaildException();
  577. }
  578. else if (ret.Item2 == Result.TIMEOUT) //timeout
  579. {
  580. Stop($"无法 {(isOpen ? "开" : "关")} 传送门 in {timeout} seconds");
  581. throw new RoutineFaildException();
  582. }
  583. else
  584. throw new RoutineBreakException();
  585. }
  586. }
  587. }
  588. }