//using Aitex.Core.RT.Routine; //using Aitex.Core.RT.SCCore; //using Venus_RT.Devices; //using MECF.Framework.Common.Equipment; //using Venus_Core; //using System.Runtime.InteropServices.WindowsRuntime; //namespace Venus_RT.Modules.TM //{ // class MFVentRoutine : ModuleRoutineBase, IRoutine // { // private enum VentStep // { // Venting, // OpenSoftVent, // SwitchFastVent, // PrepareOverVent, // CloseVentValves, // Delay, // CloseExhaustValve, // PrepareCooling, // StartCooling, // Cooling, // End, // } // private int _ventingTimeout; // private int _SoftVentEndPressure; // private readonly JetTM _JetTM; // private int _ventTimeDelay = 1; // private bool _needCooling = false; // private double _coolingMFCFlow = 0; // private bool _skipRepeatVent = false; // private int _exhaustValveWaitDelayTime; // private int _overVentFlow; // public MFVentRoutine(JetTM jetTM, ModuleName mod) : base(mod) // { // _JetTM = jetTM; // Name = "Vent "; // } // public RState Start(params object[] objs) // { // bool isLoadLock = (ModuleHelper.IsLoadLock(Module)); // if (objs.Length > 0 && isLoadLock) // { // _needCooling = (bool)objs[0]; // _coolingMFCFlow = SC.GetValue($"{Module}.Cooling.MFCFlow"); // } // _skipRepeatVent = false; // if (isLoadLock && !_needCooling && IsPressureReady()) // _skipRepeatVent = true; ; // _JetTM.TurnSoftPumpValve(Module, false); // _JetTM.TurnFastPumpValve(Module, false); // _JetTM.TurnPurgeValve(Module, false); // if (_JetTM.CheckLidClosed(Module) && // _JetTM.CheckPumpValveClosed(Module) && // _JetTM.CheckPurgeValveClosed(Module)) // { // Reset(); // _ventingTimeout = SC.GetValue($"{Module}.VentingTimeout") * 1000; // _SoftVentEndPressure = SC.GetValue($"{Module}.SoftVentEndPressure"); // _ventTimeDelay = SC.GetValue($"{Module}.OverVentTime"); // _exhaustValveWaitDelayTime = SC.GetValue($"{Module}.ExhaustValveOffDelayTime"); // _overVentFlow = SC.GetValue($"{Module}.OverVentFlow"); // return Runner.Start(Module, Name); // } // return RState.Failed; // } // public RState Monitor() // { // if (_skipRepeatVent) // { // Notify($" pressure: {_JetTM.GetModulePressure(Module)} is ready, skip the the venting routine."); // CloseVentValve(); // CloseExhaustValve(); // return RState.End; // } // if (_needCooling) // { // Runner.Run(VentStep.OpenSoftVent, OpenSoftVentValve, IsSoftVentEnd) // .Run(VentStep.SwitchFastVent, SwitchFastVentValve, IsPressureReady, _ventingTimeout) // .Delay(VentStep.Delay, _ventTimeDelay) // .Run(VentStep.CloseVentValves, CloseVentValve, _delay_1s) // .RunIf(VentStep.PrepareCooling, _needCooling, StopVent) // .RunIf(VentStep.StartCooling, _needCooling, StartCooling, 3600000) // .End(VentStep.CloseExhaustValve, CloseExhaustValve); // } // else // { // Runner.Run(VentStep.OpenSoftVent, OpenSoftVentValve, IsSoftVentEnd) // .Run(VentStep.SwitchFastVent, SwitchFastVentValve, IsPressureReady, _ventingTimeout) // .Run(VentStep.PrepareOverVent, PrepareOverVent) // .Delay(VentStep.Delay, _ventTimeDelay) // .Run(VentStep.CloseExhaustValve, CloseExhaustValve, _exhaustValveWaitDelayTime) // .End(VentStep.CloseVentValves, CloseVentValve); // } // return Runner.Status; // } // private bool OpenSoftVentValve() // { // _JetTM.TurnN2Valve(true); // _JetTM.TurnPurgeValve(Module, true); // switch (Module) // { // case ModuleName.LLA: // _JetTM.SetLLAFlow(2000); // break; // case ModuleName.LLB: // _JetTM.SetLLBFlow(2000); // break; // case ModuleName.TM: // _JetTM.SetTMFlow(100); // break; // } // return true; // } // private bool PrepareOverVent() // { // _JetTM.TurnVentValve(Module, false); // _JetTM.TurnN2Valve(true); // _JetTM.TurnPurgeValve(Module, true); // switch (Module) // { // case ModuleName.LLA: // _JetTM.SetLLAFlow(_overVentFlow); // break; // case ModuleName.LLB: // _JetTM.SetLLBFlow(_overVentFlow); // break; // case ModuleName.TM: // _JetTM.SetTMFlow(100); // break; // } // _JetTM.TurnExhaustValve(Module, true); // return true; // } // private bool CloseExhaustValve() // { // _JetTM.TurnExhaustValve(Module, false); // return true; // } // private bool IsSoftVentEnd() // { // return _JetTM.GetModulePressure(Module) > _SoftVentEndPressure; // } // private bool SwitchFastVentValve() // { // switch (Module) // { // case ModuleName.LLA: // _JetTM.SetLLAFlow(0); // break; // case ModuleName.LLB: // _JetTM.SetLLBFlow(0); // break; // case ModuleName.TM: // _JetTM.SetTMFlow(0); // break; // } // _JetTM.TurnPurgeValve(Module, false); // //_JetTM.TurnExhaustValve(Module, true); // _JetTM.TurnVentValve(Module, true); // return true; // } // private bool CloseVentValve() // { // switch (Module) // { // case ModuleName.LLA: // _JetTM.SetLLAFlow(0); // break; // case ModuleName.LLB: // _JetTM.SetLLBFlow(0); // break; // case ModuleName.TM: // _JetTM.SetTMFlow(0); // break; // } // _JetTM.TurnPurgeValve(Module, false); // //_JetTM.TurnExhaustValve(Module, false); // _JetTM.TurnVentValve(Module, false); // return true; // } // private bool StopVent() // { // _JetTM.TurnVentValve(Module, false); // _JetTM.TurnExhaustValve(Module, false); // return true; // } // private bool StartCooling() // { // _JetTM.TurnPurgeValve(Module, true); // _JetTM.TurnExhaustValve(Module, true); // if (Module == ModuleName.LLA) // { // _JetTM.SetLLAFlow(_coolingMFCFlow); // } // else if (Module == ModuleName.LLB) // { // _JetTM.SetLLBFlow(_coolingMFCFlow); // } // return true; // } // private bool IsPressureReady() // { // return _JetTM.IsModuleATM(Module); // } // public void Abort() // { // CloseVentValve(); // if (_needCooling) // { // if (Module == ModuleName.LLA) // { // _JetTM.SetLLAFlow(0); // } // else if (Module == ModuleName.LLB) // { // _JetTM.SetLLBFlow(0); // } // _JetTM.TurnPurgeValve(Module, false); // _JetTM.TurnExhaustValve(Module, false); // Notify("Cooling done"); // } // } // } //}