将Feature/XP.Common和Feature/XP.Hardware分支合并至Develop/XP.forHardwareAndCommon,完善XPapp注册和相关硬件类库通用类库功能。
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
using XP.Hardware.MotionControl.Abstractions.Enums;
|
||||
|
||||
namespace XP.Hardware.MotionControl.Abstractions
|
||||
{
|
||||
/// <summary>
|
||||
/// 旋转轴抽象基类 | Rotary Axis Abstract Base Class
|
||||
/// 提供角度边界检查、启用状态管理等通用逻辑 | Provides angle boundary check, enabled status management
|
||||
/// </summary>
|
||||
public abstract class RotaryAxisBase : IRotaryAxis
|
||||
{
|
||||
/// <summary>轴标识 | Axis identifier</summary>
|
||||
protected readonly RotaryAxisId _axisId;
|
||||
|
||||
/// <summary>最小角度(度)| Minimum angle (degrees)</summary>
|
||||
protected readonly double _minAngle;
|
||||
|
||||
/// <summary>最大角度(度)| Maximum angle (degrees)</summary>
|
||||
protected readonly double _maxAngle;
|
||||
|
||||
/// <summary>是否启用 | Is enabled</summary>
|
||||
protected readonly bool _enabled;
|
||||
|
||||
/// <summary>轴标识 | Axis identifier</summary>
|
||||
public RotaryAxisId Id => _axisId;
|
||||
|
||||
/// <summary>实际角度(度)| Actual angle (degrees)</summary>
|
||||
public double ActualAngle { get; protected set; }
|
||||
|
||||
/// <summary>轴状态 | Axis status</summary>
|
||||
public AxisStatus Status { get; protected set; } = AxisStatus.Idle;
|
||||
|
||||
/// <summary>是否启用 | Is enabled</summary>
|
||||
public bool Enabled => _enabled;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数 | Constructor
|
||||
/// </summary>
|
||||
/// <param name="axisId">轴标识 | Axis identifier</param>
|
||||
/// <param name="minAngle">最小角度(度)| Minimum angle (degrees)</param>
|
||||
/// <param name="maxAngle">最大角度(度)| Maximum angle (degrees)</param>
|
||||
/// <param name="enabled">是否启用 | Is enabled</param>
|
||||
protected RotaryAxisBase(RotaryAxisId axisId, double minAngle, double maxAngle, bool enabled)
|
||||
{
|
||||
_axisId = axisId;
|
||||
_minAngle = minAngle;
|
||||
_maxAngle = maxAngle;
|
||||
_enabled = enabled;
|
||||
}
|
||||
|
||||
/// <summary>验证目标角度是否在范围内 | Validate target angle within range</summary>
|
||||
/// <param name="targetAngle">目标角度(度)| Target angle (degrees)</param>
|
||||
/// <returns>true=在范围内,false=越界 | true=within range, false=out of range</returns>
|
||||
public bool ValidateTarget(double targetAngle) => targetAngle >= _minAngle && targetAngle <= _maxAngle;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public abstract MotionResult MoveToTarget(double targetAngle, double? speed = null);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public abstract MotionResult JogStart(bool positive);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public abstract MotionResult JogStop();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public abstract MotionResult Home();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public abstract MotionResult Stop();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public abstract void UpdateStatus();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user