using MaiMuAOI.SysCtrl; using MaiMuAOI.SysUI.StepUI.PropExtend; using Newtonsoft.Json; using OpenCvSharp; 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 PointTestProp { [PropertyOrder(1), Browsable(true), Category("1 算法"), DisplayName("1.1 引擎文件名"), Description("图像处理算法引擎文件名")] public string EngineName { get; set; } [PropertyOrder(2), Browsable(true), Category("1 算法"), DisplayName("1.2 检测项"), Description("检测项选择")] public PointTestType TestType { get; set; } [PropertyOrder(3), Browsable(true), Category("1 算法"), DisplayName("1.3 使用默认点位"), Description("使用程序默认测试点位(True-是;False-否),当使用默认点位时【2 检测】多功能无效,只有检测数量和选点顺序有效")] public bool DefPos { get; set; } [PropertyOrder(12), Browsable(true), Category("2 检测"), DisplayName("2.1 检测数量"), Description("流程检测点位的数量")] public int PointCnt { get; set; } [PropertyOrder(13), Browsable(true), Category("2 检测"), DisplayName("2.2 自动寻找点位"), Description("根据产品设置和图纸自动寻找测试点位(True-是;False-否)")] public bool AutoMark { get; set; } [PropertyOrder(14), Browsable(true), Category("2 检测"), DisplayName("2.3 自动选点按顺序测试"), Description("根据产品设置和图纸按设置顺序自动寻找测试点位(True-是;False-否)")] public bool SelectPoint { get; set; } [PropertyOrder(15), Browsable(true), Category("2 检测"), DisplayName("2.4 自动检测顺序设置"), Description("当自动选点顺序 False时,需要手动输入顺序队列")] public List Indexs { get; set; } [PropertyOrder(16), Browsable(true), Category("2 检测"), DisplayName("2.5 手动检测位置"), Description("当自动寻找点位 False时,需要手动输入检测点位")] public List Points { get; set; } [PropertyOrder(17), Browsable(true), Category("2 检测"), DisplayName("2.6 数据判定方式"), Description("对采集数据进行判定处理的方式")] public DataJudgment JudgmentData { get; set; } [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 AutoFocus { get; set; } [PropertyOrder(42), Browsable(true), Category("5 聚焦"), DisplayName("5.2 聚焦步进(mm)"), Description("每次聚焦的步进长度")] public double FocusStep { get; set; } [PropertyOrder(43), Browsable(true), Category("5 聚焦"), DisplayName("5.3 方向步进(mm)"), Description("寻找聚焦方向时的步进长度")] public double DirStep { get; set; } [PropertyOrder(44), Browsable(true), Category("5 聚焦"), DisplayName("5.4 等待稳定时间(ms)"), Description("聚焦步进之后等待稳定时间")] public int WaitDoneTime { get; set; } [PropertyOrder(45), Browsable(true), Category("5 聚焦"), DisplayName("5.5 聚焦超时(ms)"), Description("自动聚焦超时报警")] public int TimeOut { get; set; } [PropertyOrder(51), Browsable(true), Category("6 补偿"), DisplayName("6.1 补偿值"), Description("测试读取数据后加入的补偿值")] public double OffsetValue { get; set; } [PropertyOrder(61), Browsable(true), Category("7 上下限"), DisplayName("7.1 启用流程上下限"), Description("使用流程中设置的上下限判断")] public bool OpenUseLimit { get; set; } [PropertyOrder(62), Browsable(true), Category("7 上下限"), DisplayName("7.2 标准值"), Description("设置判断标志值")] public double StandardValues { get; set; } [PropertyOrder(63), Browsable(true), Category("7 上下限"), DisplayName("7.3 上限"), Description("设置判断上限")] public double MaxLimit { get; set; } [PropertyOrder(64), Browsable(true), Category("7 上下限"), DisplayName("7.4 下限"), Description("设置流程下限")] public double MinLimit { get; set; } [PropertyOrder(71), Browsable(true), Category("8 打印"), DisplayName("8.1 开启Excel打印"), Description("启用本工序数据打印")] public bool OpenPrint { get; set; } [PropertyOrder(72), Browsable(true), Category("8 打印"), DisplayName("8.2 打印数据"), Description("打印均值数据的位置")] public string ExcelData { get; set; } [PropertyOrder(73), Browsable(true), Category("8 打印"), DisplayName("8.3 打印上下限"), Description("打印上下限的位置")] public string ExcelLimit { get; set; } [PropertyOrder(74), Browsable(true), Category("8 打印"), DisplayName("8.4 开启标签打印"), Description("启用本工序数据打印")] public bool OpenPrintLabel { get; set; } [PropertyOrder(75), Browsable(true), Category("8 打印"), DisplayName("8.5 标签打印数据"), Description("打印均值数据的位置")] public string LabelData { get; set; } [PropertyOrder(76), Browsable(true), Category("8 打印"), DisplayName("8.6 标签打印上下限"), Description("打印上下限的位置")] public string LabelLimit { get; set; } [PropertyOrder(81), Browsable(true), Category("9 控制"), DisplayName("9.1 禁用工序"), Description("禁用本工序(True-是;False-否)")] public bool Disable { get; set; } public PointTestProp() { EngineName = "My_PI_PT_General"; TestType = PointTestType.Y轴方向PT值检测; DefPos = false; PointCnt = 5; AutoMark = true; SelectPoint = true; Indexs = new List(); Points = new List(); JudgmentData = DataJudgment.均值; ExposureTime = 30000; Gain = 0; VelLow = 0; VelHigh = 100; Acc = 200; Dec = 200; WaitTime = 50; AutoFocus = true; FocusStep = 0.02; DirStep = 0.04; WaitDoneTime = 200; TimeOut = 30000; OffsetValue = 0; OpenUseLimit = false; StandardValues = 0; MaxLimit = 0; MinLimit = 0; Disable = false; OpenPrint = false; OpenPrintLabel = false; ExcelData = ""; ExcelLimit = ""; LabelData = ""; LabelLimit = ""; } /// /// 序列化 /// /// /// 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); } } } } }