GasBoxLeakCheckRoutine.cs 7.7 KB

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