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