GasBoxLeakCheckRoutine.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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. //2023/04/25添加vent line漏气检测
  143. if (isCheckVentLine == true)
  144. {
  145. _chamber.OpenValve(ValveType.PVN21, true);
  146. _chamber.OpenValve(ValveType.PVN22, true);
  147. _chamber.OpenValve(ValveType.N2, true);
  148. gasLines.Append("VentLine");
  149. }
  150. _leakCheckTimer.Restart();
  151. return true;
  152. }
  153. private bool PumpingDelay()
  154. {
  155. if (_leakCheckTimer.ElapsedMilliseconds >= _leakcheckPumpTime * 1000)
  156. {
  157. if (_chamber.ProcessPressure <= _leakCheckBasePressure)
  158. return true;
  159. else
  160. {
  161. Runner.Stop($"GasBox Leakcheck失败, 工艺压力 [{_chamber.ProcessPressure}]{_pressureType}, 高于LeakCheck Base Pressure: [{_leakCheckBasePressure}] {_pressureType}");
  162. }
  163. }
  164. return false;
  165. }
  166. private bool StartLeakCheck()
  167. {
  168. CurrentStep = "Leak Check";
  169. _startPressure = _chamber.ProcessPressure;
  170. pMLeakCheckResult.StartPressure = _startPressure;
  171. Notify($"PM 压力开始值 {_startPressure} {_pressureType}");
  172. _chamber.TurnPendulumValve(false);
  173. return true;
  174. }
  175. private bool CalcLeakCheckResult()
  176. {
  177. _endPressure = _chamber.ProcessPressure;
  178. pMLeakCheckResult.EndPressure = _endPressure;
  179. LeakRate = (_endPressure - _startPressure) * 60.0 / _leakcheckHoldTime;
  180. pMLeakCheckResult.LeakRate = LeakRate;
  181. if (LeakRate < _leakRate)
  182. {
  183. Notify($"GasBox Leakcheck完成, 压力结束值: {_startPressure} {_pressureType}, 漏率:{LeakRate} {_pressureType}/min");
  184. pMLeakCheckResult.Result = "Success";
  185. }
  186. else
  187. {
  188. Stop($"GasBox Leakcheck失败, 腔体漏率 [{LeakRate}] {_pressureType}/min, 高于 [{_leakRate}] {_pressureType}/min");
  189. pMLeakCheckResult.Result = "Fail";
  190. }
  191. LeakCheckDataRecorder.Add(_leakcheckHoldTime, Math.Round(_startPressure, 1), Math.Round(_endPressure, 1), LeakRate, pMLeakCheckResult.Result, pMLeakCheckResult.CheckMode, _chamber.Name, gasLines.ToString());
  192. _chamber.StopAllGases();
  193. _chamber.TurnPendulumValve(true);
  194. _chamber.OpenValve(ValveType.PV11, false);
  195. _chamber.OpenValve(ValveType.PV21, false);
  196. _chamber.OpenValve(ValveType.PV31, false);
  197. _chamber.OpenValve(ValveType.PV41, false);
  198. if(_chamber.ChamberType==JetChamber.VenusSE|| _chamber.ChamberType == JetChamber.VenusDE)
  199. {
  200. _chamber.OpenValve(ValveType.PVN22, false);
  201. }
  202. pMLeakCheckResult.LeakCheckTime = (int)_routineTimer.ElapsedMilliseconds / 1000;
  203. //SerializeHelper.Instance.WriteToJsonFile<PMLeakCheckResult>(pMLeakCheckResult, $"LeakCheck/PM/{DateTime.Now.ToString("yyyyMMddHHmm")}.json");
  204. return true;
  205. }
  206. private void PreSetValves()
  207. {
  208. _chamber.OpenValve(ValveType.FastPump, false);
  209. if(_chamber.ChamberType!=JetChamber.VenusDE)
  210. {
  211. _chamber.OpenValve(ValveType.SoftPump, false);
  212. }
  213. _chamber.OpenValve(ValveType.SoftPump, false);
  214. _chamber.OpenValve(ValveType.TurboPumpPumping, true);
  215. _chamber.OpenValve(ValveType.Guage, true);
  216. _chamber.OpenValve(ValveType.GasFinal, true);
  217. _chamber.TurnPendulumValve(true);
  218. _chamber.StopAllGases();
  219. _chamber.OpenValve(ValveType.PV11, false);
  220. _chamber.OpenValve(ValveType.PV21, false);
  221. _chamber.OpenValve(ValveType.PV31, false);
  222. _chamber.OpenValve(ValveType.PV41, false);
  223. }
  224. }
  225. }