领胜LDS 键盘AOI检测项目
wells.liu
2020-06-28 19a9489aef9b3353171eca5e6b583aadb2828593
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
using Autofac;
using Bro.Common.Base;
using Bro.Common.Helper;
using Bro.Common.Interface;
using Bro.Common.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Bro.M071.Process
{
    public class KeyAlgorithem : IComplexDisplay
    {
        [Browsable(false)]
        public string Id { get; set; } = Guid.NewGuid().ToString();
 
        [Category("单键算法配置")]
        [Description("算法名称")]
        public string Name { get; set; }
 
        [Category("单键算法配置")]
        [Description("算法路径")]
        [Editor(typeof(FileDialogEditor), typeof(UITypeEditor))]
        public string AlgorithemPath { get; set; }
 
        public string GetDisplayText()
        {
            return $"{Name} -- {AlgorithemPath}";
        }
    }
 
    public class KeyResult : IComplexDisplay
    {
        [Browsable(false)]
        public string Id { get; set; } = Guid.NewGuid().ToString();
 
        [Category("单键结果配置")]
        [Description("结果配置名称")]
        public string Name { get; set; }
 
        [Category("单键结果配置")]
        [Description("结果配置集合")]
        [TypeConverter(typeof(SimpleCollectionConvert<string>))]
        [Editor(typeof(SimpleCollectionEditor<string>), typeof(UITypeEditor))]
        public List<string> Results { get; set; } = new List<string>();
 
        public string GetDisplayText()
        {
            return $"{Name} -- {(string.Join(" ", Results))}";
        }
    }
 
    public class SnapshotPoint : IComplexDisplay, IHalconToolPath
    {
        public string GetDisplayText()
        {
            return Name + " " + string.Join(" ", Destination.Select(u => u.GetDisplayText())) + " " + CameraOp.GetDisplayText();
        }
 
        public List<string> GetHalconToolPathList()
        {
            if (CameraOp.OpConfig is IHalconToolPath path)
            {
                return path.GetHalconToolPathList();
            }
            else
            {
                return new List<string>();
            }
        }
 
        [Browsable(false)]
        public string Id { get; set; } = Guid.NewGuid().ToString();
 
        [Category("拍照点名称")]
        [Description("拍照点名称")]
        public string Name { get; set; }
 
        [Category("设备配置")]
        [Description("运动设备")]
        [TypeConverter(typeof(DeviceSelectorConverter<IMotion>))]
        public string MotionDevice { get; set; }
 
        [Category("运动点位")]
        [Description("运动点位")]
        [TypeConverter(typeof(ComplexObjectConvert))]
        [Editor(typeof(ComplexCollectionEditor<AxisInfo>), typeof(UITypeEditor))]
        public List<AxisInfo> Destination { get; set; } = new List<AxisInfo>();
 
        [Category("相机和操作配置")]
        [Description("相机和操作配置")]
        [TypeConverter(typeof(ComplexObjectConvert))]
        [Editor(typeof(IOperationConfigByDeviceEditor), typeof(UITypeEditor))]
        public DeviceOpBind CameraOp { get; set; } = new DeviceOpBind();
    }
 
    public class KeyUnit : IComplexDisplay, IHalconToolPath
    {
        private string key = "";
        [Category("键名配置")]
        [Description("单键检测键名")]
        [TypeConverter(typeof(KeyNameDictConverter))]
        public string Key
        {
            get => key;
            set
            {
                AlignName = key = value;
            }
        }
 
        [Category("键名配置")]
        [Description("别名")]
        public string AlignName { get; set; }
 
        [Category("图像来源")]
        [Description("拍照点位")]
        [TypeConverter(typeof(SnapshotPointConverter))]
        public string SnapshotPoint { get; set; }
 
        [Category("图像来源")]
        [Description("拍照点位获取的图片索引")]
        public int ImageIndex { get; set; } = 0;
 
        [Category("算法配置")]
        [Description("单键检测配置算法类型")]
        [TypeConverter(typeof(KeyAlgorithemConverter))]
        public string KeyAlgorithem { get; set; }
 
        [Category("算法配置")]
        [Description("单键检测配置结果类型")]
        [TypeConverter(typeof(KeyResultConverter))]
        public string KeyResult { get; set; }
 
        public string GetDisplayText()
        {
            return $"{AlignName}";
        }
 
        public List<string> GetHalconToolPathList()
        {
            return null;
        }
    }
 
    public class MeasurementUint : IComplexDisplay
    {
        [Category("名称")]
        [Description("名称")]
        public string Name { get; set; } = "";
 
        [Category("算法配置")]
        [Description("检测和标准类型")]
        [TypeConverter(typeof(MeasureTypeConverter))]
        public string MeasureType { get; set; }
 
        [Category("算法配置")]
        [Description("涉及单键集合")]
        [TypeConverter(typeof(ComplexObjectConvert))]
        [Editor(typeof(ComplexCollectionEditor<KeyUnitBind>), typeof(UITypeEditor))]
        public List<KeyUnitBind> KeyUnitCollection { get; set; } = new List<KeyUnitBind>();
 
        [Browsable(false)]
        public RectangleF DisplayLocation { get; set; } = new RectangleF();
 
        public string GetDisplayText()
        {
            if (string.IsNullOrWhiteSpace(Name))
            {
                return string.Join("-", KeyUnitCollection.Select(u => u.GetDisplayText())) + "-" + MeasureType.ToString();
            }
            else
            {
                return Name;
            }
        }
    }
 
    public class KeyUnitBind : IComplexDisplay
    {
        [Category("单键配置")]
        [Description("单键配置")]
        [TypeConverter(typeof(KeyNameDictConverter))]
        public string Key { get; set; }
 
        [Category("单键配置")]
        [Description("单键结果配置")]
        [TypeConverter(typeof(KeyUnitResultConverter))]
        public string KeyResult { get; set; } = "";
 
        public string GetDisplayText()
        {
            string msg = Key;
 
            msg += string.IsNullOrWhiteSpace(KeyResult) ? "" : $"-{KeyResult}";
 
            return msg;
        }
    }
}