using Community;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model.MotionControl
{
public class Shaft : NotificationObject
{
#region 基本参数
public int ID { get; set; }
///
/// 序号
///
public int SerialNumber { get; set; }
private string inCode;
///
/// 轴简码
///
public string InCode
{
get { return inCode; }
set
{
inCode = value;
this.RaisePropertyChanged("InCode");
}
}
private int goHomeOrder;
///
/// 回原点顺序
///
public int GoHomeOrder
{
get { return goHomeOrder; }
set
{
goHomeOrder = value;
this.RaisePropertyChanged("GoHomeOrder");
}
}
private string shaftName;
///
/// 轴名称
///
public string ShaftName
{
get { return shaftName; }
set
{
shaftName = value;
this.RaisePropertyChanged("ShaftName");
}
}
///
/// 控制卡ID
///
public ushort CardID { get; set; }
private ushort axis;
///
/// 轴号
///
public ushort Axis
{
get { return axis; }
set
{
axis = value;
this.RaisePropertyChanged("Axis");
}
}
private bool toOrgin;
///
/// 是否需要回原点
///
public bool ToOrgin
{
get { return toOrgin; }
set
{
toOrgin = value;
this.RaisePropertyChanged("ToOrgin");
}
}
///
/// 是否是LAN控制器的轴
///
public bool LanControl { get; set; }
#endregion
#region 已运行距离
///
/// 脉冲位移
///
public double PulseDir { get; set; }
private double actualDir;
///
/// 实际运行距离
///
public double ActualDir
{
get
{
return actualDir;
}
set
{
actualDir = value;
this.RaisePropertyChanged("ActualDir");
}
}
private double conValue;
///
/// 换算值
///
public double ConValue
{
get { return conValue; }
set
{
conValue = value;
this.RaisePropertyChanged("ConValue");
}
}
#endregion
#region 脉冲输出模式 (步进:3;伺服:5)
private ushort pulseOutMode;
///
/// 脉冲输出模式 (步进:3;伺服:5)
///
public ushort PulseOutMode
{
get { return pulseOutMode; }
set
{
pulseOutMode = value;
this.RaisePropertyChanged("PulseOutMode");
}
}
#endregion
#region 编码器参数
private ushort encoderMode;
///
/// 编码器脉冲模式0:非AB相(脉冲/方向)1:AB相1倍计数2:AB相2倍计数3:AB相3倍计数
///
public ushort EncoderMode
{
get { return encoderMode; }
set
{
encoderMode = value;
this.RaisePropertyChanged("EncoderMode");
}
}
#endregion
#region 回原点参数
private HomePer home;
///
/// 原点参数
///
public HomePer Home
{
get { return home; }
set
{
home = value;
this.RaisePropertyChanged("Home");
}
}
#endregion
#region 运动参数
private MovementPer standbys;
///
/// 默认运动参数(运行时不能更改)
///
public MovementPer Standbys
{
get { return standbys; }
set
{
standbys = value;
this.RaisePropertyChanged("Standbys");
}
}
///
/// 通用运行参数
///
public MovementPer GengrelMp { get; set; }
#endregion
#region 限位/停止参数
private ushort hard_Enable;
///
/// 硬件限位开启模式0:正负限位禁止1:正负限位允许2:正禁止,负允许3:正允许,负禁止
///
public ushort Hard_Enable
{
get { return hard_Enable; }
set
{
hard_Enable = value;
this.RaisePropertyChanged("Hard_Enable");
}
}
private ushort hard_Logic;
///
/// 硬件限位有效电平 (0: 正负限位低电平有效/1: 正负限位高电平有效/2: 正限位低有效, 负限位高有效/3: 正限位高有效, 负限位低有效)
///
public ushort Hard_Logic
{
get { return hard_Logic; }
set
{
hard_Logic = value;
this.RaisePropertyChanged("Hard_Logic");
}
}
private ushort hard_Mode;
///
/// 硬件限位制动模式0:正负限位立即停止1:正负限位减速停止2:正立即停止,负减速停止3:正减速停止,负立即停止
///
public ushort Hard_Mode
{
get { return hard_Mode; }
set
{
hard_Mode = value;
this.RaisePropertyChanged("Hard_Mode");
}
}
private ushort soft_Enable;
///
/// 软件限位使能状态 0:禁止1:允许
///
public ushort Soft_Enable
{
get { return soft_Enable; }
set
{
soft_Enable = value;
this.RaisePropertyChanged("Soft_Enable");
}
}
private ushort soft_Mode;
///
/// 软件限位制动模式0:立即停止1:减速停止
///
public ushort Soft_Mode
{
get { return soft_Mode; }
set
{
soft_Mode = value;
this.RaisePropertyChanged("Soft_Mode");
}
}
private ushort emg_Enable;
///
/// EMG急停触发减速停止 使能状态
///
public ushort Emg_Enable
{
get { return emg_Enable; }
set
{
emg_Enable = value;
this.RaisePropertyChanged("Emg_Enable");
}
}
private ushort emg_Logic;
///
/// EMG急停触发减速停止 有效电平
///
public ushort Emg_Logic
{
get { return emg_Logic; }
set
{
emg_Logic = value;
this.RaisePropertyChanged("Emg_Logic");
}
}
#endregion
#region 伺服参数
private bool isServo;
///
/// 是否是伺服电机
///
public bool IsServo
{
get { return isServo; }
set
{
isServo = value;
this.RaisePropertyChanged("IsServo");
}
}
private short servoSwitch;
///
/// 使能开关 0:开1:关
///
public short ServoSwitch
{
get { return servoSwitch; }
set
{
servoSwitch = value;
this.RaisePropertyChanged("ServoSwitch");
}
}
private ushort inp_Enable;
///
/// INP使能(0:禁用1:允许)
///
public ushort Inp_Enable
{
get { return inp_Enable; }
set
{
inp_Enable = value;
this.RaisePropertyChanged("INP_Enable");
}
}
private ushort inp_Logic;
///
/// INP电平(0:低电平有效1:高电平有效)
///
public ushort Inp_Logic
{
get { return inp_Logic; }
set { inp_Logic = value; }
}
private ushort alm_Enable;
///
/// ALM使能(0:禁用1:允许)
///
public ushort Alm_Enable
{
get { return alm_Enable; }
set
{
alm_Enable = value;
this.RaisePropertyChanged("Alm_Enable");
}
}
private ushort alm_Logic;
///
/// ALM信号电平(0:低电平有效1:高电平有效)
///
public ushort Alm_Logic
{
get { return alm_Logic; }
set
{
alm_Logic = value;
this.RaisePropertyChanged("Alm_Logic");
}
}
#endregion
#region 专用信号对象
///
/// 专用信号对象
///
public SpecialSignals ss { get; set; }
#endregion
#region 状态显示对象
private ShowInfo shaftState;
///
/// 状态显示对象
///
public ShowInfo ShaftState
{
get { return shaftState; }
set
{
shaftState = value;
this.RaisePropertyChanged("ShaftState");
}
}
#endregion
///
/// 回原点方法
///
public DelegateCommand GoHomeCommand { get; set; }
public Shaft()
{
InCode = "-";
PulseDir = 0;
ShaftState = new ShowInfo();
ShaftState.StatusBackground = ColorStr.Red;
ShaftState.StatuInfo = "停止中";
ShaftState.StatusForeground = ColorStr.White;
ss = new SpecialSignals();
Home = new HomePer();
Standbys = new MovementPer();
HomeStep = GengralProcessEnum.Start;
GoHomeCommand = new DelegateCommand();
GoHomeCommand.ExecuteAction = new Action