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

107 строки
5.9 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 ProductionControl.UI.PropExtend;
  13. using static ProductionControl.UI.UIAxisDev;
  14. namespace ProductionControl.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(1), Browsable(true), Category("1 数据"), DisplayName("1.5 保存标识"), Description("供后续轴移动时引用此标识数据,不设则在本工序内立即进行轴校正。")]
  28. public string SizeTag { get; set; }
  29. //2023-10-27 新增图纸选点
  30. [PropertyOrder(1), Browsable(true), Category("1 数据"), DisplayName("1.6 使用点位"), Description("是否使用图纸抓取的点位")]
  31. public bool UseMapPoints { get; set; }
  32. [PropertyOrder(1), Browsable(true), Category("1 数据"), DisplayName("1.7 图纸图片"), Description("图纸图片文件名")]
  33. public string MapPath { get; set; }
  34. [PropertyOrder(1), Browsable(true), Category("1 数据"), DisplayName("1.8 抓取位置"), Description("图纸上选取的点位,根据选取的5个PT点,9个线宽点,计算真是走位。")]
  35. //public double[] GetPointList { get; set; } = new double[23];//默认对应0和2号AXIS
  36. public double[] GetPointList { get; set; } = new double[23] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  37. [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("PT1"), Description("结果"), ReadOnly(true), JsonIgnore]
  38. public double PT1 { get; set; }
  39. [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("PT2"), Description("结果"), ReadOnly(true), JsonIgnore]
  40. public double PT2 { get; set; }
  41. [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("Shanxian"), Description("结果"), ReadOnly(true), JsonIgnore]
  42. public double Shanxian { get; set; }
  43. //[PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("RowP"), Description("结果"), ReadOnly(true), JsonIgnore]
  44. //public double RowP { get; set; }
  45. [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("Circle_Ymm"), Description("结果"), ReadOnly(true), JsonIgnore]
  46. public double Circle_Ymm { get; set; }
  47. [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("Circle_Xmm"), Description("结果"), ReadOnly(true), JsonIgnore]
  48. public double Circle_Xmm { get; set; }
  49. [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("offsetX"), Description("结果"), ReadOnly(true), JsonIgnore]
  50. public double offsetX { get; set; }
  51. [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("offsetY"), Description("结果"), ReadOnly(true), JsonIgnore]
  52. public double offsetY { get; set; }
  53. [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("Mark点"), Description("Mark点"), ReadOnly(true), JsonIgnore]
  54. public double[] MarkPointList { get; set; }
  55. [PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("信息"), Description("信息"), ReadOnly(true), JsonIgnore]
  56. public string resultInfo { get; set; }
  57. [PropertyOrder(25), Browsable(true), Category("3 控制"), DisplayName("3.1 运行前Sleep(ms)"), Description("休息时间")]
  58. public uint SleepPre { get; set; }
  59. [PropertyOrder(26), Browsable(true), Category("3 控制"), DisplayName("3.2 运行后Sleep(ms)"), Description("休息时间")]
  60. public uint SleepLater { get; set; }
  61. [PropertyOrder(27), Browsable(true), Category("3 控制"), DisplayName("3.3 异步运行"), Description("非阻塞后续流程运行(True-是;False-否)")]
  62. public bool AsynRun { get; set; } = true;
  63. [PropertyOrder(28), Browsable(true), Category("3 控制"), DisplayName("3.4 禁用工序"), Description("禁用本工序(True-是;False-否)")]
  64. public bool Disable { get; set; }
  65. /// <summary>
  66. /// 序列化
  67. /// </summary>
  68. /// <param name="obj"></param>
  69. /// <returns></returns>
  70. public string serialize()
  71. {
  72. return JsonConvert.SerializeObject(this);
  73. }
  74. /// <summary>
  75. /// 反序列化
  76. /// </summary>
  77. /// <param name="json"></param>
  78. /// <returns></returns>
  79. public void deserialize(string json)
  80. {
  81. var o= JsonConvert.DeserializeObject<SizeLibProp>(json);
  82. Type type = o.GetType();
  83. System.Reflection.PropertyInfo[] properties = type.GetProperties();
  84. foreach (System.Reflection.PropertyInfo property in properties)
  85. {
  86. string name = property.Name;
  87. if (!type.GetProperty(name).IsDefined(typeof(JsonIgnoreAttribute), true))
  88. {
  89. var value = property.GetValue(o);
  90. this.GetType().GetProperty(name).SetValue(this, value);
  91. }
  92. }
  93. }
  94. }
  95. }