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

196 lines
11 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("01 尺寸检测"), DisplayName("1.1 启用尺寸检测"), Description("开启尺寸检测(True-是;False-否)")]
  16. public bool OpenSize { get; set; }
  17. [PropertyOrder(2), Browsable(true), Category("01 尺寸检测"), DisplayName("1.2 引擎文件名"), Description("图像处理算法引擎文件名")]
  18. public string EngineName { get; set; }
  19. [PropertyOrder(3), Browsable(true), Category("01 尺寸检测"), DisplayName("1.3 异步运行"), Description("非阻塞后续流程运行(True-是;False-否)")]
  20. public bool AsynRun { get; set; } = true;
  21. [PropertyOrder(11), Browsable(true), Category("02 缺陷检测"), DisplayName("2.1 启用缺陷检测"), Description("开启缺陷检测(True-是;False-否)")]
  22. public bool OpenDefect { get; set; }
  23. [PropertyOrder(12), Browsable(true), Category("02 缺陷检测"), DisplayName("2.2 切割大小"), Description("切割大小")]
  24. public Size CutSize { get; set; }
  25. [PropertyOrder(13), Browsable(true), Category("02 缺陷检测"), DisplayName("2.3 重置大小"), Description("重置大小")]
  26. public Size Resize { get; set; }
  27. [PropertyOrder(14), Browsable(true), Category("02 缺陷检测"), DisplayName("2.4 阀值"), Description("阀值")]
  28. public float Thresholds { get; set; }
  29. [PropertyOrder(17), Browsable(true), Category("02 缺陷检测"), DisplayName("2.7 异步运行"), Description("非阻塞后续流程运行(True-是;False-否)")]
  30. public bool AsynDefectRun { get; set; } = true;
  31. [PropertyOrder(21), Browsable(true), Category("03 相机"), DisplayName("3.1 自动曝光"), Description("开启自动曝光")]
  32. public bool AutoExposure { get; set; }
  33. [PropertyOrder(21), Browsable(true), Category("03 相机"), DisplayName("3.2 曝光"), Description("曝光时长(us)")]
  34. public float ExposureTime { get; set; }
  35. [PropertyOrder(22), Browsable(true), Category("03 相机"), DisplayName("3.3 增益"), Description("增益")]
  36. public float Gain { get; set; }
  37. [PropertyOrder(31), Browsable(true), Category("04 动作"), DisplayName("4.1 起始速度(mm/s)"), Description("起始速度")]
  38. public double VelLow { get; set; }
  39. [PropertyOrder(32), Browsable(true), Category("04 动作"), DisplayName("4.2 运行速度(mm/s)"), Description("运行速度")]
  40. public double VelHigh { get; set; }
  41. [PropertyOrder(33), Browsable(true), Category("04 动作"), DisplayName("4.3 加速度(mm/s)"), Description("加速度")]
  42. public double Acc { get; set; }
  43. [PropertyOrder(34), Browsable(true), Category("04 动作"), DisplayName("4.4 减速度(mm/s)"), Description("减速度")]
  44. public double Dec { get; set; }
  45. [PropertyOrder(35), Browsable(true), Category("04 动作"), DisplayName("4.5 等待稳定时间(ms)"), Description("到位等待稳定时间")]
  46. public int WaitTime { get; set; }
  47. [PropertyOrder(41), Browsable(true), Category("05 走位"), DisplayName("5.1 自动计算左上角"), Description("使用自动计算的左上角")]
  48. public bool AutoLeft { get; set; }
  49. [PropertyOrder(42), Browsable(true), Category("05 走位"), DisplayName("5.2 手动左上角位置"), Description("使用手动设置的左上角")]
  50. public List<PointF> LeftPoints { get; set; }
  51. public Point LeftPoint { get; set; }
  52. [PropertyOrder(43), Browsable(true), Category("05 走位"), DisplayName("5.3 自动计算步进"), Description("使用自动计算的步进位置")]
  53. public bool AutoStep { get; set; }
  54. [PropertyOrder(44), Browsable(true), Category("05 走位"), DisplayName("5.4 X方向步进次数"), Description("使用手动设置的步进次数")]
  55. public int Xstep { get; set; }
  56. [PropertyOrder(45), Browsable(true), Category("05 走位"), DisplayName("5.5 Y方向步进次数"), Description("使用手动设置的步进次数")]
  57. public int Ystep { get; set; }
  58. [PropertyOrder(46), Browsable(true), Category("05 走位"), DisplayName("5.6 Z形扫描走位"), Description("使用S形或者Z形走位")]
  59. public bool IsZMove { get; set; }
  60. [PropertyOrder(46), Browsable(true), Category("06 裁切"), DisplayName("6.1 开启裁切"), Description("使用裁切功能")]
  61. public bool OpenDefectCut { get; set; }
  62. [PropertyOrder(46), Browsable(true), Category("06 裁切"), DisplayName("6.2 裁切上方偏移mm"), Description("使用裁切功能时偏移裁切位置")]
  63. public double DefectCutTopOffset { get; set; }
  64. [PropertyOrder(46), Browsable(true), Category("06 裁切"), DisplayName("6.3 裁切左侧偏移mm"), Description("使用裁切功能时偏移裁切位置")]
  65. public double DefectCutLeftOffset { get; set; }
  66. [PropertyOrder(46), Browsable(true), Category("06 裁切"), DisplayName("6.4 裁切下方偏移mm"), Description("使用裁切功能时偏移裁切位置")]
  67. public double DefectCutDownOffset { get; set; }
  68. [PropertyOrder(46), Browsable(true), Category("06 裁切"), DisplayName("6.5 裁切右侧偏移mm"), Description("使用裁切功能时偏移裁切位置")]
  69. public double DefectCutRightOffset { get; set; }
  70. [PropertyOrder(51), Browsable(true), Category("07 二次检测"), DisplayName("7.01 开启二次检测"), Description("启用本工序二次检测")]
  71. public bool OpenDefcetAgian { get; set; }
  72. [PropertyOrder(52), Browsable(true), Category("07 二次检测"), DisplayName("7.02 一次检测光源通道"), Description("第一次检测使用光源通道,例:1,2,3")]
  73. public string FLightChannel { get; set; }
  74. [PropertyOrder(53), Browsable(true), Category("07 二次检测"), DisplayName("7.03 一次检测光源亮度"), Description("对应光源通道亮度,例:255,255,255")]
  75. public string FLightValue { get; set; }
  76. [PropertyOrder(54), Browsable(true), Category("07 二次检测"), DisplayName("7.04 二次检测光源通道"), Description("第二次检测使用光源通道,例:1,2,3")]
  77. public string SLightChannel { get; set; }
  78. [PropertyOrder(55), Browsable(true), Category("07 二次检测"), DisplayName("7.05 二次检测光源亮度"), Description("对应光源通道亮度,例:255,255,255")]
  79. public string SLightValue { get; set; }
  80. [PropertyOrder(56), Browsable(true), Category("07 二次检测"), DisplayName("7.06 二次检测对应曝光"), Description("对应曝光")]
  81. public double SExposureTime { get; set; }
  82. [PropertyOrder(51), Browsable(true), Category("08 打印"), DisplayName("8.01 开启Excel打印"), Description("启用本工序数据打印")]
  83. public bool OpenPrint { get; set; }
  84. [PropertyOrder(52), Browsable(true), Category("08 打印"), DisplayName("8.02 打印缺陷总数"), Description("打印数据的位置")]
  85. public string ExcelDefectCount { get; set; }
  86. [PropertyOrder(53), Browsable(true), Category("08 打印"), DisplayName("8.03 打印各类缺陷数量"), Description("打印缺陷数量数据的位置,例:A1,A2,A3。使用##为忽略改缺陷")]
  87. public string ExcelDefectEachCount { get; set; }
  88. [PropertyOrder(71), Browsable(true), Category("09 标签打印"), DisplayName("9.01 开启标签打印"), Description("启用本工序数据打印")]
  89. public bool OpenPrintLabel { get; set; }
  90. [PropertyOrder(72), Browsable(true), Category("09 标签打印"), DisplayName("9.02 标签打印缺陷总数"), Description("打印数据的位置")]
  91. public string LabelDefectCount { get; set; }
  92. [PropertyOrder(73), Browsable(true), Category("09 标签打印"), DisplayName("9.03 标签打印各类缺陷数量"), Description("打印缺陷数量数据的位置,例:A1,A2,A3。使用##为忽略改缺陷")]
  93. public string LabelDefectEachCount { get; set; }
  94. [PropertyOrder(91), Browsable(true), Category("10 控制"), DisplayName("10.1 禁用工序"), Description("禁用本工序(True-是;False-否)")]
  95. public bool Disable { get; set; }
  96. public SizeDefectProp()
  97. {
  98. OpenSize = true;
  99. EngineName = "My_PI_PT_General";
  100. AsynRun = true;
  101. OpenDefect = true;
  102. CutSize = new Size(ConfMgr.Instance.SysConfigParams.Defect_CutSize.Width, ConfMgr.Instance.SysConfigParams.Defect_CutSize.Height);
  103. Resize = new Size(ConfMgr.Instance.SysConfigParams.Defect_ReSize.Width, ConfMgr.Instance.SysConfigParams.Defect_ReSize.Height); ;
  104. Thresholds = ConfMgr.Instance.SysConfigParams.Defect_Thresholds;
  105. AsynDefectRun = true;
  106. AutoExposure = false;
  107. ExposureTime = 30000;
  108. Gain = 0;
  109. VelLow = 0;
  110. VelHigh = 100;
  111. Acc = 200;
  112. Dec = 200;
  113. WaitTime = 50;
  114. Disable = false;
  115. AutoStep = true;
  116. AutoLeft = true;
  117. LeftPoints = new List<PointF>();
  118. LeftPoint = new Point();
  119. Xstep = 5;
  120. Ystep = 5;
  121. IsZMove = true;
  122. OpenDefectCut = false;
  123. DefectCutTopOffset = 1;
  124. DefectCutLeftOffset = 1;
  125. DefectCutDownOffset = 1;
  126. DefectCutRightOffset = 1;
  127. OpenDefcetAgian = false;
  128. FLightChannel = "";
  129. FLightValue = "";
  130. SLightChannel = "";
  131. SLightValue = "";
  132. SExposureTime = 30000;
  133. OpenPrint = false;
  134. OpenPrintLabel = false;
  135. ExcelDefectCount = "";
  136. ExcelDefectEachCount = "";
  137. LabelDefectCount = "";
  138. LabelDefectEachCount = "";
  139. }
  140. /// <summary>
  141. /// 序列化
  142. /// </summary>
  143. /// <param name="obj"></param>
  144. /// <returns></returns>
  145. public string serialize()
  146. {
  147. return JsonConvert.SerializeObject(this);
  148. }
  149. /// <summary>
  150. /// 反序列化
  151. /// </summary>
  152. /// <param name="json"></param>
  153. /// <returns></returns>
  154. public void deserialize(string json)
  155. {
  156. var o = JsonConvert.DeserializeObject<SizeDefectProp>(json);
  157. Type type = o.GetType();
  158. System.Reflection.PropertyInfo[] properties = type.GetProperties();
  159. foreach (System.Reflection.PropertyInfo property in properties)
  160. {
  161. string name = property.Name;
  162. if (!type.GetProperty(name).IsDefined(typeof(JsonIgnoreAttribute), true))
  163. {
  164. var value = property.GetValue(o);
  165. this.GetType().GetProperty(name).SetValue(this, value);
  166. }
  167. }
  168. }
  169. }
  170. }