MotionContracts.cs 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. /// <summary>当前位置(用户单位)。</summary>
  11. public double Position { get; set; }
  12. /// <summary>当前速度(用户单位/秒)。</summary>
  13. public double Velocity { get; set; }
  14. public bool IsMoving { get; set; }
  15. public bool IsHomed { get; set; }
  16. public bool IsEnabled { get; set; }
  17. /// <summary>正/负限位触发。</summary>
  18. public bool PositiveLimit { get; set; }
  19. public bool NegativeLimit { get; set; }
  20. public bool Alarm { get; set; }
  21. }
  22. /// <summary>
  23. /// 运动控制卡统一契约(设备内核·第5项):
  24. /// 覆盖点/限位/IO 的最小生产集 —— 使能、回零、绝对/相对定位、点动、停止、状态读取。
  25. /// 品牌适配器(雷赛/固高/IMC60G 等)实现本接口后注册进 MotionManager;调试页通过 IDeviceDebugPageFactory 拓展。
  26. /// </summary>
  27. public interface IMotionCard : IConnectableDevice
  28. {
  29. /// <summary>轴数量。</summary>
  30. int AxisCount { get; }
  31. /// <summary>使能/下使能指定轴(axis=-1 表示全部轴)。</summary>
  32. bool SetEnable(int axis, bool enable);
  33. /// <summary>回零(mode 由品牌适配器解释,如 0=原点开关回零)。</summary>
  34. bool Home(int axis, int mode = 0);
  35. /// <summary>是否回零完成。</summary>
  36. bool IsHomed(int axis);
  37. /// <summary>绝对定位。position=目标位置(用户单位),velocity=运行速度。</summary>
  38. bool MoveAbsolute(int axis, double position, double velocity);
  39. /// <summary>相对定位。</summary>
  40. bool MoveRelative(int axis, double distance, double velocity);
  41. /// <summary>点动开始(direction: 1正 -1负)。</summary>
  42. bool JogStart(int axis, int direction, double velocity);
  43. /// <summary>点动停止。</summary>
  44. bool JogStop(int axis);
  45. /// <summary>急停指定轴(axis=-1 全部)。</summary>
  46. bool Stop(int axis = -1);
  47. /// <summary>读指定轴状态(null=轴号无效)。</summary>
  48. AxisStatus GetAxisStatus(int axis);
  49. /// <summary>读全部轴状态。</summary>
  50. List<AxisStatus> GetAllAxisStatus();
  51. }
  52. /// <summary>
  53. /// IO 卡(如 GR20T-ECT-1616ETN,16进/16出)统一契约:
  54. /// 全部接口按“批量”设计 —— 生产上一次事务读全量/写全量,避免逐点往返。
  55. /// </summary>
  56. public interface IIOCard : IConnectableDevice
  57. {
  58. /// <summary>输入点数量。</summary>
  59. int InputCount { get; }
  60. /// <summary>输出点数量。</summary>
  61. int OutputCount { get; }
  62. /// <summary>批量读全部输入点(index=点位序号,value=是否有效)。</summary>
  63. bool[] ReadAllInputs();
  64. /// <summary>批量读全部输出点(当前输出锁存状态)。</summary>
  65. bool[] ReadAllOutputs();
  66. /// <summary>写单个输出点。</summary>
  67. bool WriteOutput(int index, bool value);
  68. /// <summary>批量写输出点(values 长度不足时按可用位写)。</summary>
  69. bool WriteOutputs(bool[] values);
  70. }
  71. }