using System;
using System.Collections.Generic;
namespace TeamAAS.Global.Devices
{
/// 轴状态。
public sealed class AxisStatus
{
public int Index { get; set; }
public string Name { get; set; }
/// 当前位置(用户单位)。
public double Position { get; set; }
/// 当前速度(用户单位/秒)。
public double Velocity { get; set; }
public bool IsMoving { get; set; }
public bool IsHomed { get; set; }
public bool IsEnabled { get; set; }
/// 正/负限位触发。
public bool PositiveLimit { get; set; }
public bool NegativeLimit { get; set; }
public bool Alarm { get; set; }
}
///
/// 运动控制卡统一契约(设备内核·第5项):
/// 覆盖点/限位/IO 的最小生产集 —— 使能、回零、绝对/相对定位、点动、停止、状态读取。
/// 品牌适配器(雷赛/固高/IMC60G 等)实现本接口后注册进 MotionManager;调试页通过 IDeviceDebugPageFactory 拓展。
///
public interface IMotionCard : IConnectableDevice
{
/// 轴数量。
int AxisCount { get; }
/// 使能/下使能指定轴(axis=-1 表示全部轴)。
bool SetEnable(int axis, bool enable);
/// 回零(mode 由品牌适配器解释,如 0=原点开关回零)。
bool Home(int axis, int mode = 0);
/// 是否回零完成。
bool IsHomed(int axis);
/// 绝对定位。position=目标位置(用户单位),velocity=运行速度。
bool MoveAbsolute(int axis, double position, double velocity);
/// 相对定位。
bool MoveRelative(int axis, double distance, double velocity);
/// 点动开始(direction: 1正 -1负)。
bool JogStart(int axis, int direction, double velocity);
/// 点动停止。
bool JogStop(int axis);
/// 急停指定轴(axis=-1 全部)。
bool Stop(int axis = -1);
/// 读指定轴状态(null=轴号无效)。
AxisStatus GetAxisStatus(int axis);
/// 读全部轴状态。
List GetAllAxisStatus();
}
///
/// IO 卡(如 GR20T-ECT-1616ETN,16进/16出)统一契约:
/// 全部接口按“批量”设计 —— 生产上一次事务读全量/写全量,避免逐点往返。
///
public interface IIOCard : IConnectableDevice
{
/// 输入点数量。
int InputCount { get; }
/// 输出点数量。
int OutputCount { get; }
/// 批量读全部输入点(index=点位序号,value=是否有效)。
bool[] ReadAllInputs();
/// 批量读全部输出点(当前输出锁存状态)。
bool[] ReadAllOutputs();
/// 写单个输出点。
bool WriteOutput(int index, bool value);
/// 批量写输出点(values 长度不足时按可用位写)。
bool WriteOutputs(bool[] values);
}
}