| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 | using Aitex.Core.RT.Device;using Aitex.Core.RT.Log;using Aitex.Core.RT.Routine;using MECF.Framework.Common.Equipment;using MECF.Framework.Common.Routine;using MECF.Framework.Common.Utilities;using CyberX8_Core;using CyberX8_RT.Devices.AXIS;using CyberX8_RT.Devices.Loader;using CyberX8_RT.Devices.PUF;using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using CyberX8_RT.Devices.Safety;using Aitex.Core.Util;using CyberX8_RT.Modules.PUF;using CyberX8_RT.Modules.Transporter;using Aitex.Core.Common;using static Mono.Security.X509.X520;using Aitex.Core.RT.SCCore;namespace CyberX8_RT.Modules.Loader{    public class LoaderHomeAllRoutine : RoutineBase, IRoutine    {        private enum HomeAllStep        {            CheckPreCondition,            ShuttleAHome,            WaitShuttleAHome,            TiltAHome,            WaitTiltAHome,            TiltAGotoVERT,            TiltAGotoVERTCheck,            ShuttleAGotoMID,            ShuttleAGotoMIDCheck,            ShuttleBHome,            WaitShuttleBHome,            TiltBHome,            WaitTiltBHome,            TiltBGotoVERT,            TiltBGotoVERTCheck,            ShuttleBGotoMID,            ShuttleBGotoMIDCheck,            LSAHome,            WaitLSAHome,            LSAGotoSetup,            LSAGotoSetupCheck,            LSBHome,            WaitLSBHome,            LSBGotoSetup,            LSBGotoSetupCheck,            RotationHome,            WaitRotationHome,            RotationGotoTrnpa,            RotationGotoTrnpaCheck,            End             }        #region 内部变量        private JetAxisBase _shuttleAAxis;        private JetAxisBase _shuttleBAxis;        private JetAxisBase _tiltAAxis;        private JetAxisBase _tiltBAxis;        private JetAxisBase _rotationAxis;        private JetAxisBase _lsAAxis;        private JetAxisBase _lsBAxis;           private LoaderSideDevice _sideADevice;        private LoaderSideDevice _sideBDevice;        private int _sideAWaferSize;        private int _sideBWaferSize;        #endregion        public LoaderHomeAllRoutine(string module) : base(module)        {            _shuttleAAxis = DEVICE.GetDevice<JetAxisBase>($"{module}.ShuttleA");            _shuttleBAxis = DEVICE.GetDevice<JetAxisBase>($"{module}.ShuttleB");            _tiltAAxis = DEVICE.GetDevice<JetAxisBase>($"{module}.TiltA");            _tiltBAxis = DEVICE.GetDevice<JetAxisBase>($"{module}.TiltB");            _lsAAxis = DEVICE.GetDevice<JetAxisBase>($"{module}.LSA");            _lsBAxis = DEVICE.GetDevice<JetAxisBase>($"{module}.LSB");            _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{module}.Rotation");        }        public void Abort()        {            Runner.Stop("Manual Abort");        }        public RState Monitor()        {                            Runner.Run(HomeAllStep.CheckPreCondition, CheckPreCondition, _delay_1ms)                //Home Shuttle Goto MID                .Run(HomeAllStep.ShuttleAHome, () => { return _shuttleAAxis.Home(); }, _delay_1ms)                .WaitWithStopCondition(HomeAllStep.WaitShuttleAHome, () => { return _shuttleAAxis.Status == RState.End; }, () => { return _shuttleAAxis.Status == RState.Failed; })                //Home Tilt Goto VERT                .Run(HomeAllStep.TiltAHome, () => { return _tiltAAxis.Home(); },_delay_1ms)                .WaitWithStopCondition(HomeAllStep.WaitTiltAHome, () => { return _tiltAAxis.Status == RState.End; }, () => {return _tiltAAxis.Status == RState.Failed; })                .Run(HomeAllStep.TiltAGotoVERT, () => { return _tiltAAxis.PositionStation("VERT",true); },100)                .WaitWithStopCondition(HomeAllStep.TiltAGotoVERTCheck, () => { return _tiltAAxis.Status == RState.End; }, () => { return _tiltAAxis.Status == RState.Failed; })                .Run(HomeAllStep.ShuttleBHome, () => { return _shuttleBAxis.Home(); }, _delay_1ms)                .WaitWithStopCondition(HomeAllStep.WaitShuttleBHome, () => { return _shuttleBAxis.Status == RState.End; }, () => { return _shuttleBAxis.Status == RState.Failed; })                .Run(HomeAllStep.TiltBHome, () => { return _tiltBAxis.Home(); }, _delay_1ms)                .WaitWithStopCondition(HomeAllStep.WaitTiltBHome, () => { return _tiltBAxis.Status == RState.End; }, () => { return _tiltBAxis.Status == RState.Failed; })                .Run(HomeAllStep.TiltBGotoVERT, () => { return _tiltBAxis.PositionStation("VERT",true); }, 100)                .WaitWithStopCondition(HomeAllStep.TiltBGotoVERTCheck, () => { return _tiltBAxis.Status == RState.End; }, () => { return _tiltBAxis.Status == RState.Failed; })                .Run(HomeAllStep.ShuttleAGotoMID, () => { return _shuttleAAxis.PositionStation("MID",true); }, 100)                .WaitWithStopCondition(HomeAllStep.ShuttleAGotoMIDCheck, () => { return _shuttleAAxis.Status == RState.End; }, () => { return _shuttleAAxis.Status == RState.Failed; })                .Run(HomeAllStep.ShuttleBGotoMID, () => { return _shuttleBAxis.PositionStation("MID", true); }, 100)                .WaitWithStopCondition(HomeAllStep.ShuttleBGotoMIDCheck, () => { return _shuttleBAxis.Status == RState.End; }, () => { return _shuttleBAxis.Status == RState.Failed; })                                               //Home LS Goto Setup                .Run(HomeAllStep.LSAHome, () => { return _lsAAxis.Home(); }, _delay_1ms)                .WaitWithStopCondition(HomeAllStep.WaitLSAHome, () => { return _lsAAxis.Status == RState.End; }, () => { return _lsAAxis.Status == RState.Failed; })                .Run(HomeAllStep.LSAGotoSetup, () => { return _lsAAxis.PositionStation($"Setup{_sideAWaferSize}", true); }, _delay_1ms)                .WaitWithStopCondition(HomeAllStep.LSAGotoSetupCheck, () => { return _lsAAxis.Status == RState.End; }, () => { return _lsAAxis.Status == RState.Failed; })                .Run(HomeAllStep.LSBHome, () => { return _lsBAxis.Home(); }, _delay_1ms)                .WaitWithStopCondition(HomeAllStep.WaitLSBHome, () => { return _lsBAxis.Status == RState.End; }, () => { return _lsBAxis.Status == RState.Failed; })                .Run(HomeAllStep.LSBGotoSetup, () => { return _lsBAxis.PositionStation($"Setup{_sideBWaferSize}",true); }, 100)                .WaitWithStopCondition(HomeAllStep.LSBGotoSetupCheck, () => { return _lsBAxis.Status == RState.End; }, () => { return _lsBAxis.Status == RState.Failed; })                //Home Rotation Goto TRNPA                .Run(HomeAllStep.RotationHome, () => { return _rotationAxis.Home(); }, _delay_1ms)                .WaitWithStopCondition(HomeAllStep.WaitRotationHome, () => { return _rotationAxis.Status == RState.End; }, () => { return _rotationAxis.Status == RState.Failed; })                .Run(HomeAllStep.RotationGotoTrnpa, () => { return _rotationAxis.PositionStation("TRNPA", true); }, 100)                .WaitWithStopCondition(HomeAllStep.RotationGotoTrnpaCheck, () => { return _rotationAxis.Status == RState.End; }, () => { return _rotationAxis.Status == RState.Failed; })                .End(HomeAllStep.End,NullFun);            return Runner.Status;         }                                public RState Start(params object[] objs)        {            _sideADevice = DEVICE.GetDevice<LoaderSideDevice>($"{Module}.SideA");            _sideBDevice = DEVICE.GetDevice<LoaderSideDevice>($"{Module}.SideB");            LoaderEntity loaderEntity = Singleton<RouteManager>.Instance.GetModule<LoaderEntity>(ModuleName.Loader1.ToString());            _sideAWaferSize = loaderEntity.SideAWaferSize;            _sideBWaferSize = loaderEntity.SideBWaferSize;            Runner.Start(Module, "Home All");            return RState.Running;        }        /// <summary>        /// 检验前置条件        /// </summary>        /// <returns></returns>        private bool CheckPreCondition()        {            if (!CheckHomeCondition())            {                return false;            }            if (!CheckAxisCondition())            {                return false;            }            return true;        }        /// <summary>        /// 检验Home条件        /// </summary>        /// <returns></returns>        private bool CheckHomeCondition()        {            //检验PUF、Loader Transporter,Robot均Homed            //Efem Home            if (ModuleHelper.IsInstalled(ModuleName.PUF1))            {                PUFEntity puf1Entity = Singleton<RouteManager>.Instance.GetModule<PUFEntity>(ModuleName.PUF1.ToString());                if (!puf1Entity.IsHomed)                {                    NotifyError(eEvent.ERR_LOADER, "PUF1 is not homed", -1);                    return false;                }            }                        return true;        }        /// <summary>        /// 检验Axis条件        /// </summary>        /// <param name="side"></param>        /// <returns></returns>        private bool CheckAxisCondition()        {            //Check all motor switch on            if (!AxisManager.Instance.CheckModuleAxisSwitchOn(Module, ""))            {                return false;            }            return true;        }    }}
 |