IAxis.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using TeamAAS.Global.Devices;
  7. using static TeamAAS.Motion.Enums.MotionEnums;
  8. using static TeamAAS.Motion.Events.CardAxisEventArgs;
  9. namespace TeamAAS.Motion.Interfaces
  10. {
  11. /// <summary>
  12. /// 单轴控制接口
  13. /// </summary>
  14. public interface IAxis
  15. {
  16. // --- 1. 属性 (Properties) ---
  17. /// <summary>轴号</summary>
  18. int AxisNo { get; }
  19. /// <summary>轴名称(如 "X", "Y", "Z")</summary>
  20. string Name { get; set; }
  21. // 1.1 状态属性
  22. /// <summary>轴当前状态(使能、运动中、错误等)[reference:9]</summary>
  23. AxisState State { get; }
  24. /// <summary>轴是否已使能</summary>
  25. bool IsEnabled { get; }
  26. /// <summary>轴是否正在运动中</summary>
  27. bool IsMoving { get; }
  28. /// <summary>轴是否已完成回零</summary>
  29. bool IsHomed { get; }
  30. // 1.2 位置与速度属性
  31. /// <summary>指令位置(控制器发送的目标位置)</summary>
  32. double CommandPosition { get; }
  33. /// <summary>实际反馈位置(来自编码器)[reference:10]</summary>
  34. double ActualPosition { get; }
  35. /// <summary>实际反馈速度</summary>
  36. double ActualVelocity { get; }
  37. // 1.3 运动参数属性[reference:12]
  38. /// <summary>运行速度</summary>
  39. double Velocity { get; set; }
  40. /// <summary>加速度</summary>
  41. double Acceleration { get; set; }
  42. /// <summary>减速度</summary>
  43. double Deceleration { get; set; }
  44. /// <summary>加加速度(S曲线平滑因子)</summary>
  45. double Jerk { get; set; }
  46. // --- 2. 方法 (Methods) ---
  47. // 2.1 使能与控制
  48. /// <summary>使能轴(开启伺服)</summary>
  49. void Enable();
  50. /// <summary>关闭轴使能</summary>
  51. void Disable();
  52. // 2.2 运动指令[reference:14]
  53. /// <summary>绝对运动:移动到指定绝对位置</summary>
  54. void MoveTo(double position);
  55. /// <summary>相对运动:从当前位置移动指定距离</summary>
  56. void MoveBy(double distance);
  57. /// <summary>点动/连续运动:以指定速度持续运动</summary>
  58. void Jog(double velocity);
  59. /// <summary>停止运动(以设定减速度减速停止)</summary>
  60. void Stop();
  61. // 2.3 回零操作[reference:15]
  62. /// <summary>执行回零操作</summary>
  63. /// <param name="mode">回零模式</param>
  64. void Home(HomeMode mode = HomeMode.Default);
  65. // 2.4 参数与位置设定
  66. /// <summary>设置当前位置(用于建立坐标系)</summary>
  67. void SetPosition(double position);
  68. /// <summary>批量设置运动参数</summary>
  69. void SetMotionParams(MotionParams parameters);
  70. // --- 3. 事件 (Events) ---
  71. /// <summary>轴开始运动时触发</summary>
  72. event EventHandler<AxisMotionEventArgs> MotionStarted;
  73. /// <summary>轴运动完成时触发</summary>
  74. event EventHandler<AxisMotionEventArgs> MotionCompleted;
  75. /// <summary>轴状态发生变化时触发</summary>
  76. event EventHandler<AxisStateChangedEventArgs> StateChanged;
  77. /// <summary>轴发生错误时触发</summary>
  78. event EventHandler<AxisErrorEventArgs> ErrorOccurred;
  79. }
  80. }