using Aitex.Core.RT.Device;
using Aitex.Core.RT.Log;
using Aitex.Core.RT.Routine;
using Aitex.Core.Util;
using CyberX8_Core;
using CyberX8_RT.Devices.AXIS;
using CyberX8_RT.Devices.Facilities;
using CyberX8_RT.Devices.SRD;
using MECF.Framework.Common.Beckhoff.AxisProvider;
using MECF.Framework.Common.RecipeCenter;
using MECF.Framework.Common.Routine;
namespace CyberX8_RT.Modules.SRD
{
public class SRDRunRecipeRoutine : RoutineBase, IRoutine
{
private enum SRDRunRecipeStep
{
CloseDoor,
CheckDoorClosed,
End
}
#region 常量
#endregion
#region 内部变量
///
/// Rotation Axis
///
private JetAxisBase _rotationAxis;
///
/// SRD Common
///
private SrdCommonDevice _srdCommon;
///
/// Total SRD
///
private TotalSRDDevice _totalSRDDevice;
///
/// 另外SRD实例
///
private SRDEntity _otherSrdEntity;
///
/// Loader Common
///
private SystemFacilities _systemFacilities;
///
/// 是否正在用水
///
private bool _isUsingWater;
///
/// Recipe
///
private SrdRecipe _srdRecipe;
///
/// SRD rotation Provider对象
///
private BeckhoffProviderAxis _rotationProviderAxis;
#endregion
#region 属性
///
/// 是否正在用水
///
public bool IsUsingWater { get { return _isUsingWater; } }
#endregion
///
/// 构造函数
///
///
public SRDRunRecipeRoutine(string module) : base(module)
{
}
///
/// 中止
///
public void Abort()
{
Runner.Stop("SRD Run Recipe Abort");
}
///
/// 监控
///
///
public RState Monitor()
{
Runner//.Run(SRDRunRecipeStep.CloseDoor, !_presenceTestFlag, CheckFacilities, _delay_1ms)
.End(SRDRunRecipeStep.End, NullFun, _delay_1ms);
return Runner.Status;
}
///
/// 启动
///
///
///
public RState Start(params object[] objs)
{
_srdRecipe = (SrdRecipe)objs[0];
if (_srdRecipe == null)
{
NotifyError(eEvent.ERR_SRD, "srd recipe is null", 0);
return RState.Failed;
}
_rotationAxis = DEVICE.GetDevice($"{Module}.Rotation");
if (!_rotationAxis.IsHomed)
{
NotifyError(eEvent.ERR_SRD, "Rotation is not homed", 0);
return RState.Failed;
}
_srdCommon = DEVICE.GetDevice($"{Module}.Common");
_totalSRDDevice = DEVICE.GetDevice("SRD");
_systemFacilities = DEVICE.GetDevice("System.Facilities");
string otherSRD = Module == "SRD1" ? "SRD2" : "SRD1";
_otherSrdEntity = Singleton.Instance.GetModule(otherSRD);
_rotationProviderAxis = BeckhoffAxisProviderManager.Instance.GetAxisProvider($"{Module}.Rotation");
if (_rotationProviderAxis == null)
{
NotifyError(eEvent.ERR_SRD, $"{Module}.Rotation Provider is not exist", 0);
return RState.Failed;
}
return Runner.Start(Module, "SRD Run Recipe Start");
}
}
}