123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466 |
- using System;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using VirgoCommon;
- using VirgoRT.Devices;
- namespace VirgoRT.Modules.PMs
- {
- class LeakCheckRoutine : PMRoutineBase
- {
- private enum LeakCheckStep
- {
- PumpDown,
- CheckDoor,
- CheckDryPump,
- CloseAllValve,
- OpenPumpingValve,
- OpenGasFinalValve,
- CloseGasFinalValve,
- OpenMfc1Valve,
- OpenMfc2Valve,
- OpenMfc3Valve,
- OpenMfc4Valve,
- OpenMfc5Valve,
- CloseMfc1Valve,
- CloseMfc2Valve,
- CloseMfc3Valve,
- CloseMfc4Valve,
- CloseMfc5Valve,
- StartFlow,
- StopFlow,
- RecordStartPressure,
- RecordEndPressure,
- PumpDownDelay,
- StartPressureDelay,
- EndPressureDelay,
- ClosePumpValve,
- LeakCheckDelay,
- CalcLeakCheck,
- End,
- EndLeakCheck,
- AbortLeakCheck,
- CheckPressure
- };
- // Fields
- private double _beginPressure = 0;
- private double _endPressure = 0;
- private double _leakRate;
- public double LeakRate { get; private set; }
- private int _leakCheckPumpDownTime;
- private int _leakCheckWaitTime;
- private LeakCheckMode _mode;
- private bool[] _enableGasLine = new bool[5];
- private double[] _mfcFlow = new double[5];
- private readonly PumpDownRoutine _pumpdownRoutine;
- // Properties
- //
- public int ElapseTime => (int)(delayTimer.GetElapseTime() / 1000.0);
- // Constructor
- //
- public LeakCheckRoutine(JetPM chamber, PumpDownRoutine _pdRoutine) : base(chamber)
- {
- Name = "leak check";
- bUINotify = true;
- _pumpdownRoutine = _pdRoutine;
- }
- public void Terminate()
- {
- }
- public Result Start(params object[] objs)
- {
- // 预检查
- if (CheckLid() == Result.RUN &&
- CheckSlitDoor() == Result.RUN &&
- CheckDryPump() == Result.RUN)
- {
- _enableGasLine = new bool[5] { false, false, false, false, false };
- _mfcFlow = new double[5] { 0.0, 0.0, 0.0, 0.0, 0.0 };
- Reset();
- delayTimer.Start(0);
- try
- {
- if (objs.Length == 0)
- {
- _leakCheckPumpDownTime = SC.GetValue<int>($"{Module}.Pump.LeakCheckPumpingTime");
- _leakCheckWaitTime = SC.GetValue<int>($"{Module}.Pump.LeakCheckWaitTime");
- _leakRate = SC.GetValue<double>($"{Module}.Pump.LeakRate");
- _mode = LeakCheckMode.ChamberOnly;
- }
- else
- {
- _leakCheckPumpDownTime = Convert.ToInt32(objs[0].ToString());
- _leakCheckWaitTime = Convert.ToInt32(objs[1].ToString());
- _mode = (LeakCheckMode)Enum.Parse(typeof(LeakCheckMode), objs[2].ToString());
- _leakRate = Convert.ToInt32(objs[3].ToString());
- for (int i = 0; i < 5; i++)
- _enableGasLine[i] = Convert.ToBoolean(objs[4 + i].ToString());
- }
- for (int i = 0; i < 5; i++)
- {
- if (_enableGasLine[i]) _mfcFlow[i] = SC.GetValue<int>($"{Module}.MfcGas{i + 1}.MfcN2Scale");
- }
- }
- catch (Exception ex)
- {
- LOG.Write(ex);
- return Result.FAIL;
- }
-
- return Result.RUN;
- }
- return Result.FAIL;
- }
- public Result Monitor()
- {
- try
- {
- ExecuteRoutine((int)LeakCheckStep.PumpDown, _pumpdownRoutine);
- if (_mode == LeakCheckMode.ChamberOnly)
- {
- ;
- }
- else if (_mode == LeakCheckMode.ChamberAndGasLine)
- {
- SetValve((int)LeakCheckStep.OpenGasFinalValve, ValveType.PROCESS, true);
- if (_enableGasLine[0]) SetValve((int)LeakCheckStep.OpenMfc1Valve, ValveType.Mfc1, true);
- if (_enableGasLine[1]) SetValve((int)LeakCheckStep.OpenMfc2Valve, ValveType.Mfc2, true);
- if (_enableGasLine[2]) SetValve((int)LeakCheckStep.OpenMfc3Valve, ValveType.Mfc3, true);
- if (_enableGasLine[3]) SetValve((int)LeakCheckStep.OpenMfc4Valve, ValveType.Mfc4, true);
- if (_enableGasLine[4]) SetValve((int)LeakCheckStep.OpenMfc5Valve, ValveType.Mfc5, true);
- }
- else if (_mode == LeakCheckMode.ChamberAndGasLineAndFAC)
- {
- SetValve((int)LeakCheckStep.OpenGasFinalValve, ValveType.PROCESS, true);
- if (_enableGasLine[0]) SetValve((int)LeakCheckStep.OpenMfc1Valve, ValveType.Mfc1, true);
- if (_enableGasLine[1]) SetValve((int)LeakCheckStep.OpenMfc2Valve, ValveType.Mfc2, true);
- if (_enableGasLine[2]) SetValve((int)LeakCheckStep.OpenMfc3Valve, ValveType.Mfc3, true);
- if (_enableGasLine[3]) SetValve((int)LeakCheckStep.OpenMfc4Valve, ValveType.Mfc4, true);
- if (_enableGasLine[4]) SetValve((int)LeakCheckStep.OpenMfc5Valve, ValveType.Mfc5, true);
- StartFlowMFC((int)LeakCheckStep.StartFlow, _mfcFlow);
- }
- TimeDelay((int)LeakCheckStep.PumpDownDelay, _leakCheckPumpDownTime);
- SetValve((int)LeakCheckStep.ClosePumpValve, ValveType.FAST_PUMP, false);
-
- //记录腔体Start pressure P1
- RecordBeginPressure((int)LeakCheckStep.RecordStartPressure);
- //pump down delay
- TimeDelay((int)LeakCheckStep.EndPressureDelay, _leakCheckWaitTime);
- //记录腔体End pressure P2
- RecordEndPressure((int)LeakCheckStep.RecordEndPressure);
- CalcLeakCheck((int)LeakCheckStep.CalcLeakCheck, _leakRate, _leakCheckWaitTime, 0);
- if (_mode == LeakCheckMode.ChamberOnly)
- {
- ;
- }
- else if (_mode == LeakCheckMode.ChamberAndGasLine)
- {
- SetValve((int)LeakCheckStep.CloseGasFinalValve, ValveType.PROCESS, false);
- if (_enableGasLine[0]) SetValve((int)LeakCheckStep.CloseMfc1Valve, ValveType.Mfc1, false);
- if (_enableGasLine[1]) SetValve((int)LeakCheckStep.CloseMfc2Valve, ValveType.Mfc2, false);
- if (_enableGasLine[2]) SetValve((int)LeakCheckStep.CloseMfc3Valve, ValveType.Mfc3, false);
- if (_enableGasLine[3]) SetValve((int)LeakCheckStep.CloseMfc4Valve, ValveType.Mfc4, false);
- if (_enableGasLine[4]) SetValve((int)LeakCheckStep.CloseMfc5Valve, ValveType.Mfc5, false);
- }
- else if (_mode == LeakCheckMode.ChamberAndGasLineAndFAC)
- {
- SetValve((int)LeakCheckStep.CloseGasFinalValve, ValveType.PROCESS, false);
- if (_enableGasLine[0]) SetValve((int)LeakCheckStep.CloseMfc1Valve, ValveType.Mfc1, false);
- if (_enableGasLine[1]) SetValve((int)LeakCheckStep.CloseMfc2Valve, ValveType.Mfc2, false);
- if (_enableGasLine[2]) SetValve((int)LeakCheckStep.CloseMfc3Valve, ValveType.Mfc3, false);
- if (_enableGasLine[3]) SetValve((int)LeakCheckStep.CloseMfc4Valve, ValveType.Mfc4, false);
- if (_enableGasLine[4]) SetValve((int)LeakCheckStep.CloseMfc5Valve, ValveType.Mfc5, false);
- StopFlowMFC((int)LeakCheckStep.StopFlow);
- }
- End((int)LeakCheckStep.End);
- //ExecuteRoutine((int)LeakCheckStep.EndLeakCheck, _pumpDownRoutine);
- }
- catch (RoutineBreakException)
- {
- return Result.RUN;
- }
- catch (RoutineFaildException)
- {
- return Result.FAIL;
- }
- return Result.DONE;
- }
- public void DelayLeakCheck(int id, string name, double time)
- {
- bool Func()
- {
- Notify(name);
- return true;
- }
- Tuple<bool, Result> ret = Delay(id, Func, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.RUN)
- {
- throw new RoutineBreakException();
- }
- }
- }
- public void CheckChamberPressure(int id, double target, out double pressure, int time)
- {
- bool Func()
- {
- return true;
- }
- bool? Check1()
- {
- if (_chamber.ChamberPressure < target)
- {
- Notify($"腔体压力 [{_chamber.ChamberPressure}] mt, 低于 [{target}] mt");
- return true;
- }
- Stop($"腔体压力 [{_chamber.ChamberPressure}], 高于 [{target}]");
- return false;
- }
- pressure = _chamber.ChamberPressure;
- Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw new RoutineFaildException();
- }
- if (ret.Item2 == Result.TIMEOUT)
- {
- throw new RoutineFaildException();
- }
- throw new RoutineBreakException();
- }
- }
- public void RecordBeginPressure(int id)
- {
- bool Func()
- {
- _beginPressure = _chamber.ChamberPressure;
- Notify($"腔体压力初始值 {_beginPressure} mt");
- return true;
- }
- bool? Check1()
- {
- return true;
- }
- Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, 1 * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw new RoutineFaildException();
- }
- if (ret.Item2 == Result.TIMEOUT)
- {
- throw new RoutineFaildException();
- }
- throw new RoutineBreakException();
- }
- }
- public void RecordEndPressure(int id)
- {
- bool Func()
- {
- _endPressure = _chamber.ChamberPressure;
- Notify($"腔体压力结束值 {_endPressure} mt");
- return true;
- }
- bool? Check1()
- {
- return true;
- }
- Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, 1 * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw new RoutineFaildException();
- }
- if (ret.Item2 == Result.TIMEOUT)
- {
- throw new RoutineFaildException();
- }
- throw new RoutineBreakException();
- }
- }
- public void CalcLeakCheck(int id, double target, int timeRate, int time)
- {
- bool Func()
- {
- return true;
- }
- bool? Check1()
- {
- LeakRate = (_endPressure - _beginPressure) / (timeRate / 60.0);
- if (LeakRate < target)
- {
- Notify($"腔体漏率 [{LeakRate}] mt/min, 低于 [{target}] mt/min");
- LeakCheckResultManager.Instance.AddLeakCheck(Module, DateTime.Now, ElapseTime, (double)_beginPressure, (double)_endPressure, LeakRate, LeakCheckStatus.Succeed.ToString(), _mode.ToString());
- return true;
- }
- Stop($"腔体漏率 [{LeakRate}] mt/min, 高于 [{target}] mt/min");
- LeakCheckResultManager.Instance.AddLeakCheck(Module, DateTime.Now, ElapseTime, (double)_beginPressure, (double)_endPressure, LeakRate, LeakCheckStatus.Failed.ToString(), _mode.ToString());
- return false;
- }
- Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw new RoutineFaildException();
- }
- if (ret.Item2 == Result.TIMEOUT)
- {
- throw new RoutineFaildException();
- }
- throw new RoutineBreakException();
- }
- }
- public void StopFlowMFC(int id)
- {
- bool Func()
- {
- _chamber.StopAllGases();
- return true;
- }
- bool? Check1()
- {
- return true;
- }
- Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, 1 * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw new RoutineFaildException();
- }
- if (ret.Item2 == Result.TIMEOUT)
- {
- throw new RoutineFaildException();
- }
- throw new RoutineBreakException();
- }
- }
- public void StartFlowMFC(int id, double[] mfcValues)
- {
- bool Func()
- {
- for (int index = 0; index < mfcValues.Length; index++)
- {
- _chamber.FlowGas(index, mfcValues[index]);
- }
- return true;
- }
- bool? Check1()
- {
- return true;
- }
- Tuple<bool, Result> ret = ExecuteAndWait(id, Func, Check1, 1 * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw new RoutineFaildException();
- }
- if (ret.Item2 == Result.TIMEOUT)
- {
- throw new RoutineFaildException();
- }
- throw new RoutineBreakException();
- }
- }
- public void DeleteLeadCheck(object[] args)
- {
- LeakCheckResultManager.Instance.Delete(Module, args[0].ToString());
- }
- public override void Abort()
- {
- try
- {
- _chamber.CloseValves();
- LeakCheckResultManager.Instance.AddLeakCheck(Module, DateTime.Now, ElapseTime, (double)_beginPressure, (double)_chamber.ChamberPressure, 0, LeakCheckStatus.Aborted.ToString(), _mode.ToString());
- }
- catch (Exception ex)
- {
- LOG.Write(ex);
- }
- }
- }
- }
|