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

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