using Aitex.Core.RT.DataCenter;
using Aitex.Core.RT.Device;
using Aitex.Core.RT.Log;
using MECF.Framework.Common.Utilities;
using CyberX8_RT.Devices.AXIS;
using CyberX8_RT.Devices.AXIS.CANOpen;
using CyberX8_RT.Devices.YASKAWA;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MECF.Framework.Common.SubstrateTrackings;
namespace CyberX8_RT.Devices.PUF
{
public class PufFlipAxisInterLock : IAxisInterLock
{
#region 内部变量
private JetAxisBase _axis;
#endregion
#region 属性
///
/// 模块名称
///
public string Module { get { return _axis.Module; } }
///
/// 子模块名称
///
public string Name { get { return _axis.Name; } }
#endregion
///
/// 构造函数
///
///
///
public PufFlipAxisInterLock(JetAxisBase axis)
{
_axis=axis;
}
///
/// Positon前校验inter lock
///
///
///
public bool CheckGotoPosition(string station)
{
if (!_axis.IsHomed)
{
LOG.WriteLog(eEvent.ERROR_PUF_NOT_HOME, $"{Module}.{Name}", "axis is not homed, Cannot execute GotoSavedPosition");
return false;
}
if (!AxisManager.Instance.CheckModuleAxisSwitchOn(Module,Name))
{
return false;
}
PufVacuum _pufVacuum = DEVICE.GetDevice($"{Module}.Vacuum");
bool chuckAWaferPresent = _pufVacuum.ChuckAWaferPresent;
bool chuckBWaferPresent = _pufVacuum.ChuckBWaferPresent;
JetAxisBase rotationAxis = DEVICE.GetDevice($"{Module}.Rotation");
if(rotationAxis.Status==CyberX8_Core.RState.Running)
{
LOG.WriteLog(eEvent.ERROR_PUF_OTHERAXIS_RUNNING, $"{Module}.{Name}", "rotation status is running, Cannot execute GotoSavedPosition");
return false;
}
double rotationPosition = rotationAxis.MotionData.MotorPosition;
if (!rotationAxis.CheckPositionIsInStation(rotationPosition, "Flip"))
{
LOG.WriteLog(eEvent.ERROR_PUF_OTHER_AXIS_STATION, $"{Module}.{Name}", $"rotation station {rotationPosition} not in Flip Station,Cannot execute GotoSavedPosition");
return false;
}
//A面存在Wafer同时A面Vacuum is released
if (WaferManager.Instance.CheckHasWafer(Module,0)&&_pufVacuum.IsChuckAReleased)
{
LOG.WriteLog(eEvent.ERROR_PUF_HAS_WAFER, $"{Module}.{Name}", "Side A Has Wafer,Vacuum is Off");
return false;
}
//B面存在Wafer同时B面Vacuum is released
if (WaferManager.Instance.CheckHasWafer(Module, 1) && _pufVacuum.ISChuckBReleased)
{
LOG.WriteLog(eEvent.ERROR_PUF_HAS_WAFER, $"{Module}.{Name}", "Side B Has Wafer,Vacuum is Off");
return false;
}
if (_pufVacuum.Chuck)
{
LOG.WriteLog(eEvent.ERROR_PUF_CHUCK_ON, $"{Module}.{Name}", "Chuck is on");
return false;
}
if (_pufVacuum.SideAChuckOut)
{
LOG.WriteLog(eEvent.ERROR_PUF_SIDEA_CHUCK_OUT_ON, $"{Module}.{Name}", "SideA Chuck out is on");
return false;
}
if (_pufVacuum.SideBChuckOut)
{
LOG.WriteLog(eEvent.ERROR_PUF_SIDEA_CHUCK_OUT_ON, $"{Module}.{Name}", "SideB Chuck out is on");
return false;
}
if (!_pufVacuum.SideAChuckIn)
{
LOG.WriteLog(eEvent.ERROR_PUF_SIDEA_CHUCK_IN_OFF, $"{Module}.{Name}", "SideA Chuck in is off");
return false;
}
if (!_pufVacuum.SideBChuckIn)
{
LOG.WriteLog(eEvent.ERROR_PUF_SIDEA_CHUCK_IN_OFF, $"{Module}.{Name}", "SideB Chuck in is off");
return false;
}
return true;
}
}
}