123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using MECF.Framework.Common.Equipment;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Venus_Core;
- using Venus_RT.Devices;
- using Venus_RT.Devices.TM;
- namespace Venus_RT.Modules.TM.VenusEntity
- {
- public class SEMFVentRoutine : ModuleRoutineBase, IRoutine
- {
- private enum SEVentStep
- {
- seOpenSoftVent,
- seSwitchFastVent,
- seDelayForClose,
- seCloseVentValves,
- }
- private int _venttimeout;
- private int _ventcrosspressure;
- private int _ventDelay;
- private readonly TMBase _tm;
- public SEMFVentRoutine(TMBase tm, ModuleName module) : base(module)
- {
- _tm = tm;
- Name = "Vent";
- }
- public RState Start(params object[] objs)
- {
- if (_tm.CheckPumpValveClosed(Module))
- {
- Reset();
- _venttimeout = SC.GetValue<int>($"{Module}.VentingTimeout") * 1000;
- _ventcrosspressure = SC.GetValue<int>($"{Module}.SoftVentEndPressure");
- _ventDelay = SC.GetValue<int>($"{Module}.OverVentDelay")*1000;
- return Runner.Start(Module, Name);
- }
- else
- {
- LOG.Write(eEvent.ERR_DEVICE_INFO,Module, "Pump Valve not all Close! Cannot Vent!");
- return RState.Failed;
- }
- }
- public RState Monitor()
- {
- Runner.Run(SEVentStep.seOpenSoftVent, OpenSoftVentValve, IsSoftVentEnd)
- .Run(SEVentStep.seSwitchFastVent, SwitchFastVentValve, IsPressureReady, _venttimeout)
- .Delay(SEVentStep.seDelayForClose, _ventDelay)
- .End(SEVentStep.seCloseVentValves, CloseVentValve, _delay_50ms);
- return Runner.Status;
- }
- private bool OpenSoftVentValve()
- {
- _tm.TurnSoftVentValve(Module, true);
- return true;
- }
- private bool IsSoftVentEnd() => _tm.GetModulePressure(Module) > _ventcrosspressure;
- private bool SwitchFastVentValve()
- {
- if (Module == ModuleName.SETM || Module == ModuleName.DETM)
- _tm.SetTMFlow(100);
- _tm.TurnSoftVentValve(Module, false);
- _tm.TurnFastVentValve(Module, true);
- return true;
- }
- private bool IsPressureReady()
- {
- switch (Module)
- {
- case ModuleName.SETM:
- case ModuleName.DETM:
- return _tm.IsTMATM;
- case ModuleName.VCE1:
- return _tm.IsVCEATM;
- case ModuleName.VCEA:
- return _tm.IsVCEAATM;
- case ModuleName.VCEB:
- return _tm.IsVCEBATM;
- }
- return false;
- }
- private bool CloseVentValve()
- {
- _tm.TurnSoftVentValve(Module,false);
- _tm.TurnFastVentValve(Module,false);
- if (Module == ModuleName.SETM)
- _tm.SetTMFlow(0);
- return true;
- }
- public void Abort()
- {
- _tm.TurnFastVentValve(Module,false);
- _tm.TurnSoftVentValve(Module, false);
- }
- }
- }
|