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.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 HongHuTM _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; _tm = DEVICE.GetDevice("SETM"); pumpRoutine = new SEMFPumpRoutine(_tm, module); } public RState Start(params object[] objs) { _VceMotionTimeout = SC.GetValue($"{Module}.MotionTimeout") * 1000; _SMIFMotionTimeout = SC.GetValue($"{Module}.SMIF.MotionTimeout") * 1000; //如果不是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; } if (!Singleton.Instance.seTM.IsVCESlitDoorClosed) { 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.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; } } 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; } private bool OpenInnerDoor() { return _tm.TurnSlitDoor(Module, true); } // private bool CheckPumpOver() { RState ret = pumpRoutine.Monitor(); if (ret == RState.Failed || ret == RState.Timeout) { Singleton.Instance.VCE.PostMsg(VceMSG.Error); } return ret == RState.End; } private bool CheckVceIdle() { if (_vce.Status == RState.Failed || _vce.Status == RState.Timeout) { Singleton.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() { } } }