GasBoxLeakCheckRoutine.cs 7.9 KB

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