版博士V2.0程序
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

117 líneas
6.5 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Xml.Linq;
  8. using Advantech.Motion;
  9. using Newtonsoft.Json;
  10. using Newtonsoft.Json.Serialization;
  11. using AssistClient.UI.PropExtend;
  12. using static AssistClient.UI.UIAxisDev;
  13. namespace AssistClient.UI
  14. {
  15. //[TypeConverter(typeof(PropertySorter))] //此属性使类无法序列化和反序列化
  16. public class AxisDevProp
  17. {
  18. [PropertyOrder(1), Browsable(true), Category("1 设备"), DisplayName("1.1 设置编号"), Description("设置编号"), ReadOnly(true), JsonIgnore]
  19. public string DeviceNum { get; set; }
  20. [PropertyOrder(1), Browsable(true), Category("1 设备"), DisplayName("1.2 轴索引"), Description("轴索引")]
  21. public AxisName AxisIndex { get; set; }
  22. //[PropertyOrder(2), Browsable(true), Category("设备"), DisplayName("类型"), Description("类型")]
  23. //public AxisType DeviceType { get; set; }
  24. //[PropertyOrder(2), Browsable(true), Category("设备"), DisplayName("回原点模式"), Description("回原点模式"), ReadOnly(true), JsonIgnore]
  25. //public AxitHomeMode HomeMode { get; set; }
  26. //
  27. [PropertyOrder(11), Browsable(true), Category("2 速度"), DisplayName("2.1 起始速度(mm/s)"), Description("起始速度")]
  28. public double VelLow { get; set; }
  29. [PropertyOrder(12), Browsable(true), Category("2 速度"), DisplayName("2.2 运行速度(mm/s)"), Description("运行速度")]
  30. public double VelHigh { get; set; }
  31. [PropertyOrder(13), Browsable(true), Category("2 速度"), DisplayName("2.3 加速度(mm/s)"), Description("加速度")]
  32. public double Acc { get; set; }
  33. [PropertyOrder(14), Browsable(true), Category("2 速度"), DisplayName("2.4 减速度(mm/s)"), Description("减速度")]
  34. public double Dec { get; set; }
  35. //
  36. [PropertyOrder(21), Browsable(true), Category("3 位置"), DisplayName("3.1 运动模式"), Description("运动模式")]
  37. public AxMoveMode MoveMode { get; set; } = AxMoveMode.MODE2_Rel;
  38. [PropertyOrder(22), Browsable(true), Category("3 位置"), DisplayName("3.2 运动距离(mm)"), Description("移动量")]
  39. public double Value { get; set; }
  40. [PropertyOrder(23), Browsable(true), Category("3 位置"), DisplayName("3.3 命令位置(mm)"), Description("命令位置"), ReadOnly(true), JsonIgnore]
  41. public double CmdPos { get; set; }
  42. [PropertyOrder(24), Browsable(true), Category("3 位置"), DisplayName("3.4 反馈位置(mm)"), Description("实际/反馈位置"), ReadOnly(true), JsonIgnore]
  43. public double ActualPos { get; set; }
  44. [PropertyOrder(25), Browsable(true), Category("4 控制"), DisplayName("4.1 运行前Sleep(ms)"), Description("休息时间")]
  45. public uint SleepPre { get; set; }
  46. [PropertyOrder(26), Browsable(true), Category("4 控制"), DisplayName("4.2 运行后Sleep(ms)"), Description("休息时间")]
  47. public uint SleepLater { get; set; }
  48. [PropertyOrder(27), Browsable(true), Category("4 控制"), DisplayName("4.3 异步运行"), Description("非阻塞后续流程运行")]
  49. public bool AsynRun { get; set; }
  50. [PropertyOrder(28), Browsable(true), Category("4 控制"), DisplayName("4.4 禁用工序"), Description("禁用本工序")]
  51. public bool Disable { get; set; }
  52. //[PropertyOrder(27), Browsable(true), Category("模式"), DisplayName("脉冲输出模式"), Description("脉冲输出模式")]
  53. //public AxisPulseOutMode PulseOutMode { get; set; } = AxisPulseOutMode.O_CW_CCW;
  54. //
  55. [PropertyOrder(31), Browsable(true), Category("5 状态"), DisplayName("5.1 轴状态"), Description("轴状态"), ReadOnly(true), JsonIgnore]
  56. public AxisState AxState { get; set; }
  57. [PropertyOrder(32), Browsable(false), Category("5 状态"), DisplayName("5.2 轴IO状态"), Description("轴IO状态"), ReadOnly(true), JsonIgnore]
  58. public uint AxIOStatus { get; set; }
  59. [PropertyOrder(33), Browsable(true), Category("5 状态"), DisplayName("5.2 轴运动状态"), Description("轴运动状态"), ReadOnly(true), JsonIgnore]
  60. public uint AxMotionState { get; set; }
  61. [PropertyOrder(35), Browsable(true), Category("5 状态"), DisplayName("5.3 ALM"), Description("轴IO状态"), ReadOnly(true), JsonIgnore]
  62. public bool ALM { get; set; }
  63. [PropertyOrder(35), Browsable(true), Category("5 状态"), DisplayName("5.4 EMG"), Description("轴IO状态"), ReadOnly(true), JsonIgnore]
  64. public bool EMG { get; set; }
  65. [PropertyOrder(36), Browsable(true), Category("5 状态"), DisplayName("5.5 LMT+"), Description("轴IO状态"), ReadOnly(true), JsonIgnore]
  66. public bool LMTP { get; set; }
  67. [PropertyOrder(37), Browsable(true), Category("5 状态"), DisplayName("5.6 LMT-"), Description("轴IO状态"), ReadOnly(true), JsonIgnore]
  68. public bool LMTN { get; set; }
  69. [PropertyOrder(38), Browsable(true), Category("5 状态"), DisplayName("5.7 ORG"), Description("轴IO状态"), ReadOnly(true), JsonIgnore]
  70. public bool ORG { get; set; }
  71. [PropertyOrder(38), Browsable(true), Category("5 状态"), DisplayName("5.8 EZ"), Description("轴EZ状态"), ReadOnly(true), JsonIgnore]
  72. public bool EZ { get; set; }
  73. [PropertyOrder(39), Browsable(true), Category("5 状态"), DisplayName("5.9 SVON"), Description("轴IO状态"), ReadOnly(true), JsonIgnore]
  74. public bool SVON { get; set; }
  75. /// <summary>
  76. /// 序列化
  77. /// </summary>
  78. /// <param name="obj"></param>
  79. /// <returns></returns>
  80. public string serialize()
  81. {
  82. return JsonConvert.SerializeObject(this);
  83. }
  84. /// <summary>
  85. /// 反序列化
  86. /// </summary>
  87. /// <param name="json"></param>
  88. /// <returns></returns>
  89. public void deserialize(string json)
  90. {
  91. var o = JsonConvert.DeserializeObject<AxisDevProp>(json);
  92. Type type = o.GetType();
  93. System.Reflection.PropertyInfo[] properties = type.GetProperties();
  94. foreach (System.Reflection.PropertyInfo property in properties)
  95. {
  96. string name = property.Name;
  97. if (!type.GetProperty(name).IsDefined(typeof(JsonIgnoreAttribute), true))
  98. {
  99. var value = property.GetValue(o);
  100. this.GetType().GetProperty(name).SetValue(this, value);
  101. }
  102. }
  103. }
  104. }
  105. }