GasBoxLeakCheckRoutine.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. }
  73. foreach(string num in lineNums)
  74. {
  75. if(int.TryParse(num, out nNum))
  76. {
  77. if(nNum > 0 && nNum <= allGas && !_gasLineNums.Contains(nNum))
  78. {
  79. _gasLineNums.Add(nNum);
  80. }
  81. }
  82. }
  83. isCheckVentLine = (bool)objs[4];
  84. pMLeakCheckResult = new PMLeakCheckResult();
  85. pMLeakCheckResult.CheckMode = objs[5].ToString();
  86. if (_gasLineNums.Count == 0 && isCheckVentLine==false)
  87. {
  88. Stop($"No Gasline need do LeakCheck, please check the config item{Module}.Pump.LeakCheckGasLineNums");
  89. return RState.Failed;
  90. }
  91. gasLines.Clear();
  92. PreSetValves();
  93. pMLeakCheckResult.CheckDate = DateTime.Now.ToString("yyyyMMddHHmm");
  94. _routineTimer.Restart();
  95. Reset();
  96. return Runner.Start(Module, Name);
  97. }
  98. return RState.Failed;
  99. }
  100. public RState Monitor()
  101. {
  102. Runner.Wait(LeakCheckStep.kPumpToBasePressure, ()=> { return _chamber.ProcessPressure <= _basePressure; })
  103. .Run(LeakCheckStep.kPumpingDelay, LeakCheckPumping, PumpingDelay)
  104. .Run(LeakCheckStep.kLeakCheckDelay, StartLeakCheck, _leakcheckHoldTime * 1000)
  105. .End(LeakCheckStep.kEnd, CalcLeakCheckResult, _delay_50ms);
  106. return Runner.Status;
  107. }
  108. public void Abort()
  109. {
  110. CloseAllValves();
  111. }
  112. private bool LeakCheckPumping()
  113. {
  114. CurrentStep = "Check Pump";
  115. foreach (var num in _gasLineNums)
  116. {
  117. var _MfcN2Scale = SC.GetValue<int>($"{Module}.MfcGas{num}.MfcN2Scale");
  118. var _MfcScaleFactor = SC.GetValue<Double>($"{Module}.MfcGas{num}.MfcScaleFactor");
  119. var _GasFlow = _MfcN2Scale * _MfcScaleFactor;
  120. _chamber.FlowGas(num-1, _GasFlow);
  121. gasLines.Append($"Gas{num},");
  122. }
  123. if (_gasLineNums.Contains(1))
  124. {
  125. _chamber.OpenValve(ValveType.PV11, true);
  126. }
  127. if (_gasLineNums.Contains(2))
  128. {
  129. _chamber.OpenValve(ValveType.PV21, true);
  130. }
  131. if (_gasLineNums.Contains(3))
  132. {
  133. _chamber.OpenValve(ValveType.PV31, true);
  134. }
  135. if (_gasLineNums.Contains(4))
  136. {
  137. _chamber.OpenValve(ValveType.PV41, true);
  138. }
  139. //2023/04/25添加vent line漏气检测
  140. if (isCheckVentLine == true)
  141. {
  142. _chamber.OpenValve(ValveType.PVN21, true);
  143. _chamber.OpenValve(ValveType.PVN22, true);
  144. _chamber.OpenValve(ValveType.N2, true);
  145. gasLines.Append("VentLine");
  146. }
  147. _leakCheckTimer.Restart();
  148. return true;
  149. }
  150. private bool PumpingDelay()
  151. {
  152. if (_leakCheckTimer.ElapsedMilliseconds >= _leakcheckPumpTime * 1000)
  153. {
  154. if (_chamber.ProcessPressure <= _leakCheckBasePressure)
  155. return true;
  156. else
  157. {
  158. Runner.Stop($"GasBox Leakcheck失败, 工艺压力 [{_chamber.ProcessPressure}]{_pressureType}, 高于LeakCheck Base Pressure: [{_leakCheckBasePressure}] {_pressureType}");
  159. }
  160. }
  161. return false;
  162. }
  163. private bool StartLeakCheck()
  164. {
  165. CurrentStep = "Leak Check";
  166. _startPressure = _chamber.ProcessPressure;
  167. pMLeakCheckResult.StartPressure = _startPressure;
  168. Notify($"PM 压力开始值 {_startPressure} {_pressureType}");
  169. _chamber.TurnPendulumValve(false);
  170. return true;
  171. }
  172. private bool CalcLeakCheckResult()
  173. {
  174. _endPressure = _chamber.ProcessPressure;
  175. pMLeakCheckResult.EndPressure = _endPressure;
  176. LeakRate = (_endPressure - _startPressure) * 60.0 / _leakcheckHoldTime;
  177. pMLeakCheckResult.LeakRate = LeakRate;
  178. if (LeakRate < _leakRate)
  179. {
  180. Notify($"GasBox Leakcheck完成, 压力结束值: {_startPressure} {_pressureType}, 漏率:{LeakRate} {_pressureType}/min");
  181. pMLeakCheckResult.Result = "Success";
  182. }
  183. else
  184. {
  185. Stop($"GasBox Leakcheck失败, 腔体漏率 [{LeakRate}] {_pressureType}/min, 高于 [{_leakRate}] {_pressureType}/min");
  186. pMLeakCheckResult.Result = "Fail";
  187. }
  188. LeakCheckDataRecorder.Add(_leakcheckHoldTime, Math.Round(_startPressure, 1), Math.Round(_endPressure, 1), LeakRate, pMLeakCheckResult.Result, pMLeakCheckResult.CheckMode, _chamber.Name, gasLines.ToString());
  189. _chamber.StopAllGases();
  190. _chamber.TurnPendulumValve(true);
  191. _chamber.OpenValve(ValveType.PV11, false);
  192. _chamber.OpenValve(ValveType.PV21, false);
  193. _chamber.OpenValve(ValveType.PV31, false);
  194. _chamber.OpenValve(ValveType.PV41, false);
  195. pMLeakCheckResult.LeakCheckTime = (int)_routineTimer.ElapsedMilliseconds / 1000;
  196. //SerializeHelper.Instance.WriteToJsonFile<PMLeakCheckResult>(pMLeakCheckResult, $"LeakCheck/PM/{DateTime.Now.ToString("yyyyMMddHHmm")}.json");
  197. return true;
  198. }
  199. private void PreSetValves()
  200. {
  201. _chamber.OpenValve(ValveType.FastPump, false);
  202. _chamber.OpenValve(ValveType.SoftPump, false);
  203. _chamber.OpenValve(ValveType.TurboPumpPumping, true);
  204. _chamber.OpenValve(ValveType.Guage, true);
  205. _chamber.OpenValve(ValveType.GasFinal, true);
  206. _chamber.TurnPendulumValve(true);
  207. _chamber.StopAllGases();
  208. _chamber.OpenValve(ValveType.PV11, false);
  209. _chamber.OpenValve(ValveType.PV21, false);
  210. _chamber.OpenValve(ValveType.PV31, false);
  211. _chamber.OpenValve(ValveType.PV41, false);
  212. }
  213. }
  214. }