版博士V2.0程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

97 строки
5.0 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Xml.Linq;
  9. using Advantech.Motion;
  10. using Newtonsoft.Json;
  11. using Newtonsoft.Json.Serialization;
  12. using AssistClient.UI.PropExtend;
  13. using static AssistClient.UI.UIAxisDev;
  14. namespace AssistClient.UI
  15. {
  16. //[TypeConverter(typeof(PropertySorter))] //此属性使类无法序列化和反序列化
  17. public class SizeLibProp
  18. {
  19. //[PropertyOrder(1), Browsable(true), Category("1 数据"), DisplayName("1.1 引擎路径"), Description("引擎路径")]
  20. //public string EnginePath { get; set; }
  21. [PropertyOrder(1), Browsable(true), Category("1 数据"), DisplayName("1.2 引擎文件名"), Description("引擎文件名")]
  22. public string EngineName { get; set; }
  23. [PropertyOrder(1), Browsable(true), Category("1 数据"), DisplayName("1.3 源图"), Description("源图"), JsonIgnore]
  24. public string BmpPath { get; set; }
  25. [PropertyOrder(1), Browsable(true), Category("1 数据"), DisplayName("1.4 索引"), Description("索引 0-9")]
  26. public int Index { get; set; }
  27. [PropertyOrder(24), Browsable(true), Category("1 数据"), DisplayName("1.5 X轴反馈位置(mm)"), Description("实际/反馈位置"), JsonIgnore]
  28. public double PosX { get; set; }
  29. [PropertyOrder(24), Browsable(true), Category("1 数据"), DisplayName("1.5 Y轴反馈位置(mm)"), Description("实际/反馈位置"), JsonIgnore]
  30. public double PosY { get; set; }
  31. [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("PT1"), Description("结果"), ReadOnly(true), JsonIgnore]
  32. public double PT1 { get; set; }
  33. [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("PT2"), Description("结果"), ReadOnly(true), JsonIgnore]
  34. public double PT2 { get; set; }
  35. [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("Shanxian"), Description("结果"), ReadOnly(true), JsonIgnore]
  36. public double Shanxian { get; set; }
  37. //[PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("RowP"), Description("结果"), ReadOnly(true), JsonIgnore]
  38. //public double RowP { get; set; }
  39. [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("Circle_Ymm"), Description("结果"), ReadOnly(true), JsonIgnore]
  40. public double Circle_Ymm { get; set; }
  41. [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("Circle_Xmm"), Description("结果"), ReadOnly(true), JsonIgnore]
  42. public double Circle_Xmm { get; set; }
  43. [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("offsetX"), Description("结果"), ReadOnly(true), JsonIgnore]
  44. public double offsetX { get; set; }
  45. [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("offsetY"), Description("结果"), ReadOnly(true), JsonIgnore]
  46. public double offsetY { get; set; }
  47. [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("Mark点"), Description("Mark点"), ReadOnly(true), JsonIgnore]
  48. public double[] MarkPointList { get; set; }
  49. [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("信息"), Description("信息"), ReadOnly(true), JsonIgnore]
  50. public string resultInfo { get; set; }
  51. //====
  52. [PropertyOrder(25), Browsable(true), Category("3 控制"), DisplayName("3.1 运行前Sleep(ms)"), Description("休息时间")]
  53. public uint SleepPre { get; set; }
  54. [PropertyOrder(26), Browsable(true), Category("3 控制"), DisplayName("3.2 运行后Sleep(ms)"), Description("休息时间")]
  55. public uint SleepLater { get; set; }
  56. [PropertyOrder(27), Browsable(true), Category("3 控制"), DisplayName("3.4 禁用工序"), Description("禁用本工序")]
  57. public bool Disable { get; set; }
  58. /// <summary>
  59. /// 序列化
  60. /// </summary>
  61. /// <param name="obj"></param>
  62. /// <returns></returns>
  63. public string serialize()
  64. {
  65. return JsonConvert.SerializeObject(this);
  66. }
  67. /// <summary>
  68. /// 反序列化
  69. /// </summary>
  70. /// <param name="json"></param>
  71. /// <returns></returns>
  72. public void deserialize(string json)
  73. {
  74. var o= JsonConvert.DeserializeObject<SizeLibProp>(json);
  75. Type type = o.GetType();
  76. System.Reflection.PropertyInfo[] properties = type.GetProperties();
  77. foreach (System.Reflection.PropertyInfo property in properties)
  78. {
  79. string name = property.Name;
  80. if (!type.GetProperty(name).IsDefined(typeof(JsonIgnoreAttribute), true))
  81. {
  82. var value = property.GetValue(o);
  83. this.GetType().GetProperty(name).SetValue(this, value);
  84. }
  85. }
  86. }
  87. }
  88. }