PMRoutineBase.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  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("The chamber lid must be closed");
  50. return Result.FAIL;
  51. }
  52. return Result.RUN;
  53. }
  54. protected Result CheckSlitDoor()
  55. {
  56. if (!_chamber.IsSlitDoorClosed)
  57. {
  58. Stop("Slit door must be closed");
  59. return Result.FAIL;
  60. }
  61. return Result.RUN;
  62. }
  63. protected Result CheckDryPump()
  64. {
  65. if (!_chamber.IsPumpRunning)
  66. {
  67. Stop("The pump has not started");
  68. return Result.FAIL;
  69. }
  70. if (_chamber.HasPumpError)
  71. {
  72. Stop("The pump status error");
  73. return Result.FAIL;
  74. }
  75. return Result.RUN;
  76. }
  77. public void CheckThrottleValveFullOpen(int id)
  78. {
  79. bool execute()
  80. {
  81. Notify("Open the throttle valve");
  82. _chamber.FullOpenTV();
  83. return true;
  84. }
  85. bool? Check1()
  86. {
  87. if (_chamber.TVPosition >= 98)
  88. {
  89. Notify("The throttle valve is opened");
  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("Not open the throttle valve");
  100. throw new RoutineFaildException();
  101. }
  102. if (ret.Item2 == Result.TIMEOUT)
  103. {
  104. Stop("Start the throttle valve timeout");
  105. throw new RoutineFaildException();
  106. }
  107. throw new RoutineBreakException();
  108. }
  109. }
  110. protected Result CheckCDA()
  111. {
  112. if (!_chamber.IsCDA_OK)
  113. {
  114. Stop("The CDA pressure signal is incorrect");
  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("Close all valve");
  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 ? "open" : "close")} {vlv} valve");
  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($"Wait ATM sensor {(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 sensor {(_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($"The pressure has reached {targetPressure:N} mTorr");
  201. }
  202. return res;
  203. }
  204. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  205. {
  206. Notify($"Wait pressure {(morethan ? "rise" : "decline")} to {targetPressure:N} mTorr");
  207. return true;
  208. }, Check1, time * 1000);
  209. if (ret.Item1)
  210. {
  211. if (ret.Item2 == Result.FAIL)
  212. {
  213. Stop($"Current pressure [{_chamber.ChamberPressure}], not equal to [{targetPressure}]");
  214. throw new RoutineFaildException();
  215. }
  216. if (ret.Item2 == Result.TIMEOUT)
  217. {
  218. Stop($"Check chamber pressuer timeout, current value [{_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 {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($"Check foreline pressure timeout, current foreline pressure value {_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 sensor NOT ON");
  284. throw new RoutineFaildException();
  285. }
  286. if (Result.TIMEOUT == ret.Item2)
  287. {
  288. Stop($"VAC sensor timeout, chamber pressure {_chamber.ChamberPressure}");
  289. throw new RoutineFaildException();
  290. }
  291. throw new RoutineBreakException();
  292. }
  293. }
  294. public void SetLiftPinPos(int id, MovementPosition pos, int timeout)
  295. {
  296. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  297. {
  298. Notify($"Set lift pin {_chamber.Name} {pos}" );
  299. if (!_chamber.SetLiftPin(pos, out string reason))
  300. {
  301. Stop(reason);
  302. return false;
  303. }
  304. return true;
  305. }, () => _chamber.CheckLiftPinPos(pos), 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($"Set lift pin {pos} 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. }
  341. /// <summary>
  342. ///
  343. /// </summary>
  344. /// <param name="stepId"></param>
  345. /// <param name="delayTime">单位:秒</param>
  346. public void CloseValve(int stepId, float delayTime)
  347. {
  348. bool Func()
  349. {
  350. Notify("Vent End Close Vent Valve");
  351. _chamber.SetValveOnOff(ValveType.PURGE, false);
  352. _chamber.SetValveOnOff(ValveType.FAST_VENT, false);
  353. _chamber.SetValveOnOff(ValveType.PROCESS, false);
  354. //_chamber.OpenValve(ValveType.SOFT_PUMP, true);
  355. //_chamber.OpenValve(ValveType.FAST_PUMP, true);
  356. return true;
  357. }
  358. Tuple<bool, Result> ret = Delay(stepId, Func, delayTime * 1000);
  359. if (ret.Item1)
  360. {
  361. if (ret.Item2 == Result.FAIL)
  362. {
  363. throw new RoutineFaildException();
  364. }
  365. throw new RoutineBreakException();
  366. }
  367. }
  368. protected void StartLoop(int id, string name, int count, Action<string> notify, Action<string> error)
  369. {
  370. bool Func()
  371. {
  372. Notify($"{name} loop {LoopCounter + 1}");
  373. return true;
  374. }
  375. Tuple<bool, Result> ret = Loop(id, Func, count);
  376. if (ret.Item1)
  377. {
  378. if (ret.Item2 == Result.FAIL)
  379. throw new RoutineFaildException();
  380. }
  381. }
  382. protected void EndLoop(int id, Action<string> notify, Action<string> error)
  383. {
  384. Tuple<bool, Result> ret = EndLoop(id, () => true);
  385. if (ret.Item1)
  386. {
  387. if (ret.Item2 == Result.FAIL)
  388. throw new RoutineFaildException();
  389. throw new RoutineBreakException();
  390. }
  391. }
  392. protected void CyclePump(int id, int target, int timeLimit, bool isStopPumpOnceDone)
  393. {
  394. bool Func()
  395. {
  396. Notify($"Pumping to {target} mTorr");
  397. _chamber.SetValveOnOff(ValveType.PROCESS, false);
  398. _chamber.SetValveOnOff(ValveType.PURGE, false);
  399. _chamber.SetValveOnOff(ValveType.FAST_VENT, false);
  400. _chamber.SetValveOnOff(ValveType.FAST_PUMP, true);
  401. return true;
  402. }
  403. bool? Check1()
  404. {
  405. if (_chamber.ChamberPressure < target)
  406. {
  407. if (isStopPumpOnceDone)
  408. {
  409. _chamber.SetValveOnOff(ValveType.FAST_PUMP, false);
  410. }
  411. return true;
  412. }
  413. return true;
  414. }
  415. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, timeLimit * 1000);
  416. if (ret.Item1)
  417. {
  418. if (ret.Item2 == Result.FAIL)
  419. {
  420. throw new RoutineFaildException();
  421. }
  422. if (ret.Item2 == Result.TIMEOUT)
  423. {
  424. Stop($"Set pump pressure {target} timeout in time {timeLimit}");
  425. throw new RoutineFaildException();
  426. }
  427. throw new RoutineBreakException();
  428. }
  429. }
  430. protected void CycleVent(int id, int target, int timeLimit, bool isStopVentOnceDone)
  431. {
  432. bool Func()
  433. {
  434. Notify($"Venting to {target} mTorr");
  435. _chamber.SetValveOnOff(ValveType.FAST_PUMP, false);
  436. _chamber.SetValveOnOff(ValveType.PROCESS, true);
  437. _chamber.SetValveOnOff(ValveType.PURGE, true);
  438. return true;
  439. }
  440. bool? Check1()
  441. {
  442. if (_chamber.ChamberPressurePressure > target)
  443. {
  444. if (isStopVentOnceDone)
  445. {
  446. _chamber.SetValveOnOff(ValveType.PROCESS, false);
  447. _chamber.SetValveOnOff(ValveType.PURGE, false);
  448. _chamber.SetValveOnOff(ValveType.FAST_VENT, false);
  449. }
  450. return true;
  451. }
  452. return false;
  453. }
  454. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, timeLimit * 1000);
  455. if (ret.Item1)
  456. {
  457. if (ret.Item2 == Result.FAIL)
  458. {
  459. throw new RoutineFaildException();
  460. }
  461. if (ret.Item2 == Result.TIMEOUT) //timeout
  462. {
  463. Stop($"Set vent pressure {target} timeout in vent time {timeLimit}");
  464. if (isStopVentOnceDone)
  465. {
  466. _chamber.SetValveOnOff(ValveType.PROCESS, false);
  467. _chamber.SetValveOnOff(ValveType.PURGE, false);
  468. _chamber.SetValveOnOff(ValveType.FAST_VENT, false);
  469. }
  470. throw new RoutineFaildException();
  471. }
  472. throw new RoutineBreakException();
  473. }
  474. }
  475. protected void CheckSubstrateTemp(int id, double target, int time, double tolerance)
  476. {
  477. bool Func()
  478. {
  479. if (_chamber.SubstrateTempFB > target)
  480. {
  481. Notify($"Substrate current temp {_chamber.SubstrateTempFB} ℃, greater than target {target.ToString()} ℃");
  482. //return true;
  483. }
  484. _chamber.HeatSubstrate(target);
  485. Notify($"Check substrate temp,current temp{_chamber.SubstrateTempFB} ℃, target {target.ToString()} ℃");
  486. return true;
  487. }
  488. bool? Check1()
  489. {
  490. if (Math.Abs( target) <= 0.1)
  491. return true;
  492. if (Math.Abs(_chamber.SubstrateTempFB - target) <= tolerance)
  493. return true;
  494. return false;
  495. }
  496. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, time * 1000);
  497. if (ret.Item1)
  498. {
  499. if (ret.Item2 == Result.FAIL)
  500. {
  501. throw new RoutineFaildException();
  502. }
  503. if (ret.Item2 == Result.TIMEOUT)
  504. {
  505. Stop($"Check substrate temp timeout, current Substrate temp value {_chamber.SubstrateTempFB}");
  506. throw new RoutineFaildException();
  507. }
  508. throw new RoutineBreakException();
  509. }
  510. }
  511. protected void CheckCoolantTemp(int id, double target, double offset, int time, double tolerance)
  512. {
  513. bool Func()
  514. {
  515. if (_chamber.CoolantOutletTempFB > target)
  516. {
  517. Notify($"Chiller current temp {_chamber.CoolantOutletTempFB} ℃, greater than target value {target.ToString()} ℃");
  518. //return true;
  519. }
  520. _chamber.HeatChiller(target, offset);
  521. Notify($"Check chiller temp,current temp {_chamber.CoolantOutletTempFB} ℃, target {target.ToString()} ℃");
  522. return true;
  523. }
  524. bool? Check1()
  525. {
  526. if (!_chamber.CheckChillerStatus())
  527. return false;
  528. return Math.Abs(_chamber.CoolantOutletTempFB - target) <= tolerance;
  529. }
  530. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, time * 1000);
  531. if (ret.Item1)
  532. {
  533. if (ret.Item2 == Result.FAIL)
  534. {
  535. throw new RoutineFaildException();
  536. }
  537. if (ret.Item2 == Result.TIMEOUT)
  538. {
  539. if (!_chamber.CheckChillerStatus())
  540. {
  541. Stop($"Chiller not connected or in error");
  542. }
  543. else
  544. {
  545. Stop($"Check chiller temp timeout, current chiller temp value {_chamber.CoolantOutletTempFB}");
  546. }
  547. throw new RoutineFaildException();
  548. }
  549. throw new RoutineBreakException();
  550. }
  551. }
  552. protected void SetSlitDoor(int id, bool isOpen, int timeout)
  553. {
  554. Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
  555. {
  556. Notify($"Set slit door {_chamber.Name} " + (isOpen ? "open" : "close"));
  557. _chamber.SetSlitDoor(isOpen, out _);
  558. return true;
  559. }, () => isOpen ? _chamber.CheckSlitDoorOpen() : _chamber.CheckSlitDoorClose(), timeout * 1000);
  560. if (ret.Item1)
  561. {
  562. if (ret.Item2 == Result.FAIL)
  563. {
  564. throw new RoutineFaildException();
  565. }
  566. else if (ret.Item2 == Result.TIMEOUT) //timeout
  567. {
  568. Stop($"Set slit door {(isOpen ? "open" : "close")} timeout in {timeout} seconds");
  569. throw new RoutineFaildException();
  570. }
  571. else
  572. throw new RoutineBreakException();
  573. }
  574. }
  575. }
  576. }