|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- 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("检测项选择"), TypeConverter(typeof(genderItem))]
- public string 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<int> Indexs { get; set; }
- [PropertyOrder(16), Browsable(true), Category("2 检测"), DisplayName("2.5 手动检测位置"), Description("当自动寻找点位 False时,需要手动输入检测点位")]
- public List<PointF> 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("开启自动曝光")]
- public bool AutoExposure { get; set; }
- [PropertyOrder(21), Browsable(true), Category("3 相机"), DisplayName("3.2 曝光"), Description("曝光时长(us)")]
- public float ExposureTime { get; set; }
- [PropertyOrder(22), Browsable(true), Category("3 相机"), DisplayName("3.3 增益"), 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(64), Browsable(true), Category("7 上下限"), DisplayName("7.5 极差"), Description("设置流程极差")]
- public double MaxMinLimit { get; set; }
-
- [PropertyOrder(71), Browsable(true), Category("8 打印"), DisplayName("8.01 开启Excel打印"), Description("启用本工序数据打印")]
- public bool OpenPrint { get; set; }
- [PropertyOrder(72), Browsable(true), Category("8 打印"), DisplayName("8.02 打印数据"), Description("打印均值数据的位置")]
- public string ExcelData { get; set; }
- [PropertyOrder(73), Browsable(true), Category("8 打印"), DisplayName("8.03 打印上下限"), Description("打印上下限的位置")]
- public string ExcelLimit { get; set; }
- [PropertyOrder(74), Browsable(true), Category("8 打印"), DisplayName("8.04 开启标签打印"), Description("启用本工序数据打印")]
- public bool OpenPrintLabel { get; set; }
- [PropertyOrder(75), Browsable(true), Category("8 打印"), DisplayName("8.05 标签打印数据"), Description("打印均值数据的位置")]
- public string LabelData { get; set; }
- [PropertyOrder(76), Browsable(true), Category("8 打印"), DisplayName("8.06 标签打印上下限"), Description("打印上下限的位置")]
- public string LabelLimit { get; set; }
- [PropertyOrder(74), Browsable(true), Category("8 打印"), DisplayName("8.07 开启工单打印"), Description("启用本工序数据打印")]
- public bool OpenPrintOrder { get; set; }
- [PropertyOrder(75), Browsable(true), Category("8 打印"), DisplayName("8.08 工单打印数据"), Description("打印均值数据的位置序列")]
- public string OrderData { get; set; }
- [PropertyOrder(76), Browsable(true), Category("8 打印"), DisplayName("8.09 工单打印上下限"), Description("打印上下限的位置序列")]
- public string OrderLimit { get; set; }
- [PropertyOrder(76), Browsable(true), Category("8 打印"), DisplayName("8.10 工单打印测试名称"), Description("打印测试名称的位置序列")]
- public string OrderTestName { get; set; }
- [PropertyOrder(76), Browsable(true), Category("8 打印"), DisplayName("8.11 工单打印综合结果"), Description("打印综合结果的位置序列")]
- public string OrderTestResult { 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 = ConfMgr.Instance.SizeItemParamsList[0].Name;
- DefPos = false;
-
- PointCnt = 5;
- AutoMark = true;
- SelectPoint = true;
- Indexs = new List<int>();
- Points = new List<PointF>();
- JudgmentData = DataJudgment.均值;
-
- AutoExposure = false;
- 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;
- MaxMinLimit = 0;
-
- Disable = false;
-
- OpenPrint = false;
- OpenPrintLabel = false;
- ExcelData = "";
- ExcelLimit = "";
- LabelData = "";
- LabelLimit = "";
-
- OpenPrintOrder = false;
- OrderData = "";
- OrderLimit = "";
- OrderTestName = "";
- OrderTestResult = "";
- }
-
- /// <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<PointTestProp>(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);
- }
- }
- }
- }
-
- //自定义属性下拉效果的类,该类主要继承StringConverter类,并重载该类的一些虚拟方法
- public class genderItem : StringConverter
- {
- //true enable,false disable
- public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
- {
- return true;
- }
-
- public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
- {
- return new StandardValuesCollection(ConfMgr.Instance.SizeItemParamsList.Select(p => p.Name).Distinct().ToList()); //编辑下拉框中的items
- }
-
- //true: disable text editting. false: enable text editting;
- public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
- {
- return true;
- }
- }
- }
|