using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Community; namespace Model.MotionControl { public abstract class FeiYuShaft : NotificationObject { /// /// 此轴对应的运动控制卡或运动控制器 /// public FeiYuCard MyCard { get; set; } #region 基本参数 public int ID { get; set; } /// /// 序号 /// public int SerialNumber { get; set; } /// /// 上级ID 控制器\卡ID /// public int SuperiorID { 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"); } } 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"); } } private SpecialSignalsIO specialIO; /// /// 专用IO(众为兴) /// public SpecialSignalsIO SpecialIO { get { return specialIO; } set { specialIO = value == null ? new SpecialSignalsIO() : value; this.RaisePropertyChanged("SpecialIO"); } } #endregion #region 使能开关 private bool sevonSwitch; /// /// 使能开关 /// public bool SevonSwitch { get { return sevonSwitch; } set { sevonSwitch = value; if (value) { ServoInOut(0); } else { ServoInOut(1); } RaisePropertyChanged("SevonSwitch"); } } #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 myHomePar; /// /// 原点参数 /// public HomePer MyHomePar { get { return myHomePar; } set { myHomePar = value == null ? new HomePer() : value; this.RaisePropertyChanged("MyHomePar"); } } #endregion #region 运动参数 private MovementPer myMotionPar; /// /// 默认运动参数(运行时不能更改) /// public MovementPer MyMotionPar { get { return myMotionPar; } set { myMotionPar = value == null ? new MovementPer() : value; this.RaisePropertyChanged("MyMotionPar"); } } /// /// 通用运行参数 /// 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"); } } private ushort home_Logic; /// /// 原点信号电平(0:低电平有效1:高电平有效) /// public ushort Home_Logic { get { return alm_Logic; } set { alm_Logic = value; this.RaisePropertyChanged("Home_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 bool org_Successful { get; set; } public DateTime HomeTime; /// /// 单张回原点步骤 /// public GengralProcessEnum HomeStep { get; set; } /// /// 构造函数 /// public FeiYuShaft() { InCode = "-"; PulseDir = 0; ShaftState = new ShowInfo(); ShaftState.StatusBackground = ColorStr.Red; ShaftState.StatuInfo = "停止中"; ShaftState.StatusForeground = ColorStr.White; ss = new SpecialSignals(); MyHomePar = new HomePer(); MyMotionPar = new MovementPer(); HomeStep = GengralProcessEnum.Start; SpecialIO = new SpecialSignalsIO(); } /// /// 初始化当前轴信息 /// public abstract void Initialize(); /// /// 回原点 /// /// public abstract void HYD(InputSignal inEmg); /// /// 单轴定长运动 /// /// public abstract void DZDC(MovementPer ssmp); /// /// 获取轴状态 /// public abstract void GetShaftStart(); /// /// 专用信号状态 /// public abstract void SpecialStart(); /// /// 获取实际位移 /// public abstract void GetPluseDis(); /// /// 开启或关闭使能 /// public abstract void ServoInOut(ushort Onoff); /// /// 对应轴归零 /// public abstract void GoZero(); /// /// 获取轴的所有状态(轴运动状态,专用信号状态,脉冲位移,使能开关) /// public abstract void GetAllStart(); /// /// 连续运动 /// /// public abstract void ContinuousMove(ushort dir); /// /// 停止运行 /// public abstract void ShaftStop(); } /// /// 专用信号IO(众为兴) /// public class SpecialSignalsIO : NotificationObject { private int alm_IO; /// /// 故障异常IO /// public int Alm_IO { get { return alm_IO; } set { alm_IO = value; RaisePropertyChanged("Alm_IO"); } } private int elN_IO; /// /// 正限位IO /// public int ElN_IO { get { return elN_IO; } set { elN_IO = value; RaisePropertyChanged("ElN_IO"); } } private int elS_IO; /// /// 负限位IO /// public int ElS_IO { get { return elS_IO; } set { elS_IO = value; RaisePropertyChanged("ElS_IO"); } } private int emg_IO; /// /// 急停IO /// public int Emg_IO { get { return emg_IO; } set { emg_IO = value; RaisePropertyChanged("Emg_IO"); } } private int org_IO; /// /// 原点IO /// public int Org_IO { get { return org_IO; } set { org_IO = value; RaisePropertyChanged("Org_IO"); } } } /// /// 专用信号状态类 /// public class SpecialSignals { /// /// 故障 /// public int alm { get; set; } /// /// 正限位 /// public int elN { get; set; } /// /// 负限位 /// public int elS { get; set; } /// /// 急停 /// public int emg { get; set; } /// /// 原点 /// public int org { get; set; } } }