将Feature/XP.Common和Feature/XP.Hardware分支合并至Develop/XP.forHardwareAndCommon,完善XPapp注册和相关硬件类库通用类库功能。

This commit is contained in:
QI Mingxuan
2026-04-16 17:31:13 +08:00
parent 6ec4c3ddaa
commit 2bd6e566c3
581 changed files with 74600 additions and 222 deletions
@@ -0,0 +1,76 @@
using XP.Hardware.MotionControl.Abstractions.Enums;
namespace XP.Hardware.MotionControl.Abstractions
{
/// <summary>
/// 直线轴抽象基类 | Linear Axis Abstract Base Class
/// 提供边界检查、状态管理等通用逻辑 | Provides boundary check, status management
/// </summary>
public abstract class LinearAxisBase : ILinearAxis
{
/// <summary>轴标识 | Axis identifier</summary>
protected readonly AxisId _axisId;
/// <summary>最小位置(mm| Minimum position (mm)</summary>
protected readonly double _min;
/// <summary>最大位置(mm| Maximum position (mm)</summary>
protected readonly double _max;
/// <summary>原点偏移(mm| Origin offset (mm)</summary>
protected readonly double _origin;
/// <summary>轴标识 | Axis identifier</summary>
public AxisId Id => _axisId;
/// <summary>实际位置(mm| Actual position (mm)</summary>
public double ActualPosition { get; protected set; }
/// <summary>轴状态 | Axis status</summary>
public AxisStatus Status { get; protected set; } = AxisStatus.Idle;
/// <summary>正限位触发 | Positive limit triggered</summary>
public bool PositiveLimitHit { get; protected set; }
/// <summary>负限位触发 | Negative limit triggered</summary>
public bool NegativeLimitHit { get; protected set; }
/// <summary>
/// 构造函数 | Constructor
/// </summary>
/// <param name="axisId">轴标识 | Axis identifier</param>
/// <param name="min">最小位置(mm| Minimum position (mm)</param>
/// <param name="max">最大位置(mm| Maximum position (mm)</param>
/// <param name="origin">原点偏移(mm| Origin offset (mm)</param>
protected LinearAxisBase(AxisId axisId, double min, double max, double origin)
{
_axisId = axisId;
_min = min;
_max = max;
_origin = origin;
}
/// <summary>验证目标位置是否在范围内 | Validate target within range</summary>
/// <param name="target">目标位置(mm| Target position (mm)</param>
/// <returns>true=在范围内,false=越界 | true=within range, false=out of range</returns>
public bool ValidateTarget(double target) => target >= _min && target <= _max;
/// <inheritdoc/>
public abstract MotionResult MoveToTarget(double target, 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();
}
}