GasBoxLeakCheckRoutine.cs 8.3 KB

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