using BRS.Common.Base; using BRS.Common.Model.Helper; using BRS.Common.Interface; using BRS.Common.Model; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Drawing.Design; using System.Linq; using System.Runtime.CompilerServices; using static BRS.Common.Model.Helper.EnumHelper; using XKRS.Device.TCPSever; namespace BRS.Process { [BRS.Common.Model.Helper.Process("", EnumHelper.DeviceAttributeType.InitialConfig)] public class ProcessConfigBase : IProcessConfig { [Category("站点配置")] [DisplayName("站点名称")] [Description("站点名称")] public string StationCode { get; set; } #region 项目配置 [Browsable(false)] [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 RobotConfigCollection { get; set; } = new List(); [Category("设备配置")] [Description("川崎机械臂配置")] [DisplayName("川崎机械臂配置")] [TypeConverter(typeof(CollectionCountConvert))] [Editor(typeof(InitialConfigCollectionEditor), typeof(UITypeEditor))] public List KawasakiRobotConfigCollection { get; set; } = new List(); [Category("项目配置")] [Description("检测配置")] [DisplayName("检测配置")] [TypeConverter(typeof(CollectionCountConvert))] [Editor(typeof(InitialConfigCollectionEditor), typeof(UITypeEditor))] public List DeviceConfigs { get; set; } = new List(); //[Category("设备配置")] //[Description("过图配置")] //[DisplayName("过图配置")] //[TypeConverter(typeof(CollectionCountConvert))] //[Editor(typeof(InitialConfigCollectionEditor), typeof(UITypeEditor))] //public List DeviceConfigs4 { get; set; } = new List(); //[Category("设备配置")] //[Description("JYDAM配置")] //[DisplayName("JYDAM配置")] //[TypeConverter(typeof(CollectionCountConvert))] //[Editor(typeof(InitialConfigCollectionEditor), typeof(UITypeEditor))] //public List JYDAMConfigCollection { get; set; } = new List(); #endregion // [Category("站点配置")] // [DisplayName("站点名称")] // [Description("站点名称")] // public string StationCode111 { get; set; } //[Category("全局配置")] //[DisplayName("深度学习标注软件路径")] //[Description("深度学习标注软件路径")] //[Editor(typeof(ExeFileDialogEditor), typeof(UITypeEditor))] //public string LabelMarkerPath { get; set; } /*[Category("全局配置")] [Description("正常运行模式:产品+检测+结果交互;Debug调试模式:产品+检测+固定结果;Demo模式:取像+固定结果(无检测)")] [DisplayName("运行模式")] public RunMode RunMode { get; set; }*/ //[Category("全局配置")] //[DisplayName("视觉初始化图片")] //[Description("视觉初始化图片:用于初始化时halcon预热")] //[Editor(typeof(FileDialogEditor), typeof(UITypeEditor))] //public string ImgPath { get; set; } //[Category("离线模式")] //[DisplayName("启用离线模式")] //[Description("是否使用离线图片 true:离线图片 false:在线图片")] //public bool IsImageOffline { get; set; } //[Category("离线模式")] //[DisplayName("图片来源路径")] //[Description("离线检测图片路径,只有启用离线检测时才生效。")] //[Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))] //public string OfflineImagesDir { get; set; } = ""; [Category("日志配置")] [Description("是否启用日志记录")] [DisplayName("启用日志")] public bool IsLogEnabled { get; set; } private LogLevel defaultLogLevel = LogLevel.Information; [Category("日志配置")] [Description("默认日志级别。辅助-->详细-->信息-->动作-->错误-->警报-->异常")] [DisplayName("日志保存级别")] [TypeConverter(typeof(EnumDescriptionConverter))] public LogLevel DefaultLogLevel { get => defaultLogLevel; set => Set(ref defaultLogLevel, value); } [Category("日志配置")] [Description("是否启用CSV数据记录")] [DisplayName("启用CSV")] public bool IsCSVOutputEnabled { get; set; } //[Category("日志配置")] //[Description("是否启用动作时间记录CSV数据")] //[DisplayName("启用时间CSV")] //public bool IsEnableTimeRecordCSV { get; set; } [Category("日志配置")] [Description("日志文件夹路径")] [DisplayName("日志文件夹路径")] [Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))] public string LogPath { get; set; } = ""; #if false /// /// 过图配置 /// [Category("过图配置")] [Description("检测任务列表")] [DisplayName("检测任务列表")] public bool IsSelectPic { get; set; } //private LogLevel defaultLogLevel = LogLevel.Information; [Category("过图配置")] [Description("图片文件夹路径配置")] [DisplayName("图片文件夹路径配置")] [Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))] public string SelectPICImagesDir { get; set; } = ""; //public LogLevel DefaultLogLevel //{ // get => defaultLogLevel; // set => Set(ref defaultLogLevel, value); //} [Category("过图配置")] [Description("是否裁剪")] [DisplayName("是否裁剪")] public bool IsSelectCut { get; set; } //[Category("日志配置")] //[Description("是否启用动作时间记录CSV数据")] //[DisplayName("启用时间CSV")] //public bool IsEnableTimeRecordCSV { get; set; } [Category("过图配置")] [Description("裁剪图片保存路径配置")] [DisplayName("裁剪图片保存路径配置")] [Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))] public string CutSelectPicPath { get; set; } = ""; #endif //0726 //[Category("操作配置")] //[Description("默认操作配置集合")] //[DisplayName("默认操作配置")] //[TypeConverter(typeof(CollectionCountConvert))] //[Editor(typeof(ComplexCollectionEditor), typeof(UITypeEditor))] //public List MonitorSetCollection { get; set; } = new List(); //[Category("OEE配置")] //[Description("空闲时间判断阈值,单位s。该时间段内没有产品产出,认为进入待机时间")] //[DisplayName("待机阈值")] //public int IdleTimeThreshold { get; set; } = 10; //[Category("OEE配置")] //[Description("理想UPH,单位pcs/hr")] //[DisplayName("理想UPH")] //public int IdealUPH { get; set; } = 6000; //[Category("OEE配置")] //[Description("true:保存OEE原始数据,包括产出,运行时间分布")] //[DisplayName("OEE原始数据保存")] //public bool Is_OEEData_Saved { get; set; } = false; /// /// 获取所有设备初始化配置对象,流程中要使用的设备,必须在此处添加并返回。 /// /// 返回所有设备初始化配置对象 public virtual List GetAllDeviceInitialConfigs() { List configs = new List(); configs.AddRange(CameraConfigCollection); configs.AddRange(PLCConfigCollection); configs.AddRange(DeviceConfigs); //configs.AddRange(RobotConfigCollection); return configs; } public List GetAllMonitorSet() { List list = new List(); //0726 // 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)); } } public List GetHalconToolPathList() { List list = new List(); GetType().GetProperties().ToList().ForEach(p => { var pValue = p.GetValue(this); if (pValue is IHalconToolPath hPath) { list.AddRange(hPath.GetHalconToolPathList()); } else if (pValue is IList enumList) { foreach (var temp in enumList) { if (temp is IHalconToolPath tPath) { list.AddRange(tPath.GetHalconToolPathList()); } } } }); return list.Distinct().ToList(); } #endregion } [Device("SequenceDeviceOp", "设备连续操作配置", DeviceAttributeType.OperationConfig)] public class SequenceDeviceOpConfig : OperationConfigBase { [Category("设备操作配置")] [Description("操作重复次数")] [DisplayName("操作重复次数")] public int RepeatTime { get; set; } = 1; [Category("设备操作配置")] [Description("设备操作集合")] [TypeConverter(typeof(CollectionCountConvert))] [Editor(typeof(ComplexCollectionEditor), typeof(UITypeEditor))] [DisplayName("设备操作集合")] public List DeviceOpCollection { get; set; } = new List(); } }