using Bro.Common.Base; using Bro.Common.Helper; using Bro.Common.Interface; using Bro.Common.Model; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Drawing.Design; using System.Linq; using System.Runtime.CompilerServices; namespace Bro.Process { [Process("", EnumHelper.DeviceAttributeType.InitialConfig)] public class ProcessConfigBase : IProcessConfig { #region 设备配置 [Category("设备配置")] [Description("相机配置")] [DisplayName("相机配置")] [TypeConverter(typeof(CollectionCountConvert))] [Editor(typeof(InitialConfigCollectionEditor), typeof(UITypeEditor))] public List CameraConfigCollection { get; set; } = new List(); [Category("设备配置")] [Description("PLC配置")] [DisplayName("PLC配置")] [TypeConverter(typeof(CollectionCountConvert))] [Editor(typeof(InitialConfigCollectionEditor), typeof(UITypeEditor))] public List PLCConfigCollection { get; set; } = new List(); [Category("设备配置")] [Description("其他设备配置")] [DisplayName("其他设备配置")] [TypeConverter(typeof(CollectionCountConvert))] [Editor(typeof(InitialConfigCollectionEditor), typeof(UITypeEditor))] public List DeviceConfigs { get; set; } = new List(); #endregion [Category("全局配置")] [Description("是否使用离线图片 true:离线图片 false:在线图片")] [DisplayName("离线图片")] public bool IsImageOffline { get; set; } [Category("全局配置")] [Description("是否Demo模式 true:Demo模式 false:非Demo模式")] [DisplayName("Demo模式")] public bool IsDemoMode { get; set; } [Category("日志配置")] [Description("是否启用日志记录")] [DisplayName("启用日志")] public bool IsLogEnabled { get; set; } [Category("日志配置")] [Description("是否启用CSV数据记录")] [DisplayName("启用CSV")] public bool IsCSVOutputEnabled { get; set; } [Category("日志配置")] [Description("日志文件夹路径")] [DisplayName("日志文件夹路径")] [Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))] public string LogPath { get; set; } = ""; [Category("操作配置")] [Description("默认操作配置集合")] [DisplayName("默认操作配置")] [TypeConverter(typeof(CollectionCountConvert))] [Editor(typeof(ComplexCollectionEditor), typeof(UITypeEditor))] public List MonitorSetCollection { get; set; } = new List(); public virtual List GetAllDeviceInitialConfigs() { List configs = new List(); configs.AddRange(CameraConfigCollection); configs.AddRange(PLCConfigCollection); configs.AddRange(DeviceConfigs); return configs; } public List GetAllMonitorSet() { List list = new List(); list.AddRange(MonitorSetCollection); GetType().GetProperties().ToList().ForEach(p => { var pValue = p.GetValue(this); if (pValue is IMonitorConfig msCollection) { list.AddRange(msCollection.GetAllMonitorSet()); } else if (pValue is IList enumList) { foreach (var temp in enumList) { if (temp is IMonitorConfig tempCollection) { list.AddRange(tempCollection.GetAllMonitorSet()); } } } }); return list; } #region IPropertyChanged public event PropertyChangedEventHandler PropertyChanged; public virtual void Set(ref T field, T newValue, [CallerMemberName] string propName = null) { if (!field.Equals(newValue)) { field = newValue; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName)); } } #endregion } }