123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- using Aitex.Core.RT.DataCenter;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Log;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.Utilities;
- using CyberX8_RT.Devices.AXIS;
- using CyberX8_RT.Devices.AXIS.Yaskawa;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CyberX8_RT.Devices.Loader
- {
- public class LoaderSwingAxisInterLock : 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
- #region 内部变量
- private LoaderSideDevice _loaderSide = null;
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="Module"></param>
- /// <param name="name"></param>
- public LoaderSwingAxisInterLock(JetAxisBase axis)
- {
- _axis = axis;
- }
- /// <summary>
- /// 加载LoaderSide对象
- /// </summary>
- private void GetLoaderSide()
- {
- if (_loaderSide == null)
- {
- switch (Name)
- {
- case "SwingA":
- _loaderSide = DEVICE.GetDevice<LoaderSideDevice>($"{Module}.SideA");
- break;
- default:
- _loaderSide = DEVICE.GetDevice<LoaderSideDevice>($"{Module}.SideB");
- break;
- }
- }
- }
- /// <summary>
- /// GotoPosition条件检验
- /// </summary>
- /// <param name="station"></param>
- /// <returns></returns>
- /// <exception cref="NotImplementedException"></exception>
- public bool CheckGotoPosition(string station)
- {
- if (!_axis.IsHomed)
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{Name} is not home, Cannot execute GotoSavedPosition");
- return false;
- }
- GetLoaderSide();
- JetAxisBase tiltAxis = null;
- if(Name=="SwingA")
- {
- tiltAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.TiltA");
- }
- else
- {
- tiltAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.TiltB");
- }
- if (!tiltAxis.IsSwitchOn)
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{tiltAxis.Module} is switch off");
- return false;
- }
- if (tiltAxis.IsRun)
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, "tilt is running,Cannot execute GotoSavedPosition");
- return false;
- }
- if (station.EndsWith("CLOSED"))
- {
- double tiltPosition = tiltAxis.MotionData.MotorPosition;
- if(!tiltAxis.CheckPositionIsInStation(tiltPosition, "VERT"))
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{tiltAxis.Module} {tiltPosition} is not in VERT");
- return false;
- }
- }
- //Puf vertical is park
- if (ModuleHelper.IsInstalled(ModuleName.PUF1))
- {
- JetAxisBase puf1VerticalAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.PUF1}.Vertical");
- if (puf1VerticalAxis != null)
- {
- double puf1VertocalPosition = puf1VerticalAxis.MotionData.MotorPosition;
- if (!puf1VerticalAxis.CheckPositionIsInStation(puf1VertocalPosition, "Park"))
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{ModuleName.PUF1} Vertical {puf1VertocalPosition} is not in Park, Cannot execute GotoSavedPosition");
- return false;
- }
- }
- }
- if (ModuleHelper.IsInstalled(ModuleName.PUF2))
- {
- JetAxisBase puf2VerticalAxis = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.PUF2}.Vertical");
- if (puf2VerticalAxis != null)
- {
- double puf2VerticalPosition=puf2VerticalAxis.MotionData.MotorPosition;
- if (!puf2VerticalAxis.CheckPositionIsInStation(puf2VerticalPosition, "Park"))
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{ModuleName.PUF2} Vertical {puf2VerticalPosition} is not in Park, Cannot execute GotoSavedPosition");
- return false;
- }
- }
- }
- //Door 在Closed,无法从其他位置运动至Closed位置
- if (_loaderSide.SideData.DoorLowerLocked||_loaderSide.SideData.DoorUpperLocked)
- {
- if (station.EndsWith("CLOSED"))
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, $"door locked, {Name} cannot goto CLOSED");
- return false;
- }
- else
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, $"door locked, {Name} cannot move to other stations");
- return false;
- }
- }
- JetAxisBase rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
- if (!rotationAxis.IsSwitchOn)
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, $"{rotationAxis.Module} is switch off");
- return false;
- }
- if (rotationAxis.IsRun)
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, $"rotation is running,Cannot execute GotoSavedPosition");
- return false;
- }
- double rotationPosition = rotationAxis.MotionData.MotorPosition;
- if (rotationAxis.CheckPositionIsEmpty(rotationPosition))
- {
- //LOG.WriteLog(eEvent.ERR_LOADER, Module, "loader rotation axis is empty, Cannot execute GotoSavedPosition");
- //return false;
- return true;
- }
- else
- {
- if (rotationAxis.CheckPositionIsInStation(rotationPosition, "LOADA300") ||
- rotationAxis.CheckPositionIsInStation(rotationPosition, "LOADB300")||
- rotationAxis.CheckPositionIsInStation(rotationPosition, "SERVICEB"))
- {
- return true;
- }
- else if (rotationAxis.CheckPositionIsInStation(rotationPosition, "CAMERA"))
- {
- if (station.EndsWith("CAMERA"))
- {
- return true;
- }
- else
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, $"loader rotation axis {rotationPosition} is in Camera, {Name} only goto Camera");
- return false;
- }
- }
- else
- {
- LOG.WriteLog(eEvent.ERR_LOADER, Module, $"loader rotation axis is in {rotationAxis.CurrentStation}, can not go to position");
- return false;
- }
- }
- }
- }
- }
|