| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- using System;
- using System.Collections.Generic;
- namespace TeamAAS.Global.Devices
- {
- /// <summary>轴的整体状态。</summary>
- public enum AxisState
- {
- Off,
- StandStill,
- DiscreteMotion,
- ContinuousMotion,
- Homing,
- Error
- }
- /// <summary>回零模式。</summary>
- public enum HomeMode
- {
- Default,
- LimitSwitch,
- HomeSwitch,
- ZPhase
- }
- /// <summary>运动参数。</summary>
- public class MotionParams
- {
- public double Velocity { get; set; }
- public double Acceleration { get; set; }
- public double Deceleration { get; set; }
- public double Jerk { get; set; }
- }
- public class AxisEventArgs : EventArgs
- {
- public int AxisNo { get; }
- public AxisEventArgs(int axisNo) => AxisNo = axisNo;
- }
- public class AxisMotionEventArgs : AxisEventArgs
- {
- public double TargetPosition { get; }
- public double ActualPosition { get; }
- public AxisMotionEventArgs(int axisNo, double target, double actual) : base(axisNo)
- {
- TargetPosition = target;
- ActualPosition = actual;
- }
- }
- public class AxisStateChangedEventArgs : AxisEventArgs
- {
- public AxisState OldState { get; }
- public AxisState NewState { get; }
- public AxisStateChangedEventArgs(int axisNo, AxisState oldState, AxisState newState) : base(axisNo)
- {
- OldState = oldState;
- NewState = newState;
- }
- }
- public class AxisErrorEventArgs : AxisEventArgs
- {
- public string ErrorMessage { get; }
- public AxisErrorEventArgs(int axisNo, string message) : base(axisNo) => ErrorMessage = message;
- }
- public class MotionConnectionStateChangedEventArgs : EventArgs
- {
- public bool Connected { get; }
- public MotionConnectionStateChangedEventArgs(bool connected) => Connected = connected;
- }
- public class MotionErrorEventArgs : EventArgs
- {
- public string ErrorMessage { get; }
- public MotionErrorEventArgs(string message) => ErrorMessage = message;
- }
- /// <summary>
- /// 单轴控制接口(调试/UI 门面;流程层优先使用 <see cref="IMotionCard"/> 索引 API)。
- /// </summary>
- public interface IAxis
- {
- int AxisNo { get; }
- string Name { get; set; }
- AxisState State { get; }
- bool IsEnabled { get; }
- bool IsMoving { get; }
- bool IsHomed { get; }
- double CommandPosition { get; }
- double ActualPosition { get; }
- double ActualVelocity { get; }
- double Velocity { get; set; }
- double Acceleration { get; set; }
- double Deceleration { get; set; }
- double Jerk { get; set; }
- void Enable();
- void Disable();
- void MoveTo(double position);
- void MoveBy(double distance);
- void Jog(double velocity);
- void Stop();
- void Home(HomeMode mode = HomeMode.Default);
- void SetPosition(double position);
- void SetMotionParams(MotionParams parameters);
- event EventHandler<AxisMotionEventArgs> MotionStarted;
- event EventHandler<AxisMotionEventArgs> MotionCompleted;
- event EventHandler<AxisStateChangedEventArgs> StateChanged;
- event EventHandler<AxisErrorEventArgs> ErrorOccurred;
- }
- }
|