| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 | 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.Common.RecipeCenter;using MECF.Framework.Common.Routine;using MECF.Framework.Common.SubstrateTrackings;using PunkHPX8_Core;using PunkHPX8_RT.Devices.AXIS;using PunkHPX8_RT.Devices.VpwCell;using PunkHPX8_RT.Devices.VpwMain;using PunkHPX8_RT.Modules.VpwMain;using PunkHPX8_RT.Schedulers;using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace PunkHPX8_RT.Modules.VpwCell{    public class VpwPrepareRoutine : RoutineBase, IRoutine    {        private enum PrepareStep        {            CheckPreCondition,            Purge,            PurgeDelay,            WaitPurge,            RotationPositionOffset,            WaitRotation,            CloseDrip,            WaitForChamberDown,            ChamerDown,            Delay,            End        }        #region 内部变量        /// <summary>        /// recipe        /// </summary>        private VpwRecipe _recipe;        /// <summary>        /// 设备        /// </summary>        private VpwCellDevice _vpwCellDevice;        /// <summary>        /// 延迟时间        /// </summary>        private int _putDownAfterDripClose = 2000;        /// <summary>        /// 等待Wafer放入时间        /// </summary>        private int _waitForWaferTime = 300000;        /// <summary>        /// Main设备        /// </summary>        private VpwMainDevice _mainDevice;        /// <summary>        /// VPW Entity        /// </summary>        private VpwMainEntity _vpwMainEntity;        #endregion        /// <summary>        /// 构造函数        /// </summary>        /// <param name="module"></param>        public VpwPrepareRoutine(string module) : base(module)        {        }        /// <summary>        /// 中止        /// </summary>        public void Abort()        {            Runner.Stop("Manual abort");        }        /// <summary>        /// 监控        /// </summary>        /// <returns></returns>        public RState Monitor()        {            Runner.Run(PrepareStep.CheckPreCondition,CheckPreCondition,_delay_1ms)                .RunIf(PrepareStep.Purge,_recipe.PurgeEnable,Purge,_delay_1ms)                .DelayIf(PrepareStep.PurgeDelay,_recipe.PurgeEnable, 500)                .WaitWithStopConditionIf(PrepareStep.WaitPurge,_recipe.PurgeEnable,CheckPurgeStatus,CheckPurgeStopStatus)                .Run(PrepareStep.RotationPositionOffset,RotationPositionOffset,_delay_1ms)                .WaitWithStopCondition(PrepareStep.WaitRotation,CheckRotationStatus,CheckRotationStopStatus)                .Run(PrepareStep.CloseDrip,()=>_vpwCellDevice.FlowDripOff(),_delay_1ms)                .Run(PrepareStep.ChamerDown, ChamberDown, () => {                    return _mainDevice.CommonData.ChamberOpened && !_mainDevice.CommonData.ChamberClosed;                },_delay_2s)                .Delay(PrepareStep.Delay,_putDownAfterDripClose)                                .End(PrepareStep.End,NullFun,_delay_1ms);            return Runner.Status;        }        /// <summary>        /// Purge routine        /// </summary>        /// <returns></returns>        private bool Purge()        {            if (_vpwMainEntity == null)            {                NotifyError(eEvent.ERR_VPW, "VPW Main not exist", -1);                return false;            }            if (_vpwMainEntity.IsIdle)            {                return _vpwMainEntity.CheckToPostMessage<VPWMainState, VPWMainMsg>(eEvent.INFO_VPW, Module, (int)VPWMainMsg.Purge);            }            else if (_vpwMainEntity.State == VPWMainState.Purging)            {                return true;            }            else            {                NotifyError(eEvent.ERR_VPW, $"State {_vpwMainEntity.State} cannot purge", -1);                return false;            }        }        /// <summary>        /// 检验Purge执行是否结束        /// </summary>        /// <returns></returns>        private bool CheckPurgeStatus()        {            return _vpwMainEntity.IsIdle;        }        /// <summary>        /// 检验Purger执行是否出现异常        /// </summary>        /// <returns></returns>        private bool CheckPurgeStopStatus()        {            return _vpwMainEntity.IsError;        }        /// <summary>        /// Position运行至offset        /// </summary>        /// <returns></returns>        private bool RotationPositionOffset()        {            bool result = _vpwCellDevice.HomeRotation();            if (!result)            {                NotifyError(eEvent.ERR_VPW, "rotation start home failed", -1);            }            return result;        }        /// <summary>        /// 检验电机是否完成运动        /// </summary>        /// <returns></returns>        private bool CheckRotationStatus()        {            return _vpwCellDevice.CheckHomeEndStatus();        }        /// <summary>        /// 检验电机运动是否出现异常        /// </summary>        /// <returns></returns>        private bool CheckRotationStopStatus()        {            bool result = _vpwCellDevice.CheckRotationStopStatus();            if (result)            {                NotifyError(eEvent.ERR_VPW, "rotation home failed", -1);            }            return result;        }        /// <summary>        /// 打开 Chamber        /// </summary>        /// <returns></returns>        private bool ChamberDown()        {            return _mainDevice.ChamberDown();        }        /// <summary>        /// 启动        /// </summary>        /// <param name="objs"></param>        /// <returns></returns>        public RState Start(params object[] objs)        {            _recipe=(VpwRecipe)objs[0];            _vpwCellDevice = DEVICE.GetDevice<VpwCellDevice>(Module);            _mainDevice = DEVICE.GetDevice<VpwMainDevice>(ModuleName.VPWMain1.ToString());            _putDownAfterDripClose = SC.GetValue<int>($"{Module}.PutDownAfterDripClose");            _waitForWaferTime = SC.GetValue<int>($"{Module}.WaitForWaferTime") * 1000;            _vpwMainEntity = Singleton<RouteManager>.Instance.GetModule<VpwMainEntity>(ModuleName.VPWMain1.ToString());            return Runner.Start(Module, $"{Module} prepare");        }        /// <summary>        /// 检验前置条件        /// </summary>        /// <returns></returns>        private bool CheckPreCondition()        {            if (!_vpwCellDevice.CheckRotationSwitchOn())            {                NotifyError(eEvent.ERR_VPW,"rotaion is not switch on",-1);                return false;            }            return true;        }        /// <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(PrepareStep.CheckPreCondition, preStepIds, Module, "Prepare Retry");        }    }}
 |