| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 | 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.ModuleLibrary.VceModules;using System;using System.Collections.Generic;using System.Linq;using System.Runtime.InteropServices;using System.Text;using System.Threading.Tasks;using Venus_Core;using Venus_RT.Devices;using Venus_RT.Devices.SMIF;using Venus_RT.Devices.TM;using Venus_RT.Devices.VCE;using Venus_RT.Modules.TM;using Venus_RT.Modules.TM.VenusEntity;using static Venus_RT.Modules.VCE.LoadRoutine;namespace Venus_RT.Modules.VCE{    public class LoadWithSMIFRoutine : ModuleRoutineBase, IRoutine    {        private enum LoadWithSMIFStep        {            VceGotoLP,            VceOuterDoorOpen,            SMIFLoad,            CloseOutDoor,            Mapping,            ReadMap,            VcePumpDown,            OpenInnerDoor,            NotifyOver        }        private TMBase _tm;        private VCEModuleBase _vce;        private ISMIF _smif;        private int _VceMotionTimeout;        private int _SMIFMotionTimeout;        private SEMFPumpRoutine pumpRoutine;        public LoadWithSMIFRoutine(ModuleName module, VCEModuleBase vce, ISMIF smif) : base(module)        {            _vce = vce;            _smif = smif;            if (module == ModuleName.VCE1)                _tm = DEVICE.GetDevice<HongHuTM>("SETM");            else                _tm = DEVICE.GetDevice<HongHuDETM>("DETM");            pumpRoutine = new SEMFPumpRoutine(_tm, module);        }        public RState Start(params object[] objs)        {            _VceMotionTimeout = SC.GetValue<int>($"{Module}.MotionTimeout") * 1000;            _SMIFMotionTimeout = SC.GetValue<int>($"{Module}.SMIF.MotionTimeout") * 1000;            //如果不是ATM 不允许执行            if (!Singleton<RouteManager>.Instance.seTM.VCEIsATM(Module))            {                LOG.Write(eEvent.ERR_VCE_COMMON_Failed, Module, $"VCE is not atm cannot load prepare! Please Vent it First!");                return RState.Failed;            }            if (!Singleton<RouteManager>.Instance.seTM.IsVCESlitDoorClosed(Module))            {                LOG.Write(eEvent.ERR_VCE_COMMON_Failed, Module, $"VCE Inner Door is open! Please close it First!");                return RState.Failed;            }            Reset();            return Runner.Start(Module,"Start Load with smif");        }        public RState Monitor()        {            Runner                .Run(LoadWithSMIFStep.VceGotoLP,        VceGotoLP,          CheckVceStageDownDone,          _VceMotionTimeout)                .Run(LoadWithSMIFStep.VceOuterDoorOpen, VceOuterDoorOpen,   CheckVceOuterDoorOpenDone,      _VceMotionTimeout)                .Run(LoadWithSMIFStep.SMIFLoad,         SMIFLoad,           CheckSMIFLoadDone,              _SMIFMotionTimeout)                .Run(LoadWithSMIFStep.CloseOutDoor,     CloseOutDoor,       CheckVceIdle,                   _VceMotionTimeout)                .Run(LoadWithSMIFStep.Mapping,          Mapping,            CheckVceIdle,                   _VceMotionTimeout)                .Run(LoadWithSMIFStep.ReadMap,          ReadMap,            CheckVceIdle,                   _VceMotionTimeout)                .Run(LoadWithSMIFStep.VcePumpDown,      PumpDown,           CheckPumpOver,                  2*60*1000)                .Run(LoadWithSMIFStep.OpenInnerDoor,    OpenInnerDoor,      CheckInnerDoorOpen,             _VceMotionTimeout)                .End(LoadWithSMIFStep.NotifyOver,       NullFun,                                            100);            return Runner.Status;        }        private bool SMIFLoad()        {            //_smif.Load();            return true;        }        private bool CheckSMIFLoadDone()        {             return true;        }        private bool VceGotoLP()        {            return _vce.GotoLP();        }        private bool VceOuterDoorOpen()        {            if (Singleton<RouteManager>.Instance.seTM.VCEIsATM(Module) && Singleton<RouteManager>.Instance.seTM.VCEPressure(Module) >= SC.GetValue<int>($"{Module}.OutDoorOpenPressure"))            {                return _vce.OpenDoor();            }            else            {                LOG.Write(eEvent.ERR_VCE_COMMON_Failed, Module, $"{Module} is not ATM or Pressure not arrive {SC.GetValue<int>($"{Module}.OutDoorOpenPressure")}");                return false;            }        }        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 CheckInnerDoorOpen()        {            return !_tm.VCESlitDoorClosed(Module);        }        private bool OpenInnerDoor()        {            return _tm.TurnSlitDoor(Module, true);        }        //        private bool CheckPumpOver()        {            RState ret = pumpRoutine.Monitor();            if (ret == RState.Failed || ret == RState.Timeout)            {                Singleton<RouteManager>.Instance.VCE.PostMsg(VceMSG.Error);            }            return ret == RState.End;        }        private bool CheckVceIdle()        {            if (_vce.Status == RState.Failed || _vce.Status == RState.Timeout)            {                Singleton<RouteManager>.Instance.GetVCE(Module).PostMsg(VceMSG.Error);                return false;            }            return _vce.Status == RState.End;        }        private bool PumpDown()        {            return pumpRoutine.Start() == RState.Running;        }        private bool ReadMap()        {            return _vce.ReadMap();        }        private bool Mapping()        {            return _vce.Map();        }        private bool CloseOutDoor()        {            return _vce.CloseDoor();        }        public void Abort()        {        }    }}
 |