版博士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.
 
 
 
 

151 lines
8.0 KiB

  1. using MaiMuAOI.SysCtrl;
  2. using MaiMuAOI.SysUI.StepUI.PropExtend;
  3. using Newtonsoft.Json;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace MaiMuAOI.SysUI.ProcessStep.Prop
  12. {
  13. public class SizeDefectProp
  14. {
  15. [PropertyOrder(1), Browsable(true), Category("1 尺寸检测"), DisplayName("1.1 启用尺寸检测"), Description("开启尺寸检测(True-是;False-否)")]
  16. public bool OpenSize { get; set; }
  17. [PropertyOrder(2), Browsable(true), Category("1 尺寸检测"), DisplayName("1.2 引擎文件名"), Description("图像处理算法引擎文件名")]
  18. public string EngineName { get; set; }
  19. [PropertyOrder(3), Browsable(true), Category("1 尺寸检测"), DisplayName("1.3 异步运行"), Description("非阻塞后续流程运行(True-是;False-否)")]
  20. public bool AsynRun { get; set; } = true;
  21. [PropertyOrder(11), Browsable(true), Category("2 缺陷检测"), DisplayName("2.1 启用缺陷检测"), Description("开启缺陷检测(True-是;False-否)")]
  22. public bool OpenDefect { get; set; }
  23. [PropertyOrder(12), Browsable(true), Category("2 缺陷检测"), DisplayName("2.2 切割大小"), Description("切割大小")]
  24. public Size CutSize { get; set; }
  25. [PropertyOrder(13), Browsable(true), Category("2 缺陷检测"), DisplayName("2.3 重置大小"), Description("重置大小")]
  26. public Size Resize { get; set; }
  27. [PropertyOrder(14), Browsable(true), Category("2 缺陷检测"), DisplayName("2.4 阀值"), Description("阀值")]
  28. public float Thresholds { get; set; }
  29. [PropertyOrder(17), Browsable(true), Category("2 缺陷检测"), DisplayName("2.7 异步运行"), Description("非阻塞后续流程运行(True-是;False-否)")]
  30. public bool AsynDefectRun { get; set; } = true;
  31. [PropertyOrder(21), Browsable(true), Category("3 相机"), DisplayName("3.1 曝光"), Description("曝光时长(us)")]
  32. public float ExposureTime { get; set; }
  33. [PropertyOrder(22), Browsable(true), Category("3 相机"), DisplayName("3.2 增益"), Description("增益")]
  34. public float Gain { get; set; }
  35. [PropertyOrder(31), Browsable(true), Category("4 动作"), DisplayName("4.1 起始速度(mm/s)"), Description("起始速度")]
  36. public double VelLow { get; set; }
  37. [PropertyOrder(32), Browsable(true), Category("4 动作"), DisplayName("4.2 运行速度(mm/s)"), Description("运行速度")]
  38. public double VelHigh { get; set; }
  39. [PropertyOrder(33), Browsable(true), Category("4 动作"), DisplayName("4.3 加速度(mm/s)"), Description("加速度")]
  40. public double Acc { get; set; }
  41. [PropertyOrder(34), Browsable(true), Category("4 动作"), DisplayName("4.4 减速度(mm/s)"), Description("减速度")]
  42. public double Dec { get; set; }
  43. [PropertyOrder(35), Browsable(true), Category("4 动作"), DisplayName("4.5 等待稳定时间(ms)"), Description("到位等待稳定时间")]
  44. public int WaitTime { get; set; }
  45. [PropertyOrder(41), Browsable(true), Category("5 走位"), DisplayName("5.1 自动计算左上角"), Description("使用自动计算的左上角")]
  46. public bool AutoLeft { get; set; }
  47. [PropertyOrder(42), Browsable(true), Category("5 走位"), DisplayName("5.2 手动左上角位置"), Description("使用手动设置的左上角")]
  48. public List<PointF> LeftPoints { get; set; }
  49. public Point LeftPoint { get; set; }
  50. [PropertyOrder(43), Browsable(true), Category("5 走位"), DisplayName("5.3 自动计算步进"), Description("使用自动计算的步进位置")]
  51. public bool AutoStep { get; set; }
  52. [PropertyOrder(44), Browsable(true), Category("5 走位"), DisplayName("5.4 X方向步进次数"), Description("使用手动设置的步进次数")]
  53. public int Xstep { get; set; }
  54. [PropertyOrder(45), Browsable(true), Category("5 走位"), DisplayName("5.5 Y方向步进次数"), Description("使用手动设置的步进次数")]
  55. public int Ystep { get; set; }
  56. [PropertyOrder(51), Browsable(true), Category("6 打印"), DisplayName("6.01 开启Excel打印"), Description("启用本工序数据打印")]
  57. public bool OpenPrint { get; set; }
  58. [PropertyOrder(52), Browsable(true), Category("6 打印"), DisplayName("6.02 打印缺陷总数"), Description("打印数据的位置")]
  59. public string ExcelDefectCount { get; set; }
  60. [PropertyOrder(53), Browsable(true), Category("6 打印"), DisplayName("6.03 打印各类缺陷数量"), Description("打印缺陷数量数据的位置,例:A1,A2,A3。使用##为忽略改缺陷")]
  61. public string ExcelDefectEachCount { get; set; }
  62. [PropertyOrder(71), Browsable(true), Category("7 标签打印"), DisplayName("7.01 开启标签打印"), Description("启用本工序数据打印")]
  63. public bool OpenPrintLabel { get; set; }
  64. [PropertyOrder(72), Browsable(true), Category("7 标签打印"), DisplayName("7.02 标签打印缺陷总数"), Description("打印数据的位置")]
  65. public string LabelDefectCount { get; set; }
  66. [PropertyOrder(73), Browsable(true), Category("7 标签打印"), DisplayName("7.03 标签打印各类缺陷数量"), Description("打印缺陷数量数据的位置,例:A1,A2,A3。使用##为忽略改缺陷")]
  67. public string LabelDefectEachCount { get; set; }
  68. [PropertyOrder(91), Browsable(true), Category("8 控制"), DisplayName("8.1 禁用工序"), Description("禁用本工序(True-是;False-否)")]
  69. public bool Disable { get; set; }
  70. public SizeDefectProp()
  71. {
  72. OpenSize = true;
  73. EngineName = "My_PI_PT_General";
  74. AsynRun = true;
  75. OpenDefect = true;
  76. CutSize = new Size(ConfMgr.Instance.SysConfigParams.Defect_CutSize.Width, ConfMgr.Instance.SysConfigParams.Defect_CutSize.Height);
  77. Resize = new Size(ConfMgr.Instance.SysConfigParams.Defect_ReSize.Width, ConfMgr.Instance.SysConfigParams.Defect_ReSize.Height); ;
  78. Thresholds = ConfMgr.Instance.SysConfigParams.Defect_Thresholds;
  79. AsynDefectRun = true;
  80. ExposureTime = 30000;
  81. Gain = 0;
  82. VelLow = 0;
  83. VelHigh = 100;
  84. Acc = 200;
  85. Dec = 200;
  86. WaitTime = 50;
  87. Disable = false;
  88. AutoStep = true;
  89. AutoLeft = true;
  90. LeftPoints = new List<PointF>();
  91. LeftPoint = new Point();
  92. Xstep = 5;
  93. Ystep = 5;
  94. OpenPrint = false;
  95. OpenPrintLabel = false;
  96. ExcelDefectCount = "";
  97. ExcelDefectEachCount = "";
  98. LabelDefectCount = "";
  99. LabelDefectEachCount = "";
  100. }
  101. /// <summary>
  102. /// 序列化
  103. /// </summary>
  104. /// <param name="obj"></param>
  105. /// <returns></returns>
  106. public string serialize()
  107. {
  108. return JsonConvert.SerializeObject(this);
  109. }
  110. /// <summary>
  111. /// 反序列化
  112. /// </summary>
  113. /// <param name="json"></param>
  114. /// <returns></returns>
  115. public void deserialize(string json)
  116. {
  117. var o = JsonConvert.DeserializeObject<SizeDefectProp>(json);
  118. Type type = o.GetType();
  119. System.Reflection.PropertyInfo[] properties = type.GetProperties();
  120. foreach (System.Reflection.PropertyInfo property in properties)
  121. {
  122. string name = property.Name;
  123. if (!type.GetProperty(name).IsDefined(typeof(JsonIgnoreAttribute), true))
  124. {
  125. var value = property.GetValue(o);
  126. this.GetType().GetProperty(name).SetValue(this, value);
  127. }
  128. }
  129. }
  130. }
  131. }