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(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("使用自动计算的左上角")] public bool AutoLeft { get; set; } [PropertyOrder(42), Browsable(true), Category("5 走位"), DisplayName("5.2 手动左上角位置"), Description("使用手动设置的左上角")] public List LeftPoints { get; set; } public Point LeftPoint { get; set; } [PropertyOrder(43), Browsable(true), Category("5 走位"), DisplayName("5.3 自动计算步进"), Description("使用自动计算的步进位置")] public bool AutoStep { get; set; } [PropertyOrder(44), Browsable(true), Category("5 走位"), DisplayName("5.4 X方向步进次数"), Description("使用手动设置的步进次数")] public int Xstep { get; set; } [PropertyOrder(45), Browsable(true), Category("5 走位"), DisplayName("5.5 Y方向步进次数"), Description("使用手动设置的步进次数")] public int Ystep { get; set; } [PropertyOrder(51), Browsable(true), Category("6 打印"), DisplayName("6.01 开启Excel打印"), Description("启用本工序数据打印")] public bool OpenPrint { get; set; } [PropertyOrder(52), Browsable(true), Category("6 打印"), DisplayName("6.02 打印缺陷总数"), Description("打印数据的位置")] public string ExcelDefectCount { get; set; } [PropertyOrder(53), Browsable(true), Category("6 打印"), DisplayName("6.03 打印各类缺陷数量"), Description("打印缺陷数量数据的位置,例:A1,A2,A3。使用##为忽略改缺陷")] public string ExcelDefectEachCount { get; set; } [PropertyOrder(71), Browsable(true), Category("7 标签打印"), DisplayName("7.01 开启标签打印"), Description("启用本工序数据打印")] public bool OpenPrintLabel { get; set; } [PropertyOrder(72), Browsable(true), Category("7 标签打印"), DisplayName("7.02 标签打印缺陷总数"), Description("打印数据的位置")] public string LabelDefectCount { get; set; } [PropertyOrder(73), Browsable(true), Category("7 标签打印"), DisplayName("7.03 标签打印各类缺陷数量"), Description("打印缺陷数量数据的位置,例:A1,A2,A3。使用##为忽略改缺陷")] public string LabelDefectEachCount { get; set; } [PropertyOrder(91), Browsable(true), Category("8 控制"), DisplayName("8.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; ExposureTime = 30000; Gain = 0; VelLow = 0; VelHigh = 100; Acc = 200; Dec = 200; WaitTime = 50; Disable = false; AutoStep = true; AutoLeft = true; LeftPoints = new List(); LeftPoint = new Point(); Xstep = 5; Ystep = 5; OpenPrint = false; OpenPrintLabel = false; ExcelDefectCount = ""; ExcelDefectEachCount = ""; LabelDefectCount = ""; LabelDefectEachCount = ""; } /// /// 序列化 /// /// /// public string serialize() { return JsonConvert.SerializeObject(this); } /// /// 反序列化 /// /// /// public void deserialize(string json) { var o = JsonConvert.DeserializeObject(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); } } } } }