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($"{module}.ShuttleA"); _shuttleBAxis = DEVICE.GetDevice($"{module}.ShuttleB"); _tiltAAxis = DEVICE.GetDevice($"{module}.TiltA"); _tiltBAxis = DEVICE.GetDevice($"{module}.TiltB"); _lsAAxis = DEVICE.GetDevice($"{module}.LSA"); _lsBAxis = DEVICE.GetDevice($"{module}.LSB"); _rotationAxis = DEVICE.GetDevice($"{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($"{Module}.SideA"); _sideBDevice = DEVICE.GetDevice($"{Module}.SideB"); if (SC.ContainsItem($"Loader1.SideAWaferSize")) { _sideAWaferSize = SC.GetValue($"Loader1.SideAWaferSize"); } if (SC.ContainsItem($"Loader1.SideBWaferSize")) { _sideBWaferSize = SC.GetValue($"Loader1.SideBWaferSize"); } Runner.Start(Module, "Home All"); return RState.Running; } /// /// 检验前置条件 /// /// private bool CheckPreCondition() { if (!CheckHomeCondition()) { return false; } if (!CheckAxisCondition()) { return false; } return true; } /// /// 检验Home条件 /// /// private bool CheckHomeCondition() { //检验PUF、Loader Transporter,Robot均Homed //Efem Home if (ModuleHelper.IsInstalled(ModuleName.EFEM)) { EfemEntity efemEntity = Singleton.Instance.GetModule(ModuleName.EFEM.ToString()); if (!efemEntity.IsHomed) { LOG.WriteLog(eEvent.ERR_EFEM_ROBOT, Module, $"{ModuleName.EFEM.ToString()} is not home, Cannot execute GotoSavedPosition"); return false; } } if (ModuleHelper.IsInstalled(ModuleName.PUF1)) { PUFEntity puf1Entity = Singleton.Instance.GetModule(ModuleName.PUF1.ToString()); if (!puf1Entity.IsHomed) { NotifyError(eEvent.ERR_LOADER, "PUF1 is not homed", -1); return false; } } if (ModuleHelper.IsInstalled(ModuleName.Transporter2)) { TransporterEntity loaderTransportEntity = Singleton.Instance.GetModule(ModuleName.Transporter2.ToString()); if (!loaderTransportEntity.IsHomed) { NotifyError(eEvent.ERR_LOADER, "Loader Transporter is not homed", -1); return false; } } return true; } /// /// 检验Axis条件 /// /// /// private bool CheckAxisCondition() { //Check all motor switch on if (!AxisManager.Instance.CheckModuleAxisSwitchOn(Module, "")) { return false; } return true; } } }