| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 | 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.Runtime.InteropServices;using System.Text;using System.Threading.Tasks;namespace PunkHPX8_RT.Modules.VpwCell{    public class VpwManualRecipeRoutine : RoutineBase, IRoutine    {        private enum RecipeStep        {            Prepare,            WaitPrepare,            VacuumPrewet,            WaitVacuumPrewet,            VentPrewet,            WaitVentPrewet,            ExtendClean,            WaitExtendClean,            SpinOff,            WaitSpinOff,            StopRotation,            WaitStop,            End        }        #region 内部变量        /// <summary>        /// 手动Prepare routine        /// </summary>        private VpwManualPrepareRoutine _manualPrepareRoutine;        /// <summary>        /// Vacuum prewet routine        /// </summary>        private VpwVacuumPrewetRoutine _vacuumPrewetRoutine;        /// <summary>        /// Vent Prewet        /// </summary>        private VpwVentPrewetRoutine _ventPrewetRoutine;        /// <summary>        /// Extend clean        /// </summary>        private VpwExtendCleanRoutine _extendCleanRoutine;        /// <summary>        /// Spin Off Routine        /// </summary>        private VpwSpinOffRoutine _spinOffRoutine;        /// <summary>        /// recipe        /// </summary>        private VpwRecipe _recipe;        /// <summary>        /// Cell device        /// </summary>        private VpwCellDevice _vpwCellDevice;        /// <summary>        /// Main device        /// </summary>        private VpwMainDevice _mainDevice;        #endregion        /// <summary>        /// 构造函数        /// </summary>        /// <param name="module"></param>        public VpwManualRecipeRoutine(string module) : base(module)        {            _manualPrepareRoutine = new VpwManualPrepareRoutine(module);            _vacuumPrewetRoutine=new VpwVacuumPrewetRoutine(module);            _ventPrewetRoutine = new VpwVentPrewetRoutine(module);            _extendCleanRoutine= new VpwExtendCleanRoutine(module);            _spinOffRoutine=new VpwSpinOffRoutine(module);        }        /// <summary>        /// 中止        /// </summary>        public void Abort()        {            Runner.Stop("Manual stop");            _mainDevice.VPWBoostPumpTarget = VpwMain.VPWBoostPumpTarget.Pressure;        }        /// <summary>        /// 监控        /// </summary>        /// <returns></returns>        public RState Monitor()        {            Runner.Run(RecipeStep.Prepare, Prepare, _delay_1ms)                .WaitWithStopCondition(RecipeStep.WaitPrepare, () => CommonFunction.CheckRoutineEndState(_manualPrepareRoutine),                    () => { return CheckSubRoutineError(_manualPrepareRoutine, _manualPrepareRoutine, 0); })                 .Run(RecipeStep.VacuumPrewet, VacuumPrewet)                 .WaitWithStopCondition(RecipeStep.WaitVacuumPrewet, () => CommonFunction.CheckRoutineEndState(_vacuumPrewetRoutine),                    () => { return CheckSubRoutineError(_vacuumPrewetRoutine, _vacuumPrewetRoutine, 1); })                 .Run(RecipeStep.VentPrewet, VentPrewet)                 .WaitWithStopCondition(RecipeStep.WaitVentPrewet, () => CommonFunction.CheckRoutineEndState(_ventPrewetRoutine),                    () => { return CheckSubRoutineError(_ventPrewetRoutine, _ventPrewetRoutine, 2); })                 .Run(RecipeStep.ExtendClean, ExtendClean)                 .WaitWithStopCondition(RecipeStep.WaitExtendClean, () => CommonFunction.CheckRoutineEndState(_extendCleanRoutine),                    () => { return CheckSubRoutineError(_extendCleanRoutine, _extendCleanRoutine, 3); })                 .Run(RecipeStep.SpinOff, SpinOff)                 .WaitWithStopCondition(RecipeStep.WaitSpinOff, () => CommonFunction.CheckRoutineEndState(_spinOffRoutine),                    () => { return CheckSubRoutineError(_spinOffRoutine, _spinOffRoutine, 4); })                .Run(RecipeStep.StopRotation, StopRotation, _delay_1ms)                .WaitWithStopCondition(RecipeStep.WaitStop, CheckStopEndStatus, CheckStopErrorStatus)                .End(RecipeStep.End, End, _delay_1ms);            return Runner.Status;        }        /// <summary>        /// Prepare        /// </summary>        /// <returns></returns>        private bool Prepare()        {            return _manualPrepareRoutine.Start(_recipe) == RState.Running;        }        /// <summary>        /// Vacuum Prewet        /// </summary>        /// <returns></returns>        private bool VacuumPrewet()        {            return _vacuumPrewetRoutine.Start(_recipe) == RState.Running;        }        /// <summary>        /// Vent Prewet        /// </summary>        /// <returns></returns>        private bool VentPrewet()        {            return _ventPrewetRoutine.Start(_recipe) == RState.Running;        }        /// <summary>        /// Extend Clean        /// </summary>        /// <returns></returns>        private bool ExtendClean()        {            return _extendCleanRoutine.Start(_recipe) == RState.Running;        }        /// <summary>        /// Vacuum Prewet        /// </summary>        /// <returns></returns>        private bool SpinOff()        {            return _spinOffRoutine.Start(_recipe) == RState.Running;        }        /// <summary>        /// 检验子routine异常        /// </summary>        /// <param name="routine"></param>        /// <param name="routineBase"></param>        /// <param name="index"></param>        /// <returns></returns>        private bool CheckSubRoutineError(IRoutine routine,RoutineBase routineBase,int index)        {            bool result = CommonFunction.CheckRoutineStopState(routine);            if (result)            {                NotifyError(eEvent.ERR_VPW, routineBase.ErrorMsg, index);            }            return result;        }        /// <summary>        /// 停止rotation        /// </summary>        /// <returns></returns>        private bool StopRotation()        {            bool result = _vpwCellDevice.StopProfilePosition();            if (!result)            {                NotifyError(eEvent.ERR_VPW, "Stop rotation failed", 0);            }            return result;        }        /// <summary>        /// 检验停止完成状态        /// </summary>        /// <returns></returns>        private bool CheckStopEndStatus()        {            return _vpwCellDevice.CheckRotationEndStatus();        }        /// <summary>        /// 检验停止异常        /// </summary>        /// <returns></returns>        private bool CheckStopErrorStatus()        {            bool result = _vpwCellDevice.CheckRotationStopStatus();            if (result)            {                NotifyError(eEvent.ERR_VPW, "Stop rotation failed", 0);            }            return result;        }        /// <summary>        /// 结束        /// </summary>        /// <returns></returns>        private bool End()        {            _mainDevice.VPWBoostPumpTarget = VpwMain.VPWBoostPumpTarget.Pressure;            _mainDevice.CommonData.BoosterPumpSpeedAuto = false;            return true;        }        /// <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 manual recipe");        }    }}
 |