using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; using System.Web; namespace TeamAAS_VP.Core.Robots { /// /// Represents command node names for an axis. /// public class AxisCommand { /// /// 使能,Bool类型 /// public string PowerNode { get; set; } /// /// 停止,Bool类型 /// public string StopNode { get; set; } /// /// 手动回原,Bool类型 /// public string ManuToHomeNode { get; set; } /// /// 自动回原,Bool类型 /// public string AutoToHomeNode { get; set; } /// /// 手动J0G+,Bool类型 /// public string ManuJogFowardNode { get; set; } /// /// 手动J0G-,Bool类型 /// public string ManuJogBackwardNode { get; set; } /// /// 速度模式控制,Bool类型 /// public string VelocityControlNode { get; set; } /// /// 速度模式变速,Bool类型 /// public string VelocityChangeNode { get; set; } /// /// 自动相对运动,Int类型 /// public string AutoINCNode { get; set; } /// /// 自动绝对运动,Int类型 /// public string AutoABSNode { get; set; } /// /// 转矩控制运动,Int类型 /// public string TorqueNode { get; set; } /// /// 点位选择,Int类型 /// public string PointSelectNode { get; set; } /// /// 示教使能,Bool类型 /// public string TeachOnNode { get; set; } /// /// 示教位置,Bool类型 /// public string TeachNode { get; set; } /// /// 手动绝对运动点位,Bool类型 /// public string ManuPointNode { get; set; } /// /// 手动绝对运动指定位置,Bool类型 /// public string ManuPositionNode { get; set; } } /// /// Represents parameter node names for an axis. /// public class AxisParameter { /// /// 手动定位点位,Real类型 /// public string ManuPositionNode { get; set; } /// /// 手动定位速度,Real类型 /// public string ManuVelocityNode { get; set; } /// /// 速度模式定位速度,Real类型 /// public string VelModeVelocityNode { get; set; } /// /// 轴名称,String类型 /// public string CommentNode { get; set; } } /// /// Represents state node names for an axis. /// public class AxisState { /// /// 轴已使能,Bool类型 /// public string PowerOnNode { get; set; } /// /// 运转中,Bool类型 /// public string BusyNode { get; set; } /// /// 定位完成,Bool类型 /// public string PosOKNode { get; set; } /// /// 回原完成,Bool类型 /// public string InitialedNode { get; set; } /// /// 轴暂停中,Bool类型 /// public string PausedNode { get; set; } /// /// 轴正转中,Bool类型 /// public string PosiNode { get; set; } /// /// 轴反转中,Bool类型 /// public string NegaNode { get; set; } /// /// 错误,Bool类型 /// public string ErrorNode { get; set; } /// /// 错误代码,Int类型 /// public string ErrorIdNode { get; set; } /// /// 实际位置,Real类型 /// public string ActPositionNode { get; set; } /// /// 实际速度,Real类型 /// public string ActVelocityNode { get; set; } /// /// 实际扭矩,Real类型 /// public string ActTorqueNode { get; set; } /// /// 停止位置,Real类型 /// public string StopPositionNode { get; set; } /// /// 绝对位置点位,Real类型 /// public string HmiPositionNode { get; set; } /// /// 运动时间,Int类型 /// public string SpTimeNode { get; set; } /// /// 轴状态,Int类型 /// public string StateNode { get; set; } } /// /// Axis model that groups command, parameter and state node names. /// public class Axis { public Axis() { Command = new AxisCommand(); Parameter = new AxisParameter(); State = new AxisState(); } public Axis(string name, int index) : this() { Name = name; Index = index; } /// /// Logical name of the axis, e.g. "X","Y","Z","U" or "A1". /// public string Name { get; set; } /// /// Axis index (1-based) when applicable. /// public int Index { get; set; } public AxisCommand Command { get; set; } public AxisParameter Parameter { get; set; } public AxisState State { get; set; } } public class AxisExtended : Axis, INotifyPropertyChanged { //当前坐标 private double _CurrentPosition; public double CurrentPosition { get { return _CurrentPosition; } set { SetProperty(ref _CurrentPosition, value); } } #region 属性通知 /// /// Occurs when a property value changes. /// public event PropertyChangedEventHandler PropertyChanged; /// /// Checks if a property already matches a desired value. Sets the property and /// notifies listeners only when necessary. /// /// Type of the property. /// Reference to a property with both getter and setter. /// Desired value for the property. /// Name of the property used to notify listeners. This /// value is optional and can be provided automatically when invoked from compilers that /// support CallerMemberName. /// True if the value was changed, false if the existing value matched the /// desired value. protected virtual bool SetProperty(ref T storage, T value, [CallerMemberName] string propertyName = null) { if (EqualityComparer.Default.Equals(storage, value)) return false; storage = value; RaisePropertyChanged(propertyName); return true; } /// /// Checks if a property already matches a desired value. Sets the property and /// notifies listeners only when necessary. /// /// Type of the property. /// Reference to a property with both getter and setter. /// Desired value for the property. /// Name of the property used to notify listeners. This /// value is optional and can be provided automatically when invoked from compilers that /// support CallerMemberName. /// Action that is called after the property value has been changed. /// True if the value was changed, false if the existing value matched the /// desired value. protected virtual bool SetProperty(ref T storage, T value, Action onChanged, [CallerMemberName] string propertyName = null) { if (EqualityComparer.Default.Equals(storage, value)) return false; storage = value; onChanged?.Invoke(); RaisePropertyChanged(propertyName); return true; } /// /// Raises this object's PropertyChanged event. /// /// Name of the property used to notify listeners. This /// value is optional and can be provided automatically when invoked from compilers /// that support . protected void RaisePropertyChanged([CallerMemberName] string propertyName = null) { OnPropertyChanged(new PropertyChangedEventArgs(propertyName)); } /// /// Raises this object's PropertyChanged event. /// /// The PropertyChangedEventArgs protected virtual void OnPropertyChanged(PropertyChangedEventArgs args) { PropertyChanged?.Invoke(this, args); } #endregion } }