PMLeakCheckRoutine.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. using System;
  2. using System.Reflection;
  3. using Aitex.Core.RT.Log;
  4. using Aitex.Core.RT.Routine;
  5. using Aitex.Core.RT.SCCore;
  6. using Virgo_DCommon;
  7. using Virgo_DRT.Devices;
  8. using Virgo_DRT.Modules.PMs;
  9. using Virgo_DCommon;
  10. using Virgo_DRT.Devices;
  11. namespace Virgo_DRT.Modules.PMs
  12. {
  13. class LeakCheckRoutine : PMRoutineBase
  14. {
  15. private enum LeakCheckStep
  16. {
  17. PumpDown,
  18. CheckDoor,
  19. CheckDryPump,
  20. CloseAllValve,
  21. OpenPumpingValve,
  22. OpenGasFinalValve,
  23. CloseGasFinalValve,
  24. OpenMfc1Valve,
  25. OpenMfc2Valve,
  26. OpenMfc3Valve,
  27. OpenMfc4Valve,
  28. //OpenMfc5Valve,
  29. CloseMfc1Valve,
  30. CloseMfc2Valve,
  31. CloseMfc3Valve,
  32. CloseMfc4Valve,
  33. //CloseMfc5Valve,
  34. StartFlow,
  35. StopFlow,
  36. RecordStartPressure,
  37. RecordEndPressure,
  38. PumpDownDelay,
  39. StartPressureDelay,
  40. EndPressureDelay,
  41. ClosePumpValve,
  42. LeakCheckDelay,
  43. CalcLeakCheck,
  44. End,
  45. EndLeakCheck,
  46. AbortLeakCheck,
  47. CheckPressure
  48. };
  49. // Fields
  50. private double _beginPressure = 0;
  51. private double _endPressure = 0;
  52. private double _leakRate;
  53. public double LeakRate { get; private set; }
  54. private int _leakCheckPumpDownTime;
  55. private int _leakCheckWaitTime;
  56. private LeakCheckMode _mode;
  57. private bool[] _enableGasLine = new bool[5];
  58. private double[] _mfcFlow = new double[5];
  59. private readonly PumpDownRoutine _pumpdownRoutine;
  60. // Properties
  61. //
  62. public int ElapseTime => (int)(delayTimer.GetElapseTime() / 1000.0);
  63. // Constructor
  64. //
  65. public LeakCheckRoutine(JetPM chamber, PumpDownRoutine _pdRoutine) : base(chamber)
  66. {
  67. Name = "leak check";
  68. bUINotify = true;
  69. _pumpdownRoutine = _pdRoutine;
  70. }
  71. public void Terminate()
  72. {
  73. }
  74. public Result Start(params object[] objs)
  75. {
  76. // 预检查
  77. if (CheckLid() == Result.RUN &&
  78. CheckSlitDoor() == Result.RUN &&
  79. CheckDryPump() == Result.RUN)
  80. {
  81. _enableGasLine = new bool[5] { false, false, false, false, false };
  82. _mfcFlow = new double[5] { 0.0, 0.0, 0.0, 0.0, 0.0 };
  83. Reset();
  84. delayTimer.Start(0);
  85. try
  86. {
  87. if (objs.Length == 0)
  88. {
  89. _leakCheckPumpDownTime = SC.GetValue<int>($"{Module}.Pump.LeakCheckPumpingTime");
  90. _leakCheckWaitTime = SC.GetValue<int>($"{Module}.Pump.LeakCheckWaitTime");
  91. _leakRate = SC.GetValue<double>($"{Module}.Pump.LeakRate");
  92. _mode = LeakCheckMode.ChamberOnly;
  93. }
  94. else
  95. {
  96. _leakCheckPumpDownTime = Convert.ToInt32(objs[0].ToString());
  97. _leakCheckWaitTime = Convert.ToInt32(objs[1].ToString());
  98. _mode = (LeakCheckMode)Enum.Parse(typeof(LeakCheckMode), objs[2].ToString());
  99. _leakRate = Convert.ToInt32(objs[3].ToString());
  100. for (int i = 0; i < 5; i++)
  101. _enableGasLine[i] = Convert.ToBoolean(objs[4 + i].ToString());
  102. }
  103. for (int i = 0; i < 5; i++)
  104. {
  105. if (_enableGasLine[i]) _mfcFlow[i] = SC.GetValue<int>($"{Module}.MfcGas{i + 1}.MfcN2Scale");
  106. }
  107. }
  108. catch (Exception ex)
  109. {
  110. LOG.Write(ex);
  111. return Result.FAIL;
  112. }
  113. return Result.RUN;
  114. }
  115. return Result.FAIL;
  116. }
  117. public Result Monitor()
  118. {
  119. try
  120. {
  121. ExecuteRoutine((int)LeakCheckStep.PumpDown, _pumpdownRoutine);
  122. if (_mode == LeakCheckMode.ChamberOnly)
  123. {
  124. ;
  125. }
  126. else if (_mode == LeakCheckMode.ChamberAndGasLine)
  127. {
  128. OpenValve((int)LeakCheckStep.OpenGasFinalValve, ValveType.PROCESS, true);
  129. if (_enableGasLine[0]) OpenValve((int)LeakCheckStep.OpenMfc1Valve, ValveType.Mfc1, true);
  130. if (_enableGasLine[1]) OpenValve((int)LeakCheckStep.OpenMfc2Valve, ValveType.Mfc2, true);
  131. if (_enableGasLine[2]) OpenValve((int)LeakCheckStep.OpenMfc3Valve, ValveType.Mfc3, true);
  132. if (_enableGasLine[3]) OpenValve((int)LeakCheckStep.OpenMfc4Valve, ValveType.Mfc4, true);
  133. //if (_enableGasLine[4]) OpenValve((int)LeakCheckStep.OpenMfc5Valve, ValveType.Mfc5, true);
  134. }
  135. else if (_mode == LeakCheckMode.ChamberAndGasLineAndFAC)
  136. {
  137. OpenValve((int)LeakCheckStep.OpenGasFinalValve, ValveType.PROCESS, true);
  138. if (_enableGasLine[0]) OpenValve((int)LeakCheckStep.OpenMfc1Valve, ValveType.Mfc1, true);
  139. if (_enableGasLine[1]) OpenValve((int)LeakCheckStep.OpenMfc2Valve, ValveType.Mfc2, true);
  140. if (_enableGasLine[2]) OpenValve((int)LeakCheckStep.OpenMfc3Valve, ValveType.Mfc3, true);
  141. if (_enableGasLine[3]) OpenValve((int)LeakCheckStep.OpenMfc4Valve, ValveType.Mfc4, true);
  142. //if (_enableGasLine[4]) OpenValve((int)LeakCheckStep.OpenMfc5Valve, ValveType.Mfc5, true);
  143. StartFlowMFC((int)LeakCheckStep.StartFlow, _mfcFlow);
  144. }
  145. TimeDelay((int)LeakCheckStep.PumpDownDelay, _leakCheckPumpDownTime);
  146. OpenValve((int)LeakCheckStep.ClosePumpValve, ValveType.FAST_PUMP, false);
  147. //记录腔体Start pressure P1
  148. RecordBeginPressure((int)LeakCheckStep.RecordStartPressure);
  149. //pump down delay
  150. TimeDelay((int)LeakCheckStep.EndPressureDelay, _leakCheckWaitTime);
  151. //记录腔体End pressure P2
  152. RecordEndPressure((int)LeakCheckStep.RecordEndPressure);
  153. CalcLeakCheck((int)LeakCheckStep.CalcLeakCheck, _leakRate, _leakCheckWaitTime, 0);
  154. if (_mode == LeakCheckMode.ChamberOnly)
  155. {
  156. ;
  157. }
  158. else if (_mode == LeakCheckMode.ChamberAndGasLine)
  159. {
  160. OpenValve((int)LeakCheckStep.CloseGasFinalValve, ValveType.PROCESS, false);
  161. if (_enableGasLine[0]) OpenValve((int)LeakCheckStep.CloseMfc1Valve, ValveType.Mfc1, false);
  162. if (_enableGasLine[1]) OpenValve((int)LeakCheckStep.CloseMfc2Valve, ValveType.Mfc2, false);
  163. if (_enableGasLine[2]) OpenValve((int)LeakCheckStep.CloseMfc3Valve, ValveType.Mfc3, false);
  164. if (_enableGasLine[3]) OpenValve((int)LeakCheckStep.CloseMfc4Valve, ValveType.Mfc4, false);
  165. //if (_enableGasLine[4]) OpenValve((int)LeakCheckStep.CloseMfc5Valve, ValveType.Mfc5, false);
  166. }
  167. else if (_mode == LeakCheckMode.ChamberAndGasLineAndFAC)
  168. {
  169. OpenValve((int)LeakCheckStep.CloseGasFinalValve, ValveType.PROCESS, false);
  170. if (_enableGasLine[0]) OpenValve((int)LeakCheckStep.CloseMfc1Valve, ValveType.Mfc1, false);
  171. if (_enableGasLine[1]) OpenValve((int)LeakCheckStep.CloseMfc2Valve, ValveType.Mfc2, false);
  172. if (_enableGasLine[2]) OpenValve((int)LeakCheckStep.CloseMfc3Valve, ValveType.Mfc3, false);
  173. if (_enableGasLine[3]) OpenValve((int)LeakCheckStep.CloseMfc4Valve, ValveType.Mfc4, false);
  174. //if (_enableGasLine[4]) OpenValve((int)LeakCheckStep.CloseMfc5Valve, ValveType.Mfc5, false);
  175. StopFlowMFC((int)LeakCheckStep.StopFlow);
  176. }
  177. End((int)LeakCheckStep.End);
  178. //ExecuteRoutine((int)LeakCheckStep.EndLeakCheck, _pumpDownRoutine);
  179. }
  180. catch (RoutineBreakException)
  181. {
  182. return Result.RUN;
  183. }
  184. catch (RoutineFaildException)
  185. {
  186. return Result.FAIL;
  187. }
  188. return Result.DONE;
  189. }
  190. public void DelayLeakCheck(int id, string name, double time)
  191. {
  192. bool Func()
  193. {
  194. Notify(name);
  195. return true;
  196. }
  197. Tuple<bool, Result> ret = Delay(id, Func, time * 1000);
  198. if (ret.Item1)
  199. {
  200. if (ret.Item2 == Result.RUN)
  201. {
  202. throw new RoutineBreakException();
  203. }
  204. }
  205. }
  206. public void CheckChamberPressure(int id, double target, out double pressure, int time)
  207. {
  208. bool Func()
  209. {
  210. return true;
  211. }
  212. bool? Check1()
  213. {
  214. if (_chamber.ChamberPressure < target)
  215. {
  216. Notify($"Chamber pressure [{_chamber.ChamberPressure}] mt, less than [{target}] mt");
  217. return true;
  218. }
  219. Stop($"Chamber pressure [{_chamber.ChamberPressure}], greater than [{target}]");
  220. return false;
  221. }
  222. pressure = _chamber.ChamberPressure;
  223. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, time * 1000);
  224. if (ret.Item1)
  225. {
  226. if (ret.Item2 == Result.FAIL)
  227. {
  228. throw new RoutineFaildException();
  229. }
  230. if (ret.Item2 == Result.TIMEOUT)
  231. {
  232. throw new RoutineFaildException();
  233. }
  234. throw new RoutineBreakException();
  235. }
  236. }
  237. public void RecordBeginPressure(int id)
  238. {
  239. bool Func()
  240. {
  241. _beginPressure = _chamber.ChamberPressure;
  242. Notify($"Record PM begin pressure {_beginPressure} mt");
  243. return true;
  244. }
  245. bool? Check1()
  246. {
  247. return true;
  248. }
  249. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, 1 * 1000);
  250. if (ret.Item1)
  251. {
  252. if (ret.Item2 == Result.FAIL)
  253. {
  254. throw new RoutineFaildException();
  255. }
  256. if (ret.Item2 == Result.TIMEOUT)
  257. {
  258. throw new RoutineFaildException();
  259. }
  260. throw new RoutineBreakException();
  261. }
  262. }
  263. public void RecordEndPressure(int id)
  264. {
  265. bool Func()
  266. {
  267. _endPressure = _chamber.ChamberPressure;
  268. Notify($"Record PM end pressure {_endPressure} mt");
  269. return true;
  270. }
  271. bool? Check1()
  272. {
  273. return true;
  274. }
  275. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, 1 * 1000);
  276. if (ret.Item1)
  277. {
  278. if (ret.Item2 == Result.FAIL)
  279. {
  280. throw new RoutineFaildException();
  281. }
  282. if (ret.Item2 == Result.TIMEOUT)
  283. {
  284. throw new RoutineFaildException();
  285. }
  286. throw new RoutineBreakException();
  287. }
  288. }
  289. public void CalcLeakCheck(int id, double target, int timeRate, int time)
  290. {
  291. bool Func()
  292. {
  293. return true;
  294. }
  295. bool? Check1()
  296. {
  297. LeakRate = (_endPressure - _beginPressure) / (timeRate / 60.0);
  298. if (LeakRate < target)
  299. {
  300. Notify($"PM leak rate [{LeakRate}] mt/min, less than [{target}] mt/min");
  301. LeakCheckResultManager.Instance.AddLeakCheck(Module, DateTime.Now, ElapseTime, (int)_beginPressure, (int)_endPressure, LeakRate, LeakCheckStatus.Succeed.ToString(), _mode.ToString());
  302. return true;
  303. }
  304. Stop($"PM leak rate [{LeakRate}] mt/min, greater than [{target}] mt/min");
  305. LeakCheckResultManager.Instance.AddLeakCheck(Module, DateTime.Now, ElapseTime, (int)_beginPressure, (int)_endPressure, LeakRate, LeakCheckStatus.Failed.ToString(), _mode.ToString());
  306. return false;
  307. }
  308. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, time * 1000);
  309. if (ret.Item1)
  310. {
  311. if (ret.Item2 == Result.FAIL)
  312. {
  313. throw new RoutineFaildException();
  314. }
  315. if (ret.Item2 == Result.TIMEOUT)
  316. {
  317. throw new RoutineFaildException();
  318. }
  319. throw new RoutineBreakException();
  320. }
  321. }
  322. public void StopFlowMFC(int id)
  323. {
  324. bool Func()
  325. {
  326. _chamber.StopAllGases();
  327. return true;
  328. }
  329. bool? Check1()
  330. {
  331. return true;
  332. }
  333. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, 1 * 1000);
  334. if (ret.Item1)
  335. {
  336. if (ret.Item2 == Result.FAIL)
  337. {
  338. throw new RoutineFaildException();
  339. }
  340. if (ret.Item2 == Result.TIMEOUT)
  341. {
  342. throw new RoutineFaildException();
  343. }
  344. throw new RoutineBreakException();
  345. }
  346. }
  347. public void StartFlowMFC(int id, double[] mfcValues)
  348. {
  349. bool Func()
  350. {
  351. for (int index = 0; index < mfcValues.Length; index++)
  352. {
  353. _chamber.FlowGas(index, mfcValues[index]);
  354. }
  355. return true;
  356. }
  357. bool? Check1()
  358. {
  359. return true;
  360. }
  361. Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, 1 * 1000);
  362. if (ret.Item1)
  363. {
  364. if (ret.Item2 == Result.FAIL)
  365. {
  366. throw new RoutineFaildException();
  367. }
  368. if (ret.Item2 == Result.TIMEOUT)
  369. {
  370. throw new RoutineFaildException();
  371. }
  372. throw new RoutineBreakException();
  373. }
  374. }
  375. public void DeleteLeadCheck(object[] args)
  376. {
  377. LeakCheckResultManager.Instance.Delete(Module, args[0].ToString());
  378. }
  379. public override void Abort()
  380. {
  381. try
  382. {
  383. _chamber.CloseValves();
  384. LeakCheckResultManager.Instance.AddLeakCheck(Module, DateTime.Now, ElapseTime, (int)_beginPressure, (int)_chamber.ChamberPressure, 0, LeakCheckStatus.Aborted.ToString(), _mode.ToString());
  385. }
  386. catch (Exception ex)
  387. {
  388. LOG.Write(ex);
  389. }
  390. }
  391. }
  392. }