将Feature/XP.Common和Feature/XP.Hardware分支合并至Develop/XP.forHardwareAndCommon,完善XPapp注册和相关硬件类库通用类库功能。
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
namespace XP.Hardware.MotionControl.Abstractions.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// 直线轴标识 | Linear Axis Identifier
|
||||
/// </summary>
|
||||
public enum AxisId
|
||||
{
|
||||
/// <summary>射线源Z轴 | X-ray source Z axis</summary>
|
||||
SourceZ,
|
||||
|
||||
/// <summary>探测器Z轴 | Detector Z axis</summary>
|
||||
DetectorZ,
|
||||
|
||||
/// <summary>载物台X轴 | Stage X axis</summary>
|
||||
StageX,
|
||||
|
||||
/// <summary>载物台Y轴 | Stage Y axis</summary>
|
||||
StageY
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace XP.Hardware.MotionControl.Abstractions.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// 轴状态 | Axis Status
|
||||
/// </summary>
|
||||
public enum AxisStatus
|
||||
{
|
||||
/// <summary>空闲 | Idle</summary>
|
||||
Idle,
|
||||
|
||||
/// <summary>运动中 | Moving</summary>
|
||||
Moving,
|
||||
|
||||
/// <summary>回零中 | Homing</summary>
|
||||
Homing,
|
||||
|
||||
/// <summary>错误 | Error</summary>
|
||||
Error,
|
||||
|
||||
/// <summary>报警(限位触发等)| Alarm (limit triggered, etc.)</summary>
|
||||
Alarm
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace XP.Hardware.MotionControl.Abstractions.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// 安全门状态 | Safety Door Status
|
||||
/// </summary>
|
||||
public enum DoorStatus
|
||||
{
|
||||
/// <summary>未知 | Unknown</summary>
|
||||
Unknown,
|
||||
|
||||
/// <summary>开门中 | Opening</summary>
|
||||
Opening,
|
||||
|
||||
/// <summary>已打开 | Open</summary>
|
||||
Open,
|
||||
|
||||
/// <summary>关门中 | Closing</summary>
|
||||
Closing,
|
||||
|
||||
/// <summary>已关闭 | Closed</summary>
|
||||
Closed,
|
||||
|
||||
/// <summary>已锁定 | Locked</summary>
|
||||
Locked,
|
||||
|
||||
/// <summary>错误 | Error</summary>
|
||||
Error
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace XP.Hardware.MotionControl.Abstractions.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// 旋转轴标识 | Rotary Axis Identifier
|
||||
/// </summary>
|
||||
public enum RotaryAxisId
|
||||
{
|
||||
/// <summary>探测器摆动 | Detector swing</summary>
|
||||
DetectorSwing,
|
||||
|
||||
/// <summary>载物台旋转 | Stage rotation</summary>
|
||||
StageRotation,
|
||||
|
||||
/// <summary>夹具旋转 | Fixture rotation</summary>
|
||||
FixtureRotation
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Prism.Events;
|
||||
using XP.Hardware.MotionControl.Abstractions.Enums;
|
||||
|
||||
namespace XP.Hardware.MotionControl.Abstractions.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// 轴状态变化事件数据 | Axis Status Changed Event Data
|
||||
/// </summary>
|
||||
/// <param name="AxisId">轴标识 | Axis identifier</param>
|
||||
/// <param name="Status">新的轴状态 | New axis status</param>
|
||||
public record AxisStatusChangedData(AxisId AxisId, AxisStatus Status);
|
||||
|
||||
/// <summary>
|
||||
/// 轴状态变化事件 | Axis Status Changed Event
|
||||
/// 当任意轴状态发生变化时发布 | Published when any axis status changes
|
||||
/// </summary>
|
||||
public class AxisStatusChangedEvent : PubSubEvent<AxisStatusChangedData> { }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using Prism.Events;
|
||||
|
||||
namespace XP.Hardware.MotionControl.Abstractions.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// 门联锁状态变化事件 | Door Interlock Status Changed Event
|
||||
/// 当安全门联锁信号发生变化时发布 | Published when safety door interlock signal changes
|
||||
/// Payload: true=已联锁, false=未联锁 | Payload: true=interlocked, false=not interlocked
|
||||
/// </summary>
|
||||
public class DoorInterlockChangedEvent : PubSubEvent<bool> { }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using Prism.Events;
|
||||
using XP.Hardware.MotionControl.Abstractions.Enums;
|
||||
|
||||
namespace XP.Hardware.MotionControl.Abstractions.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// 门状态变化事件 | Door Status Changed Event
|
||||
/// 当安全防护门状态发生变化时发布 | Published when safety door status changes
|
||||
/// </summary>
|
||||
public class DoorStatusChangedEvent : PubSubEvent<DoorStatus> { }
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using Prism.Events;
|
||||
|
||||
namespace XP.Hardware.MotionControl.Abstractions.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// 几何反算结果填入请求数据 | Geometry inverse calculation apply request data
|
||||
/// </summary>
|
||||
public class GeometryApplyRequestData
|
||||
{
|
||||
public double SourceZTarget { get; }
|
||||
public double DetectorZTarget { get; }
|
||||
public double StageXActual { get; }
|
||||
public double StageYActual { get; }
|
||||
public double DetSwingActual { get; }
|
||||
public double StageRotActual { get; }
|
||||
public double FixtureRotActual { get; }
|
||||
|
||||
public GeometryApplyRequestData(
|
||||
double sourceZTarget, double detectorZTarget,
|
||||
double stageXActual, double stageYActual,
|
||||
double detSwingActual, double stageRotActual, double fixtureRotActual)
|
||||
{
|
||||
SourceZTarget = sourceZTarget;
|
||||
DetectorZTarget = detectorZTarget;
|
||||
StageXActual = stageXActual;
|
||||
StageYActual = stageYActual;
|
||||
DetSwingActual = detSwingActual;
|
||||
StageRotActual = stageRotActual;
|
||||
FixtureRotActual = fixtureRotActual;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 几何反算结果填入请求事件 | Geometry inverse calculation apply request event
|
||||
/// 由 DebugWindow 发布,MotionControlViewModel 订阅后填入目标值
|
||||
/// Published by DebugWindow, subscribed by MotionControlViewModel to fill target values
|
||||
/// </summary>
|
||||
public class GeometryApplyRequestEvent : PubSubEvent<GeometryApplyRequestData> { }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Prism.Events;
|
||||
|
||||
namespace XP.Hardware.MotionControl.Abstractions.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// 几何参数数据 | Geometry Data
|
||||
/// </summary>
|
||||
/// <param name="FOD">焦点到旋转中心距离(mm)| Focus to Object Distance (mm)</param>
|
||||
/// <param name="FDD">焦点到探测器距离(mm)| Focus to Detector Distance (mm)</param>
|
||||
/// <param name="Magnification">放大倍率 | Magnification</param>
|
||||
public record GeometryData(double FOD, double FDD, double Magnification);
|
||||
|
||||
/// <summary>
|
||||
/// 几何参数更新事件 | Geometry Updated Event
|
||||
/// 当几何参数(FOD/FDD/放大倍率)重新计算后发布 | Published when geometry parameters are recalculated
|
||||
/// </summary>
|
||||
public class GeometryUpdatedEvent : PubSubEvent<GeometryData> { }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Prism.Events;
|
||||
using XP.Hardware.MotionControl.Abstractions.Enums;
|
||||
|
||||
namespace XP.Hardware.MotionControl.Abstractions.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// 运动错误事件数据 | Motion Error Event Data
|
||||
/// </summary>
|
||||
/// <param name="AxisId">轴标识 | Axis identifier</param>
|
||||
/// <param name="ErrorMessage">错误信息 | Error message</param>
|
||||
public record MotionErrorData(AxisId AxisId, string ErrorMessage);
|
||||
|
||||
/// <summary>
|
||||
/// 运动错误事件 | Motion Error Event
|
||||
/// 当轴状态变为 Error 或 Alarm 时发布 | Published when axis status changes to Error or Alarm
|
||||
/// </summary>
|
||||
public class MotionErrorEvent : PubSubEvent<MotionErrorData> { }
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace XP.Hardware.MotionControl.Abstractions
|
||||
{
|
||||
/// <summary>
|
||||
/// 轴复位接口 | Axis Reset Interface
|
||||
/// 提供轴复位写入和复位完成状态读取 | Provides axis reset write and reset-done status read
|
||||
/// </summary>
|
||||
public interface IAxisReset
|
||||
{
|
||||
/// <summary>复位是否完成 | Whether reset is done</summary>
|
||||
bool IsResetDone { get; }
|
||||
|
||||
/// <summary>发送复位命令 | Send reset command</summary>
|
||||
/// <returns>操作结果 | Operation result</returns>
|
||||
MotionResult Reset();
|
||||
|
||||
/// <summary>从 PLC 更新复位完成状态 | Update reset-done status from PLC</summary>
|
||||
void UpdateStatus();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using XP.Hardware.MotionControl.Abstractions.Enums;
|
||||
|
||||
namespace XP.Hardware.MotionControl.Abstractions
|
||||
{
|
||||
/// <summary>
|
||||
/// 直线轴策略接口 | Linear Axis Strategy Interface
|
||||
/// 定义直线轴的运动控制能力 | Defines linear axis motion control capabilities
|
||||
/// </summary>
|
||||
public interface ILinearAxis
|
||||
{
|
||||
/// <summary>轴标识 | Axis identifier</summary>
|
||||
AxisId Id { get; }
|
||||
|
||||
/// <summary>实际位置(mm)| Actual position (mm)</summary>
|
||||
double ActualPosition { get; }
|
||||
|
||||
/// <summary>轴状态 | Axis status</summary>
|
||||
AxisStatus Status { get; }
|
||||
|
||||
/// <summary>正限位触发 | Positive limit triggered</summary>
|
||||
bool PositiveLimitHit { get; }
|
||||
|
||||
/// <summary>负限位触发 | Negative limit triggered</summary>
|
||||
bool NegativeLimitHit { get; }
|
||||
|
||||
/// <summary>移动到目标位置 | Move to target position</summary>
|
||||
/// <param name="target">目标位置(mm)| Target position (mm)</param>
|
||||
/// <returns>操作结果 | Operation result</returns>
|
||||
MotionResult MoveToTarget(double target, double? speed = null);
|
||||
|
||||
/// <summary>Jog 启动 | Jog start</summary>
|
||||
/// <param name="positive">true=正向,false=反向 | true=positive, false=negative</param>
|
||||
/// <returns>操作结果 | Operation result</returns>
|
||||
MotionResult JogStart(bool positive);
|
||||
|
||||
/// <summary>Jog 停止 | Jog stop</summary>
|
||||
/// <returns>操作结果 | Operation result</returns>
|
||||
MotionResult JogStop();
|
||||
|
||||
/// <summary>回零 | Home</summary>
|
||||
/// <returns>操作结果 | Operation result</returns>
|
||||
MotionResult Home();
|
||||
|
||||
/// <summary>停止 | Stop</summary>
|
||||
/// <returns>操作结果 | Operation result</returns>
|
||||
MotionResult Stop();
|
||||
|
||||
/// <summary>从 PLC 更新状态 | Update status from PLC</summary>
|
||||
void UpdateStatus();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System.Collections.Generic;
|
||||
using XP.Hardware.MotionControl.Abstractions.Enums;
|
||||
|
||||
namespace XP.Hardware.MotionControl.Abstractions
|
||||
{
|
||||
/// <summary>
|
||||
/// 运动系统顶层管理接口 | Motion System Top-Level Management Interface
|
||||
/// 持有所有轴和安全门实例 | Holds all axis and safety door instances
|
||||
/// </summary>
|
||||
public interface IMotionSystem
|
||||
{
|
||||
/// <summary>按 AxisId 获取直线轴 | Get linear axis by AxisId</summary>
|
||||
/// <param name="axisId">直线轴标识 | Linear axis identifier</param>
|
||||
/// <returns>直线轴实例 | Linear axis instance</returns>
|
||||
ILinearAxis GetLinearAxis(AxisId axisId);
|
||||
|
||||
/// <summary>按 RotaryAxisId 获取旋转轴 | Get rotary axis by RotaryAxisId</summary>
|
||||
/// <param name="axisId">旋转轴标识 | Rotary axis identifier</param>
|
||||
/// <returns>旋转轴实例 | Rotary axis instance</returns>
|
||||
IRotaryAxis GetRotaryAxis(RotaryAxisId axisId);
|
||||
|
||||
/// <summary>安全门实例 | Safety door instance</summary>
|
||||
ISafetyDoor SafetyDoor { get; }
|
||||
|
||||
/// <summary>轴复位实例 | Axis reset instance</summary>
|
||||
IAxisReset AxisReset { get; }
|
||||
|
||||
/// <summary>所有直线轴 | All linear axes</summary>
|
||||
IReadOnlyDictionary<AxisId, ILinearAxis> LinearAxes { get; }
|
||||
|
||||
/// <summary>所有旋转轴 | All rotary axes</summary>
|
||||
IReadOnlyDictionary<RotaryAxisId, IRotaryAxis> RotaryAxes { get; }
|
||||
|
||||
/// <summary>更新所有轴和门的状态 | Update all axis and door status</summary>
|
||||
void UpdateAllStatus();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using XP.Hardware.MotionControl.Abstractions.Enums;
|
||||
|
||||
namespace XP.Hardware.MotionControl.Abstractions
|
||||
{
|
||||
/// <summary>
|
||||
/// 旋转轴策略接口 | Rotary Axis Strategy Interface
|
||||
/// 定义旋转轴的运动控制能力 | Defines rotary axis motion control capabilities
|
||||
/// </summary>
|
||||
public interface IRotaryAxis
|
||||
{
|
||||
/// <summary>轴标识 | Axis identifier</summary>
|
||||
RotaryAxisId Id { get; }
|
||||
|
||||
/// <summary>实际角度(度)| Actual angle (degrees)</summary>
|
||||
double ActualAngle { get; }
|
||||
|
||||
/// <summary>轴状态 | Axis status</summary>
|
||||
AxisStatus Status { get; }
|
||||
|
||||
/// <summary>是否启用 | Is enabled</summary>
|
||||
bool Enabled { get; }
|
||||
|
||||
/// <summary>移动到目标角度 | Move to target angle</summary>
|
||||
/// <param name="targetAngle">目标角度(度)| Target angle (degrees)</param>
|
||||
/// <returns>操作结果 | Operation result</returns>
|
||||
MotionResult MoveToTarget(double targetAngle, double? speed = null);
|
||||
|
||||
/// <summary>Jog 启动 | Jog start</summary>
|
||||
/// <param name="positive">true=正向,false=反向 | true=positive, false=negative</param>
|
||||
/// <returns>操作结果 | Operation result</returns>
|
||||
MotionResult JogStart(bool positive);
|
||||
|
||||
/// <summary>Jog 停止 | Jog stop</summary>
|
||||
/// <returns>操作结果 | Operation result</returns>
|
||||
MotionResult JogStop();
|
||||
|
||||
/// <summary>回零 | Home</summary>
|
||||
/// <returns>操作结果 | Operation result</returns>
|
||||
MotionResult Home();
|
||||
|
||||
/// <summary>停止 | Stop</summary>
|
||||
/// <returns>操作结果 | Operation result</returns>
|
||||
MotionResult Stop();
|
||||
|
||||
/// <summary>从 PLC 更新状态 | Update status from PLC</summary>
|
||||
void UpdateStatus();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using XP.Hardware.MotionControl.Abstractions.Enums;
|
||||
|
||||
namespace XP.Hardware.MotionControl.Abstractions
|
||||
{
|
||||
/// <summary>
|
||||
/// 安全门策略接口 | Safety Door Strategy Interface
|
||||
/// 定义安全防护门的控制能力 | Defines safety door control capabilities
|
||||
/// </summary>
|
||||
public interface ISafetyDoor
|
||||
{
|
||||
/// <summary>门状态 | Door status</summary>
|
||||
DoorStatus Status { get; }
|
||||
|
||||
/// <summary>联锁信号是否有效(true=联锁中,禁止开门)| Interlock active (true=interlocked, door open blocked)</summary>
|
||||
bool IsInterlocked { get; }
|
||||
|
||||
/// <summary>开门 | Open door</summary>
|
||||
/// <returns>操作结果 | Operation result</returns>
|
||||
MotionResult Open();
|
||||
|
||||
/// <summary>关门 | Close door</summary>
|
||||
/// <returns>操作结果 | Operation result</returns>
|
||||
MotionResult Close();
|
||||
|
||||
/// <summary>停止门 | Stop door</summary>
|
||||
/// <returns>操作结果 | Operation result</returns>
|
||||
MotionResult Stop();
|
||||
|
||||
/// <summary>从 PLC 更新状态 | Update status from PLC</summary>
|
||||
void UpdateStatus();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
namespace XP.Hardware.MotionControl.Abstractions
|
||||
{
|
||||
/// <summary>
|
||||
/// 运动控制操作结果封装类 | Motion Control Operation Result Wrapper
|
||||
/// 用于统一返回操作状态和错误信息 | Unified return of operation status and error messages
|
||||
/// </summary>
|
||||
public class MotionResult
|
||||
{
|
||||
/// <summary>
|
||||
/// 操作是否成功 | Operation success status
|
||||
/// </summary>
|
||||
public bool Success { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 错误消息(成功时为null)| Error message (null when successful)
|
||||
/// </summary>
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建成功结果 | Create success result
|
||||
/// </summary>
|
||||
/// <param name="message">可选的附加消息 | Optional additional message</param>
|
||||
/// <returns>成功结果对象 | Success result object</returns>
|
||||
public static MotionResult Ok(string message = null) =>
|
||||
new MotionResult { Success = true, ErrorMessage = message };
|
||||
|
||||
/// <summary>
|
||||
/// 创建失败结果 | Create failure result
|
||||
/// </summary>
|
||||
/// <param name="message">错误消息 | Error message</param>
|
||||
/// <returns>失败结果对象 | Failure result object</returns>
|
||||
public static MotionResult Fail(string message) =>
|
||||
new MotionResult { Success = false, ErrorMessage = message };
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using XP.Hardware.MotionControl.Abstractions.Enums;
|
||||
|
||||
namespace XP.Hardware.MotionControl.Abstractions
|
||||
{
|
||||
/// <summary>
|
||||
/// 安全门抽象基类 | Safety Door Abstract Base Class
|
||||
/// 提供门状态管理等通用逻辑 | Provides door status management
|
||||
/// </summary>
|
||||
public abstract class SafetyDoorBase : ISafetyDoor
|
||||
{
|
||||
/// <summary>门状态 | Door status</summary>
|
||||
protected DoorStatus _status = DoorStatus.Unknown;
|
||||
|
||||
/// <summary>门状态 | Door status</summary>
|
||||
public DoorStatus Status => _status;
|
||||
|
||||
/// <summary>联锁信号是否有效 | Interlock active</summary>
|
||||
public abstract bool IsInterlocked { get; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public abstract MotionResult Open();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public abstract MotionResult Close();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public abstract MotionResult Stop();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public abstract void UpdateStatus();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user