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

209 строки
11 KiB

  1. using MaiMuAOI.SysCtrl;
  2. using MaiMuAOI.SysUI.StepUI.PropExtend;
  3. using Newtonsoft.Json;
  4. using OpenCvSharp;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Drawing;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. namespace MaiMuAOI.SysUI.ProcessStep.Prop
  13. {
  14. public class PointTestProp
  15. {
  16. [PropertyOrder(1), Browsable(true), Category("1 算法"), DisplayName("1.1 引擎文件名"), Description("图像处理算法引擎文件名")]
  17. public string EngineName { get; set; }
  18. [PropertyOrder(2), Browsable(true), Category("1 算法"), DisplayName("1.2 检测项"), Description("检测项选择"), TypeConverter(typeof(genderItem))]
  19. public string TestType { get; set; }
  20. [PropertyOrder(3), Browsable(true), Category("1 算法"), DisplayName("1.3 使用默认点位"), Description("使用程序默认测试点位(True-是;False-否),当使用默认点位时【2 检测】多功能无效,只有检测数量和选点顺序有效")]
  21. public bool DefPos { get; set; }
  22. [PropertyOrder(12), Browsable(true), Category("2 检测"), DisplayName("2.1 检测数量"), Description("流程检测点位的数量")]
  23. public int PointCnt { get; set; }
  24. [PropertyOrder(13), Browsable(true), Category("2 检测"), DisplayName("2.2 自动寻找点位"), Description("根据产品设置和图纸自动寻找测试点位(True-是;False-否)")]
  25. public bool AutoMark { get; set; }
  26. [PropertyOrder(14), Browsable(true), Category("2 检测"), DisplayName("2.3 自动选点按顺序测试"), Description("根据产品设置和图纸按设置顺序自动寻找测试点位(True-是;False-否)")]
  27. public bool SelectPoint { get; set; }
  28. [PropertyOrder(15), Browsable(true), Category("2 检测"), DisplayName("2.4 自动检测顺序设置"), Description("当自动选点顺序 False时,需要手动输入顺序队列")]
  29. public List<int> Indexs { get; set; }
  30. [PropertyOrder(16), Browsable(true), Category("2 检测"), DisplayName("2.5 手动检测位置"), Description("当自动寻找点位 False时,需要手动输入检测点位")]
  31. public List<PointF> Points { get; set; }
  32. [PropertyOrder(17), Browsable(true), Category("2 检测"), DisplayName("2.6 数据判定方式"), Description("对采集数据进行判定处理的方式")]
  33. public DataJudgment JudgmentData { get; set; }
  34. [PropertyOrder(21), Browsable(true), Category("3 相机"), DisplayName("3.1 曝光"), Description("曝光时长(us)")]
  35. public float ExposureTime { get; set; }
  36. [PropertyOrder(22), Browsable(true), Category("3 相机"), DisplayName("3.2 增益"), Description("增益")]
  37. public float Gain { get; set; }
  38. [PropertyOrder(31), Browsable(true), Category("4 动作"), DisplayName("4.1 起始速度(mm/s)"), Description("起始速度")]
  39. public double VelLow { get; set; }
  40. [PropertyOrder(32), Browsable(true), Category("4 动作"), DisplayName("4.2 运行速度(mm/s)"), Description("运行速度")]
  41. public double VelHigh { get; set; }
  42. [PropertyOrder(33), Browsable(true), Category("4 动作"), DisplayName("4.3 加速度(mm/s)"), Description("加速度")]
  43. public double Acc { get; set; }
  44. [PropertyOrder(34), Browsable(true), Category("4 动作"), DisplayName("4.4 减速度(mm/s)"), Description("减速度")]
  45. public double Dec { get; set; }
  46. [PropertyOrder(35), Browsable(true), Category("4 动作"), DisplayName("4.5 等待稳定时间(ms)"), Description("到位等待稳定时间")]
  47. public int WaitTime { get; set; }
  48. [PropertyOrder(41), Browsable(true), Category("5 聚焦"), DisplayName("5.1 开启自动聚焦"), Description("是否开启自动聚焦功能(True-是;False-否)")]
  49. public bool AutoFocus { get; set; }
  50. [PropertyOrder(42), Browsable(true), Category("5 聚焦"), DisplayName("5.2 聚焦步进(mm)"), Description("每次聚焦的步进长度")]
  51. public double FocusStep { get; set; }
  52. [PropertyOrder(43), Browsable(true), Category("5 聚焦"), DisplayName("5.3 方向步进(mm)"), Description("寻找聚焦方向时的步进长度")]
  53. public double DirStep { get; set; }
  54. [PropertyOrder(44), Browsable(true), Category("5 聚焦"), DisplayName("5.4 等待稳定时间(ms)"), Description("聚焦步进之后等待稳定时间")]
  55. public int WaitDoneTime { get; set; }
  56. [PropertyOrder(45), Browsable(true), Category("5 聚焦"), DisplayName("5.5 聚焦超时(ms)"), Description("自动聚焦超时报警")]
  57. public int TimeOut { get; set; }
  58. [PropertyOrder(51), Browsable(true), Category("6 补偿"), DisplayName("6.1 补偿值"), Description("测试读取数据后加入的补偿值")]
  59. public double OffsetValue { get; set; }
  60. [PropertyOrder(61), Browsable(true), Category("7 上下限"), DisplayName("7.1 启用流程上下限"), Description("使用流程中设置的上下限判断")]
  61. public bool OpenUseLimit { get; set; }
  62. [PropertyOrder(62), Browsable(true), Category("7 上下限"), DisplayName("7.2 标准值"), Description("设置判断标志值")]
  63. public double StandardValues { get; set; }
  64. [PropertyOrder(63), Browsable(true), Category("7 上下限"), DisplayName("7.3 上限"), Description("设置判断上限")]
  65. public double MaxLimit { get; set; }
  66. [PropertyOrder(64), Browsable(true), Category("7 上下限"), DisplayName("7.4 下限"), Description("设置流程下限")]
  67. public double MinLimit { get; set; }
  68. [PropertyOrder(64), Browsable(true), Category("7 上下限"), DisplayName("7.5 极差"), Description("设置流程极差")]
  69. public double MaxMinLimit { get; set; }
  70. [PropertyOrder(71), Browsable(true), Category("8 打印"), DisplayName("8.01 开启Excel打印"), Description("启用本工序数据打印")]
  71. public bool OpenPrint { get; set; }
  72. [PropertyOrder(72), Browsable(true), Category("8 打印"), DisplayName("8.02 打印数据"), Description("打印均值数据的位置")]
  73. public string ExcelData { get; set; }
  74. [PropertyOrder(73), Browsable(true), Category("8 打印"), DisplayName("8.03 打印上下限"), Description("打印上下限的位置")]
  75. public string ExcelLimit { get; set; }
  76. [PropertyOrder(74), Browsable(true), Category("8 打印"), DisplayName("8.04 开启标签打印"), Description("启用本工序数据打印")]
  77. public bool OpenPrintLabel { get; set; }
  78. [PropertyOrder(75), Browsable(true), Category("8 打印"), DisplayName("8.05 标签打印数据"), Description("打印均值数据的位置")]
  79. public string LabelData { get; set; }
  80. [PropertyOrder(76), Browsable(true), Category("8 打印"), DisplayName("8.06 标签打印上下限"), Description("打印上下限的位置")]
  81. public string LabelLimit { get; set; }
  82. [PropertyOrder(74), Browsable(true), Category("8 打印"), DisplayName("8.07 开启工单打印"), Description("启用本工序数据打印")]
  83. public bool OpenPrintOrder { get; set; }
  84. [PropertyOrder(75), Browsable(true), Category("8 打印"), DisplayName("8.08 工单打印数据"), Description("打印均值数据的位置序列")]
  85. public string OrderData { get; set; }
  86. [PropertyOrder(76), Browsable(true), Category("8 打印"), DisplayName("8.09 工单打印上下限"), Description("打印上下限的位置序列")]
  87. public string OrderLimit { get; set; }
  88. [PropertyOrder(76), Browsable(true), Category("8 打印"), DisplayName("8.10 工单打印测试名称"), Description("打印测试名称的位置序列")]
  89. public string OrderTestName { get; set; }
  90. [PropertyOrder(76), Browsable(true), Category("8 打印"), DisplayName("8.11 工单打印综合结果"), Description("打印综合结果的位置序列")]
  91. public string OrderTestResult { get; set; }
  92. [PropertyOrder(81), Browsable(true), Category("9 控制"), DisplayName("9.1 禁用工序"), Description("禁用本工序(True-是;False-否)")]
  93. public bool Disable { get; set; }
  94. public PointTestProp()
  95. {
  96. EngineName = "My_PI_PT_General";
  97. TestType = ConfMgr.Instance.SizeItemParamsList[0].Name;
  98. DefPos = false;
  99. PointCnt = 5;
  100. AutoMark = true;
  101. SelectPoint = true;
  102. Indexs = new List<int>();
  103. Points = new List<PointF>();
  104. JudgmentData = DataJudgment.均值;
  105. ExposureTime = 30000;
  106. Gain = 0;
  107. VelLow = 0;
  108. VelHigh = 100;
  109. Acc = 200;
  110. Dec = 200;
  111. WaitTime = 50;
  112. AutoFocus = true;
  113. FocusStep = 0.02;
  114. DirStep = 0.04;
  115. WaitDoneTime = 200;
  116. TimeOut = 30000;
  117. OffsetValue = 0;
  118. OpenUseLimit = false;
  119. StandardValues = 0;
  120. MaxLimit = 0;
  121. MinLimit = 0;
  122. MaxMinLimit = 0;
  123. Disable = false;
  124. OpenPrint = false;
  125. OpenPrintLabel = false;
  126. ExcelData = "";
  127. ExcelLimit = "";
  128. LabelData = "";
  129. LabelLimit = "";
  130. OpenPrintOrder = false;
  131. OrderData = "";
  132. OrderLimit = "";
  133. OrderTestName = "";
  134. OrderTestResult = "";
  135. }
  136. /// <summary>
  137. /// 序列化
  138. /// </summary>
  139. /// <param name="obj"></param>
  140. /// <returns></returns>
  141. public string serialize()
  142. {
  143. return JsonConvert.SerializeObject(this);
  144. }
  145. /// <summary>
  146. /// 反序列化
  147. /// </summary>
  148. /// <param name="json"></param>
  149. /// <returns></returns>
  150. public void deserialize(string json)
  151. {
  152. var o = JsonConvert.DeserializeObject<PointTestProp>(json);
  153. Type type = o.GetType();
  154. System.Reflection.PropertyInfo[] properties = type.GetProperties();
  155. foreach (System.Reflection.PropertyInfo property in properties)
  156. {
  157. string name = property.Name;
  158. if (!type.GetProperty(name).IsDefined(typeof(JsonIgnoreAttribute), true))
  159. {
  160. var value = property.GetValue(o);
  161. this.GetType().GetProperty(name).SetValue(this, value);
  162. }
  163. }
  164. }
  165. }
  166. //自定义属性下拉效果的类,该类主要继承StringConverter类,并重载该类的一些虚拟方法
  167. public class genderItem : StringConverter
  168. {
  169. //true enable,false disable
  170. public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
  171. {
  172. return true;
  173. }
  174. public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
  175. {
  176. return new StandardValuesCollection(ConfMgr.Instance.SizeItemParamsList.Select(p => p.Name).Distinct().ToList()); //编辑下拉框中的items
  177. }
  178. //true: disable text editting. false: enable text editting;
  179. public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
  180. {
  181. return true;
  182. }
  183. }
  184. }