|
- 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("01 尺寸检测"), DisplayName("1.1 启用尺寸检测"), Description("开启尺寸检测(True-是;False-否)")]
- public bool OpenSize { get; set; }
- [PropertyOrder(2), Browsable(true), Category("01 尺寸检测"), DisplayName("1.2 引擎文件名"), Description("图像处理算法引擎文件名")]
- public string EngineName { get; set; }
- [PropertyOrder(3), Browsable(true), Category("01 尺寸检测"), DisplayName("1.3 异步运行"), Description("非阻塞后续流程运行(True-是;False-否)")]
- public bool AsynRun { get; set; } = true;
-
- [PropertyOrder(11), Browsable(true), Category("02 缺陷检测"), DisplayName("2.1 启用缺陷检测"), Description("开启缺陷检测(True-是;False-否)")]
- public bool OpenDefect { get; set; }
- [PropertyOrder(12), Browsable(true), Category("02 缺陷检测"), DisplayName("2.2 切割大小"), Description("切割大小")]
- public Size CutSize { get; set; }
- [PropertyOrder(13), Browsable(true), Category("02 缺陷检测"), DisplayName("2.3 重置大小"), Description("重置大小")]
- public Size Resize { get; set; }
- [PropertyOrder(14), Browsable(true), Category("02 缺陷检测"), DisplayName("2.4 阀值"), Description("阀值")]
- public float Thresholds { get; set; }
- [PropertyOrder(17), Browsable(true), Category("02 缺陷检测"), DisplayName("2.7 异步运行"), Description("非阻塞后续流程运行(True-是;False-否)")]
- public bool AsynDefectRun { get; set; } = true;
-
- [PropertyOrder(21), Browsable(true), Category("03 相机"), DisplayName("3.1 自动曝光"), Description("开启自动曝光")]
- public bool AutoExposure { get; set; }
- [PropertyOrder(21), Browsable(true), Category("03 相机"), DisplayName("3.2 曝光"), Description("曝光时长(us)")]
- public float ExposureTime { get; set; }
- [PropertyOrder(22), Browsable(true), Category("03 相机"), DisplayName("3.3 增益"), Description("增益")]
- public float Gain { get; set; }
-
- [PropertyOrder(31), Browsable(true), Category("04 动作"), DisplayName("4.1 起始速度(mm/s)"), Description("起始速度")]
- public double VelLow { get; set; }
- [PropertyOrder(32), Browsable(true), Category("04 动作"), DisplayName("4.2 运行速度(mm/s)"), Description("运行速度")]
- public double VelHigh { get; set; }
- [PropertyOrder(33), Browsable(true), Category("04 动作"), DisplayName("4.3 加速度(mm/s)"), Description("加速度")]
- public double Acc { get; set; }
- [PropertyOrder(34), Browsable(true), Category("04 动作"), DisplayName("4.4 减速度(mm/s)"), Description("减速度")]
- public double Dec { get; set; }
- [PropertyOrder(35), Browsable(true), Category("04 动作"), DisplayName("4.5 等待稳定时间(ms)"), Description("到位等待稳定时间")]
- public int WaitTime { get; set; }
-
- [PropertyOrder(41), Browsable(true), Category("05 走位"), DisplayName("5.1 自动计算左上角"), Description("使用自动计算的左上角")]
- public bool AutoLeft { get; set; }
- [PropertyOrder(42), Browsable(true), Category("05 走位"), DisplayName("5.2 手动左上角位置"), Description("使用手动设置的左上角")]
- public List<PointF> LeftPoints { get; set; }
- public Point LeftPoint { get; set; }
- [PropertyOrder(43), Browsable(true), Category("05 走位"), DisplayName("5.3 自动计算步进"), Description("使用自动计算的步进位置")]
- public bool AutoStep { get; set; }
- [PropertyOrder(44), Browsable(true), Category("05 走位"), DisplayName("5.4 X方向步进次数"), Description("使用手动设置的步进次数")]
- public int Xstep { get; set; }
- [PropertyOrder(45), Browsable(true), Category("05 走位"), DisplayName("5.5 Y方向步进次数"), Description("使用手动设置的步进次数")]
- public int Ystep { get; set; }
- [PropertyOrder(46), Browsable(true), Category("05 走位"), DisplayName("5.6 Z形扫描走位"), Description("使用S形或者Z形走位")]
- public bool IsZMove { get; set; }
-
-
- [PropertyOrder(46), Browsable(true), Category("06 裁切"), DisplayName("6.1 开启裁切"), Description("使用裁切功能")]
- public bool OpenDefectCut { get; set; }
- [PropertyOrder(46), Browsable(true), Category("06 裁切"), DisplayName("6.2 裁切上方偏移mm"), Description("使用裁切功能时偏移裁切位置")]
- public double DefectCutTopOffset { get; set; }
- [PropertyOrder(46), Browsable(true), Category("06 裁切"), DisplayName("6.3 裁切左侧偏移mm"), Description("使用裁切功能时偏移裁切位置")]
- public double DefectCutLeftOffset { get; set; }
- [PropertyOrder(46), Browsable(true), Category("06 裁切"), DisplayName("6.4 裁切下方偏移mm"), Description("使用裁切功能时偏移裁切位置")]
- public double DefectCutDownOffset { get; set; }
- [PropertyOrder(46), Browsable(true), Category("06 裁切"), DisplayName("6.5 裁切右侧偏移mm"), Description("使用裁切功能时偏移裁切位置")]
- public double DefectCutRightOffset { get; set; }
-
- [PropertyOrder(51), Browsable(true), Category("07 二次检测"), DisplayName("7.01 开启二次检测"), Description("启用本工序二次检测")]
- public bool OpenDefcetAgian { get; set; }
- [PropertyOrder(52), Browsable(true), Category("07 二次检测"), DisplayName("7.02 一次检测光源通道"), Description("第一次检测使用光源通道,例:1,2,3")]
- public string FLightChannel { get; set; }
- [PropertyOrder(53), Browsable(true), Category("07 二次检测"), DisplayName("7.03 一次检测光源亮度"), Description("对应光源通道亮度,例:255,255,255")]
- public string FLightValue { get; set; }
- [PropertyOrder(54), Browsable(true), Category("07 二次检测"), DisplayName("7.04 二次检测光源通道"), Description("第二次检测使用光源通道,例:1,2,3")]
- public string SLightChannel { get; set; }
- [PropertyOrder(55), Browsable(true), Category("07 二次检测"), DisplayName("7.05 二次检测光源亮度"), Description("对应光源通道亮度,例:255,255,255")]
- public string SLightValue { get; set; }
- [PropertyOrder(56), Browsable(true), Category("07 二次检测"), DisplayName("7.06 二次检测对应曝光"), Description("对应曝光")]
- public double SExposureTime { get; set; }
-
-
- [PropertyOrder(51), Browsable(true), Category("08 打印"), DisplayName("8.01 开启Excel打印"), Description("启用本工序数据打印")]
- public bool OpenPrint { get; set; }
- [PropertyOrder(52), Browsable(true), Category("08 打印"), DisplayName("8.02 打印缺陷总数"), Description("打印数据的位置")]
- public string ExcelDefectCount { get; set; }
- [PropertyOrder(53), Browsable(true), Category("08 打印"), DisplayName("8.03 打印各类缺陷数量"), Description("打印缺陷数量数据的位置,例:A1,A2,A3。使用##为忽略改缺陷")]
- public string ExcelDefectEachCount { get; set; }
-
- [PropertyOrder(71), Browsable(true), Category("09 标签打印"), DisplayName("9.01 开启标签打印"), Description("启用本工序数据打印")]
- public bool OpenPrintLabel { get; set; }
- [PropertyOrder(72), Browsable(true), Category("09 标签打印"), DisplayName("9.02 标签打印缺陷总数"), Description("打印数据的位置")]
- public string LabelDefectCount { get; set; }
- [PropertyOrder(73), Browsable(true), Category("09 标签打印"), DisplayName("9.03 标签打印各类缺陷数量"), Description("打印缺陷数量数据的位置,例:A1,A2,A3。使用##为忽略改缺陷")]
- public string LabelDefectEachCount { get; set; }
-
-
- [PropertyOrder(91), Browsable(true), Category("10 控制"), DisplayName("10.1 禁用工序"), Description("禁用本工序(True-是;False-否)")]
- public bool Disable { get; set; }
-
- public SizeDefectProp()
- {
- OpenSize = true;
- EngineName = "My_PI_PT_General";
- 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;
- AsynDefectRun = true;
-
- AutoExposure = false;
- ExposureTime = 30000;
- Gain = 0;
-
- VelLow = 0;
- VelHigh = 100;
- Acc = 200;
- Dec = 200;
- WaitTime = 50;
-
- Disable = false;
-
- AutoStep = true;
- AutoLeft = true;
- LeftPoints = new List<PointF>();
- LeftPoint = new Point();
- Xstep = 5;
- Ystep = 5;
- IsZMove = true;
-
- OpenDefectCut = false;
- DefectCutTopOffset = 1;
- DefectCutLeftOffset = 1;
- DefectCutDownOffset = 1;
- DefectCutRightOffset = 1;
-
- OpenDefcetAgian = false;
- FLightChannel = "";
- FLightValue = "";
- SLightChannel = "";
- SLightValue = "";
- SExposureTime = 30000;
-
- OpenPrint = false;
- OpenPrintLabel = false;
-
- ExcelDefectCount = "";
- ExcelDefectEachCount = "";
-
- LabelDefectCount = "";
- LabelDefectEachCount = "";
- }
-
- /// <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);
- }
- }
- }
- }
- }
|