版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

118 line
6.8 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 MaiMuAOI.SysCtrl;
  9. using MaiMuAOI.SysUI.StepUI.PropExtend;
  10. using Newtonsoft.Json;
  11. using Newtonsoft.Json.Serialization;
  12. namespace ProductionControl.UI
  13. {
  14. //[TypeConverter(typeof(PropertySorter))] //此属性使类无法序列化和反序列化
  15. public class AxisDevProp
  16. {
  17. [PropertyOrder(1), Browsable(true), Category("1 设备"), DisplayName("1.0 轴索引"), Description("Axis0-X1轴; Axis1-X2轴; Axis2-Y轴; Axis3-Z轴")]
  18. public AxisName AxisIndex { get; set; }
  19. [PropertyOrder(1), Browsable(true), Category("1 设备"), DisplayName("1.1 保存此轴设置"), Description("保存此轴设置供流程使用(True-是;False-否)")]//JsonIgnore 不好加,切换时不好判断
  20. public bool Enable { get; set; }//后加,有可能为空
  21. //[PropertyOrder(2), Browsable(true), Category("设备"), DisplayName("类型"), Description("类型")]
  22. //public AxisType DeviceType { get; set; }
  23. //[PropertyOrder(2), Browsable(true), Category("设备"), DisplayName("回原点模式"), Description("回原点模式"), ReadOnly(true), JsonIgnore]
  24. //public AxitHomeMode HomeMode { get; set; }
  25. //
  26. [PropertyOrder(11), Browsable(true), Category("2 速度"), DisplayName("2.1 起始速度(mm/s)"), Description("起始速度")]
  27. public double VelLow { get; set; }
  28. [PropertyOrder(12), Browsable(true), Category("2 速度"), DisplayName("2.2 运行速度(mm/s)"), Description("运行速度")]
  29. public double VelHigh { get; set; }
  30. [PropertyOrder(13), Browsable(true), Category("2 速度"), DisplayName("2.3 加速度(mm/s)"), Description("加速度")]
  31. public double Acc { get; set; }
  32. [PropertyOrder(14), Browsable(true), Category("2 速度"), DisplayName("2.4 减速度(mm/s)"), Description("减速度")]
  33. public double Dec { get; set; }
  34. //----
  35. [PropertyOrder(21), Browsable(true), Category("3 位置"), DisplayName("3.1 运动模式"), Description("运动模式")]
  36. public AxMoveMode MoveMode { get; set; } = AxMoveMode.相对位置;
  37. [PropertyOrder(22), Browsable(true), Category("3 位置"), DisplayName("3.2 运动距离(mm)"), Description("移动量")]
  38. public double Value { get; set; }
  39. [PropertyOrder(23), Browsable(true), Category("3 位置"), DisplayName("3.3 命令位置(mm)"), Description("命令位置"), ReadOnly(true), JsonIgnore]
  40. public double CmdPos { get; set; }
  41. [PropertyOrder(24), Browsable(true), Category("3 位置"), DisplayName("3.4 反馈位置(mm)"), Description("实际/反馈位置"), ReadOnly(true), JsonIgnore]
  42. public double ActualPos { get; set; }
  43. [PropertyOrder(25), Browsable(true), Category("4 控制"), DisplayName("4.1 运行前Sleep(ms)"), Description("休息时间")]
  44. public uint SleepPre { get; set; }
  45. [PropertyOrder(26), Browsable(true), Category("4 控制"), DisplayName("4.2 运行后Sleep(ms)"), Description("休息时间")]
  46. public uint SleepLater { get; set; }
  47. //轴组内多轴自动异步,轴组如果强制等待完成
  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("禁用本工序(True-是;False-否)")]
  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. }