PMLeakCheckRoutine.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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 Venus_Core;
  7. using System;
  8. using Venus_Unity;
  9. using MECF.Framework.Common.DBCore;
  10. namespace Venus_RT.Modules.PMs
  11. {
  12. class PMLeakCheckRoutine : 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. public string CurrentStep;
  30. private JetChamber jetChamber = JetChamber.None;
  31. Stopwatch _leakCheckTimer = new Stopwatch();
  32. PMLeakCheckResult pMLeakCheckResult;
  33. Stopwatch _routineTimer = new Stopwatch();
  34. PressureType _pressureType = PressureType.mTorr;
  35. private bool _readPenningGuagePressureFlag;
  36. private double _penningGuagePressure;
  37. public PMLeakCheckRoutine(JetPMBase chamber) : base(chamber)
  38. {
  39. jetChamber = (JetChamber)SC.GetValue<int>($"{chamber.Name}.ChamberType");
  40. Name = "PM Leakcheck";
  41. if (chamber.ChamberType == JetChamber.Kepler2200A || chamber.ChamberType == JetChamber.Kepler2200B)
  42. {
  43. _pressureType = PressureType.Pa;
  44. }
  45. }
  46. public RState Start(params object[] objs)
  47. {
  48. if (CheckLid() &&
  49. CheckSlitDoor() &&
  50. CheckTurboPump())
  51. {
  52. CurrentStep = "Pump To BasePressure";
  53. Reset();
  54. _basePressure = SC.GetValue<int>($"{Module}.Pump.PumpBasePressure");
  55. //_leakcheckPumpTime = SC.GetValue<int>($"{Module}.Pump.LeakCheckPumpingTime");
  56. //_leakcheckHoldTime = SC.GetValue<int>($"{Module}.Pump.LeakCheckHoldTime");
  57. //_leakRate = SC.GetValue<double>($"{Module}.Pump.LeakRate");
  58. _leakcheckPumpTime = (int)(objs[0]);
  59. _leakcheckHoldTime = (int)(objs[1]);
  60. _leakRate = (double)(objs[2]);
  61. _leakCheckBasePressure = SC.GetValue<double>($"{Module}.Pump.LeakCheckBasePressure");
  62. PreSetValves();
  63. pMLeakCheckResult = new PMLeakCheckResult();
  64. pMLeakCheckResult.CheckDate = DateTime.Now.ToString("yyyyMMddHHmm");
  65. pMLeakCheckResult.CheckMode = "ChamberOnly";
  66. _routineTimer.Restart();
  67. _readPenningGuagePressureFlag = false;
  68. return Runner.Start(Module, Name);
  69. }
  70. return RState.Failed;
  71. }
  72. public RState Monitor()
  73. {
  74. Runner.Wait(LeakCheckStep.kPumpToBasePressure, PumpingToBasePressure)
  75. .Run(LeakCheckStep.kPumpingDelay, StartPumpDelay, PumpingDelay , (_leakcheckPumpTime+10)*1000)
  76. .Run(LeakCheckStep.kLeakCheckDelay, StartLeakCheck, _leakcheckHoldTime * 1000)
  77. .End(LeakCheckStep.kEnd, CalcLeakCheckResult, _delay_50ms);
  78. return Runner.Status;
  79. }
  80. public void Abort()
  81. {
  82. CloseAllValves();
  83. }
  84. private bool PumpingToBasePressure()
  85. {
  86. if (_chamber.ProcessPressure <= _basePressure)
  87. {
  88. _leakCheckTimer.Restart();
  89. return true;
  90. }
  91. else
  92. return false;
  93. }
  94. private bool PumpingDelay()
  95. {
  96. if (_leakCheckTimer.ElapsedMilliseconds > (_leakcheckPumpTime - 5) * 1000 && _readPenningGuagePressureFlag==false)
  97. {
  98. _penningGuagePressure = _chamber.PenningGuagePressure;
  99. pMLeakCheckResult.BasePressure = _penningGuagePressure;
  100. _readPenningGuagePressureFlag = true;
  101. }
  102. if (_leakCheckTimer.ElapsedMilliseconds >= _leakcheckPumpTime * 1000)
  103. {
  104. if (_chamber.ProcessPressure <= _leakCheckBasePressure)
  105. return true;
  106. else
  107. {
  108. Runner.Stop($"PM Leakcheck失败, 工艺压力 [{_chamber.ProcessPressure}]{_pressureType}, 高于LeakCheck Base Pressure: [{_leakCheckBasePressure}] {_pressureType}");
  109. }
  110. }
  111. return false;
  112. }
  113. private bool StartPumpDelay()
  114. {
  115. _chamber.OpenValve(ValveType.GasFinal, false);
  116. CurrentStep = "Check Pump";
  117. return true;
  118. }
  119. private bool StartLeakCheck()
  120. {
  121. CurrentStep = "Leak Check";
  122. _startPressure = _chamber.ProcessPressure;
  123. pMLeakCheckResult.StartPressure = _startPressure;
  124. Notify($"PM 压力开始值 {_startPressure} {_pressureType}");
  125. _chamber.TurnPendulumValve(false);
  126. return true;
  127. }
  128. private bool CalcLeakCheckResult()
  129. {
  130. _endPressure = _chamber.ProcessPressure;
  131. pMLeakCheckResult.EndPressure = _endPressure;
  132. LeakRate = (_endPressure - _startPressure) * 60.0 / _leakcheckHoldTime;
  133. pMLeakCheckResult.LeakRate = LeakRate;
  134. if (LeakRate < _leakRate)
  135. {
  136. Notify($"PM Leakcheck完成, 压力结束值: {_startPressure} {_pressureType}, 漏率:{LeakRate} {_pressureType}/min");
  137. pMLeakCheckResult.Result = "Success";
  138. }
  139. else
  140. {
  141. Stop($"PM Leakcheck失败, 腔体漏率 [{LeakRate}] {_pressureType}/min, 高于 [{_leakRate}] {_pressureType}/min");
  142. pMLeakCheckResult.Result = "Fail";
  143. }
  144. if (RtInstance.ConfigType == ConfigType.Kepler2200)
  145. {
  146. LeakCheckDataRecorder.AddKepler2200(_leakcheckHoldTime, pMLeakCheckResult.BasePressure, Math.Round(_startPressure, 5), Math.Round(_endPressure, 5), LeakRate, pMLeakCheckResult.Result, "ChamberOnly", _chamber.Name);
  147. }
  148. else
  149. {
  150. LeakCheckDataRecorder.Add(_leakcheckHoldTime, Math.Round(_startPressure, 5), Math.Round(_endPressure, 5), LeakRate, pMLeakCheckResult.Result, "ChamberOnly", _chamber.Name);
  151. }
  152. _chamber.OpenValve(ValveType.GasFinal, true);
  153. _chamber.TurnPendulumValve(true);
  154. pMLeakCheckResult.LeakCheckTime = (int)_routineTimer.ElapsedMilliseconds / 1000;
  155. //SerializeHelper.Instance.WriteToJsonFile<PMLeakCheckResult>(pMLeakCheckResult, $"LeakCheck/PM/{DateTime.Now.ToString("yyyyMMddHHmm")}.json");
  156. return true;
  157. }
  158. private void PreSetValves()
  159. {
  160. _chamber.OpenValve(ValveType.FastPump, false);
  161. if (jetChamber != JetChamber.VenusDE)
  162. {
  163. _chamber.OpenValve(ValveType.SoftPump, false);
  164. }
  165. _chamber.OpenValve(ValveType.TurboPumpPumping, true);
  166. _chamber.OpenValve(ValveType.Guage, true);
  167. _chamber.OpenValve(ValveType.GasFinal, true);
  168. _chamber.TurnPendulumValve(true);
  169. }
  170. }
  171. }