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

98 строки
4.6 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Xml.Linq;
  8. using MaiMuAOI.SysCtrl;
  9. using MaiMuAOI.SysUI.StepUI.PropExtend;
  10. using Newtonsoft.Json;
  11. using Newtonsoft.Json.Serialization;
  12. using static ProductionControl.UI.UIAxisDev;
  13. namespace ProductionControl.UI
  14. {
  15. //[TypeConverter(typeof(PropertySorter))] //此属性使类无法序列化和反序列化
  16. public class ScannerDevProp
  17. {
  18. public ScannerDevProp(ScannerType devType = ScannerType.GENTL) {
  19. DeviceType=devType;
  20. AutoFocus = true;
  21. FocusStep = 0.02;
  22. DirStep = 0.04;
  23. WaitTime = 200;
  24. TimeOut = 30000;
  25. }
  26. [PropertyOrder(1), Browsable(true), Category("1 设备"), DisplayName("设备类型"), Description("设备类型"), ReadOnly(true)]
  27. public ScannerType DeviceType { get;set; }
  28. [PropertyOrder(1), Browsable(true), Category("2 图像"), DisplayName("图像名称"), Description("图像名称"), ReadOnly(true), JsonIgnore]
  29. public string[] ImageList { get; set; }
  30. [PropertyOrder(1), Browsable(true), Category("2 图像"), DisplayName("AI引擎库"), Description("此照片所调用的AI库")]
  31. public AIEngineLibEnum AIEngineLib { get; set; }
  32. //100-9999500
  33. [PropertyOrder(11), Browsable(true), Category("3 参数"), DisplayName("曝光"), Description("曝光时长(us)")]
  34. public float ExposureTime { get; set; }
  35. [PropertyOrder(12), Browsable(true), Category("3 参数"), DisplayName("增益"), Description("增益")]
  36. public float Gain { get; set; }
  37. [PropertyOrder(13), Browsable(true), Category("3 参数"), DisplayName("帧率"), Description("帧率")]
  38. public float ResultingFrameRate { get; set; }
  39. //2024-1-24
  40. [PropertyOrder(21), Browsable(true), Category("4 聚焦"), DisplayName("4.1 开启自动聚焦"), Description("是否开启自动聚焦功能(True-是;False-否),开启后后面测试项会开始时自动聚焦一次")]
  41. public bool AutoFocus { get; set; }
  42. [PropertyOrder(22), Browsable(true), Category("4 聚焦"), DisplayName("4.2 聚焦步进(mm)"), Description("每次聚焦的步进长度")]
  43. public double FocusStep { get; set; }
  44. [PropertyOrder(23), Browsable(true), Category("4 聚焦"), DisplayName("4.3 方向步进(mm)"), Description("寻找聚焦方向时的步进长度")]
  45. public double DirStep { get; set; }
  46. [PropertyOrder(24), Browsable(true), Category("4 聚焦"), DisplayName("4.4 等待稳定时间(ms)"), Description("聚焦步进之后等待稳定时间")]
  47. public int WaitTime { get; set; }
  48. [PropertyOrder(25), Browsable(true), Category("4 聚焦"), DisplayName("4.5 聚焦超时(ms)"), Description("自动聚焦超时报警")]
  49. public int TimeOut { get; set; }
  50. [PropertyOrder(35), Browsable(true), Category("5 控制"), DisplayName("5.1 运行前Sleep(ms)"), Description("休息时间")]
  51. public uint SleepPre { get; set; }
  52. [PropertyOrder(36), Browsable(true), Category("5 控制"), DisplayName("5.2 运行后Sleep(ms)"), Description("休息时间")]
  53. public uint SleepLater { get; set; }
  54. [PropertyOrder(37), Browsable(true), Category("5 控制"), DisplayName("5.4 禁用工序"), Description("禁用本工序(True-是;False-否)")]
  55. public bool Disable { get; set; }
  56. /// <summary>
  57. /// 序列化
  58. /// </summary>
  59. /// <param name="obj"></param>
  60. /// <returns></returns>
  61. public string serialize()
  62. {
  63. return JsonConvert.SerializeObject(this);
  64. }
  65. /// <summary>
  66. /// 反序列化
  67. /// </summary>
  68. /// <param name="json"></param>
  69. /// <returns></returns>
  70. public void deserialize(string json)
  71. {
  72. var o= JsonConvert.DeserializeObject<ScannerDevProp>(json);
  73. Type type = o.GetType();
  74. System.Reflection.PropertyInfo[] properties = type.GetProperties();
  75. foreach (System.Reflection.PropertyInfo property in properties)
  76. {
  77. string name = property.Name;
  78. if (!type.GetProperty(name).IsDefined(typeof(JsonIgnoreAttribute), true))
  79. {
  80. var value = property.GetValue(o);
  81. this.GetType().GetProperty(name).SetValue(this, value);
  82. }
  83. }
  84. }
  85. }
  86. }