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; }
}
///
/// 运动控制卡统一契约:索引式 API(流程层)+ 轴对象(调试层)+ 插补/IO。
/// 品牌适配器(仿真/雷赛/汇川 IMC60G 等)实现本接口后注册进 MotionManager。
///
public interface IMotionCard : IConnectableDevice
{
int AxisCount { get; }
// --- 流程层:索引 API ---
bool SetEnable(int axis, bool enable);
bool Home(int axis, int mode = 0);
bool IsHomed(int axis);
bool MoveAbsolute(int axis, double position, double velocity);
bool MoveRelative(int axis, double distance, double velocity);
bool JogStart(int axis, int direction, double velocity);
bool JogStop(int axis);
/// 平滑停止(axis=-1 表示全部轴)。
bool Stop(int axis = -1);
AxisStatus GetAxisStatus(int axis);
List GetAllAxisStatus();
// --- 调试层:轴对象 ---
IAxis GetAxis(int axisNo);
IList GetAxes();
// --- 多轴协同 ---
bool MoveLinear(double[] targetPositions, double velocity);
bool MoveArc(double[] centerPoint, double[] targetPositions, double velocity);
/// 急停全部轴。
bool EmergencyStop();
// --- 板载 IO(无 bank 时按本地端子)---
bool ReadDI(int portIndex);
bool WriteDO(int portIndex, bool value);
event EventHandler ConnectionStateChanged;
event EventHandler ErrorOccurred;
}
/// 运动卡 IO 分区:本地端子板与 EtherCAT 扩展点号相互独立。
public enum MotionIoBank
{
Local = 0,
EtherCat = 1
}
/// 运动卡本地 / EtherCAT 数字量 IO。
public interface IMotionIoHost
{
bool CanSimulateDi { get; }
int GetDiCount(MotionIoBank bank);
int GetDoCount(MotionIoBank bank);
bool ReadDI(MotionIoBank bank, int index);
bool ReadDO(MotionIoBank bank, int index);
bool WriteDO(MotionIoBank bank, int index, bool value);
bool WriteDI(MotionIoBank bank, int index, bool value);
}
///
/// 卡级安全互锁:急停下使能并禁止使能/运动;停止信号禁止运动。
///
public interface IMotionSafetyHost
{
bool IsEstopActive { get; }
bool IsStopActive { get; }
bool AllowEnable(out string reason);
bool AllowMotion(out string reason);
event EventHandler SafetyChanged;
}
///
/// 仿真卡时钟。点到点应一次拨完剩余行程;超时只用于真实等待(点动/硬件),不要和仿真行程绑在同一循环。
///
public interface IMotionSimulation
{
void Simulate(double deltaSeconds);
/// 把所有点到点运动按剩余路程/速度一次仿真到结束。点动保持运动中。
void FinishDiscreteMoves();
}
///
/// IO 卡(如 GR20T-ECT-1616ETN)统一契约。
///
public interface IIOCard : IConnectableDevice
{
int InputCount { get; }
int OutputCount { get; }
bool[] ReadAllInputs();
bool[] ReadAllOutputs();
bool WriteOutput(int index, bool value);
bool WriteOutputs(bool[] values);
}
}