|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- using MaiMuAOI.SysCtrl;
- using MaiMuAOI.SysUI.StepUI.PropExtend;
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace MaiMuAOI.SysUI.ProcessStep.Prop
- {
- public class SizeDefectProp
- {
- [PropertyOrder(1), Browsable(true), Category("1 尺寸检测"), DisplayName("1.1 启用尺寸检测"), Description("开启尺寸检测(True-是;False-否)")]
- public bool OpenSize { get; set; }
- [PropertyOrder(2), Browsable(true), Category("1 尺寸检测"), DisplayName("1.2 引擎文件名"), Description("图像处理算法引擎文件名")]
- public string EngineName { get; set; }
- [PropertyOrder(3), Browsable(true), Category("1 尺寸检测"), DisplayName("1.3 异步运行"), Description("非阻塞后续流程运行(True-是;False-否)")]
- public bool AsynRun { get; set; } = true;
-
- [PropertyOrder(11), Browsable(true), Category("2 缺陷检测"), DisplayName("2.1 启用缺陷检测"), Description("开启缺陷检测(True-是;False-否)")]
- public bool OpenDefect { get; set; }
- [PropertyOrder(12), Browsable(true), Category("2 缺陷检测"), DisplayName("2.2 切割大小"), Description("切割大小")]
- public Size CutSize { get; set; }
- [PropertyOrder(13), Browsable(true), Category("2 缺陷检测"), DisplayName("2.3 重置大小"), Description("重置大小")]
- public Size Resize { get; set; }
- [PropertyOrder(14), Browsable(true), Category("2 缺陷检测"), DisplayName("2.4 阀值"), Description("阀值")]
- public float Thresholds { get; set; }
- [PropertyOrder(15), Browsable(true), Category("2 缺陷检测"), DisplayName("2.5 种类阀值"), Description("多个用半号逗号(,)或分号(;)分隔")]
- public string ThresholdsClass { get; set; }
- [PropertyOrder(16), Browsable(true), Category("2 缺陷检测"), DisplayName("2.6 种类个数"), Description("种类阀值的数量")]
- public int ThresholdsClassCount { get; set; }
- [PropertyOrder(17), Browsable(true), Category("2 缺陷检测"), DisplayName("2.7 异步运行"), Description("非阻塞后续流程运行(True-是;False-否)")]
- public bool AsynDefectRun { get; set; } = true;
-
- [PropertyOrder(21), Browsable(true), Category("3 相机"), DisplayName("3.1 曝光"), Description("曝光时长(us)")]
- public float ExposureTime { get; set; }
- [PropertyOrder(22), Browsable(true), Category("3 相机"), DisplayName("3.2 增益"), Description("增益")]
- public float Gain { get; set; }
-
- [PropertyOrder(31), Browsable(true), Category("4 动作"), DisplayName("4.1 起始速度(mm/s)"), Description("起始速度")]
- public double VelLow { get; set; }
- [PropertyOrder(32), Browsable(true), Category("4 动作"), DisplayName("4.2 运行速度(mm/s)"), Description("运行速度")]
- public double VelHigh { get; set; }
- [PropertyOrder(33), Browsable(true), Category("4 动作"), DisplayName("4.3 加速度(mm/s)"), Description("加速度")]
- public double Acc { get; set; }
- [PropertyOrder(34), Browsable(true), Category("4 动作"), DisplayName("4.4 减速度(mm/s)"), Description("减速度")]
- public double Dec { get; set; }
- [PropertyOrder(35), Browsable(true), Category("4 动作"), DisplayName("4.5 等待稳定时间(ms)"), Description("到位等待稳定时间")]
- public int WaitTime { get; set; }
-
- [PropertyOrder(41), Browsable(true), Category("5 控制"), DisplayName("5.1 禁用工序"), Description("禁用本工序(True-是;False-否)")]
- public bool Disable { get; set; }
-
- public SizeDefectProp()
- {
- OpenSize = true;
- EngineName = "";
- AsynRun = true;
-
- OpenDefect = true;
- CutSize = new Size(ConfMgr.Instance.SysConfigParams.Defect_CutSize.Width, ConfMgr.Instance.SysConfigParams.Defect_CutSize.Height);
- Resize = new Size(ConfMgr.Instance.SysConfigParams.Defect_ReSize.Width, ConfMgr.Instance.SysConfigParams.Defect_ReSize.Height); ;
- Thresholds = ConfMgr.Instance.SysConfigParams.Defect_Thresholds;
- ThresholdsClass = "";
- ThresholdsClassCount = 0;
- AsynDefectRun = true;
-
- ExposureTime = 30000;
- Gain = 0;
-
- VelLow = 0;
- VelHigh = 100;
- Acc = 200;
- Dec = 200;
- WaitTime = 50;
-
- 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<SizeDefectProp>(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);
- }
- }
- }
- }
- }
|