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

2 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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(15), Browsable(true), Category("2 缺陷检测"), DisplayName("2.5 种类阀值"), Description("多个用半号逗号(,)或分号(;)分隔")]
  30. public string ThresholdsClass { get; set; }
  31. [PropertyOrder(16), Browsable(true), Category("2 缺陷检测"), DisplayName("2.6 种类个数"), Description("种类阀值的数量")]
  32. public int ThresholdsClassCount { get; set; }
  33. [PropertyOrder(17), Browsable(true), Category("2 缺陷检测"), DisplayName("2.7 异步运行"), Description("非阻塞后续流程运行(True-是;False-否)")]
  34. public bool AsynDefectRun { get; set; } = true;
  35. [PropertyOrder(21), Browsable(true), Category("3 相机"), DisplayName("3.1 曝光"), Description("曝光时长(us)")]
  36. public float ExposureTime { get; set; }
  37. [PropertyOrder(22), Browsable(true), Category("3 相机"), DisplayName("3.2 增益"), Description("增益")]
  38. public float Gain { get; set; }
  39. [PropertyOrder(31), Browsable(true), Category("4 动作"), DisplayName("4.1 起始速度(mm/s)"), Description("起始速度")]
  40. public double VelLow { get; set; }
  41. [PropertyOrder(32), Browsable(true), Category("4 动作"), DisplayName("4.2 运行速度(mm/s)"), Description("运行速度")]
  42. public double VelHigh { get; set; }
  43. [PropertyOrder(33), Browsable(true), Category("4 动作"), DisplayName("4.3 加速度(mm/s)"), Description("加速度")]
  44. public double Acc { get; set; }
  45. [PropertyOrder(34), Browsable(true), Category("4 动作"), DisplayName("4.4 减速度(mm/s)"), Description("减速度")]
  46. public double Dec { get; set; }
  47. [PropertyOrder(35), Browsable(true), Category("4 动作"), DisplayName("4.5 等待稳定时间(ms)"), Description("到位等待稳定时间")]
  48. public int WaitTime { get; set; }
  49. [PropertyOrder(41), Browsable(true), Category("5 控制"), DisplayName("5.1 禁用工序"), Description("禁用本工序(True-是;False-否)")]
  50. public bool Disable { get; set; }
  51. public SizeDefectProp()
  52. {
  53. OpenSize = true;
  54. EngineName = "";
  55. AsynRun = true;
  56. OpenDefect = true;
  57. CutSize = new Size(ConfMgr.Instance.SysConfigParams.Defect_CutSize.Width, ConfMgr.Instance.SysConfigParams.Defect_CutSize.Height);
  58. Resize = new Size(ConfMgr.Instance.SysConfigParams.Defect_ReSize.Width, ConfMgr.Instance.SysConfigParams.Defect_ReSize.Height); ;
  59. Thresholds = ConfMgr.Instance.SysConfigParams.Defect_Thresholds;
  60. ThresholdsClass = "";
  61. ThresholdsClassCount = 0;
  62. AsynDefectRun = true;
  63. ExposureTime = 30000;
  64. Gain = 0;
  65. VelLow = 0;
  66. VelHigh = 100;
  67. Acc = 200;
  68. Dec = 200;
  69. WaitTime = 50;
  70. Disable = false;
  71. }
  72. /// <summary>
  73. /// 序列化
  74. /// </summary>
  75. /// <param name="obj"></param>
  76. /// <returns></returns>
  77. public string serialize()
  78. {
  79. return JsonConvert.SerializeObject(this);
  80. }
  81. /// <summary>
  82. /// 反序列化
  83. /// </summary>
  84. /// <param name="json"></param>
  85. /// <returns></returns>
  86. public void deserialize(string json)
  87. {
  88. var o = JsonConvert.DeserializeObject<SizeDefectProp>(json);
  89. Type type = o.GetType();
  90. System.Reflection.PropertyInfo[] properties = type.GetProperties();
  91. foreach (System.Reflection.PropertyInfo property in properties)
  92. {
  93. string name = property.Name;
  94. if (!type.GetProperty(name).IsDefined(typeof(JsonIgnoreAttribute), true))
  95. {
  96. var value = property.GetValue(o);
  97. this.GetType().GetProperty(name).SetValue(this, value);
  98. }
  99. }
  100. }
  101. }
  102. }