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

175 строки
9.8 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(46), Browsable(true), Category("5 走位"), DisplayName("5.6 Z形扫描走位"), Description("使用S形或者Z形走位")]
  57. public bool IsZMove { get; set; }
  58. [PropertyOrder(51), Browsable(true), Category("6 二次检测"), DisplayName("6.01 开启二次检测"), Description("启用本工序二次检测")]
  59. public bool OpenDefcetAgian { get; set; }
  60. [PropertyOrder(52), Browsable(true), Category("6 二次检测"), DisplayName("6.02 一次检测光源通道"), Description("第一次检测使用光源通道,例:1,2,3")]
  61. public string FLightChannel { get; set; }
  62. [PropertyOrder(53), Browsable(true), Category("6 二次检测"), DisplayName("6.03 一次检测光源亮度"), Description("对应光源通道亮度,例:255,255,255")]
  63. public string FLightValue { get; set; }
  64. [PropertyOrder(54), Browsable(true), Category("6 二次检测"), DisplayName("6.04 二次检测光源通道"), Description("第二次检测使用光源通道,例:1,2,3")]
  65. public string SLightChannel { get; set; }
  66. [PropertyOrder(55), Browsable(true), Category("6 二次检测"), DisplayName("6.05 二次检测光源亮度"), Description("对应光源通道亮度,例:255,255,255")]
  67. public string SLightValue { get; set; }
  68. [PropertyOrder(56), Browsable(true), Category("6 二次检测"), DisplayName("6.06 二次检测对应曝光"), Description("对应曝光")]
  69. public double SExposureTime { get; set; }
  70. [PropertyOrder(51), Browsable(true), Category("7 打印"), DisplayName("7.01 开启Excel打印"), Description("启用本工序数据打印")]
  71. public bool OpenPrint { get; set; }
  72. [PropertyOrder(52), Browsable(true), Category("7 打印"), DisplayName("7.02 打印缺陷总数"), Description("打印数据的位置")]
  73. public string ExcelDefectCount { get; set; }
  74. [PropertyOrder(53), Browsable(true), Category("7 打印"), DisplayName("7.03 打印各类缺陷数量"), Description("打印缺陷数量数据的位置,例:A1,A2,A3。使用##为忽略改缺陷")]
  75. public string ExcelDefectEachCount { get; set; }
  76. [PropertyOrder(71), Browsable(true), Category("8 标签打印"), DisplayName("8.01 开启标签打印"), Description("启用本工序数据打印")]
  77. public bool OpenPrintLabel { get; set; }
  78. [PropertyOrder(72), Browsable(true), Category("8 标签打印"), DisplayName("8.02 标签打印缺陷总数"), Description("打印数据的位置")]
  79. public string LabelDefectCount { get; set; }
  80. [PropertyOrder(73), Browsable(true), Category("8 标签打印"), DisplayName("8.03 标签打印各类缺陷数量"), Description("打印缺陷数量数据的位置,例:A1,A2,A3。使用##为忽略改缺陷")]
  81. public string LabelDefectEachCount { get; set; }
  82. [PropertyOrder(91), Browsable(true), Category("9 控制"), DisplayName("9.1 禁用工序"), Description("禁用本工序(True-是;False-否)")]
  83. public bool Disable { get; set; }
  84. public SizeDefectProp()
  85. {
  86. OpenSize = true;
  87. EngineName = "My_PI_PT_General";
  88. AsynRun = true;
  89. OpenDefect = true;
  90. CutSize = new Size(ConfMgr.Instance.SysConfigParams.Defect_CutSize.Width, ConfMgr.Instance.SysConfigParams.Defect_CutSize.Height);
  91. Resize = new Size(ConfMgr.Instance.SysConfigParams.Defect_ReSize.Width, ConfMgr.Instance.SysConfigParams.Defect_ReSize.Height); ;
  92. Thresholds = ConfMgr.Instance.SysConfigParams.Defect_Thresholds;
  93. AsynDefectRun = true;
  94. ExposureTime = 30000;
  95. Gain = 0;
  96. VelLow = 0;
  97. VelHigh = 100;
  98. Acc = 200;
  99. Dec = 200;
  100. WaitTime = 50;
  101. Disable = false;
  102. AutoStep = true;
  103. AutoLeft = true;
  104. LeftPoints = new List<PointF>();
  105. LeftPoint = new Point();
  106. Xstep = 5;
  107. Ystep = 5;
  108. IsZMove = true;
  109. OpenDefcetAgian = false;
  110. FLightChannel = "";
  111. FLightValue = "";
  112. SLightChannel = "";
  113. SLightValue = "";
  114. SExposureTime = 30000;
  115. OpenPrint = false;
  116. OpenPrintLabel = false;
  117. ExcelDefectCount = "";
  118. ExcelDefectEachCount = "";
  119. LabelDefectCount = "";
  120. LabelDefectEachCount = "";
  121. }
  122. /// <summary>
  123. /// 序列化
  124. /// </summary>
  125. /// <param name="obj"></param>
  126. /// <returns></returns>
  127. public string serialize()
  128. {
  129. return JsonConvert.SerializeObject(this);
  130. }
  131. /// <summary>
  132. /// 反序列化
  133. /// </summary>
  134. /// <param name="json"></param>
  135. /// <returns></returns>
  136. public void deserialize(string json)
  137. {
  138. var o = JsonConvert.DeserializeObject<SizeDefectProp>(json);
  139. Type type = o.GetType();
  140. System.Reflection.PropertyInfo[] properties = type.GetProperties();
  141. foreach (System.Reflection.PropertyInfo property in properties)
  142. {
  143. string name = property.Name;
  144. if (!type.GetProperty(name).IsDefined(typeof(JsonIgnoreAttribute), true))
  145. {
  146. var value = property.GetValue(o);
  147. this.GetType().GetProperty(name).SetValue(this, value);
  148. }
  149. }
  150. }
  151. }
  152. }