|
- using MaiMuAOI.SysCtrl;
- using MaiMuAOI.SysUI.StepUI.PropExtend;
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace MaiMuAOI.SysUI.ProcessStep.Prop
- {
- public class LensProp
- {
- [PropertyOrder(1), Browsable(true), Category("1 变倍"), DisplayName("1.1 自动变倍"), Description("是否镜头电机自动变倍(True-是;False-否)")]
- public bool AutoMotor { get; set; }
- [PropertyOrder(2), Browsable(true), Category("1 变倍"), DisplayName("1.2 变焦倍率"), Description("需要进行的变焦的倍率")]
- public SmallAxCmdPos FcousPos { get; set; }
- [PropertyOrder(3), Browsable(true), Category("1 变倍"), DisplayName("1.3 手动变倍位置(pulse)"), Description("当自动变倍 False时,需要手动输入变倍脉冲")]
- public int MotorPulse { get; set; }
-
- [PropertyOrder(11), Browsable(true), Category("2 变焦"), DisplayName("2.1 自动对焦"), Description("是否自动移动Z轴到对焦点位(True-是;False-否)")]
- public bool AutoZPoints { get; set; }
- [PropertyOrder(12), Browsable(true), Category("2 变焦"), DisplayName("2.2 手动对焦位置(mm)"), Description("当自动对焦 False时,需要手动输入对焦点位")]
- public double ZPoints { get; set; }
-
- [PropertyOrder(21), Browsable(true), Category("3 聚焦"), DisplayName("3.1 开启自动聚焦"), Description("是否开启自动聚焦功能(True-是;False-否),开启后后面测试项会开始时自动聚焦一次")]
- public bool AutoFocus { get; set; }
- [PropertyOrder(22), Browsable(true), Category("3 聚焦"), DisplayName("3.2 聚焦步进(mm)"), Description("每次聚焦的步进长度")]
- public double FocusStep { get; set; }
- [PropertyOrder(23), Browsable(true), Category("3 聚焦"), DisplayName("3.3 方向步进(mm)"), Description("寻找聚焦方向时的步进长度")]
- public double DirStep { get; set; }
- [PropertyOrder(24), Browsable(true), Category("3 聚焦"), DisplayName("3.4 等待稳定时间(ms)"), Description("聚焦步进之后等待稳定时间")]
- public int WaitTime { get; set; }
- [PropertyOrder(25), Browsable(true), Category("3 聚焦"), DisplayName("3.5 聚焦超时(ms)"), Description("自动聚焦超时报警")]
- public int TimeOut { get; set; }
-
- [PropertyOrder(31), Browsable(true), Category("4 控制"), DisplayName("4.1 禁用工序"), Description("禁用本工序(True-是;False-否)")]
- public bool Disable { get; set; }
-
-
- public LensProp()
- {
- AutoMotor = true;
- FcousPos = SmallAxCmdPos.倍率0_58X;
- MotorPulse = 0;
-
- AutoZPoints = true;
- ZPoints = 0;
-
- AutoFocus = true;
- FocusStep = 0.02;
- DirStep = 0.04;
- WaitTime = 200;
- TimeOut = 30000;
-
- Disable = false;
- }
-
- /// <summary>
- /// 序列化
- /// </summary>
- /// <param name="obj"></param>
- /// <returns></returns>
- public string serialize()
- {
- return JsonConvert.SerializeObject(this);
- }
- /// <summary>
- /// 反序列化
- /// </summary>
- /// <param name="json"></param>
- /// <returns></returns>
- public void deserialize(string json)
- {
- var o = JsonConvert.DeserializeObject<LensProp>(json);
- Type type = o.GetType();
- System.Reflection.PropertyInfo[] properties = type.GetProperties();
- foreach (System.Reflection.PropertyInfo property in properties)
- {
- string name = property.Name;
- if (!type.GetProperty(name).IsDefined(typeof(JsonIgnoreAttribute), true))
- {
- var value = property.GetValue(o);
- this.GetType().GetProperty(name).SetValue(this, value);
- }
- }
- }
- }
- }
|