using Aitex.Core.RT.Routine; using Aitex.Core.RT.SCCore; using Venus_RT.Devices; using MECF.Framework.Common.Routine; using Venus_Core; using Aitex.Core.RT.DataCenter; namespace Venus_RT.Modules.PMs { class VentRoutine : PMRoutineBase, IRoutine { private enum VentStep { kISODelay, kClosePVValves, kClosePVValveDelay, KCloseTurboPurgeValve, KCloseISOValve, kOpenVentValves, kDelay_2, kCloseVentValves, } //private int _ventTime; private int _ventTimeDelay = 1; private int _checkATMTimeout = 90; public bool VentingFlag => _ventingflag; private bool _ventingflag = false; public VentRoutine(JetPMBase chamber) : base(chamber) { Name = "PM Vent"; } public RState Start(params object[] objs) { if (CheckLid() && CheckSlitDoor() && CheckCDA() && CheckATM()) { Reset(); _chamber.CloseValves(); //_chamber.OpenValve(ValveType.TurboPumpPumping, true); //_chamber.OpenValve(ValveType.TurboPumpPurge, true); //_chamber.OpenValve(ValveType.PVN22, true); //_chamber.OpenValve(ValveType.N2, true); //_chamber.OpenValve(ValveType.GasFinal, true); _checkATMTimeout = SC.GetValue($"{Module}.CheckATMTimeout"); _ventTimeDelay = SC.GetValue($"{Module}.OverVentTime"); if (Runner.Start(Module, Name) == RState.Running) { _ventingflag = true; return RState.Running; } else { _ventingflag = false; return RState.Failed; } } return RState.Failed; } public RState Monitor() { Runner .Run(VentStep.kClosePVValves, ClosePVValves, PVIsOpen) .Delay(VentStep.kClosePVValveDelay, _delay_2s) .Run(VentStep.KCloseTurboPurgeValve, HOFs.WrapAction(_chamber.OpenValve, ValveType.TurboPumpPurge, false), _delay_1s) .Run(VentStep.KCloseISOValve, HOFs.WrapAction(_chamber.OpenValve, ValveType.TurboPumpPumping, false), _delay_1s) .Run(VentStep.kOpenVentValves, OpenValve, () => { return _chamber.IsATM; }, _checkATMTimeout * 1000) .Delay(VentStep.kDelay_2, _ventTimeDelay) .End(VentStep.kCloseVentValves, CloseVentGasFinalValves, _delay_2s); _ventingflag = Runner.Status == RState.Running; return Runner.Status; } private bool ClosePVValves() { _chamber.OpenValve(ValveType.Guage, false); if (_chamber.PendulumValveIsOpen()) { return _chamber.TurnPendulumValve(false); } _chamber.OpenValve(ValveType.TurboPumpPumping, false); _chamber.OpenValve(ValveType.TurboPumpPurge, false); _chamber.OpenValve(ValveType.FastPump, false); _chamber.OpenValve(ValveType.SoftPump, false); return true; } private bool PVIsOpen() { return !_chamber.PendulumValveIsOpen(); } private bool OpenValve() { if (_chamber.ChamberType == JetChamber.VenusSE || _chamber.ChamberType == JetChamber.VenusDE) { _chamber.OpenValve(ValveType.PVN22, true); } _chamber.OpenValve(ValveType.PVN22, true); _chamber.OpenValve(ValveType.N2, true); _chamber.OpenValve(ValveType.GasFinal, true); return true; } private bool CloseVentGasFinalValves() { //if (_chamber.ChamberType == JetChamber.VenusSE || _chamber.ChamberType == JetChamber.VenusDE) //{ // _chamber.OpenValve(ValveType.PVN22, false); //} _chamber.OpenValve(ValveType.GasFinal, false); _chamber.OpenValve(ValveType.N2, false); _chamber.OpenValve(ValveType.PVN22, false); return true; } public void Abort() { CloseAllValves(); } } }