123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Log;
- using MECF.Framework.Common.Equipment;
- using CyberX8_RT.Devices.AXIS;
- using System;
- using Aitex.Core.Util;
- using CyberX8_RT.Modules;
- using CyberX8_RT.Modules.Transporter;
- using CyberX8_RT.Modules.PUF;
- namespace CyberX8_RT.Devices.Loader
- {
- public class LoaderRotationAxisInterLock : IAxisInterLock
- {
- #region 内部变量
- private JetAxisBase _axis;
- #endregion
- #region 属性
- /// <summary>
- /// 模块名称
- /// </summary>
- public string Module { get { return _axis.Module; } }
- /// <summary>
- /// 子模块名称
- /// </summary>
- public string Name { get { return _axis.Name; } }
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="Module"></param>
- /// <param name="name"></param>
- public LoaderRotationAxisInterLock(JetAxisBase axis)
- {
- _axis = axis;
- }
- /// <summary>
- /// GotoPosition条件检验
- /// </summary>
- /// <param name="station"></param>
- /// <returns></returns>
- /// <exception cref="NotImplementedException"></exception>
- public bool CheckGotoPosition(string station)
- {
- //Check Home
- if (!CheckHomeCondition())
- {
- return false;
- }
- //Rotation is homed
- if (!_axis.IsHomed)
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} Rotation is not home, Cannot execute GotoSavedPosition");
- return false;
- }
- if (!AxisManager.Instance.CheckModuleAxisSwitchOn(Module, Name))
- {
- return false;
- }
- //Loader ShuttleA
- JetAxisBase shuttleAAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.ShuttleA");
- if(shuttleAAxis == null)
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} ShuttleA Axis is null");
- return false;
- }
- if (shuttleAAxis.Status==CyberX8_Core.RState.Running)
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} shuttleA status is running, Cannot execute GotoSavedPosition");
- return false;
- }
- //Loader ShuttleB
- JetAxisBase shuttleBAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.ShuttleB");
- if (shuttleBAxis == null)
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} ShuttleB Axis is null");
- return false;
- }
- if (shuttleBAxis.Status== CyberX8_Core.RState.Running)
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} shuttleB status is running, Cannot execute GotoSavedPosition");
- return false;
- }
- //Loader TiltA
- JetAxisBase tiltAAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.TiltA");
- if (tiltAAxis == null)
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} TiltA Axis is null");
- return false;
- }
- if (tiltAAxis.Status== CyberX8_Core.RState.Running)
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} tiltA status is running, Cannot execute GotoSavedPosition");
- return false;
- }
- //Loader TiltB
- JetAxisBase tiltBAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.TiltB");
- if(tiltBAxis == null)
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} tiltB Axis is null");
- return false;
- }
- if (tiltBAxis.Status==CyberX8_Core.RState.Running)
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} tiltB status is running, Cannot execute GotoSavedPosition");
- return false;
- }
- //PUF1 的 ROTATION 轴在‘HOME’、‘FLIP’或‘ROBOT’位
- if (ModuleHelper.IsInstalled(ModuleName.PUF1))
- {
- JetAxisBase puf1RotationAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.PUF1}.Rotation");
- if(puf1RotationAxis == null)
- {
- LOG.WriteLog(eEvent.ERR_PUF, Module, "Puf1 Rotation Axis is null");
- return false;
- }
- double puf1RotationPosition = puf1RotationAxis.MotionData.MotorPosition;
- if (!puf1RotationAxis.CheckPositionIsInStation(puf1RotationPosition, "Home")
- && !puf1RotationAxis.CheckPositionIsInStation(puf1RotationPosition, "Flip")
- && !puf1RotationAxis.CheckPositionIsInStation(puf1RotationPosition, "Robot"))
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, $"PUF1 Rotation {puf1RotationPosition} is not in Home, Flip or Robot station,Cannot execute GotoSavedPosition");
- return false;
- }
- }
- //Loader 的 SHUTTLE A 轴在‘MID’、‘LS’或‘IN’位
- double shuttleAPosition = shuttleAAxis.MotionData.MotorPosition;
- if (!shuttleAAxis.CheckPositionIsInStation(shuttleAPosition, "MID")
- && !shuttleAAxis.CheckPositionIsInStation(shuttleAPosition, "LS")
- && !shuttleAAxis.CheckPositionIsInStation(shuttleAPosition, "IN"))
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} ShuttleA {shuttleAPosition} is not in MID, LS or IN station,Cannot execute GotoSavedPosition");
- return false;
- }
- //Loader 的 SHUTTLE B 轴在‘MID’、‘LS’或‘IN’位
- double shuttleBPosition = shuttleBAxis.MotionData.MotorPosition;
- if (!shuttleBAxis.CheckPositionIsInStation(shuttleBPosition, "MID")
- && !shuttleBAxis.CheckPositionIsInStation(shuttleBPosition, "LS")
- && !shuttleBAxis.CheckPositionIsInStation(shuttleBPosition, "IN"))
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Module} ShuttleB {shuttleBPosition} is not in MID, LS or IN station,Cannot execute GotoSavedPosition");
- return false;
- }
- //Loader transporter 的 ELEVATOR 在‘UP’位。
- bool loaderTransporterInstalled = ModuleHelper.IsInstalled(ModuleName.Transporter2);
- if (loaderTransporterInstalled)
- {
- JetAxisBase loaderTransporterElevatorAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.Transporter2}.Elevator");
- if(loaderTransporterElevatorAxis == null)
- {
- LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module, "Loader transporter elevator Axis is null");
- return false;
- }
- double loaderTransporterPosition = loaderTransporterElevatorAxis.MotionData.MotorPosition;
- if (!loaderTransporterElevatorAxis.CheckPositionIsInStation(loaderTransporterPosition, "UP"))
- {
- LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module, $"Loader transporter elevator is not in UP station, Cannot execute GotoSavedPosition");
- return false;
- }
- }
- return true;
- }
- /// <summary>
- /// Check Home
- /// </summary>
- /// <returns></returns>
- private bool CheckHomeCondition()
- {
- //Efem Home
- if (ModuleHelper.IsInstalled(ModuleName.EFEM))
- {
- EfemEntity efemEntity = Singleton<RouteManager>.Instance.GetModule<EfemEntity>(ModuleName.EFEM.ToString());
- if (efemEntity == null)
- {
- LOG.WriteLog(eEvent.ERR_EFEM_ROBOT, Module, $"{ModuleName.EFEM.ToString()} entity is null");
- return false;
- }
- if (!efemEntity.IsHomed)
- {
- LOG.WriteLog(eEvent.ERR_EFEM_ROBOT, Module, $"{ModuleName.EFEM.ToString()} is not home, Cannot execute GotoSavedPosition");
- return false;
- }
- }
- //Transporter2 Home
- if (ModuleHelper.IsInstalled(ModuleName.Transporter2))
- {
- TransporterEntity loaderTransporterEntity = Singleton<RouteManager>.Instance.GetModule<TransporterEntity>(ModuleName.Transporter2.ToString());
- if (loaderTransporterEntity == null)
- {
- LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module, $"{ModuleName.Transporter2.ToString()} entity is null");
- return false;
- }
- if (!loaderTransporterEntity.IsHomed)
- {
- LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module, $"{ModuleName.Transporter2.ToString()} is not home, Cannot execute GotoSavedPosition");
- return false;
- }
- }
- //Puf1 Home
- if (ModuleHelper.IsInstalled(ModuleName.PUF1))
- {
- PUFEntity puf1Entity = Singleton<RouteManager>.Instance.GetModule<PUFEntity>(ModuleName.PUF1.ToString());
- if (puf1Entity == null)
- {
- LOG.WriteLog(eEvent.ERR_PUF, Module, $"{ModuleName.PUF1.ToString()} entity is null");
- return false;
- }
- if (!puf1Entity.IsHomed)
- {
- LOG.WriteLog(eEvent.ERR_PUF, Module, $"{ModuleName.PUF1.ToString()} is not home, Cannot execute GotoSavedPosition");
- return false;
- }
- }
- return true;
- }
- }
- }
|