| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 | using Aitex.Core.RT.Device;using Aitex.Core.RT.Log;using Aitex.Core.RT.Routine;using MECF.Framework.Common.Equipment;using MECF.Framework.Common.RecipeCenter;using MECF.Framework.Common.Routine;using MECF.Framework.Common.Utilities;using PunkHPX8_Core;using PunkHPX8_RT.Devices.VpwCell;using PunkHPX8_RT.Devices.VpwMain;using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace PunkHPX8_RT.Modules.VpwCell{    public class VpwRecipeRoutine : RoutineBase, IRoutine    {        private enum RecipeStep        {            ChamberUp,            CloseDrain,            CheckLoopDO,            VacuumPrewet,            WaitVacuumPrewet,            End        }        #region 内部变量        /// <summary>        /// recipe        /// </summary>        private VpwRecipe _recipe;        /// <summary>        /// 设备        /// </summary>        private VpwCellDevice _vpwCellDevice;        /// <summary>        /// Main设备        /// </summary>        private VpwMainDevice _mainDevice;        /// <summary>        /// Vacuum prewet routine        /// </summary>        private VpwVacuumPrewetRoutine _vacuumPrewetRoutine;        #endregion        /// <summary>        /// 构造函数        /// </summary>        /// <param name="module"></param>        public VpwRecipeRoutine(string module) : base(module)        {            _vacuumPrewetRoutine = new VpwVacuumPrewetRoutine(Module);        }        /// <summary>        /// 中止        /// </summary>        public void Abort()        {            Runner.Stop("Manual stop");        }        /// <summary>        /// 监控        /// </summary>        /// <returns></returns>        public RState Monitor()        {            Runner.Run(RecipeStep.ChamberUp, ChamberUp, CheckChamberClosed)                .Run(RecipeStep.CloseDrain, _vpwCellDevice.DrainValveOff, _delay_1ms)                .Run(RecipeStep.CheckLoopDO, CheckLoopDO, _delay_1ms)                .Run(RecipeStep.VacuumPrewet,VacuumPrewet,_delay_1ms)                .WaitWithStopCondition(RecipeStep.WaitVacuumPrewet,CheckVacuumPrewetEndStatus,CheckVacuumPrewetStopStatus)                .End(RecipeStep.End, NullFun, _delay_1ms);            return Runner.Status;        }        /// <summary>        /// chamber up        /// </summary>        /// <returns></returns>        private bool ChamberUp()        {            bool result = _mainDevice.ChamberUp();            if (!result)            {                NotifyError(eEvent.ERR_VPW, "chamber up failed", 0);            }            return result;        }        /// <summary>        /// 检验Chamber是否关闭        /// </summary>        /// <returns></returns>        private bool CheckChamberClosed()        {            bool result= _mainDevice.CommonData.ChamberClosed && !_mainDevice.CommonData.ChamberOpened;            if (!result)            {                NotifyError(eEvent.ERR_VPW, $"Chamber Closed is {_mainDevice.CommonData.ChamberClosed} and opened is {_mainDevice.CommonData.ChamberOpened}",0);            }            return result;        }        /// <summary>        /// Check LoopDO数值        /// </summary>        /// <returns></returns>        private bool CheckLoopDO()        {            if(_recipe.DiwLoopDoSet == 0)            {                return true;            }            double loopDoValue = _vpwCellDevice.LoopDOValue;            bool result = loopDoValue < _recipe.DiwLoopDoSet;            if (!result)            {                NotifyError(eEvent.ERR_VPW, $"LoopDO value {loopDoValue} is less than {_recipe.DiwLoopDoSet}", 0);            }            return result;        }        /// <summary>        /// Vacuum Prewet        /// </summary>        /// <returns></returns>        private bool VacuumPrewet()        {            bool result = _vacuumPrewetRoutine.Start(_recipe) == RState.Running;            if (!result)            {                NotifyError(eEvent.ERR_VPW, _vacuumPrewetRoutine.ErrorMsg, 1);            }            return result;        }        /// <summary>        /// 检验Vacuum Prewet结束状态        /// </summary>        /// <returns></returns>        private bool CheckVacuumPrewetEndStatus()        {            bool result = CommonFunction.CheckRoutineEndState(_vacuumPrewetRoutine);            return result;        }        /// <summary>        /// 检验Vacuum Prewet异常        /// </summary>        /// <returns></returns>        private bool CheckVacuumPrewetStopStatus()        {            bool result=CommonFunction.CheckRoutineStopState(_vacuumPrewetRoutine);            if (result)            {                NotifyError(eEvent.ERR_VPW, _vacuumPrewetRoutine.ErrorMsg, 1);            }            return result;        }        /// <summary>        /// 启动        /// </summary>        /// <param name="objs"></param>        /// <returns></returns>        public RState Start(params object[] objs)        {            _recipe = objs[0] as VpwRecipe;            _vpwCellDevice = DEVICE.GetDevice<VpwCellDevice>(Module);            _mainDevice = DEVICE.GetDevice<VpwMainDevice>(ModuleName.VPWMain1.ToString());            return Runner.Start(Module, "start run recipe");        }        /// <summary>        /// 重试        /// </summary>        /// <param name="step"></param>        public RState Retry(int step)        {            if (_recipe == null)            {                NotifyError(eEvent.ERR_VPW, "recipe is null", -1);                return RState.Failed;            }            List<Enum> preStepIds = new List<Enum>();            return Runner.Retry(RecipeStep.ChamberUp, preStepIds, Module, "Run recipe Retry");        }    }}
 |