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