using Aitex.Core.RT.DataCenter;
using Aitex.Core.RT.Device;
using Aitex.Core.RT.Event;
using Aitex.Core.RT.Log;
using Aitex.Core.RT.OperationCenter;
using Aitex.Core.RT.Routine;
using Aitex.Core.RT.SCCore;
using Aitex.Core.Util;
using MECF.Framework.Common.Beckhoff.ModuleIO;
using MECF.Framework.Common.CommonData.SRD;
using MECF.Framework.Common.Persistent.Prewet;
using MECF.Framework.Common.Persistent.SRD;
using MECF.Framework.Common.TwinCat;
using CyberX8_Core;
using System.Reflection;
using CyberX8_RT.Modules.Rinse;
using CyberX8_RT.Modules;
using CyberX8_RT.Modules.SRD;
using CyberX8_RT.Devices.AXIS;
using MECF.Framework.Common.Persistent.Rinse;
using System.Security.Principal;
using MECF.Framework.Common.IOCore;
using Aitex.Core.Common;
namespace CyberX8_RT.Devices.SRD
{
public class SrdCommonDevice : BaseDevice, IDevice
{
///
/// Srd操作枚举
///
private enum SrdCommonOperation
{
None,
DoorClose,
DoorOpen,
ChuckVacuumOn,
ChuckVacuumOff,
LiftUpOn,
LiftUpOff,
FlippersIn,
FlippersOut,
ChuckATMClick
}
#region 常量
private const string FLUID_CONTAINMENT = "FluidContainment";
private const string VACUUM_VALUE = "VacuumValue";
private const string WAFER_PRESENCE = "WaferPresence";
private const string WAFER_PRESENCE_STATUS = "WaferPresenceStatus";
private const string WATER_PRESSURE = "WaterPressure";
private const string DOOR_CLOSE="DoorClose";
private const string DOOR_CLOSED = "DoorClosed";
private const string DOOR_OPENED = "DoorOpened";
private const string WATER_ABOVE="WaterAbove";
private const string WATER_BELOW = "WaterBelow";
private const string CHUCK_VACUUM="ChuckVacuum";
private const string EXHAUST_ON="ExhaustOn";
private const string COMMON_DATA = "CommonData";
private const string PERSISTENT_VALUE= "PersistentValue";
private const string CHUCK_ATM_ON = "ChuckATMOn";
private const string CHUCK_VACUUM_OK = "ChuckVacuumOK";
private const string WAFER_PRESENT = "WaferPresent";
private const string LIFT_UP = "LiftUp";
private const string LIFT_UP_STATUS = "LiftUpStatus";
private const string FLIPPER1_OUT_100_STATUS = "Flipper1Out100Status";
private const string FLIPPER2_OUT_100_STATUS = "Flipper2Out100Status";
private const string FLIPPER3_OUT_100_STATUS = "Flipper3Out100Status";
private const string FLIPPER1_OUT_150_STATUS = "Flipper1Out150Status";
private const string FLIPPER2_OUT_150_STATUS = "Flipper2Out150Status";
private const string FLIPPER3_OUT_150_STATUS = "Flipper3Out150Status";
private const string FLIPPER1_OUT_200_STATUS = "Flipper1Out200Status";
private const string FLIPPER2_OUT_200_STATUS = "Flipper2Out200Status";
private const string FLIPPER3_OUT_200_STATUS = "Flipper3Out200Status";
private const string FLIPPERS_IN_100 = "FlippersIn100";
private const string FLIPPERS_IN_150 = "FlippersIn150";
private const string FLIPPERS_IN_200 = "FlippersIn200";
private const string WATER_FLOW = "WaterFlow";
private const string WATER_ON = "WaterOn";
private const string N2_ON= "N2On";
#endregion
#region 内部变量
///
/// Common数据
///
private SrdCommonData _commonData = new SrdCommonData();
///
/// 状态
///
private RState _status;
///
/// 当前操作
///
private SrdCommonOperation _currentOperation;
///
/// Wafer Presence
///
private string _waferPresence;
///
/// Persistent Value对象
///
private SRDPersistentValue _srdPersistentValue;
///
/// IsWaferPresence
///
private bool _isWaferPresence = true;
///
/// Total Device
///
private TotalSRDDevice _totalSRDDevice;
#region Routine
///
/// Close Routine
///
private SrdCommonDoorCloseRoutine _doorCloseRoutine;
///
/// Vacuum Routine
///
private SrdCommonChuckVacuumRoutine _chuckVacuumRoutine;
///
/// Lift Up routine
///
private SrdCommonLiftUpRoutine _liftUpRoutine;
///
/// Flippers Routine
///
private SrdCommonFlipperRoutine _flipperRoutine;
///
/// Chuck ATM Click Routine
///
private SrdCommonChuckATMRoutine _chuckATMRoutine;
#endregion
#endregion
#region 属性
///
/// Common数据
///
public SrdCommonData CommonData
{
get { return _commonData; }
}
///
/// 状态
///
public RState Status { get { return _status; } }
///
/// Wafer Presence
///
public string WaferPresence
{
get { return _waferPresence; }
}
///
/// IsWaferPresence
///
public bool IsWaferPresence
{
get { return _isWaferPresence; }
}
#endregion
///
/// 构造函数
///
///
///
public SrdCommonDevice(string moduleName) : base(moduleName, "Common", "Common", "Common")
{
}
///
/// 初始化
///
///
public bool Initialize()
{
InitializeRoutine();
SubscribeData();
SubscribeValueAction();
InitializeOperation();
return true;
}
///
/// 初始化Routine
///
private void InitializeRoutine()
{
_doorCloseRoutine = new SrdCommonDoorCloseRoutine(Module);
_chuckVacuumRoutine = new SrdCommonChuckVacuumRoutine(Module);
_liftUpRoutine = new SrdCommonLiftUpRoutine(Module);
_flipperRoutine = new SrdCommonFlipperRoutine(Module);
_chuckATMRoutine = new SrdCommonChuckATMRoutine(Module);
}
///
/// 订阅数据
///
private void SubscribeData()
{
_srdPersistentValue = SRDPersistentManager.Instance.GetModulePersistentValue(Module);
if(_srdPersistentValue==null)
{
LOG.WriteLog(eEvent.ERR_SRD, Module, "Persistent Value Object is not exist");
}
DATA.Subscribe($"{Module}.{PERSISTENT_VALUE}", () => _srdPersistentValue, SubscriptionAttribute.FLAG.IgnoreSaveDB);
DATA.Subscribe($"{Module}.{COMMON_DATA}", () => _commonData, SubscriptionAttribute.FLAG.IgnoreSaveDB);
DATA.Subscribe($"{Module}.{WAFER_PRESENCE_STATUS}", () => _waferPresence, SubscriptionAttribute.FLAG.IgnoreSaveDB);
DATA.Subscribe($"{Module}.IsWaferPresence", () => IsWaferPresence, SubscriptionAttribute.FLAG.IgnoreSaveDB);
}
///
/// 订阅变量数值发生变化
///
private void SubscribeValueAction()
{
IOModuleManager.Instance.SubscribeModuleVariable(Module, VACUUM_VALUE, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, WAFER_PRESENCE, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, DOOR_CLOSE, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, DOOR_CLOSED, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, DOOR_OPENED, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, WATER_ABOVE, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, WATER_BELOW, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, CHUCK_VACUUM, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, EXHAUST_ON, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, CHUCK_ATM_ON, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, CHUCK_VACUUM_OK, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, WAFER_PRESENT, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, LIFT_UP, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, LIFT_UP_STATUS, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER1_OUT_100_STATUS, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER2_OUT_100_STATUS, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER3_OUT_100_STATUS, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER1_OUT_150_STATUS, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER2_OUT_150_STATUS, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER3_OUT_150_STATUS, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER1_OUT_200_STATUS, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER2_OUT_200_STATUS, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPER3_OUT_200_STATUS, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPERS_IN_100, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPERS_IN_150, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, FLIPPERS_IN_200, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, WATER_FLOW, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, N2_ON, UpdateVariableValue);
IOModuleManager.Instance.SubscribeModuleVariable(Module, WATER_ON, UpdateVariableValue);
}
///
/// 初始化操作
///
private void InitializeOperation()
{
OP.Subscribe($"{Module}.{Name}.DoorClose", DoorCloseAction);
OP.Subscribe($"{Module}.{Name}.DoorOpen", DoorOpenAction);
OP.Subscribe($"{Module}.{Name}.WaterOn", WaterOnAction);
OP.Subscribe($"{Module}.{Name}.WaterOff", WaterOffAction);
OP.Subscribe($"{Module}.{Name}.ChuckVacuumOn", ChuckVacuumOnAction);
OP.Subscribe($"{Module}.{Name}.ChuckVacuumOff", ChuckVacuumOffAction);
OP.Subscribe($"{Module}.{Name}.N2On", N2OnAction);
OP.Subscribe($"{Module}.{Name}.N2Off", N2OffAction);
OP.Subscribe($"{Module}.{Name}.LiftUpOn", LiftUpOnAction);
OP.Subscribe($"{Module}.{Name}.LiftUpOff", LiftUpOffAction);
OP.Subscribe($"{Module}.{Name}.ChuckATMOn", ChuckATMOnAction);
OP.Subscribe($"{Module}.{Name}.ChuckATMOff", ChuckATMOffAction);
OP.Subscribe($"{Module}.{Name}.FlipperIn", FlipperInAction);
OP.Subscribe($"{Module}.{Name}.FlipperOut", FlipperOutAction);
OP.Subscribe($"{Module}.KeyDown", KeyDownAction);
OP.Subscribe($"{Module}.DisabledAction", DisabledOperation);
OP.Subscribe($"{Module}.ManualAction", ManualOperation);
OP.Subscribe($"{Module}.AutoAction", AutoOperation);
OP.Subscribe($"{Module}.EngineeringModeAction", EngineeringModeOperation);
OP.Subscribe($"{Module}.ProductionModeAction", ProductionModeOperation);
OP.Subscribe($"{Module}.UpdateIsWaferPresenceAction", UpdateIsWaferPresenceAction);
}
/// 更新变量数值
///
///
///
private void UpdateVariableValue(string variable, object value)
{
if(!CommonData.IsDataInitialized)
{
CommonData.IsDataInitialized = true;
}
PropertyInfo property = CommonData.GetType().GetProperty(variable);
if (property != null)
{
property.SetValue(CommonData, value);
}
UpdateWaferPresence(variable, value);
}
///
/// 更新Wafer Presence
///
private void UpdateWaferPresence(string variable,object value)
{
if (variable == WAFER_PRESENCE&&value is double)
{
UpdateWaferPresence((double)value);
}
}
///
/// 更新Wafer Presence
///
///
private void UpdateWaferPresence(double waferPresence)
{
if (_srdPersistentValue != null)
{
if (waferPresence > _srdPersistentValue.EmptyThreshold)
{
_waferPresence = "Empty";
}
else if (waferPresence >= _srdPersistentValue.WellPlacedHighThreshold && waferPresence <= _srdPersistentValue.EmptyThreshold)
{
_waferPresence = "PoorlyPlaced";
}
else if (waferPresence < _srdPersistentValue.WellPlacedLowThreshold)
{
_waferPresence = "PoorlyPlaced";
}
else
{
_waferPresence = "WellPlaced";
}
}
}
#region Operation
#region OperationStatus
///
/// DisabledAction
///
///
///
///
private bool DisabledOperation(string cmd, object[] args)
{
string currentOperation = "Disabled";
SRDEntity srdEntity = Singleton.Instance.GetModule(Module);
if (srdEntity == null || _srdPersistentValue == null) return false;
if (_srdPersistentValue.OperatingMode != "Disabled") srdEntity.EnterInit();
SRDPersistentManager.Instance.UpdateOperationModeValue(Module,currentOperation);
return true;
}
///
/// ManualAction
///
///
///
///
private bool ManualOperation(string cmd, object[] args)
{
string currentOperation = "Manual";
SRDEntity srdEntity = Singleton.Instance.GetModule(Module);
if (srdEntity == null || _srdPersistentValue == null) return false;
if (_srdPersistentValue.OperatingMode == "Auto" && srdEntity.IsBusy)
{
LOG.WriteLog(eEvent.ERR_SRD, Module, $"{Module} is Busy, can't change to manual mode");
return false;
}
if (_srdPersistentValue.OperatingMode != "Manual") srdEntity.EnterInit();
SRDPersistentManager.Instance.UpdateOperationModeValue(Module,currentOperation);
return true;
}
///
/// AutoAction
///
///
///
///
private bool AutoOperation(string cmd, object[] args)
{
string currentOperation = "Auto";
SRDEntity srdEntity = Singleton.Instance.GetModule(Module);
if (srdEntity == null || _srdPersistentValue == null) return false;
if (_srdPersistentValue.OperatingMode != "Auto") srdEntity.EnterInit();
SRDPersistentManager.Instance.UpdateOperationModeValue(Module,currentOperation);
return true;
}
///
/// EngineeringModeAction
///
///
///
///
private bool EngineeringModeOperation(string cmd, object[] args)
{
string currentRecipeOperation = "Engineering";
SRDPersistentManager.Instance.UpdateRecipeOperationModeValue(Module, currentRecipeOperation);
return true;
}
///
/// ProductionAction
///
///
///
///
private bool ProductionModeOperation(string cmd, object[] args)
{
string currentRecipeOperation = "Production";
SRDPersistentManager.Instance.UpdateRecipeOperationModeValue(Module, currentRecipeOperation);
return true;
}
#endregion
#region keydown
private bool KeyDownAction(string cmd, object[] args)
{
string variableName = args[0].ToString();
PropertyInfo property = _srdPersistentValue.GetType().GetProperty(variableName);
if(property!=null)
{
property.SetValue(_srdPersistentValue, args[1]);
}
SRDPersistentManager.Instance.UpdateModulePersistentValue(Module);
UpdateWaferPresence(CommonData.WaferPresence);
return true;
}
#endregion
#region Door
///
/// Door Close操作
///
public bool DoorCloseAction(string cmd, object[] args)
{
if (!JudgeRunningState(SrdCommonOperation.DoorClose))
{
_currentOperation = SrdCommonOperation.DoorClose;
_status = _doorCloseRoutine.Start(true);
return _status==RState.Running;
}
else
{
return false;
}
}
///
/// Door Open操作
///
public bool DoorOpenAction(string cmd, object[] args)
{
if (!JudgeRunningState(SrdCommonOperation.DoorOpen))
{
_currentOperation = SrdCommonOperation.DoorOpen;
_status = _doorCloseRoutine.Start(false);
return _status==RState.Running;
}
else
{
return false;
}
}
#endregion
#region N2 On
///
/// N2 On
///
///
///
///
public bool N2OnAction(string cmd, object[] args)
{
return N2On();
}
///
/// N2 Off
///
///
///
///
public bool N2OffAction(string cmd, object[] args)
{
return N2Off();
}
///
/// Exhaust On(不确认信号)
///
///
public bool N2On()
{
string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{N2_ON}");
return IOModuleManager.Instance.WriteIoValue(ioName, true);
}
///
/// Exhaust On(不确认信号)
///
///
public bool N2Off()
{
string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{N2_ON}");
return IOModuleManager.Instance.WriteIoValue(ioName, false);
}
#endregion
#region Flipper
///
/// FlipperIn
///
///
///
///
public bool FlipperInAction(string cmd, object[] args)
{
int waferSize = (int)args[0];
if (!JudgeRunningState(SrdCommonOperation.FlippersIn))
{
_currentOperation = SrdCommonOperation.FlippersIn;
_status = _flipperRoutine.Start(true, waferSize);
return _status == RState.Running;
}
else
{
return false;
}
}
///
/// FlipperOut
///
///
///
///
public bool FlipperOutAction(string cmd, object[] args)
{
int waferSize = (int)args[0];
if (!JudgeRunningState(SrdCommonOperation.FlippersOut))
{
_currentOperation = SrdCommonOperation.FlippersOut;
_status = _flipperRoutine.Start(false, waferSize);
return _status == RState.Running;
}
else
{
return false;
}
}
#endregion
#region Water
///
/// Water On操作
///
public bool WaterOnAction(string cmd, object[] args)
{
return WaterOn();
}
///
/// water Off操作
///
public bool WaterOffAction(string cmd, object[] args)
{
return WaterOff();
}
///
/// Water On(不确认信号)
///
///
public bool WaterOn()
{
string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{WATER_ON}");
return IOModuleManager.Instance.WriteIoValue(ioName, true);
}
///
/// Water Off(不确认信号)
///
///
public bool WaterOff()
{
string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{WATER_ON}");
return IOModuleManager.Instance.WriteIoValue(ioName, false);
}
#endregion
#region Chuck Vacuum
///
/// Chuck Vacuum操作
///
public bool ChuckVacuumOnAction(string cmd, object[] args)
{
if (!JudgeRunningState(SrdCommonOperation.ChuckVacuumOn))
{
_currentOperation = SrdCommonOperation.ChuckVacuumOn;
_status = _chuckVacuumRoutine.Start(false);
return _status==RState.Running;
}
else
{
return false;
}
}
///
/// chuck Vacuum Off操作
///
public bool ChuckVacuumOffAction(string cmd, object[] args)
{
if (!JudgeRunningState(SrdCommonOperation.ChuckVacuumOff))
{
_currentOperation = SrdCommonOperation.ChuckVacuumOff;
_status= _chuckVacuumRoutine.Start(true);
return _status==RState.Running;
}
else
{
return false;
}
}
#endregion
#region LiftUp
///
/// Lift Up On
///
///
///
///
public bool LiftUpOnAction(string cmd, object[] args)
{
if (!JudgeRunningState(SrdCommonOperation.LiftUpOn))
{
_currentOperation = SrdCommonOperation.LiftUpOn;
_status = _liftUpRoutine.Start(true);
return _status == RState.Running;
}
else
{
return false;
}
}
///
/// Lift Up Off
///
///
///
///
public bool LiftUpOffAction(string cmd, object[] args)
{
if (!JudgeRunningState(SrdCommonOperation.LiftUpOff))
{
_currentOperation = SrdCommonOperation.LiftUpOff;
_status = _liftUpRoutine.Start(false);
return _status == RState.Running;
}
else
{
return false;
}
}
#endregion
#region ChuckATM
///
/// Chuck ATM On
///
///
///
///
public bool ChuckATMOnAction(string cmd, object[] args)
{
return ChuckATM(true);
}
///
/// Chuck ATM Off
///
///
///
///
public bool ChuckATMOffAction(string cmd, object[] args)
{
return ChuckATM(false);
}
private bool ChuckATM(bool value)
{
string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{CHUCK_ATM_ON}");
return IOModuleManager.Instance.WriteIoValue(ioName, value);
}
///
/// Chuck ATM Routine
///
///
///
///
public bool ChuckATMAction(string cmd, object[] args)
{
if (!JudgeRunningState(SrdCommonOperation.ChuckATMClick))
{
_currentOperation = SrdCommonOperation.ChuckATMClick;
_status = _chuckATMRoutine.Start();
return _status == RState.Running;
}
else
{
return false;
}
}
#endregion
#region Water Above
///
/// Water Above On操作
///
public bool WaterAboveOnAction(string cmd, object[] args)
{
return WaterAboveOn();
}
///
/// water above Off操作
///
public bool WaterAboveOffAction(string cmd, object[] args)
{
return WaterAboveOff();
}
///
/// Water Above On(不确认信号)
///
///
public bool WaterAboveOn()
{
string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{WATER_ABOVE}");
return IOModuleManager.Instance.WriteIoValue(ioName, true);
}
///
/// Water Above Off(不确认信号)
///
///
public bool WaterAboveOff()
{
string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{WATER_ABOVE}");
return IOModuleManager.Instance.WriteIoValue(ioName, false);
}
#endregion
#region Water Below
///
/// Water Below On操作
///
public bool WaterBelowOnAction(string cmd, object[] args)
{
return WaterBelowOn();
}
///
/// water Below Off操作
///
public bool WaterBelowOffAction(string cmd, object[] args)
{
return WaterBelowOff();
}
///
/// Water Below On(不确认信号)
///
///
public bool WaterBelowOn()
{
string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{WATER_BELOW}");
return IOModuleManager.Instance.WriteIoValue(ioName, true);
}
///
/// Water Below Off(不确认信号)
///
///
public bool WaterBelowOff()
{
string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{WATER_BELOW}");
return IOModuleManager.Instance.WriteIoValue(ioName, false);
}
#endregion
///
/// Update IsWaferPresence 标志位
///
///
///
///
public bool UpdateIsWaferPresenceAction(string cmd, object[] args)
{
_isWaferPresence = (bool)args[0];
return true;
}
///
/// 判定运行状态
///
///
private bool JudgeRunningState(SrdCommonOperation operation)
{
if (_status == RState.Running)
{
EV.PostAlarmLog($"{Module}", eEvent.ERR_SRD, $"{Module} current execute {_currentOperation},cannot {operation}");
return true;
}
return false;
}
///
/// ErrorOperation
///
public void EnterErrorOperation()
{
//关闭风扇
if (CommonData.N2On)
{
bool result = N2OffAction("", null);
if (!result)
{
LOG.WriteLog(eEvent.ERR_SRD, Module, "EnterError: N2 Off is failed");
}
}
//关闭WaterAbove
if (CommonData.WaterOn)
{
bool result = WaterOff();
if (!result)
{
LOG.WriteLog(eEvent.INFO_SRD, Module, "EnterError: Water Off is failed");
}
}
//停电机
JetAxisBase _rotationAxis = DEVICE.GetDevice($"{Module}.Rotation");
if (_rotationAxis != null && _rotationAxis.IsRun) _rotationAxis.StopPositionOperation();
}
#endregion
///
/// Rotation InterLock
///
///
public bool RotationInterLock()
{
if (!CommonData.DoorClosed)
{
LOG.WriteLog(eEvent.ERR_SRD, Module, "Door is not closed. Rotation can not position");
return false;
}
//Check Flippers
if (CommonData.FlippersIn150 || CommonData.FlippersIn200) //|| _srdCommon.CommonData.FlippersIn100
{
LOG.WriteLog(eEvent.ERR_SRD, Module, "FlippersIn is on. Rotation can not position");
return false;
}
if (!CommonData.Flipper1Out150Status || !CommonData.Flipper2Out150Status || !CommonData.Flipper3Out150Status
|| !CommonData.Flipper1Out200Status || !CommonData.Flipper2Out200Status || !CommonData.Flipper3Out200Status)
//|| !_srdCommon.CommonData.Flipper1Out100Status || !_srdCommon.CommonData.Flipper2Out100Status || !_srdCommon.CommonData.Flipper3Out100Status
{
LOG.WriteLog(eEvent.ERR_SRD, Module, "Flippers are at In position. Rotation can not position");
return false;
}
return true;
}
///
/// 定时器
///
///
public bool OnTimer()
{
if (_status == RState.Running)
{
if (_currentOperation != SrdCommonOperation.None)
{
IRoutine routine = GetCurrentRoutine(_currentOperation);
if (routine != null)
{
CheckRoutineState(routine, _currentOperation);
}
else
{
EndOperation();
}
}
}
//将公有的数据赋值于对象的数值
if (_totalSRDDevice == null)
{
_totalSRDDevice = DEVICE.GetDevice("SRD");
}
if (_totalSRDDevice != null)
{
CommonData.FluidContainment = _totalSRDDevice.FluidContainment;
CommonData.WaterPressure = _totalSRDDevice.WaterPressure;
}
return true;
}
///
/// 获取当前操作对应的Routine
///
///
///
private IRoutine GetCurrentRoutine(SrdCommonOperation currentOperation)
{
switch (currentOperation)
{
case SrdCommonOperation.DoorClose:
case SrdCommonOperation.DoorOpen:
return _doorCloseRoutine;
case SrdCommonOperation.ChuckVacuumOn:
case SrdCommonOperation.ChuckVacuumOff:
return _chuckVacuumRoutine;
case SrdCommonOperation.LiftUpOn:
case SrdCommonOperation.LiftUpOff:
return _liftUpRoutine;
case SrdCommonOperation.FlippersIn:
case SrdCommonOperation.FlippersOut:
return _flipperRoutine;
case SrdCommonOperation.ChuckATMClick:
return _chuckATMRoutine;
default:
return null;
}
}
///
/// 检验Routine状态
///
///
///
private void CheckRoutineState(IRoutine routine, SrdCommonOperation currentOperation)
{
RState state = routine.Monitor();
if (state == RState.End)
{
EndOperation();
}
else if (state == RState.Failed || state == RState.Timeout)
{
LOG.WriteLog(eEvent.ERR_SRD, $"{Module}", $"{currentOperation} error");
EndOperation();
}
}
///
/// 结束操作
///
private void EndOperation()
{
_status = RState.End;
_currentOperation = SrdCommonOperation.None;
}
#region 设备接口
///
/// 监控
///
public void Monitor()
{
}
public void Reset()
{
}
public void Terminate()
{
}
#endregion
}
}