GasBoxLeakCheckRoutine.cs 8.8 KB

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