using System;
using System.Collections.Generic;
namespace TeamAAS.Global.Devices
{
/// 轴的整体状态。
public enum AxisState
{
Off,
StandStill,
DiscreteMotion,
ContinuousMotion,
Homing,
Error
}
/// 回零模式。
public enum HomeMode
{
Default,
LimitSwitch,
HomeSwitch,
ZPhase
}
/// 运动参数。
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;
}
///
/// 单轴控制接口(调试/UI 门面;流程层优先使用 索引 API)。
///
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 MotionStarted;
event EventHandler MotionCompleted;
event EventHandler StateChanged;
event EventHandler ErrorOccurred;
}
}