| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365 | using Aitex.Core.RT.Device;using Aitex.Core.RT.Routine;using MECF.Framework.Common.Equipment;using MECF.Framework.Common.Routine;using CyberX8_Core;using CyberX8_RT.Devices.AXIS;using CyberX8_RT.Devices.Loader;using System;using System.Collections.Generic;using Aitex.Core.RT.Log;using MECF.Framework.Common.CommonData.Loader;using Aitex.Core.RT.SCCore;using Aitex.Core.Util;namespace CyberX8_RT.Modules.Loader{    public class LoaderUnloadSideRoutine : RoutineBase, IRoutine    {        private enum UnloadStep        {            RotationGoToLOADA,            RotationGoToLOADAWait,            SideUnload,            UnloadAllWait,            End        }        #region 常量        private const string SIDE_A = "SideA";        private const string SIDE_B = "SideB";        private const int LOTTRACK_TIME = 1000;        #endregion        #region 内部变量        private JetAxisBase _rotationAxis;        private string _side;        private LoaderUnloadRoutine _sideUnloadRoutine;        private bool _isSideUnloaded = false;        private bool _isSideStop = false;        /// <summary>        /// lotTrack time        /// </summary>        private DateTime _lotTackTime = DateTime.Now;        /// <summary>        /// Loader Common        /// </summary>        private LoaderCommonDevice _loaderCommon;        /// <summary>        /// LoaderSide        /// </summary>        private LoaderSideDevice _loaderSide;        /// <summary>        /// Loader LotTrackData        /// </summary>        private List<LoaderLotTrackData> _datas = new List<LoaderLotTrackData>();        /// <summary>        /// Wafer组        /// </summary>        private string _waferGroup;        /// <summary>        /// Wafer尺寸        /// </summary>        private int _waferSize;        #endregion        #region 属性        /// <summary>        /// UnLoad LotTrackData        /// </summary>        public List<LoaderLotTrackData> UnloadLotTrackDatas { get { return _datas; } }        /// <summary>        /// Wafer组        /// </summary>        public string WaferGroup { get { return _waferGroup; } }        /// <summary>        /// is SideA        /// </summary>        public bool IsSideA { get { return _side == SIDE_A ? true : false; } }        #endregion        /// <summary>        /// 构造函数        /// </summary>        /// <param name="module"></param>        public LoaderUnloadSideRoutine(string module) : base(module)        {        }        /// <summary>        /// 中止        /// </summary>        public void Abort()        {        }        /// <summary>        /// 监控        /// </summary>        /// <returns></returns>        public RState Monitor()        {            LottrackRecord();            Runner.Run(UnloadStep.RotationGoToLOADA,RotationGotoLOAD,_delay_1ms)                .WaitWithStopCondition(UnloadStep.RotationGoToLOADAWait,CheckRotationPositionStatus,CheckRotationPositionRunStop)                .Run(UnloadStep.SideUnload, () => StartUnloadRoutine(_sideUnloadRoutine,_isSideUnloaded), _delay_1ms)                .WaitWithStopCondition(UnloadStep.UnloadAllWait, CheckUnloadAllRoutineEndStatus,CheckUnloadAllRoutineStopStatus)                .End(UnloadStep.End, NullFun, _delay_1ms);            return Runner.Status;        }        /// <summary>        /// Rotation Goto LOADA        /// </summary>        /// <returns></returns>        private bool RotationGotoLOAD()        {            string side = _side == SIDE_A ? "A" : "B";            bool result = _rotationAxis.PositionStation($"LOAD{side}{_waferSize}", false);            if (!result)            {                NotifyError(eEvent.ERR_LOADER, "rotation start goto LOAD failed", 0);            }            return result;        }        /// <summary>        /// 检验Rotation移动状态        /// </summary>        /// <returns></returns>        private bool CheckRotationPositionStatus()        {            return _rotationAxis.Status == RState.End;        }        /// <summary>        /// 检验Rotation是否还在运动        /// </summary>        /// <returns></returns>        private bool CheckRotationPositionRunStop()        {            bool result = _rotationAxis.Status == RState.Failed || _rotationAxis.Status == RState.Timeout ;            if (result)            {                NotifyError(eEvent.ERR_LOADER, "rotation goto position failed",0);            }            return result;        }        /// <summary>        /// 启动Unload routine        /// </summary>        /// <param name="unloadRoutine"></param>        /// <returns></returns>        private bool StartUnloadRoutine(LoaderUnloadRoutine unloadRoutine,bool isSideUnloaded)        {            if (isSideUnloaded)            {                return true;            }            bool result= unloadRoutine.Start()==RState.Running;            if(!result)            {                NotifyError(eEvent.ERR_LOADER, unloadRoutine.ErrorMsg, 0);            }            return result;        }        /// <summary>        /// 检验UnloadAll完成状态        /// </summary>        /// <returns></returns>        private bool CheckUnloadAllRoutineEndStatus()        {            bool sideResult = true;            if (!_isSideUnloaded)            {                sideResult = CheckUnloadRoutineEndStatus(_sideUnloadRoutine);            }            return sideResult;        }        /// <summary>        /// 检查UnloadAll停止状态        /// </summary>        /// <returns></returns>        private bool CheckUnloadAllRoutineStopStatus()        {            bool sideComplete = false;            if (!_isSideUnloaded&&!_isSideStop)            {                RState ret = _sideUnloadRoutine.Monitor();                _isSideStop = ret == RState.Failed || ret == RState.Timeout;                sideComplete = (ret != RState.Running);                if (_isSideStop)                {                    NotifyError(eEvent.ERR_LOADER, $"unload A failed\r\n{_sideUnloadRoutine.ErrorMsg}", 1);                }            }            return _isSideStop;        }        /// <summary>        /// 检验routine完成状态        /// </summary>        /// <param name="unloadRoutine"></param>        /// <returns></returns>        private bool CheckUnloadRoutineEndStatus(LoaderUnloadRoutine unloadRoutine)        {            return unloadRoutine.Monitor() == RState.End;        }        /// <summary>        /// 检验Routine结束状态        /// </summary>        /// <param name="unloadRoutine"></param>        /// <returns></returns>        private bool CheckUnloadRoutineStopStatus(LoaderUnloadRoutine unloadRoutine,string side)         {            RState state=unloadRoutine.Monitor();            if (state == RState.Failed || state == RState.Timeout)            {                NotifyError(eEvent.ERR_LOADER, $"{side} Unload failed", 0);                return true;            }            return false;        }        /// <summary>        /// 启动        /// </summary>        /// <param name="objs"></param>        /// <returns></returns>        public RState Start(params object[] objs)        {            _side = objs[0].ToString();            if (objs.Length > 1)            {                _waferGroup = objs[1].ToString();            }            LoaderEntity loaderEntity=Singleton<RouteManager>.Instance.GetModule<LoaderEntity>(ModuleName.Loader1.ToString());            if (_side == SIDE_A)            {                _waferSize = loaderEntity.SideAWaferSize;            }            else            {                _waferSize = loaderEntity.SideBWaferSize;            }            InitializeParameters();            _loaderCommon = DEVICE.GetDevice<LoaderCommonDevice>($"{Module}.Common");            _loaderSide = DEVICE.GetDevice<LoaderSideDevice>($"{Module}.{_side}");            //清除lotTrack数据            _datas.Clear();            return Runner.Start(Module, "Start Unload side");        }        /// <summary>        /// 初始化参数        /// </summary>        private void InitializeParameters()        {            _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");            _sideUnloadRoutine = new LoaderUnloadRoutine(ModuleName.Loader1.ToString(), _side);            _isSideUnloaded = false;            _isSideStop = false;        }        /// <summary>        /// 重试        /// </summary>        /// <param name="step"></param>        public RState Retry(int step)        {            InitializeParameters();            List<Enum> preStepIds = new List<Enum>();            return Runner.Retry(UnloadStep.RotationGoToLOADA,preStepIds,Module,"UnloadAll Retry");        }        /// <summary>        /// 检验前面Unload完成状态        /// </summary>        /// <returns></returns>        public bool CheckCompleteCondition(int index)        {            string side = _side == SIDE_A ? "A" : "B";            if (!CheckSideUnloadCondition(side, index,true))            {                return false;            }            return true;        }        /// <summary>        /// 检验Side Unload情况         /// </summary>        /// <param name="side"></param>        /// <param name="index"></param>        /// <returns></returns>        private bool CheckSideUnloadCondition(string side, int index,bool showError)        {            JetAxisBase shuttleAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.Shuttle{side}");            double shuttlePosition = shuttleAxis.MotionData.MotorPosition;            if (!shuttleAxis.CheckPositionInStationIgnoreWaferSize(shuttlePosition, "OUT"))            {                if (showError)                {                    NotifyError(eEvent.ERR_LOADER, $"shuttle{side} {shuttlePosition} is not in Out", index);                }                return false;            }            JetAxisBase tiltAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.Tilt{side}");            double tiltPosition = tiltAxis.MotionData.MotorPosition;            if (!tiltAxis.CheckPositionInStationIgnoreWaferSize(tiltPosition, "HORI"))            {                if (showError)                {                    NotifyError(eEvent.ERR_LOADER, $"tilt{side} {tiltPosition} is not in HORI", index);                    return false;                }            }            JetAxisBase crsAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Loader1}.LS{side}");            double crsPosition = crsAxis.MotionData.MotorPosition;            if (!crsAxis.CheckPositionInStationIgnoreWaferSize(crsPosition, "Unlock"))            {                if (showError)                {                    NotifyError(eEvent.ERR_LOADER, $"LS{side} {crsPosition} is not in Unlock", index);                }                return false;            }            return true;        }        /// <summary>        /// 记录Lottrack        /// </summary>        private void LottrackRecord()        {            //记录Lottrack            if (DateTime.Now.Subtract(_lotTackTime).TotalMilliseconds >= LOTTRACK_TIME)            {                AddLotTrackData();                _lotTackTime = DateTime.Now;            }        }        /// <summary>        /// 获取Lot Track数据        /// </summary>        /// <returns></returns>        private void AddLotTrackData()        {            LoaderLotTrackData data = new LoaderLotTrackData();            data.TimeStamp = DateTime.Now;            if(_side == SIDE_A)            {                data.LoaderABernoulliBladderEnable = _loaderSide.SideData.BernoulliBladder;                data.LoaderABernoulliBladderPressure = _loaderSide.SideData.BernoulliBladderPressure;                data.LoaderABernoulliN2Pressure = _loaderSide.SideData.BernoulliPressure;                data.LoaderACRSVacuum = _loaderSide.SideData.CRSVacuum;                data.LoaderACRSVacuumAnlg = _loaderSide.SideData.CRSVacuumValue;                data.LoaderAWHPressure = _loaderSide.SideData.WHBladderPressure;            }            else            {                data.LoaderBBernoulliBladderEnable = _loaderSide.SideData.BernoulliBladder;                data.LoaderBBernoulliBladderPressure = _loaderSide.SideData.BernoulliBladderPressure;                data.LoaderBBernoulliN2Pressure = _loaderSide.SideData.BernoulliPressure;                data.LoaderBCRSVacuum = _loaderSide.SideData.CRSVacuum;                data.LoaderBCRSVacuumAnlg = _loaderSide.SideData.CRSVacuumValue;                data.LoaderBWHPressure = _loaderSide.SideData.WHBladderPressure;            }                      data.LoaderWHClamped = _loaderCommon.CommonData.WaferHolderClamp;            _datas.Add(data);        }            }}
 |