using Aitex.Core.RT.Routine; using Aitex.Core.RT.SCCore; using Venus_RT.Devices; using MECF.Framework.Common.Routine; using Venus_Core; namespace Venus_RT.Modules.PMs { class VentRoutine : PMRoutineBase, IRoutine { private enum VentStep { kClosePVValves, kOpenVentValves, kDelay_2, kCloseVentValves, } //private int _ventTime; private readonly int _defaut_timeout = 5000; private double _ventTimeDelay = 1; private int _checkATMTimeout = 90; public VentRoutine(JetPM chamber) : base(chamber) { Name = "PM Vent"; } public RState Start(params object[] objs) { if (CheckLid() && CheckSlitDoor() && CheckCDA() && CheckATM()) { Reset(); _chamber.CloseValves(); _checkATMTimeout = SC.GetValue($"{Module}.CheckATMTimeout"); _ventTimeDelay = SC.GetValue($"{Module}.OverVentTime"); return Runner.Start(Module, Name); } return RState.Failed; } public RState Monitor() { Runner.Run( (int)VentStep.kClosePVValves, ClosePVValves, _delay_1s) .Run( (int)VentStep.kOpenVentValves, HOFs.Apply(TurnVentValves, true), ()=> { return _chamber.IsATM; }, _checkATMTimeout * 1000) .Delay( (int)VentStep.kDelay_2, (int)_ventTimeDelay) .End( (int)VentStep.kCloseVentValves, HOFs.Apply(TurnVentValves, false), _defaut_timeout); return Runner.Status; } private bool ClosePVValves() { return _chamber.TurnPendulumValve(false); } private bool TurnVentValves(bool bOpen) { _chamber.OpenValve(ValveType.GasFinal, bOpen); _chamber.OpenValve(ValveType.N2, bOpen); _chamber.OpenValve(ValveType.PVN22, bOpen); return true; } public void Abort() { CloseAllValves(); } } }