MotionContracts.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Collections.Generic;
  3. namespace TeamAAS.Global.Devices
  4. {
  5. /// <summary>轴状态快照(流程/状态栏批量读取用)。</summary>
  6. public sealed class AxisStatus
  7. {
  8. public int Index { get; set; }
  9. public string Name { get; set; }
  10. public double Position { get; set; }
  11. public double Velocity { get; set; }
  12. public bool IsMoving { get; set; }
  13. public bool IsHomed { get; set; }
  14. public bool IsEnabled { get; set; }
  15. public bool PositiveLimit { get; set; }
  16. public bool NegativeLimit { get; set; }
  17. public bool Alarm { get; set; }
  18. }
  19. /// <summary>
  20. /// 运动控制卡统一契约:索引式 API(流程层)+ 轴对象(调试层)+ 插补/IO。
  21. /// 品牌适配器(仿真/雷赛/汇川 IMC60G 等)实现本接口后注册进 MotionManager。
  22. /// </summary>
  23. public interface IMotionCard : IConnectableDevice
  24. {
  25. int AxisCount { get; }
  26. // --- 流程层:索引 API ---
  27. bool SetEnable(int axis, bool enable);
  28. bool Home(int axis, int mode = 0);
  29. bool IsHomed(int axis);
  30. bool MoveAbsolute(int axis, double position, double velocity);
  31. bool MoveRelative(int axis, double distance, double velocity);
  32. bool JogStart(int axis, int direction, double velocity);
  33. bool JogStop(int axis);
  34. /// <summary>平滑停止(axis=-1 表示全部轴)。</summary>
  35. bool Stop(int axis = -1);
  36. AxisStatus GetAxisStatus(int axis);
  37. List<AxisStatus> GetAllAxisStatus();
  38. // --- 调试层:轴对象 ---
  39. IAxis GetAxis(int axisNo);
  40. IList<IAxis> GetAxes();
  41. // --- 多轴协同 ---
  42. bool MoveLinear(double[] targetPositions, double velocity);
  43. bool MoveArc(double[] centerPoint, double[] targetPositions, double velocity);
  44. /// <summary>急停全部轴。</summary>
  45. bool EmergencyStop();
  46. // --- 板载 IO ---
  47. bool ReadDI(int portIndex);
  48. bool WriteDO(int portIndex, bool value);
  49. event EventHandler<MotionConnectionStateChangedEventArgs> ConnectionStateChanged;
  50. event EventHandler<MotionErrorEventArgs> ErrorOccurred;
  51. }
  52. /// <summary>
  53. /// IO 卡(如 GR20T-ECT-1616ETN)统一契约。
  54. /// </summary>
  55. public interface IIOCard : IConnectableDevice
  56. {
  57. int InputCount { get; }
  58. int OutputCount { get; }
  59. bool[] ReadAllInputs();
  60. bool[] ReadAllOutputs();
  61. bool WriteOutput(int index, bool value);
  62. bool WriteOutputs(bool[] values);
  63. }
  64. }