patrick
2019-12-10 1c4426810c71eead57084be8a18ade8d314dd8c4
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
using Bro.Common.Base;
using Bro.Common.Helper;
using Bro.Common.Interface;
using Bro.Common.Model;
using Bro.Common.Model.Interface;
using Bro.Device.AuboRobot;
using Bro.Device.HikCamera;
using Bro.Device.OmronFins;
using Bro.Device.SeerAGV;
using Bro.Device.Station;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
using System.Linq;
using static Bro.Common.Helper.EnumHelper;
 
namespace A032.Process
{
    public class ProcessConfig : IStationConfig, IHalconToolPath
    {
        #region 设备配置
        [Category("设备配置")]
        [Description("PLC配置")]
        [TypeConverter(typeof(CollectionCountConvert))]
        [Editor(typeof(ComplexCollectionEditor<OmronFinsInitialConfig>), typeof(UITypeEditor))]
        public List<OmronFinsInitialConfig> PLCConfigCollection { get; set; } = new List<OmronFinsInitialConfig>();
 
        [Category("设备配置")]
        [Description("机器人配置")]
        [TypeConverter(typeof(CollectionCountConvert))]
        [Editor(typeof(ComplexCollectionEditor<AuboRobotInitialConfig>), typeof(UITypeEditor))]
        public List<AuboRobotInitialConfig> RobotConfigCollection { get; set; } = new List<AuboRobotInitialConfig>();
 
        [Category("设备配置")]
        [Description("AGV配置")]
        [TypeConverter(typeof(CollectionCountConvert))]
        [Editor(typeof(ComplexCollectionEditor<SeerAGVInitialConfig>), typeof(UITypeEditor))]
        public List<SeerAGVInitialConfig> AGVConfigCollection { get; set; } = new List<SeerAGVInitialConfig>();
 
        [Category("设备配置")]
        [Description("相机配置")]
        [TypeConverter(typeof(CollectionCountConvert))]
        [Editor(typeof(ComplexCollectionEditor<HikCameraInitialConfig>), typeof(UITypeEditor))]
        public List<HikCameraInitialConfig> CameraConfigCollection { get; set; } = new List<HikCameraInitialConfig>();
 
        [Category("设备配置")]
        [Description("AGV小车设备绑定配置,配置绑定的AGV,机器人和相机信息")]
        [TypeConverter(typeof(CollectionCountConvert))]
        [Editor(typeof(ComplexCollectionEditor<AGVBindUnit>), typeof(UITypeEditor))]
        public List<AGVBindUnit> AGVBindCollection { get; set; } = new List<AGVBindUnit>();
        #endregion
 
        #region 操作配置
        //[Category("操作配置")]
        //[Description("PLC监听配置")]
        //[TypeConverter(typeof(CollectionCountConvert))]
        //[Editor(typeof(MonitorSetBindEditor), typeof(UITypeEditor))]
        //public Dictionary<string, MonitorSet> PLCMonitorSet { get; set; } = new Dictionary<string, MonitorSet>();
 
        /// <summary>
        /// 操作配置的字典集合
        /// Key:MethodCode,Value:操作配置
        /// </summary>
        [Category("操作配置")]
        [Description("默认操作配置集合")]
        [TypeConverter(typeof(CollectionCountConvert))]
        [Editor(typeof(OperationConfigBindEditor), typeof(UITypeEditor))]
        public Dictionary<string, IOperationConfig> ProcessOpConfigDict { get; set; } = new Dictionary<string, IOperationConfig>();
 
        [Category("操作配置")]
        [Description("操作超时设置,单位min")]
        public int OperationTimeout { get; set; } = 10;
 
        //[Category("监听和操作配置")]
        //[Description("监听操作配置集合")]
        //[TypeConverter(typeof(CollectionCountConvert))]
        //[Editor(typeof(ComplexCollectionEditor<MonitorSet>), typeof(UITypeEditor))]
        //public List<MonitorSet> MonitorSetCollection { get; set; } = new List<MonitorSet>();
        #endregion
 
