GasBoxLeakCheckRoutine.cs 9.1 KB

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