| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349 | 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;using MECF.Framework.Common.DBCore;using System.Text;namespace Venus_RT.Modules.PMs{    class GasBoxLeakCheckRoutine : PMRoutineBase, IRoutine    {        private enum LeakCheckStep        {            kPumpToBasePressure,            kPumpingDelay,            kLeakCheckDelay,            kEnd,        }        public double LeakRate { get; private set; }        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<int> _gasLineNums = new List<int>();        Stopwatch _leakCheckTimer = new Stopwatch();        bool isCheckVentLine;        PMLeakCheckResult pMLeakCheckResult;        Stopwatch _routineTimer = new Stopwatch();        StringBuilder  gasLines=new StringBuilder();        public string CurrentStep;        PressureType _pressureType = PressureType.mTorr;        public GasBoxLeakCheckRoutine(JetPMBase chamber) : base(chamber)        {            Name = "GasBox Leakcheck";            if (chamber.ChamberType == JetChamber.Kepler2200A || chamber.ChamberType == JetChamber.Kepler2200B)            {                _pressureType = PressureType.Pa;            }        }        public RState Start(params object[] objs)        {            if (CheckLid() &&                CheckSlitDoor() &&                CheckTurboPump())            {                CurrentStep = "Pump To BasePressure";                Reset();                _basePressure = SC.GetValue<int>($"{Module}.Pump.PumpBasePressure");                //_leakcheckPumpTime = SC.GetValue<int>($"{Module}.Pump.LeakCheckPumpingTime");                //_leakcheckHoldTime = SC.GetValue<int>($"{Module}.Pump.LeakCheckHoldTime");                //_leakRate = SC.GetValue<double>($"{Module}.Pump.LeakRate");                _leakcheckPumpTime = (int)(objs[0]);                _leakcheckHoldTime = (int)(objs[1]);                _leakRate = (double)(objs[2]);                _leakCheckBasePressure = SC.GetValue<double>($"{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;                int allGas=8;                if (_chamber.ChamberType == JetChamber.Kepler2200A || _chamber.ChamberType == JetChamber.Kepler2200B)                {                    allGas = 6;                }else if (_chamber.ChamberType == JetChamber.VenusSE || _chamber.ChamberType == JetChamber.VenusDE)                {                    allGas = 10;                }                    foreach (string num in lineNums)                {                    if(int.TryParse(num, out nNum))                    {                        if(nNum > 0 && nNum <= allGas && !_gasLineNums.Contains(nNum))                        {                            _gasLineNums.Add(nNum);                        }                    }                }                isCheckVentLine = (bool)objs[4];                pMLeakCheckResult = new PMLeakCheckResult();                pMLeakCheckResult.CheckMode = objs[5].ToString();                if (_gasLineNums.Count == 0 && isCheckVentLine==false)                {                    Stop($"No Gasline need do LeakCheck, please check the config item{Module}.Pump.LeakCheckGasLineNums");                    return RState.Failed;                }                gasLines.Clear();                PreSetValves();                pMLeakCheckResult.CheckDate = DateTime.Now.ToString("yyyyMMddHHmm");                _routineTimer.Restart();                Reset();                return Runner.Start(Module, Name);            }            return RState.Failed;        }        public RState Monitor()        {            Runner.Wait(LeakCheckStep.kPumpToBasePressure,                                                     ()=> { return _chamber.ProcessPressure <= _basePressure; })                .Run(LeakCheckStep.kPumpingDelay,          LeakCheckPumping,                                   PumpingDelay)                .Run(LeakCheckStep.kLeakCheckDelay,        StartLeakCheck,                                     _leakcheckHoldTime * 1000)                .End(LeakCheckStep.kEnd,                   CalcLeakCheckResult,                                _delay_50ms);            return Runner.Status;        }        public void Abort()        {            CloseAllValves();        }        private bool LeakCheckPumping()        {            CurrentStep = "Check Pump";            foreach (var num in _gasLineNums)            {                             var _MfcN2Scale = SC.GetValue<int>($"{Module}.MfcGas{num}.MfcN2Scale");                var _MfcScaleFactor = SC.GetValue<Double>($"{Module}.MfcGas{num}.MfcScaleFactor");                var _GasFlow = _MfcN2Scale * _MfcScaleFactor;                _chamber.FlowGas(num-1, _GasFlow);                gasLines.Append($"Gas{num},");            }            if (_gasLineNums.Contains(1))            {                _chamber.OpenValve(ValveType.PV11, true);            }            if (_gasLineNums.Contains(2))            {                _chamber.OpenValve(ValveType.PV21, true);            }            if (_gasLineNums.Contains(3))            {                _chamber.OpenValve(ValveType.PV31, true);            }            if (_gasLineNums.Contains(4))            {                _chamber.OpenValve(ValveType.PV41, true);            }            if (_gasLineNums.Contains(5))            {                _chamber.OpenValve(ValveType.PV51, true);            }            if (_gasLineNums.Contains(6))            {                _chamber.OpenValve(ValveType.PV61, true);            }            if (_gasLineNums.Contains(7))            {                _chamber.OpenValve(ValveType.PV71, true);            }            if (_gasLineNums.Contains(8))            {                _chamber.OpenValve(ValveType.PV81, true);            }            if (_gasLineNums.Contains(9))            {                _chamber.OpenValve(ValveType.PV91, true);            }            if (_gasLineNums.Contains(10))            {                _chamber.OpenValve(ValveType.PVA1, true);            }            if (_gasLineNums.Contains(11))            {                _chamber.OpenValve(ValveType.PVB1, true);            }            if (_gasLineNums.Contains(12))            {                _chamber.OpenValve(ValveType.PVC1, true);            }            //2023/04/25添加vent line漏气检测            if (isCheckVentLine == true)            {                _chamber.OpenValve(ValveType.PVN21, true);                _chamber.OpenValve(ValveType.PVN22, true);                _chamber.OpenValve(ValveType.N2, true);                gasLines.Append("VentLine");            }            _leakCheckTimer.Restart();            return true;        }        private bool PumpingDelay()        {            if (_leakCheckTimer.ElapsedMilliseconds >= _leakcheckPumpTime * 1000)            {                if (_chamber.ProcessPressure <= _leakCheckBasePressure)                    return true;                else                {                    Runner.Stop($"GasBox Leakcheck失败, 工艺压力 [{_chamber.ProcessPressure}]{_pressureType}, 高于LeakCheck Base Pressure: [{_leakCheckBasePressure}] {_pressureType}");                }            }            return false;        }        private bool StartLeakCheck()        {            CurrentStep = "Leak Check";            _startPressure = _chamber.ProcessPressure;            pMLeakCheckResult.StartPressure = _startPressure;            Notify($"PM 压力开始值 {_startPressure} {_pressureType}");            _chamber.TurnPendulumValve(false);            return true;        }        private bool CalcLeakCheckResult()        {            _endPressure = _chamber.ProcessPressure;            pMLeakCheckResult.EndPressure = _endPressure;            LeakRate = (_endPressure - _startPressure) * 60.0 / _leakcheckHoldTime;            pMLeakCheckResult.LeakRate = LeakRate;            if (LeakRate < _leakRate)            {                Notify($"GasBox Leakcheck完成, 压力结束值: {_startPressure} {_pressureType}, 漏率:{LeakRate} {_pressureType}/min");                pMLeakCheckResult.Result = "Success";            }            else            {                Stop($"GasBox Leakcheck失败, 腔体漏率 [{LeakRate}] {_pressureType}/min, 高于 [{_leakRate}] {_pressureType}/min");                pMLeakCheckResult.Result = "Fail";            }            LeakCheckDataRecorder.Add(_leakcheckHoldTime, Math.Round(_startPressure, 1), Math.Round(_endPressure, 1), LeakRate, pMLeakCheckResult.Result, pMLeakCheckResult.CheckMode, _chamber.Name, gasLines.ToString());            _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);            if (_gasLineNums.Contains(5))            {                _chamber.OpenValve(ValveType.PV51, false);            }            if (_gasLineNums.Contains(6))            {                _chamber.OpenValve(ValveType.PV61, false);            }            if (_gasLineNums.Contains(7))            {                _chamber.OpenValve(ValveType.PV71, false);            }            if (_gasLineNums.Contains(8))            {                _chamber.OpenValve(ValveType.PV81, false);            }            if (_gasLineNums.Contains(9))            {                _chamber.OpenValve(ValveType.PV91, false);            }            if (_gasLineNums.Contains(10))            {                _chamber.OpenValve(ValveType.PVA1, false);            }            if (_gasLineNums.Contains(11))            {                _chamber.OpenValve(ValveType.PVB1, false);            }            if (_gasLineNums.Contains(12))            {                _chamber.OpenValve(ValveType.PVC1, false);            }            if (_chamber.ChamberType==JetChamber.VenusSE|| _chamber.ChamberType == JetChamber.VenusDE)            {                _chamber.OpenValve(ValveType.PVN22, false);            }            pMLeakCheckResult.LeakCheckTime = (int)_routineTimer.ElapsedMilliseconds / 1000;            //SerializeHelper.Instance.WriteToJsonFile<PMLeakCheckResult>(pMLeakCheckResult, $"LeakCheck/PM/{DateTime.Now.ToString("yyyyMMddHHmm")}.json");            return true;        }        private void PreSetValves()        {            _chamber.OpenValve(ValveType.FastPump, false);            if(_chamber.ChamberType!=JetChamber.VenusDE)             {                _chamber.OpenValve(ValveType.SoftPump, 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);            if (_gasLineNums.Contains(5))            {                _chamber.OpenValve(ValveType.PV51, false);            }            if (_gasLineNums.Contains(6))            {                _chamber.OpenValve(ValveType.PV61, false);            }            if (_gasLineNums.Contains(7))            {                _chamber.OpenValve(ValveType.PV71, false);            }            if (_gasLineNums.Contains(8))            {                _chamber.OpenValve(ValveType.PV81, false);            }            if (_gasLineNums.Contains(9))            {                _chamber.OpenValve(ValveType.PV91, false);            }            if (_gasLineNums.Contains(10))            {                _chamber.OpenValve(ValveType.PVA1, false);            }            if (_gasLineNums.Contains(11))            {                _chamber.OpenValve(ValveType.PVB1, false);            }            if (_gasLineNums.Contains(12))            {                _chamber.OpenValve(ValveType.PVC1, false);            }        }    }}
 |