        #region 全局配置
        [Category("全局配置")]
        [Description("是否采用离线图片")]
        public virtual bool IsImageOffline { get; set; } = false;
 
        [Category("Demo模式")]
        [Description("是否测试模式 测试模式下始终反馈OK信号")]
        public virtual bool IsDemoMode { get; set; } = false;
 
        //[Category("Demo模式")]
        //[Description("测试模式下程序启动时反馈1至该地址,非测试模式反馈0")]
        //public int DemoReplayAddress { get; set; }
        #endregion
 
        #region 日志和CSV配置
        [Category("日志配置")]
        [Description("是否启用日志")]
        public bool IsLogEnabled { get; set; } = false;
 
        [Category("日志配置")]
        [Description("日志文件夹路径")]
        [Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))]
        public string LogPath { get; set; }
 
        //[Category("日志配置")]
        //[Description("GRR日志文件夹路径")]
        //[Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))]
        //public string GRRLogPath { get; set; }
 
        [Category("CSV文件配置")]
        [Description("是否做CSV文件输出")]
        [Browsable(false)]
        public bool IsCSVOutput { get; set; } = false;
 
        [Category("CSV文件配置")]
        [Description("CSV输出文件夹路径")]
        [Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))]
        [Browsable(false)]
        public string CSVFilePath { get; set; }
        #endregion
 
        //[Category("PLC相关配置")]
        //[Description("警报配置列表")]
        //[TypeConverter(typeof(CollectionCountConvert))]
        //[Editor(typeof(ComplexCollectionEditor<WarningSet>), typeof(UITypeEditor))]
        //public List<WarningSet> WarningSets { get; set; } = new List<WarningSet>();
 
        //[Category("PLC相关配置")]
        //[Description("产品出列时是否有确认动作。true:有确认动作,确认后产品出列;false:没有确认动作,查询时产品出列")]
        //public bool IsConfirmWhenProductionDone { get; set; } = false;
 
        [Category("NG图片保存配置")]
        [Description("NG图片保存目录")]
        [Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))]
        [Browsable(false)]
        public string NGImageFolderPath { get; set; }
 
        //[Category("算法配置")]
        //[Description("是否采用外部算子。true:采用外部算子,false:使用内部算法")]
        //public bool IsUsingExternalAlgorithem { get; set; } = true;
 
        #region A032
        [Category("路径相关")]
        [Description("路径节点配置")]
        [TypeConverter(typeof(CollectionCountConvert))]
        [Editor(typeof(ComplexCollectionEditor<PathPosition>), typeof(UITypeEditor))]
        public List<PathPosition> PositionCollection { get; set; } = new List<PathPosition>();
 
        [Category("路径相关")]
        [Description("各位置标定矩阵")]
        [TypeConverter(typeof(CollectionCountConvert))]
        [Editor(typeof(ComplexCollectionEditor<PositionVisionConfig>), typeof(UITypeEditor))]
        public List<PositionVisionConfig> VisionConfigCollection { get; set; } = new List<PositionVisionConfig>();
 
        [Category("视觉配置")]
        [Description("是否启用视觉引导")]
        public bool IsEnableVisionGuide { get; set; } = false;
 
        [Category("视觉配置")]
        [Description("视觉引导次数")]
        public int VisionGuideTimes { get; set; } = 2;
 
        [Category("设备参数配置")]
        [Description("光源开关索引配置")]
        public int LightOutputIndex { get; set; }
 
        [Category("设备参数配置")]
        [Description("AGV满载满Tray/空Tray数量")]
        public int AGVAvailableTrayNums { get; set; } = 6;
 
        [Category("设备参数配置")]
        [Description("默认等待任务轮数。当某些条件不满足当前任务执行前提,当前任务会等待若干任务数后执行")]
        public int DefaultWaitShift { get; set; } = 3;
 
        /// <summary>
        /// 产线忙时拍照确认等待间隔,以秒为单位
        /// </summary>
        [Category("阈值设置")]
        [Description("产线忙时拍照确认等待间隔,以秒为单位")]
        public int LineBusyWaitInterval { get; set; } = 60;
 
        /// <summary>
        /// 产线忙时拍照重试次数
        /// </summary>
        [Category("阈值设置")]
        [Description("产线忙时拍照重试次数")]
        public int LineBusyRetryTimes { get; set; } = 10;
 
        [Category("阈值设置")]
        [Description("机台压机满Tray数量")]
        public int Machine_FullTrayNum { get; set; } = 6;
 
        [Category("阈值设置")]
        [Description("机台压机空Tray数量")]
        public int Machine_EmptyTrayNum { get; set; } = 6;
        #endregion
 
        #region IHalconToolPath
        public List<string> GetHalconToolPathList()
        {
            List<string> list = new List<string>();
 
            ProcessOpConfigDict.Values.ToList().ForEach(c =>
            {
                if (c is IHalconToolPath)
                {
                    list.AddRange((c as IHalconToolPath).GetHalconToolPathList());
                }
            });
 
            this.GetType().GetProperties().ToList().ForEach(p =>
            {
                var pValue = p.GetValue(this);
 
                if (pValue is IHalconToolPath)
                {
                    list.AddRange((pValue as IHalconToolPath).GetHalconToolPathList());
                }
                else if (pValue is IEnumerable<IHalconToolPath>)
                {
                    list.AddRange((pValue as IEnumerable<IHalconToolPath>).SelectMany(u => u.GetHalconToolPathList()));
                }
            });
 
            return list.Distinct().ToList();
        }
        #endregion
 
        #region Ignore
        [Browsable(false)]
        [JsonIgnore]
        public List<OperationCTCollection> CTStatistic { get; set; }
 
        [Browsable(false)]
        [JsonIgnore]
        public bool IsUseMountCorrectionLimit { get; set; }
 
        [Browsable(false)]
        [JsonIgnore]
        public List<Spec> MountCorrectionRanges { get; set; }
 
        [Category("全局配置")]
        [Description("超时时间设置,单位为毫秒")]
        [Browsable(false)]
        public int TimeOut { get; set; } = 9999;
 
        //[Category("全局配置")]
        //[Description("空闲时间设置,当机器空闲时间超过该值,认为机器开始空闲,单位为秒")]
        //public int IdleTimeThreshold { get; set; } = 60;
 
        [Category("全局配置")]
        [Description("站点代码 例如S1")]
        [ReadOnly(true)]
        [Browsable(false)]
        [JsonIgnore]
        public virtual string StationCode { get; set; }
 
        [Category("全局配置")]
        [Description("站点序号,从1开始")]
        [Browsable(false)]
        [JsonIgnore]
        public virtual int SequenceIndex { get; set; }
 
        [Category("全局配置")]
        [Description("是否做过站检查")]
        [Browsable(false)]
        [JsonIgnore]
        public virtual bool IsCheckPrePass { get; set; } = false;
 
        [Category("全局配置")]
        [Description("是否数据库保存")]
        [Browsable(false)]
        [JsonIgnore]
        public virtual bool IsDBSave { get; set; } = false;
        #endregion
    }
 
    [Device("OperationTest", "测试方法配置", DeviceAttributeType.OperationConfig)]
    public class OperationTestConfig : OperationConfigBase
    {
        //[Category("测试配置")]
        //[Description("方法类型")]
        //public TaskType TaskType { get; set; } = TaskType.LoadEmptyTrayToAGV;
 
        [Category("测试配置")]
        [Description("方法信息")]
        [TypeConverter(typeof(ComplexObjectConvert))]
        [Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))]
        public TrayTask TaskInfo { get; set; } = new TrayTask();
 
        [Category("测试配置")]
        [Description("执行AGV设备")]
        [TypeConverter(typeof(AGVDeviceConverter))]
        public string AGVId { get; set; }
    }
}