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
using Bro.Common.Helper;
using Bro.Common.Interface;
using Bro.Common.Model;
using Bro.Common.Model.Interface;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Bro.Common.Base
{
    public class DeviceConfigBase : IDeviceConfig
    {
    }
 
    public class InitialConfigBase : IInitialConfig
    {
        [Category("通用配置")]
        [Description("设备索引")]
        [ReadOnly(true)]
        public string ID { get; set; } = Guid.NewGuid().ToString().ToUpper();
 
        [Category("通用配置")]
        [Description("设备名称")]
        public string Name { get; set; } = "UnNamed";
 
        /// <summary>
        /// 设备是否启用
        /// </summary>
        [Category("通用配置")]
        [Description("设备是否启用")]
        public bool IsEnabled { get; set; } = false;
 
        [Browsable(false)]
        public virtual string DriverType { get; set; } = "";
 
        [Category("日志配置")]
        [Description("日志记录目录")]
        [Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))]
        public string LogPath { get; set; }
 
        [Category("日志配置")]
        [Description("true:启用日志记录  false:不启用日志记录")]
        public bool IsEnableLog { get; set; } = false;
 
        public virtual List<string> GetHalconToolPathList()
        {
            return new List<string>();
        }
    }
 
    public class InitialMonitorConfigBase : InitialConfigBase, IMonitorInitialConfig, IHalconToolPath
    {
        [Category("监听设置")]
        [Description("true:启用监听 false:不启用监听")]
        public bool IsEnableMonitor { get; set; } = true;
 
        [Category("监听设置")]
        [Description("扫描间隔时间,单位:ms")]
        public int ScanInterval { get; set; } = 100;
 
        [Category("监听设置")]
        [Description("超时设置,单位:ms")]
        public int Timeout { get; set; } = 500;
 
        [Category("监听设置")]
        [Description("警报配置列表")]
        [TypeConverter(typeof(CollectionCountConvert))]
        [Editor(typeof(ComplexCollectionEditor<WarningSet>), typeof(UITypeEditor))]
        public List<WarningSet> WarningSetCollection { get; set; } = new List<WarningSet>();
 
        [Category("监听设置")]
        [Description("监听操作配置集合")]
        [TypeConverter(typeof(CollectionCountConvert))]
        [Editor(typeof(ComplexCollectionEditor<MonitorSet>), typeof(UITypeEditor))]
        public List<MonitorSet> MonitorSetCollection { get; set; } = new List<MonitorSet>();
 
        public new virtual List<string> GetHalconToolPathList()
        {
            return MonitorSetCollection.SelectMany(u =>
            {
                if (u.OpConfig is IHalconToolPath)
                {
                    return (u.OpConfig as IHalconToolPath).GetHalconToolPathList();
                }
                else
                {
                    return new List<string>();
                }
            }).ToList();
        }
    }
}