using Aitex.Core.RT.Routine; using MECF.Framework.Common.CommonData.PUF; using MECF.Framework.Common.Routine; using CyberX8_Core; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CyberX8_RT.Devices.AXIS.GalilLipsel { public class GalilRotationSwitchOnRoutine : RoutineBase, IRoutine { private enum SwitchOnStep { WriteTargetPosition, SwitchOn, End } #region 常量 private const string TARGET_POSITION = "TargetPosition"; #endregion #region 内部变量 private JetAxisBase _axis; #endregion public GalilRotationSwitchOnRoutine(string module,JetAxisBase axis) : base(module) { _axis = axis; } public void Abort() { Runner.Stop("Manual Abort"); } public RState Monitor() { Runner.Run(SwitchOnStep.WriteTargetPosition, WriteTargetPosition, _delay_1ms) .Run(SwitchOnStep.SwitchOn, SwitchOn,CheckSwitchOn,1000) .End(SwitchOnStep.End, NullFun, _delay_1ms); return Runner.Status; } /// /// 上电 /// /// private bool SwitchOn() { return _axis.WriteSwitchOn(); } /// /// 当前位置写入Target /// /// private bool WriteTargetPosition() { int targetPosition =_axis.CalculateValueMultiplyScale(_axis.MotionData.MotorPosition); return _axis.WriteAbsolutePosition(targetPosition); } /// /// 检验上电状态 /// /// private bool CheckSwitchOn() { return _axis.IsSwitchOn; } public RState Start(params object[] objs) { return Runner.Start(Module, "Switch On"); } } }