using Aitex.Core.RT.Device; using Aitex.Core.RT.Log; using Aitex.Core.RT.Routine; using Aitex.Core.RT.SCCore; using Aitex.Core.Util; using MECF.Framework.Common.Equipment; using MECF.Framework.RT.Core.Equipments; using MECF.Framework.RT.ModuleLibrary.VceModules; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; using Venus_Core; using Venus_RT.Devices; using Venus_RT.Modules.TM.VenusEntity; namespace Venus_RT.Modules.VCE { public class LoadPrepareRoutine : ModuleRoutineBase, IRoutine { private enum LoadPrepareStep { VceGotoLP, VceOuterDoorOpen, NotifyDone } private VceModuleBase _vce;//动作驱动 private int _vcetimeout; public LoadPrepareRoutine(ModuleName module, VceModuleBase vce) : base(module) { Module = module; _vce = vce; } public RState Start(params object[] objs) { //如果不是ATM 不允许执行 if (!Singleton.Instance.seTM.VCEIsATM) { LOG.Write(eEvent.ERR_VCE_COMMON_Failed, Module, $"VCE is not atm cannot load prepare! Please Vent it First!"); return RState.Failed; } _vcetimeout = SC.GetValue($"{Module}.MotionTimeout") * 1000; Reset(); return Runner.Start(Module, $"Load Prepare"); } public RState Monitor() { Runner.Run(LoadPrepareStep.VceGotoLP, VceGotoLP, CheckVceStageDownDone , _vcetimeout) .Run(LoadPrepareStep.VceOuterDoorOpen, VceOuterDoorOpen, CheckVceOuterDoorOpenDone, _vcetimeout) .End(LoadPrepareStep.NotifyDone, NullFun, 100); return Runner.Status; } private bool CheckVceStageDownDone() { if (_vce.Status == RState.Timeout || _vce.Status == RState.Failed) { LOG.Write(eEvent.ERR_VCE_COMMON_Failed, Module, $"VCE Stage Down failed"); } return _vce.Status == RState.End; } private bool CheckVceOuterDoorOpenDone() { if (_vce.Status == RState.Timeout || _vce.Status == RState.Failed) { LOG.Write(eEvent.ERR_VCE_COMMON_Failed, Module, $"VCE OuterDoor Open failed"); } return _vce.Status == RState.End; } private bool VceGotoLP() { return _vce.GotoLP(); } private bool VceOuterDoorOpen() { if (Singleton.Instance.seTM.VCEIsATM && Singleton.Instance.seTM.VCEPressure >= SC.GetValue($"{Module}.OutDoorOpenPressure")) { return _vce.OpenDoor(); } else { LOG.Write(eEvent.ERR_VCE_COMMON_Failed, Module, $"{Module} is not ATM or Pressure not arrive {SC.GetValue($"{Module}.OutDoorOpenPressure")}"); return false; } } public void Abort() { } } }