using Aitex.Core.RT.Routine; using Aitex.Core.RT.SCCore; using Venus_RT.Devices; using MECF.Framework.Common.Routine; using System.Diagnostics; using System.Collections.Generic; using Venus_Core; using System; using Venus_Unity; namespace Venus_RT.Modules.PMs { class GasBoxLeakCheckRoutine : PMRoutineBase, IRoutine { private enum LeakCheckStep { kPumpToBasePressure, kPumpingDelay, kLeakCheckDelay, kEnd, } public double LeakRate { get; private set; } private readonly double _GasFlow = 1.0; private int _basePressure = 100; private int _leakcheckPumpTime = 180; private int _leakcheckHoldTime = 300; private double _startPressure = 0; private double _endPressure = 0; private double _leakRate = 30.0; private double _leakCheckBasePressure = 1; private List _gasLineNums = new List(); Stopwatch _leakCheckTimer = new Stopwatch(); bool isCheckVentLine; PMLeakCheckResult pMLeakCheckResult; Stopwatch _routineTimer = new Stopwatch(); public GasBoxLeakCheckRoutine(JetPM chamber) : base(chamber) { Name = "GasBox Leakcheck"; } public RState Start(params object[] objs) { if (CheckLidLoadLock() && CheckSlitDoor() && CheckTurboPump()) { Reset(); _basePressure = SC.GetValue($"{Module}.Pump.PumpBasePressure"); //_leakcheckPumpTime = SC.GetValue($"{Module}.Pump.LeakCheckPumpingTime"); //_leakcheckHoldTime = SC.GetValue($"{Module}.Pump.LeakCheckHoldTime"); //_leakRate = SC.GetValue($"{Module}.Pump.LeakRate"); _leakcheckPumpTime = (int)(objs[0]); _leakcheckHoldTime = (int)(objs[1]); _leakRate = (double)(objs[2]); _leakCheckBasePressure = SC.GetValue($"{Module}.Pump.LeakCheckBasePressure"); // Extract line numbers which need do Leakcheck from config file _gasLineNums.Clear(); //var lineNums = SC.GetStringValue($"{Module}.Pump.LeakCheckGasLineNums").Split(','); var lineNums = objs[3].ToString().Split(','); int nNum; foreach(string num in lineNums) { if(int.TryParse(num, out nNum)) { if(nNum > 0 && nNum <= 8 && !_gasLineNums.Contains(nNum)) { _gasLineNums.Add(nNum); } } } isCheckVentLine = (bool)objs[4]; pMLeakCheckResult = new PMLeakCheckResult(); pMLeakCheckResult.CheckMode = $"{objs[5].ToString()}({objs[3].ToString()})"; if (_gasLineNums.Count == 0 && isCheckVentLine==false) { Stop($"No Gasline need do LeakCheck, please check the config item{Module}.Pump.LeakCheckGasLineNums"); return RState.Failed; } PreSetValves(); pMLeakCheckResult.CheckDate = DateTime.Now.ToString("yyyyMMddHHmm"); _routineTimer.Restart(); Reset(); return Runner.Start(Module, Name); } return RState.Failed; } public RState Monitor() { Runner.Wait((int)LeakCheckStep.kPumpToBasePressure, ()=> { return _chamber.ChamberPressure <= _basePressure; }) .Run((int)LeakCheckStep.kPumpingDelay, LeakCheckPumping, PumpingDelay) .Run((int)LeakCheckStep.kLeakCheckDelay, StartLeakCheck, _leakcheckHoldTime * 1000) .End((int)LeakCheckStep.kEnd, CalcLeakCheckResult, _delay_50ms); return Runner.Status; } public void Abort() { CloseAllValves(); } private bool LeakCheckPumping() { foreach(var num in _gasLineNums) { _chamber.FlowGas(num-1, _GasFlow); } _chamber.OpenValve(ValveType.PV11, true); _chamber.OpenValve(ValveType.PV21, true); _chamber.OpenValve(ValveType.PV31, true); _chamber.OpenValve(ValveType.PV41, true); //2023/04/25添加vent line漏气检测 if (isCheckVentLine == true) { _chamber.OpenValve(ValveType.PVN21, true); _chamber.OpenValve(ValveType.PVN22, true); _chamber.OpenValve(ValveType.N2, true); } _leakCheckTimer.Restart(); return true; } private bool PumpingDelay() { if (_leakCheckTimer.ElapsedMilliseconds >= _leakcheckPumpTime * 1000) { if (_chamber.ChamberPressure <= _leakCheckBasePressure) return true; else { Runner.Stop($"GasBox Leakcheck失败, 腔体压力 [{_chamber.ChamberPressure}]mTor, 高于LeakCheck Base Pressure: [{_leakCheckBasePressure}] mTor"); } } return false; } private bool StartLeakCheck() { _startPressure = _chamber.ChamberPressure; pMLeakCheckResult.StartPressure = _startPressure; Notify($"PM 压力开始值 {_startPressure} mt"); _chamber.TurnPendulumValve(false); return true; } private bool CalcLeakCheckResult() { _endPressure = _chamber.ChamberPressure; pMLeakCheckResult.EndPressure = _endPressure; LeakRate = (_endPressure - _startPressure) * 60.0 / _leakcheckHoldTime; pMLeakCheckResult.LeakRate = LeakRate; if (LeakRate < _leakRate) { Notify($"GasBox Leakcheck完成, 压力结束值: {_startPressure} mt, 漏率:{LeakRate} mt/min"); pMLeakCheckResult.Result = "Success"; } else { Stop($"GasBox Leakcheck失败, 腔体漏率 [{LeakRate}] mt/min, 高于 [{_leakRate}] mt/min"); pMLeakCheckResult.Result = "Fail"; } _chamber.StopAllGases(); _chamber.TurnPendulumValve(true); _chamber.OpenValve(ValveType.PV11, false); _chamber.OpenValve(ValveType.PV21, false); _chamber.OpenValve(ValveType.PV31, false); _chamber.OpenValve(ValveType.PV41, false); pMLeakCheckResult.LeakCheckTime = (int)_routineTimer.ElapsedMilliseconds / 1000; SerializeHelper.Instance.WriteToJsonFile(pMLeakCheckResult, $"LeakCheck/PM/{DateTime.Now.ToString("yyyyMMddHHmm")}.json"); return true; } private void PreSetValves() { _chamber.OpenValve(ValveType.FastPump, false); _chamber.OpenValve(ValveType.SoftPump, false); _chamber.OpenValve(ValveType.TurboPumpPumping, true); _chamber.OpenValve(ValveType.Guage, true); _chamber.OpenValve(ValveType.GasFinal, true); _chamber.TurnPendulumValve(true); _chamber.StopAllGases(); _chamber.OpenValve(ValveType.PV11, false); _chamber.OpenValve(ValveType.PV21, false); _chamber.OpenValve(ValveType.PV31, false); _chamber.OpenValve(ValveType.PV41, false); } } }