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

103 lines
4.5 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 MarkProp
  15. {
  16. [PropertyOrder(1), Browsable(true), Category("1 算法"), DisplayName("1.1 引擎文件名"), Description("图像处理算法引擎文件名")]
  17. public string EngineName { get; set; }
  18. [PropertyOrder(11), Browsable(true), Category("2 Mark"), DisplayName("2.1 Mark类型"), Description("流程找Mark的类型位置")]
  19. public MarkCam MarkType { get; set; }
  20. [PropertyOrder(12), Browsable(true), Category("2 Mark"), DisplayName("2.2 Mark数量"), Description("流程找Mark的数量")]
  21. public int MarkCnt { get; set; }
  22. [PropertyOrder(13), Browsable(true), Category("2 Mark"), DisplayName("2.3 自动寻找Mark"), Description("根据产品设置和图纸自动寻找Mark(True-是;False-否)")]
  23. public bool AutoMark { get; set; }
  24. [PropertyOrder(14), Browsable(true), Category("2 Mark"), DisplayName("2.4 手动Mark位置列表"), Description("当自动寻找Mark False时,需要手动输入Mark点位")]
  25. public List<PointF> Points { get; set; }
  26. [PropertyOrder(21), Browsable(true), Category("3 相机"), DisplayName("3.1 自动曝光"), Description("开启自动曝光")]
  27. public bool AutoExposure { get; set; }
  28. [PropertyOrder(21), Browsable(true), Category("3 相机"), DisplayName("3.2 曝光"), Description("曝光时长(us)")]
  29. public float ExposureTime { get; set; }
  30. [PropertyOrder(22), Browsable(true), Category("3 相机"), DisplayName("3.3 增益"), Description("增益")]
  31. public float Gain { get; set; }
  32. [PropertyOrder(31), Browsable(true), Category("4 动作"), DisplayName("4.1 起始速度(mm/s)"), Description("起始速度")]
  33. public double VelLow { get; set; }
  34. [PropertyOrder(32), Browsable(true), Category("4 动作"), DisplayName("4.2 运行速度(mm/s)"), Description("运行速度")]
  35. public double VelHigh { get; set; }
  36. [PropertyOrder(33), Browsable(true), Category("4 动作"), DisplayName("4.3 加速度(mm/s)"), Description("加速度")]
  37. public double Acc { get; set; }
  38. [PropertyOrder(34), Browsable(true), Category("4 动作"), DisplayName("4.4 减速度(mm/s)"), Description("减速度")]
  39. public double Dec { get; set; }
  40. [PropertyOrder(35), Browsable(true), Category("4 动作"), DisplayName("4.5 等待稳定时间(ms)"), Description("到位等待稳定时间")]
  41. public int WaitTime { get; set; }
  42. [PropertyOrder(41), Browsable(true), Category("5 控制"), DisplayName("5.1 禁用工序"), Description("禁用本工序(True-是;False-否)")]
  43. public bool Disable { get; set; }
  44. public MarkProp()
  45. {
  46. EngineName = "My_PI_PT_General";
  47. MarkType = MarkCam.尺寸检测Mark;
  48. MarkCnt = 4;
  49. AutoMark = true;
  50. Points = new List<PointF>();
  51. AutoExposure = false;
  52. ExposureTime = 30000;
  53. Gain = 0;
  54. VelLow = 0;
  55. VelHigh = 100;
  56. Acc = 200;
  57. Dec = 200;
  58. WaitTime = 50;
  59. Disable = false;
  60. }
  61. /// <summary>
  62. /// 序列化
  63. /// </summary>
  64. /// <param name="obj"></param>
  65. /// <returns></returns>
  66. public string serialize()
  67. {
  68. return JsonConvert.SerializeObject(this);
  69. }
  70. /// <summary>
  71. /// 反序列化
  72. /// </summary>
  73. /// <param name="json"></param>
  74. /// <returns></returns>
  75. public void deserialize(string json)
  76. {
  77. var o = JsonConvert.DeserializeObject<MarkProp>(json);
  78. Type type = o.GetType();
  79. System.Reflection.PropertyInfo[] properties = type.GetProperties();
  80. foreach (System.Reflection.PropertyInfo property in properties)
  81. {
  82. string name = property.Name;
  83. if (!type.GetProperty(name).IsDefined(typeof(JsonIgnoreAttribute), true))
  84. {
  85. var value = property.GetValue(o);
  86. this.GetType().GetProperty(name).SetValue(this, value);
  87. }
  88. }
  89. }
  90. }
  91. }