GasBoxLeakCheckRoutine.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. using Aitex.Core.RT.Routine;
  2. using Aitex.Core.RT.SCCore;
  3. using Venus_RT.Devices;
  4. using MECF.Framework.Common.Routine;
  5. using System.Diagnostics;
  6. using System.Collections.Generic;
  7. using Venus_Core;
  8. using System;
  9. using Venus_Unity;
  10. using MECF.Framework.Common.DBCore;
  11. using System.Text;
  12. namespace Venus_RT.Modules.PMs
  13. {
  14. class GasBoxLeakCheckRoutine : PMRoutineBase, IRoutine
  15. {
  16. private enum LeakCheckStep
  17. {
  18. kPumpToBasePressure,
  19. kPumpingDelay,
  20. kLeakCheckDelay,
  21. kEnd,
  22. }
  23. public double LeakRate { get; private set; }
  24. private int _basePressure = 100;
  25. private int _leakcheckPumpTime = 180;
  26. private int _leakcheckHoldTime = 300;
  27. private double _startPressure = 0;
  28. private double _endPressure = 0;
  29. private double _leakRate = 30.0;
  30. private double _leakCheckBasePressure = 1;
  31. private List<int> _gasLineNums = new List<int>();
  32. Stopwatch _leakCheckTimer = new Stopwatch();
  33. bool isCheckVentLine;
  34. PMLeakCheckResult pMLeakCheckResult;
  35. Stopwatch _routineTimer = new Stopwatch();
  36. StringBuilder gasLines=new StringBuilder();
  37. public string CurrentStep;
  38. PressureType _pressureType = PressureType.mTorr;
  39. public GasBoxLeakCheckRoutine(JetPMBase chamber) : base(chamber)
  40. {
  41. Name = "GasBox Leakcheck";
  42. if (chamber.ChamberType == JetChamber.Kepler2200A || chamber.ChamberType == JetChamber.Kepler2200B)
  43. {
  44. _pressureType = PressureType.Pa;
  45. }
  46. }
  47. public RState Start(params object[] objs)
  48. {
  49. if (CheckLid() &&
  50. CheckSlitDoor() &&
  51. CheckTurboPump())
  52. {
  53. CurrentStep = "Pump To BasePressure";
  54. Reset();
  55. _basePressure = SC.GetValue<int>($"{Module}.Pump.PumpBasePressure");
  56. //_leakcheckPumpTime = SC.GetValue<int>($"{Module}.Pump.LeakCheckPumpingTime");
  57. //_leakcheckHoldTime = SC.GetValue<int>($"{Module}.Pump.LeakCheckHoldTime");
  58. //_leakRate = SC.GetValue<double>($"{Module}.Pump.LeakRate");
  59. _leakcheckPumpTime = (int)(objs[0]);
  60. _leakcheckHoldTime = (int)(objs[1]);
  61. _leakRate = (double)(objs[2]);
  62. _leakCheckBasePressure = SC.GetValue<double>($"{Module}.Pump.LeakCheckBasePressure");
  63. // Extract line numbers which need do Leakcheck from config file
  64. _gasLineNums.Clear();
  65. //var lineNums = SC.GetStringValue($"{Module}.Pump.LeakCheckGasLineNums").Split(',');
  66. var lineNums = objs[3].ToString().Split(',');
  67. int nNum;
  68. int allGas=8;
  69. if (_chamber.ChamberType == JetChamber.Kepler2200A || _chamber.ChamberType == JetChamber.Kepler2200B)
  70. {
  71. allGas = 6;
  72. }else if (_chamber.ChamberType == JetChamber.VenusSE || _chamber.ChamberType == JetChamber.VenusDE)
  73. {
  74. allGas = 10;
  75. }
  76. foreach (string num in lineNums)
  77. {
  78. if(int.TryParse(num, out nNum))
  79. {
  80. if(nNum > 0 && nNum <= allGas && !_gasLineNums.Contains(nNum))
  81. {
  82. _gasLineNums.Add(nNum);
  83. }
  84. }
  85. }
  86. isCheckVentLine = (bool)objs[4];
  87. pMLeakCheckResult = new PMLeakCheckResult();
  88. pMLeakCheckResult.CheckMode = objs[5].ToString();
  89. if (_gasLineNums.Count == 0 && isCheckVentLine==false)
  90. {
  91. Stop($"No Gasline need do LeakCheck, please check the config item{Module}.Pump.LeakCheckGasLineNums");
  92. return RState.Failed;
  93. }
  94. gasLines.Clear();
  95. PreSetValves();
  96. pMLeakCheckResult.CheckDate = DateTime.Now.ToString("yyyyMMddHHmm");
  97. _routineTimer.Restart();
  98. Reset();
  99. return Runner.Start(Module, Name);
  100. }
  101. return RState.Failed;
  102. }
  103. public RState Monitor()
  104. {
  105. Runner.Wait(LeakCheckStep.kPumpToBasePressure, ()=> { return _chamber.ProcessPressure <= _basePressure; })
  106. .Run(LeakCheckStep.kPumpingDelay, LeakCheckPumping, PumpingDelay)
  107. .Run(LeakCheckStep.kLeakCheckDelay, StartLeakCheck, _leakcheckHoldTime * 1000)
  108. .End(LeakCheckStep.kEnd, CalcLeakCheckResult, _delay_50ms);
  109. return Runner.Status;
  110. }
  111. public void Abort()
  112. {
  113. CloseAllValves();
  114. }
  115. private bool LeakCheckPumping()
  116. {
  117. CurrentStep = "Check Pump";
  118. foreach (var num in _gasLineNums)
  119. {
  120. var _MfcN2Scale = SC.GetValue<int>($"{Module}.MfcGas{num}.MfcN2Scale");
  121. var _MfcScaleFactor = SC.GetValue<Double>($"{Module}.MfcGas{num}.MfcScaleFactor");
  122. var _GasFlow = _MfcN2Scale * _MfcScaleFactor;
  123. _chamber.FlowGas(num-1, _GasFlow);
  124. gasLines.Append($"Gas{num},");
  125. }
  126. if (_gasLineNums.Contains(1))
  127. {
  128. _chamber.OpenValve(ValveType.PV11, true);
  129. }
  130. if (_gasLineNums.Contains(2))
  131. {
  132. _chamber.OpenValve(ValveType.PV21, true);
  133. }
  134. if (_gasLineNums.Contains(3))
  135. {
  136. _chamber.OpenValve(ValveType.PV31, true);
  137. }
  138. if (_gasLineNums.Contains(4))
  139. {
  140. _chamber.OpenValve(ValveType.PV41, true);
  141. }
  142. if (_gasLineNums.Contains(5))
  143. {
  144. _chamber.OpenValve(ValveType.PV51, true);
  145. }
  146. if (_gasLineNums.Contains(6))
  147. {
  148. _chamber.OpenValve(ValveType.PV61, true);
  149. }
  150. if (_gasLineNums.Contains(7))
  151. {
  152. _chamber.OpenValve(ValveType.PV71, true);
  153. }
  154. if (_gasLineNums.Contains(8))
  155. {
  156. _chamber.OpenValve(ValveType.PV81, true);
  157. }
  158. if (_gasLineNums.Contains(9))
  159. {
  160. _chamber.OpenValve(ValveType.PV91, true);
  161. }
  162. if (_gasLineNums.Contains(10))
  163. {
  164. _chamber.OpenValve(ValveType.PVA1, true);
  165. }
  166. if (_gasLineNums.Contains(11))
  167. {
  168. _chamber.OpenValve(ValveType.PVB1, true);
  169. }
  170. if (_gasLineNums.Contains(12))
  171. {
  172. _chamber.OpenValve(ValveType.PVC1, true);
  173. }
  174. //2023/04/25添加vent line漏气检测
  175. if (isCheckVentLine == true)
  176. {
  177. _chamber.OpenValve(ValveType.PVN21, true);
  178. _chamber.OpenValve(ValveType.PVN22, true);
  179. _chamber.OpenValve(ValveType.N2, true);
  180. gasLines.Append("VentLine");
  181. }
  182. _leakCheckTimer.Restart();
  183. return true;
  184. }
  185. private bool PumpingDelay()
  186. {
  187. if (_leakCheckTimer.ElapsedMilliseconds >= _leakcheckPumpTime * 1000)
  188. {
  189. if (_chamber.ProcessPressure <= _leakCheckBasePressure)
  190. return true;
  191. else
  192. {
  193. Runner.Stop($"GasBox Leakcheck失败, 工艺压力 [{_chamber.ProcessPressure}]{_pressureType}, 高于LeakCheck Base Pressure: [{_leakCheckBasePressure}] {_pressureType}");
  194. }
  195. }
  196. return false;
  197. }
  198. private bool StartLeakCheck()
  199. {
  200. CurrentStep = "Leak Check";
  201. _startPressure = _chamber.ProcessPressure;
  202. pMLeakCheckResult.StartPressure = _startPressure;
  203. Notify($"PM 压力开始值 {_startPressure} {_pressureType}");
  204. _chamber.TurnPendulumValve(false);
  205. return true;
  206. }
  207. private bool CalcLeakCheckResult()
  208. {
  209. _endPressure = _chamber.ProcessPressure;
  210. pMLeakCheckResult.EndPressure = _endPressure;
  211. LeakRate = (_endPressure - _startPressure) * 60.0 / _leakcheckHoldTime;
  212. pMLeakCheckResult.LeakRate = LeakRate;
  213. if (LeakRate < _leakRate)
  214. {
  215. Notify($"GasBox Leakcheck完成, 压力结束值: {_startPressure} {_pressureType}, 漏率:{LeakRate} {_pressureType}/min");
  216. pMLeakCheckResult.Result = "Success";
  217. }
  218. else
  219. {
  220. Stop($"GasBox Leakcheck失败, 腔体漏率 [{LeakRate}] {_pressureType}/min, 高于 [{_leakRate}] {_pressureType}/min");
  221. pMLeakCheckResult.Result = "Fail";
  222. }
  223. LeakCheckDataRecorder.Add(_leakcheckHoldTime, Math.Round(_startPressure, 1), Math.Round(_endPressure, 1), LeakRate, pMLeakCheckResult.Result, pMLeakCheckResult.CheckMode, _chamber.Name, gasLines.ToString());
  224. _chamber.StopAllGases();
  225. _chamber.TurnPendulumValve(true);
  226. _chamber.OpenValve(ValveType.PV11, false);
  227. _chamber.OpenValve(ValveType.PV21, false);
  228. _chamber.OpenValve(ValveType.PV31, false);
  229. _chamber.OpenValve(ValveType.PV41, false);
  230. if (_gasLineNums.Contains(5))
  231. {
  232. _chamber.OpenValve(ValveType.PV51, false);
  233. }
  234. if (_gasLineNums.Contains(6))
  235. {
  236. _chamber.OpenValve(ValveType.PV61, false);
  237. }
  238. if (_gasLineNums.Contains(7))
  239. {
  240. _chamber.OpenValve(ValveType.PV71, false);
  241. }
  242. if (_gasLineNums.Contains(8))
  243. {
  244. _chamber.OpenValve(ValveType.PV81, false);
  245. }
  246. if (_gasLineNums.Contains(9))
  247. {
  248. _chamber.OpenValve(ValveType.PV91, false);
  249. }
  250. if (_gasLineNums.Contains(10))
  251. {
  252. _chamber.OpenValve(ValveType.PVA1, false);
  253. }
  254. if (_gasLineNums.Contains(11))
  255. {
  256. _chamber.OpenValve(ValveType.PVB1, false);
  257. }
  258. if (_gasLineNums.Contains(12))
  259. {
  260. _chamber.OpenValve(ValveType.PVC1, false);
  261. }
  262. if (_chamber.ChamberType==JetChamber.VenusSE|| _chamber.ChamberType == JetChamber.VenusDE)
  263. {
  264. _chamber.OpenValve(ValveType.PVN22, false);
  265. }
  266. pMLeakCheckResult.LeakCheckTime = (int)_routineTimer.ElapsedMilliseconds / 1000;
  267. //SerializeHelper.Instance.WriteToJsonFile<PMLeakCheckResult>(pMLeakCheckResult, $"LeakCheck/PM/{DateTime.Now.ToString("yyyyMMddHHmm")}.json");
  268. return true;
  269. }
  270. private void PreSetValves()
  271. {
  272. _chamber.OpenValve(ValveType.FastPump, false);
  273. if(_chamber.ChamberType!=JetChamber.VenusDE)
  274. {
  275. _chamber.OpenValve(ValveType.SoftPump, false);
  276. }
  277. _chamber.OpenValve(ValveType.SoftPump, false);
  278. _chamber.OpenValve(ValveType.TurboPumpPumping, true);
  279. _chamber.OpenValve(ValveType.Guage, true);
  280. _chamber.OpenValve(ValveType.GasFinal, true);
  281. _chamber.TurnPendulumValve(true);
  282. _chamber.StopAllGases();
  283. _chamber.OpenValve(ValveType.PV11, false);
  284. _chamber.OpenValve(ValveType.PV21, false);
  285. _chamber.OpenValve(ValveType.PV31, false);
  286. _chamber.OpenValve(ValveType.PV41, false);
  287. if (_gasLineNums.Contains(5))
  288. {
  289. _chamber.OpenValve(ValveType.PV51, false);
  290. }
  291. if (_gasLineNums.Contains(6))
  292. {
  293. _chamber.OpenValve(ValveType.PV61, false);
  294. }
  295. if (_gasLineNums.Contains(7))
  296. {
  297. _chamber.OpenValve(ValveType.PV71, false);
  298. }
  299. if (_gasLineNums.Contains(8))
  300. {
  301. _chamber.OpenValve(ValveType.PV81, false);
  302. }
  303. if (_gasLineNums.Contains(9))
  304. {
  305. _chamber.OpenValve(ValveType.PV91, false);
  306. }
  307. if (_gasLineNums.Contains(10))
  308. {
  309. _chamber.OpenValve(ValveType.PVA1, false);
  310. }
  311. if (_gasLineNums.Contains(11))
  312. {
  313. _chamber.OpenValve(ValveType.PVB1, false);
  314. }
  315. if (_gasLineNums.Contains(12))
  316. {
  317. _chamber.OpenValve(ValveType.PVC1, false);
  318. }
  319. }
  320. }
  321. }