版博士V2.0程序
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 

91 Zeilen
4.1 KiB

  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.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace MaiMuAOI.SysUI.ProcessStep.Prop
  11. {
  12. public class LensProp
  13. {
  14. [PropertyOrder(1), Browsable(true), Category("1 变倍"), DisplayName("1.1 自动变倍"), Description("是否镜头电机自动变倍(True-是;False-否)")]
  15. public bool AutoMotor { get; set; }
  16. [PropertyOrder(2), Browsable(true), Category("1 变倍"), DisplayName("1.2 变焦倍率"), Description("需要进行的变焦的倍率")]
  17. public SmallAxCmdPos FcousPos { get; set; }
  18. [PropertyOrder(3), Browsable(true), Category("1 变倍"), DisplayName("1.3 手动变倍位置(pulse)"), Description("当自动变倍 False时,需要手动输入变倍脉冲")]
  19. public int MotorPulse { get; set; }
  20. [PropertyOrder(11), Browsable(true), Category("2 变焦"), DisplayName("2.1 自动对焦"), Description("是否自动移动Z轴到对焦点位(True-是;False-否)")]
  21. public bool AutoZPoints { get; set; }
  22. [PropertyOrder(12), Browsable(true), Category("2 变焦"), DisplayName("2.2 手动对焦位置(mm)"), Description("当自动对焦 False时,需要手动输入对焦点位")]
  23. public double ZPoints { get; set; }
  24. [PropertyOrder(21), Browsable(true), Category("3 聚焦"), DisplayName("3.1 开启自动聚焦"), Description("是否开启自动聚焦功能(True-是;False-否),开启后后面测试项会开始时自动聚焦一次")]
  25. public bool AutoFocus { get; set; }
  26. [PropertyOrder(22), Browsable(true), Category("3 聚焦"), DisplayName("3.2 聚焦步进(mm)"), Description("每次聚焦的步进长度")]
  27. public double FocusStep { get; set; }
  28. [PropertyOrder(23), Browsable(true), Category("3 聚焦"), DisplayName("3.3 方向步进(mm)"), Description("寻找聚焦方向时的步进长度")]
  29. public double DirStep { get; set; }
  30. [PropertyOrder(24), Browsable(true), Category("3 聚焦"), DisplayName("3.4 等待稳定时间(ms)"), Description("聚焦步进之后等待稳定时间")]
  31. public int WaitTime { get; set; }
  32. [PropertyOrder(25), Browsable(true), Category("3 聚焦"), DisplayName("3.5 聚焦超时(ms)"), Description("自动聚焦超时报警")]
  33. public int TimeOut { get; set; }
  34. [PropertyOrder(31), Browsable(true), Category("4 控制"), DisplayName("4.1 禁用工序"), Description("禁用本工序(True-是;False-否)")]
  35. public bool Disable { get; set; }
  36. public LensProp()
  37. {
  38. AutoMotor = true;
  39. FcousPos = SmallAxCmdPos.倍率0_58X;
  40. MotorPulse = 0;
  41. AutoZPoints = true;
  42. ZPoints = 0;
  43. AutoFocus = true;
  44. FocusStep = 0.02;
  45. DirStep = 0.04;
  46. WaitTime = 200;
  47. TimeOut = 30000;
  48. Disable = false;
  49. }
  50. /// <summary>
  51. /// 序列化
  52. /// </summary>
  53. /// <param name="obj"></param>
  54. /// <returns></returns>
  55. public string serialize()
  56. {
  57. return JsonConvert.SerializeObject(this);
  58. }
  59. /// <summary>
  60. /// 反序列化
  61. /// </summary>
  62. /// <param name="json"></param>
  63. /// <returns></returns>
  64. public void deserialize(string json)
  65. {
  66. var o = JsonConvert.DeserializeObject<LensProp>(json);
  67. Type type = o.GetType();
  68. System.Reflection.PropertyInfo[] properties = type.GetProperties();
  69. foreach (System.Reflection.PropertyInfo property in properties)
  70. {
  71. string name = property.Name;
  72. if (!type.GetProperty(name).IsDefined(typeof(JsonIgnoreAttribute), true))
  73. {
  74. var value = property.GetValue(o);
  75. this.GetType().GetProperty(name).SetValue(this, value);
  76. }
  77. }
  78. }
  79. }
  80. }