123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- 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 内部变量
- /// <summary>
- /// Rotation Axis
- /// </summary>
- private JetAxisBase _rotationAxis;
- /// <summary>
- /// SRD Common
- /// </summary>
- private SrdCommonDevice _srdCommon;
- /// <summary>
- /// Total SRD
- /// </summary>
- private TotalSRDDevice _totalSRDDevice;
- /// <summary>
- /// 另外SRD实例
- /// </summary>
- private SRDEntity _otherSrdEntity;
- /// <summary>
- /// Loader Common
- /// </summary>
- private SystemFacilities _systemFacilities;
- /// <summary>
- /// 是否正在用水
- /// </summary>
- private bool _isUsingWater;
- /// <summary>
- /// Recipe
- /// </summary>
- private SrdRecipe _srdRecipe;
- /// <summary>
- /// SRD rotation Provider对象
- /// </summary>
- private BeckhoffProviderAxis _rotationProviderAxis;
- #endregion
- #region 属性
- /// <summary>
- /// 是否正在用水
- /// </summary>
- public bool IsUsingWater { get { return _isUsingWater; } }
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="module"></param>
- public SRDRunRecipeRoutine(string module) : base(module)
- {
- }
- /// <summary>
- /// 中止
- /// </summary>
- public void Abort()
- {
- Runner.Stop("SRD Run Recipe Abort");
- }
- /// <summary>
- /// 监控
- /// </summary>
- /// <returns></returns>
- public RState Monitor()
- {
- Runner//.Run(SRDRunRecipeStep.CloseDoor, !_presenceTestFlag, CheckFacilities, _delay_1ms)
- .End(SRDRunRecipeStep.End, NullFun, _delay_1ms);
- return Runner.Status;
- }
- /// <summary>
- /// 启动
- /// </summary>
- /// <param name="objs"></param>
- /// <returns></returns>
- 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<JetAxisBase>($"{Module}.Rotation");
- if (!_rotationAxis.IsHomed)
- {
- NotifyError(eEvent.ERR_SRD, "Rotation is not homed", 0);
- return RState.Failed;
- }
- _srdCommon = DEVICE.GetDevice<SrdCommonDevice>($"{Module}.Common");
- _totalSRDDevice = DEVICE.GetDevice<TotalSRDDevice>("SRD");
- _systemFacilities = DEVICE.GetDevice<SystemFacilities>("System.Facilities");
- string otherSRD = Module == "SRD1" ? "SRD2" : "SRD1";
- _otherSrdEntity = Singleton<RouteManager>.Instance.GetModule<SRDEntity>(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");
- }
- }
- }
|