| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 | using Aitex.Core.RT.Routine;using Aitex.Core.RT.SCCore;using MECF.Framework.Common.Equipment;using System;using System.Collections.Generic;using System.Diagnostics;using System.Linq;using System.Text;using System.Threading.Tasks;using Venus_Core;using Venus_RT.Devices;namespace Venus_RT.Modules.TM{    class MFCoolingRoutine : ModuleRoutineBase, IRoutine    {        private enum CoolingStep        {            kDelay,            kStopVent,            kStartCooling,            kWaitCoolingEnd,            kEndCooling,        }        private int _coolingTime;        private double _coolingMFCFlow;        private readonly JetTM _JetTM;        private Stopwatch _coolingStopWatch = new Stopwatch();        public MFCoolingRoutine(JetTM jetTM, ModuleName mod) : base(mod)        {            _JetTM = jetTM;        }        public RState Start(params object[] objs)        {             _coolingMFCFlow = SC.GetValue<double>($"{Module}.Cooling.MFCFlow");             _coolingTime    = SC.GetValue<int>($"{Module}.Cooling.CoolingTime");            return Runner.Start(Module, Name);        }        public RState Monitor()        {            Runner .Delay(CoolingStep.kDelay,         1000)                   .Run(CoolingStep.kStopVent,        StopVent)                                     .Run(CoolingStep.kStartCooling,    StartCooling)                   .Wait(CoolingStep.kWaitCoolingEnd, CoolingIsEnd)                   .End(CoolingStep.kEndCooling,      ResetCooling, NullFun);            return Runner.Status;        }        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);            }            _coolingStopWatch.Start();            return true;        }        private bool CoolingIsEnd()        {            return _coolingStopWatch.ElapsedMilliseconds > _coolingTime * 1000;        }        private bool ResetCooling()        {            _coolingStopWatch.Reset();            if (Module == ModuleName.LLA)            {                _JetTM.SetLLAFlow(0d);            }            else if (Module == ModuleName.LLB)            {                _JetTM.SetLLBFlow(0d);            }            _JetTM.TurnPurgeValve(Module, false);            _JetTM.TurnExhaustValve(Module, false);            return true;        }        public void Abort()        {            _coolingStopWatch.Reset();            if (Module == ModuleName.LLA)            {                _JetTM.SetLLAFlow(0);            }            else if (Module == ModuleName.LLB)            {                _JetTM.SetLLBFlow(0);            }            _JetTM.TurnPurgeValve(Module, false);            _JetTM.TurnExhaustValve(Module, false);        }    }}
 |