From 6696c4e106147e51bdd559b5b8c4235912774161 Mon Sep 17 00:00:00 2001 From: "xhm\\HP" <1173131411@qq.com> Date: Tue, 18 Mar 2025 14:20:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CanFly.Canvas/Shape/FlyShape.cs | 2 +- CanFly.Canvas/UI/FlyCanvas.Designer.cs | 8 +- CanFly.Canvas/UI/FlyCanvas.cs | 4 +- CanFly/Properties/Resources.Designer.cs | 16 +- CanFly/UI/GuidePanel/CtrlTitleBar.Designer.cs | 8 +- .../UI/GuidePanel/GuideCircleCtrl.Designer.cs | 8 +- .../UI/GuidePanel/GuideHeightCtrl.Designer.cs | 8 +- .../GuideLineCircleCtrl.Designer.cs | 8 +- .../UI/GuidePanel/GuideLineCtrl.Designer.cs | 8 +- CanFly/XKRS.CanFly.csproj | 10 +- DH.Commons.Devies/Base/CameraBase.cs | 6 +- DH.Commons/DetectionConfig.cs | 368 +++++++++++------- DH.Commons/Helper/EnumHelper.cs | 48 +-- DH.Commons/Helper/OpenCVEngineTool.cs | 4 +- DH.Commons/Helper/UIHelper.cs | 2 +- DH.Devices.Motion/MCDLL_NET.cs | 6 +- DH.Devices.Motion/MotionBase.cs | 8 +- DH.Devices.Motion/SLDMotion.cs | 10 +- DH.Devices.Vision/SimboDetection.cs | 12 +- .../SimboInstanceSegmentation.cs | 8 +- DH.Devices.Vision/SimboObjectDetection.cs | 12 +- DH.Devices.Vision/SimboVisionMLBase.cs | 12 +- DH.Devices.Vision/SimboVisionModel.cs | 6 +- DH.Process/DH.Process.csproj | 19 + DH.Process/XKRS.Process.cs | 49 +++ DH.UI.Model.Winform/Canvas.Designer.cs | 8 +- DH.UI.Model.Winform/CanvasImage.Designer.cs | 4 +- DH.UI.Model.Winform/CanvasImage.cs | 4 +- DH.UI.Model.Winform/Ctrl/GridCtrl.Designer.cs | 8 +- .../Ctrl/IOIndicatorCtrl.Designer.cs | 8 +- DH.UI.Model.Winform/Element/ElementBase.cs | 16 +- DH.UI.Model.Winform/GridCtrl.Designer.cs | 8 +- .../IOIndicatorCtrl.Designer.cs | 8 +- DHSoftware.sln | 13 + DHSoftware/DHSoftware.csproj | 1 + DHSoftware/MainWindow.cs | 137 ++++++- DHSoftware/Program.cs | 2 +- DHSoftware/Properties/Resources.Designer.cs | 28 +- DHSoftware/Views/CamConfigFrm.Designer.cs | 8 +- .../Views/CameraConfigControl.Designer.cs | 8 +- .../Views/CorrelatedCameraEdit.Designer.cs | 8 +- .../Views/CtrlVisionDisplay.Designer.cs | 8 +- .../Views/CtrlVisionRunBase.Designer.cs | 8 +- DHSoftware/Views/DefectRowEdit.Designer.cs | 8 +- .../Views/DetectConfigControl.Designer.cs | 8 +- DHSoftware/Views/DetectControl.Designer.cs | 171 ++++---- DHSoftware/Views/DetectControl.cs | 364 ++++++++++++++--- .../Views/DetectionLableEdit.Designer.cs | 8 +- DHSoftware/Views/PreTreatEdit.Designer.cs | 8 +- .../Views/PreTreatUserControl.Designer.cs | 8 +- DHSoftware/Views/SettingWindow1.Designer.cs | 2 + DHSoftware/Views/SettingWindow1.cs | 132 ++++++- DHSoftware/Views/SettingWindow1.resx | 4 +- .../Views/SizeConfigControl.Designer.cs | 8 +- DHSoftware/Views/SizeLabelEdit.Designer.cs | 8 +- DHSoftware/Views/UserConfigFrm.Designer.cs | 8 +- DHSoftware/Views/UserDetetion.Designer.cs | 8 +- DHSoftware/Views/​MotionControl.Designer.cs | 8 +- DHSoftware/app.manifest | 18 +- 59 files changed, 1161 insertions(+), 545 deletions(-) create mode 100644 DH.Process/DH.Process.csproj create mode 100644 DH.Process/XKRS.Process.cs diff --git a/CanFly.Canvas/Shape/FlyShape.cs b/CanFly.Canvas/Shape/FlyShape.cs index 4d96583..e88d635 100644 --- a/CanFly.Canvas/Shape/FlyShape.cs +++ b/CanFly.Canvas/Shape/FlyShape.cs @@ -110,7 +110,7 @@ namespace CanFly.Canvas.Shape /// - /// 是否填充多边形。使用:select_fill_color 或 fill_color 填充。 + /// 是否填充多边形 使用:select_fill_color 或 fill_color 填充 /// public bool fill = false; diff --git a/CanFly.Canvas/UI/FlyCanvas.Designer.cs b/CanFly.Canvas/UI/FlyCanvas.Designer.cs index 872796a..03f4ec7 100644 --- a/CanFly.Canvas/UI/FlyCanvas.Designer.cs +++ b/CanFly.Canvas/UI/FlyCanvas.Designer.cs @@ -3,14 +3,14 @@ partial class FlyCanvas { /// - /// 必需的设计器变量。 + /// 必需的设计器变量 /// private System.ComponentModel.IContainer components = null; ///// - ///// 清理所有正在使用的资源。 + ///// 清理所有正在使用的资源 ///// - ///// 如果应释放托管资源,为 true;否则为 false。 + ///// 如果应释放托管资源,为 true;否则为 false //protected override void Dispose(bool disposing) //{ // if (disposing && (components != null)) @@ -24,7 +24,7 @@ /// /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 + /// 使用代码编辑器修改此方法的内容 /// private void InitializeComponent() { diff --git a/CanFly.Canvas/UI/FlyCanvas.cs b/CanFly.Canvas/UI/FlyCanvas.cs index e361abb..f0298db 100644 --- a/CanFly.Canvas/UI/FlyCanvas.cs +++ b/CanFly.Canvas/UI/FlyCanvas.cs @@ -1704,9 +1704,9 @@ namespace CanFly.Canvas.UI /// - /// 清理所有正在使用的资源。 + /// 清理所有正在使用的资源 /// - /// 如果应释放托管资源,为 true;否则为 false。 + /// 如果应释放托管资源,为 true;否则为 false protected override void Dispose(bool disposing) { if (disposing && (components != null)) diff --git a/CanFly/Properties/Resources.Designer.cs b/CanFly/Properties/Resources.Designer.cs index aeeb7f5..32fe825 100644 --- a/CanFly/Properties/Resources.Designer.cs +++ b/CanFly/Properties/Resources.Designer.cs @@ -1,10 +1,10 @@ //------------------------------------------------------------------------------ // -// 此代码由工具生成。 +// 此代码由工具生成 // 运行时版本:4.0.30319.42000 // // 对此文件的更改可能会导致不正确的行为,并且如果 -// 重新生成代码,这些更改将会丢失。 +// 重新生成代码,这些更改将会丢失 // //------------------------------------------------------------------------------ @@ -13,12 +13,12 @@ namespace XKRS.CanFly.Properties { /// - /// 一个强类型的资源类,用于查找本地化的字符串等。 + /// 一个强类型的资源类,用于查找本地化的字符串等 /// // 此类是由 StronglyTypedResourceBuilder - // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的 // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen - // (以 /str 作为命令选项),或重新生成 VS 项目。 + // (以 /str 作为命令选项),或重新生成 VS 项目 [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] @@ -33,7 +33,7 @@ namespace XKRS.CanFly.Properties { } /// - /// 返回此类使用的缓存的 ResourceManager 实例。 + /// 返回此类使用的缓存的 ResourceManager 实例 /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Resources.ResourceManager ResourceManager { @@ -48,7 +48,7 @@ namespace XKRS.CanFly.Properties { /// /// 重写当前线程的 CurrentUICulture 属性,对 - /// 使用此强类型资源类的所有资源查找执行重写。 + /// 使用此强类型资源类的所有资源查找执行重写 /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Globalization.CultureInfo Culture { @@ -61,7 +61,7 @@ namespace XKRS.CanFly.Properties { } /// - /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// 查找 System.Drawing.Bitmap 类型的本地化资源 /// internal static System.Drawing.Bitmap Close { get { diff --git a/CanFly/UI/GuidePanel/CtrlTitleBar.Designer.cs b/CanFly/UI/GuidePanel/CtrlTitleBar.Designer.cs index dd63885..5c7d3c5 100644 --- a/CanFly/UI/GuidePanel/CtrlTitleBar.Designer.cs +++ b/CanFly/UI/GuidePanel/CtrlTitleBar.Designer.cs @@ -3,14 +3,14 @@ partial class CtrlTitleBar { /// - /// 必需的设计器变量。 + /// 必需的设计器变量 /// private System.ComponentModel.IContainer components = null; /// - /// 清理所有正在使用的资源。 + /// 清理所有正在使用的资源 /// - /// 如果应释放托管资源,为 true;否则为 false。 + /// 如果应释放托管资源,为 true;否则为 false protected override void Dispose(bool disposing) { if (disposing && (components != null)) @@ -24,7 +24,7 @@ /// /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 + /// 使用代码编辑器修改此方法的内容 /// private void InitializeComponent() { diff --git a/CanFly/UI/GuidePanel/GuideCircleCtrl.Designer.cs b/CanFly/UI/GuidePanel/GuideCircleCtrl.Designer.cs index 73cfadc..4998a10 100644 --- a/CanFly/UI/GuidePanel/GuideCircleCtrl.Designer.cs +++ b/CanFly/UI/GuidePanel/GuideCircleCtrl.Designer.cs @@ -3,14 +3,14 @@ partial class GuideCircleCtrl { /// - /// 必需的设计器变量。 + /// 必需的设计器变量 /// private System.ComponentModel.IContainer components = null; /// - /// 清理所有正在使用的资源。 + /// 清理所有正在使用的资源 /// - /// 如果应释放托管资源,为 true;否则为 false。 + /// 如果应释放托管资源,为 true;否则为 false protected override void Dispose(bool disposing) { if (disposing && (components != null)) @@ -24,7 +24,7 @@ /// /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 + /// 使用代码编辑器修改此方法的内容 /// private void InitializeComponent() { diff --git a/CanFly/UI/GuidePanel/GuideHeightCtrl.Designer.cs b/CanFly/UI/GuidePanel/GuideHeightCtrl.Designer.cs index bf3bc74..dfeaa99 100644 --- a/CanFly/UI/GuidePanel/GuideHeightCtrl.Designer.cs +++ b/CanFly/UI/GuidePanel/GuideHeightCtrl.Designer.cs @@ -3,14 +3,14 @@ partial class GuideHeightCtrl { /// - /// 必需的设计器变量。 + /// 必需的设计器变量 /// private System.ComponentModel.IContainer components = null; /// - /// 清理所有正在使用的资源。 + /// 清理所有正在使用的资源 /// - /// 如果应释放托管资源,为 true;否则为 false。 + /// 如果应释放托管资源,为 true;否则为 false protected override void Dispose(bool disposing) { if (disposing && (components != null)) @@ -24,7 +24,7 @@ /// /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 + /// 使用代码编辑器修改此方法的内容 /// private void InitializeComponent() { diff --git a/CanFly/UI/GuidePanel/GuideLineCircleCtrl.Designer.cs b/CanFly/UI/GuidePanel/GuideLineCircleCtrl.Designer.cs index 7cc0816..cde986c 100644 --- a/CanFly/UI/GuidePanel/GuideLineCircleCtrl.Designer.cs +++ b/CanFly/UI/GuidePanel/GuideLineCircleCtrl.Designer.cs @@ -3,14 +3,14 @@ partial class GuideLineCircleCtrl { /// - /// 必需的设计器变量。 + /// 必需的设计器变量 /// private System.ComponentModel.IContainer components = null; /// - /// 清理所有正在使用的资源。 + /// 清理所有正在使用的资源 /// - /// 如果应释放托管资源,为 true;否则为 false。 + /// 如果应释放托管资源,为 true;否则为 false protected override void Dispose(bool disposing) { if (disposing && (components != null)) @@ -24,7 +24,7 @@ /// /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 + /// 使用代码编辑器修改此方法的内容 /// private void InitializeComponent() { diff --git a/CanFly/UI/GuidePanel/GuideLineCtrl.Designer.cs b/CanFly/UI/GuidePanel/GuideLineCtrl.Designer.cs index 85a5ddf..62d2c87 100644 --- a/CanFly/UI/GuidePanel/GuideLineCtrl.Designer.cs +++ b/CanFly/UI/GuidePanel/GuideLineCtrl.Designer.cs @@ -3,14 +3,14 @@ partial class GuideLineCtrl { /// - /// 必需的设计器变量。 + /// 必需的设计器变量 /// private System.ComponentModel.IContainer components = null; /// - /// 清理所有正在使用的资源。 + /// 清理所有正在使用的资源 /// - /// 如果应释放托管资源,为 true;否则为 false。 + /// 如果应释放托管资源,为 true;否则为 false protected override void Dispose(bool disposing) { if (disposing && (components != null)) @@ -24,7 +24,7 @@ /// /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 + /// 使用代码编辑器修改此方法的内容 /// private void InitializeComponent() { diff --git a/CanFly/XKRS.CanFly.csproj b/CanFly/XKRS.CanFly.csproj index bcae58e..94a81c0 100644 --- a/CanFly/XKRS.CanFly.csproj +++ b/CanFly/XKRS.CanFly.csproj @@ -11,6 +11,12 @@ AnyCPU;x64 + + + + + + @@ -24,10 +30,6 @@ - - - - diff --git a/DH.Commons.Devies/Base/CameraBase.cs b/DH.Commons.Devies/Base/CameraBase.cs index 8673e88..34bbb3f 100644 --- a/DH.Commons.Devies/Base/CameraBase.cs +++ b/DH.Commons.Devies/Base/CameraBase.cs @@ -11,7 +11,7 @@ namespace DH.Devices.Devices public virtual bool isEnabled { get; set; } = false; [Category("采图模式")] - [Description("是否连续模式。true:连续模式采图;false:触发模式采图")] + [Description("是否连续模式 true:连续模式采图;false:触发模式采图")] [DisplayName("连续模式")] public bool IsContinueMode { get; set; } = false; @@ -31,7 +31,7 @@ namespace DH.Devices.Devices public ImageFormat ImageFormat { get; set; } = ImageFormat.Jpeg; [Category("采图模式")] - [Description("是否硬触发模式。true:硬触发;false:软触发")] + [Description("是否硬触发模式 true:硬触发;false:软触发")] [DisplayName("硬触发")] public bool IsHardwareTrigger { get; set; } = false; @@ -45,7 +45,7 @@ namespace DH.Devices.Devices // public StreamFormat dvpStreamFormat = dvpStreamFormat.; [Category("采图模式")] - [Description("是否传感器直接硬触发。true:传感器硬触发,不通过软件触发;false:通过软件触发IO 的硬触发模式")] + [Description("是否传感器直接硬触发 true:传感器硬触发,不通过软件触发;false:通过软件触发IO 的硬触发模式")] [DisplayName("是否传感器直接硬触发")] public bool IsDirectHardwareTrigger { get; set; } = false; diff --git a/DH.Commons/DetectionConfig.cs b/DH.Commons/DetectionConfig.cs index 30cbe8f..85f20b4 100644 --- a/DH.Commons/DetectionConfig.cs +++ b/DH.Commons/DetectionConfig.cs @@ -6,7 +6,10 @@ using System.Text.RegularExpressions; using System.Text; using System.Drawing.Design; using AntdUI; + +using System.Text.Json.Serialization; using static DH.Commons.Enums.EnumHelper; +using System.Collections.ObjectModel; namespace DH.Commons.Enums @@ -117,20 +120,20 @@ namespace DH.Commons.Enums /// public class DetectionResultDetail { -#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 + public string LabelBGR { get; set; }//识别到对象的标签BGR public int LabelNo { get; set; } // 识别到对象的标签索引 -#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 + public string LabelName { get; set; }//识别到对象的标签名称 public double Score { get; set; }//识别目标结果的可能性、得分 -#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 + public string LabelDisplay { get; set; }//识别到对象的 显示信息 @@ -151,10 +154,10 @@ namespace DH.Commons.Enums public class MLResult { public bool IsSuccess = false; -#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 + public string ResultMessage; -#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 + public Bitmap ResultMap; public List ResultDetails = new List(); @@ -178,8 +181,8 @@ namespace DH.Commons.Enums public bool IsGPU; public int GPUId; public float Score_thre; -#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 -#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 + + public MLInit(string modelFile, bool isGPU, int gpuId, float score_thre) @@ -204,18 +207,18 @@ namespace DH.Commons.Enums } public class DetectStationResult { -#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 + public string Pid { get; set; } -#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 + public string TempPid { get; set; } /// /// 检测工位名称 /// -#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 + public string DetectName { get; set; } @@ -262,9 +265,9 @@ namespace DH.Commons.Enums public int StationDetectElapsed { get; set; } public static string NormalizeAndClean(string input) { -#pragma warning disable CS8603 // 可能返回 null 引用。 +#pragma warning disable CS8603 // 可能返回 null 引用 if (input == null) return null; -#pragma warning restore CS8603 // 可能返回 null 引用。 +#pragma warning restore CS8603 // 可能返回 null 引用 // Step 1: 标准化字符编码为 Form C (规范组合) string normalizedString = input.Normalize(NormalizationForm.FormC); @@ -289,6 +292,7 @@ namespace DH.Commons.Enums [Category("关联相机")] [DisplayName("相机源ID")] [Description("关联相机的唯一标识符")] + [JsonPropertyName("camera_sourceId")] //[TypeConverter(typeof(CollectionCountConvert))] public string CameraSourceId { @@ -462,193 +466,217 @@ namespace DH.Commons.Enums return new CustomizedPoint(p1.X + p2.X, p1.Y + p2.Y); } } -// public class PreTreatParam -// { + // public class PreTreatParam + // { -// /// -// /// 参数名称 -// /// -// /// -// [Category("预处理参数")] -// [DisplayName("参数名称")] -// [Description("参数名称")] -//#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 -// public string Name { get; set; } + // /// + // /// 参数名称 + // /// + // /// + // [Category("预处理参数")] + // [DisplayName("参数名称")] + // [Description("参数名称")] + // + // public string Name { get; set; } -// /// -// /// 参数值 -// /// -// /// -// [Category("预处理参数")] -// [DisplayName("参数值")] -// [Description("参数值")] -//#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 -// public string Value { get; set; } + // /// + // /// 参数值 + // /// + // /// + // [Category("预处理参数")] + // [DisplayName("参数值")] + // [Description("参数值")] + // + // public string Value { get; set; } -// } - public class DetectionConfig + // } + public class DetectionConfig : NotifyProperty { + #region 基本信息 + [JsonPropertyName("id")] [ReadOnly(true)] - public string Id { get; set; } = Guid.NewGuid().ToString(); - + public string Id { get; private set; } = Guid.NewGuid().ToString(); [Category("检测配置")] [DisplayName("检测配置名称")] [Description("检测配置名称")] + [JsonPropertyName("name")] public string Name { get; set; } + #endregion + + #region 相机配置 [Category("关联相机")] [DisplayName("关联相机")] [Description("关联相机描述")] - - + [JsonPropertyName("camera_source_id")] public string CameraSourceId { get; set; } = ""; - [Category("关联相机集合")] [DisplayName("关联相机集合")] [Description("关联相机描述")] - //[TypeConverter(typeof(DeviceIdSelectorConverter))] - - - - public List CameraCollects { get; set; } = new List(); - + [JsonPropertyName("camera_Collects")] + public List CameraCollects { get; set; } = new(); + #endregion + #region 启用选项 [Category("启用配置")] [DisplayName("是否启用GPU检测")] - [Description("是否启用GPU检测")] - public bool IsEnableGPU { get; set; } = false; + [JsonPropertyName("is_enable_gpu")] + public bool IsEnableGPU { get; set; } [Category("启用配置")] [DisplayName("是否混料模型")] - [Description("是否混料模型")] - public bool IsMixModel { get; set; } = false; - - + [JsonPropertyName("is_mixModel")] + public bool IsMixModel { get; set; } [Category("启用配置")] [DisplayName("是否启用该检测")] - [Description("是否启用该检测")] + [JsonPropertyName("is_enabled")] public bool IsEnabled { get; set; } [Category("启用配置")] - [DisplayName("是否加入检测工位")] - [Description("是否加入检测工位")] - public bool IsAddStation { get; set; } = true; + [DisplayName("是否启用预处理")] + [JsonPropertyName("is_PreEnabled")] + public bool IsPreEnabled { get; set; } + // public bool IsAddStation { get; set; } = true; + private bool _isAddStation; + [Category("启用配置")] + [DisplayName("是否加入检测工位")] + [JsonPropertyName("is_addstation")] + public bool IsAddStation + { + get => _isAddStation; + set + { + if (_isAddStation != value) + { + _isAddStation = value; + OnPropertyChanged(nameof(IsAddStation)); + } + } + } + #endregion + + #region 预处理(视觉算子) [Category("1.预处理(视觉算子)")] [DisplayName("预处理-算法文件路径")] - // [Description("预处理算法文件路径配置")][Editor(typeof(FileDialogEditor), typeof(UITypeEditor))] + [JsonPropertyName("halcon_algorithemPath_pre")] public string HalconAlgorithemPath_Pre { get; set; } - // [Category("1.预处理(视觉算子)")] - //[DisplayName("预处理-输出结果的SPEC标准")] - //[Description("预处理输出结果的SPEC标准配置")] - - // public List OutputSpec_Pre { get; set; } = new List(); - [Category("1.预处理(视觉算子)")] [DisplayName("预处理-参数列表")] - [Description("预处理-参数列表")] - - public List PreTreatParams { get; set; } = new List(); + [JsonPropertyName("pre_treatParams")] + public List PreTreatParams { get; set; } = new(); [Category("1.预处理(视觉算子)")] [DisplayName("预处理-输出参数列表")] - [Description("预处理-输出参数列表")] - - public List OUTPreTreatParams { get; set; } = new List(); + [JsonPropertyName("out_preTreatParams")] + public List OUTPreTreatParams { get; set; } = new(); + #endregion + #region 深度学习检测 [Category("2.中检测(深度学习)")] - [DisplayName("中检测-模型类型")] - [Description("模型类型:ImageClassification-图片分类;ObjectDetection:目标检测;Segmentation-图像分割")] - //[TypeConverter(typeof(EnumDescriptionConverter))] + [DisplayName("模型类型")] + [JsonPropertyName("model_Type")] public MLModelType ModelType { get; set; } = MLModelType.ObjectDetection; - //[Category("2.中检测(深度学习)")] - //[DisplayName("中检测-GPU索引")] - //[Description("GPU索引")] - //public int GPUIndex { get; set; } = 0; - [Category("2.中检测(深度学习)")] - [DisplayName("中检测-模型文件路径")] - [Description("中处理 深度学习模型文件路径,路径中不可含有中文字符,一般情况可以只配置中检测模型,当需要先用预检测过滤一次时,请先配置好与预检测相关配置")] - + [DisplayName("模型文件路径")] + [JsonPropertyName("model_Path")] public string ModelPath { get; set; } [Category("2.中检测(深度学习)")] - [DisplayName("中检测-模型宽度")] - [Description("中处理-模型宽度")] - + [DisplayName("模型宽度")] + [JsonPropertyName("model_Width")] public int ModelWidth { get; set; } = 640; [Category("2.中检测(深度学习)")] - [DisplayName("中检测-模型高度")] - [Description("中处理-模型高度")] - + [DisplayName("模型高度")] + [JsonPropertyName("model_Height")] public int ModelHeight { get; set; } = 640; [Category("2.中检测(深度学习)")] - [DisplayName("中检测-模型节点名称")] - [Description("中处理-模型节点名称")] - + [DisplayName("模型节点名称")] + [JsonPropertyName("model_outNodeName")] public string ModeloutNodeName { get; set; } = "output0"; [Category("2.中检测(深度学习)")] - [DisplayName("中检测-模型置信度")] - [Description("中处理-模型置信度")] - + [DisplayName("模型置信度")] + [JsonPropertyName("model_confThreshold")] public float ModelconfThreshold { get; set; } = 0.5f; [Category("2.中检测(深度学习)")] - [DisplayName("中检测-模型标签路径")] - [Description("中处理-模型标签路径")] - + [DisplayName("模型标签路径")] + [JsonPropertyName("in_lablepath")] public string in_lable_path { get; set; } + #endregion + #region 尺寸测量 + + // public List PreTreatCollects { get; set; } = new(); + private List _preTreatParams = new(); + + [Category("1.尺寸测量集合")] + [DisplayName("尺寸测量集合")] + [JsonPropertyName("Pre_TreatCollects")] + public List PreTreatCollects + { + get => _preTreatParams; + set + { + if (_preTreatParams != value) + { + _preTreatParams = value; + OnPropertyChanged(nameof(PreTreatCollects)); + + } + } + } + + #endregion + + #region 过滤器 [Category("4.最终过滤(逻辑过滤)")] [DisplayName("过滤器集合")] - [Description("最后的逻辑过滤:可根据 识别出对象的 宽度、高度、面积、得分来设置最终检测结果,同一识别目标同一判定,多项过滤器之间为“或”关系")] - - public List DetectionFilterList { get; set; } = new List(); + [JsonPropertyName("detection_filterList")] + public List DetectionFilterList { get; set; } = new(); + #endregion + #region 其他信息 + [JsonPropertyName("Detection_LableList")] + public List DetectionLableList { get; set; } = new(); - /// - /// 标签集合 - /// - public List DetectionLableList { get; set; } = new List(); - //[Category("深度学习配置")] - //[DisplayName("检测配置标签")] - //[Description("检测配置标签关联")] - - //public List DetectConfigLabelList { get; set; } = new List(); [Category("显示配置")] [DisplayName("显示位置")] - [Description("检测信息显示位置。左上角为(1,1),向右向下为正方向")] - // [TypeConverter(typeof(ComplexObjectConvert))] - // [Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))] - public CustomizedPoint ShowLocation { get; set; } = new CustomizedPoint(); + [JsonPropertyName("Show_Location")] + public CustomizedPoint ShowLocation { get; set; } = new(); + #endregion + //public event PropertyChangedEventHandler PropertyChanged; - public DetectionConfig() + //protected virtual void OnPropertyChanged(string propertyName) + //{ + // PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + //} + + #region 构造函数 + public DetectionConfig() { } + + public DetectionConfig(string name, MLModelType modelType, string modelPath, bool isEnableGPU, string sCameraSourceId) { - - } - - public DetectionConfig(string name, MLModelType modelType, string modelPath, bool isEnableGPU,string sCameraSourceId) - { - ModelPath = modelPath ?? string.Empty; Name = name; ModelType = modelType; + ModelPath = modelPath ?? string.Empty; IsEnableGPU = isEnableGPU; - Id = Guid.NewGuid().ToString(); CameraSourceId = sCameraSourceId; - + Id = Guid.NewGuid().ToString(); } + #endregion } //大改预处理类 @@ -660,6 +688,7 @@ namespace DH.Commons.Enums private bool _selected = false; + public bool Selected { get { return _selected; } @@ -670,6 +699,7 @@ namespace DH.Commons.Enums OnPropertyChanged(nameof(Selected)); } } + [JsonPropertyName("name")] private string _name; public string Name { @@ -684,6 +714,7 @@ namespace DH.Commons.Enums private string _value; + [JsonPropertyName("value")] public string Value { get { return _value; } @@ -698,7 +729,9 @@ namespace DH.Commons.Enums private CellLink[] cellLinks; public CellLink[] CellLinks { - get { return cellLinks; } + get { + + return cellLinks; } set { if (cellLinks == value) return; @@ -737,7 +770,7 @@ namespace DH.Commons.Enums } - + [JsonPropertyName("labelId")] public string LabelId { get { return _labelId; } @@ -748,7 +781,7 @@ namespace DH.Commons.Enums OnPropertyChanged(nameof(LabelId)); } } - + [JsonPropertyName("labelName")] public string LabelName { get { return _labelName; } @@ -759,7 +792,7 @@ namespace DH.Commons.Enums OnPropertyChanged(nameof(LabelName)); } } - + [JsonPropertyName("maxSource")] public double MaxSource { get { return _maxSource; } @@ -771,6 +804,7 @@ namespace DH.Commons.Enums } } + [JsonPropertyName("minSource")] public double MinSource { get { return _minSource; } @@ -781,7 +815,7 @@ namespace DH.Commons.Enums OnPropertyChanged(nameof(MinSource)); } } - + [JsonPropertyName("maxArea")] public double MaxArea { get { return _maxArea; } @@ -792,7 +826,7 @@ namespace DH.Commons.Enums OnPropertyChanged(nameof(MaxArea)); } } - + [JsonPropertyName("minArea")] public double MinArea { get { return _minArea; } @@ -803,7 +837,7 @@ namespace DH.Commons.Enums OnPropertyChanged(nameof(MinArea)); } } - + [JsonPropertyName("_resultState")] public ResultState ResultState { get { return _resultState; } @@ -814,11 +848,13 @@ namespace DH.Commons.Enums OnPropertyChanged(nameof(ResultState)); } } - + private CellLink[] cellLinks; public CellLink[] CellLinks { - get { return cellLinks; } + get { + + return cellLinks; } set { if (cellLinks == value) return; @@ -827,6 +863,60 @@ namespace DH.Commons.Enums } } } + public class PreTreatCollect + { + + [Category("尺寸测量集合")] + [DisplayName("预处理-算法文件路径")] + [Description("预处理算法文件路径配置")] + [JsonPropertyName("halconPath_Pre")] + // [Editor(typeof(FileDialogEditor), typeof(UITypeEditor))] + public string HalconPath_Pre { get; set; } + + [Category("尺寸测量集合")] + [DisplayName("输入参数列表")] + [Description("输入参数列表")] + [JsonPropertyName("preParams")] + // [TypeConverter(typeof(CollectionCountConvert))] + // [Editor(typeof(ComplexCollectionEditor), typeof(UITypeEditor))] + public List PreParams { get; set; } = new List(); + + [Category("尺寸测量集合")] + [DisplayName("输出参数列表")] + [Description("输出参数列表")] + [JsonPropertyName("outPreParams")] + // [TypeConverter(typeof(CollectionCountConvert))] + // [Editor(typeof(ComplexCollectionEditor), typeof(UITypeEditor))] + public List outPreParams { get; set; } = new List(); + + [Category("尺寸测量集合")] + [DisplayName("预处理-名称")] + [Description("预处理名称")] + [JsonPropertyName("preName")] + public string PreName { get; set; } + + [Category("尺寸测量集合")] + [DisplayName("预处理-启用")] + [Description("预处理启用")] + [JsonPropertyName("preIsEnable")] + public bool PreIsEnable { get; set; } = false; + + + [Category("尺寸测量集合")] + [DisplayName("类型")] + [Description("类型")] + [JsonPropertyName("preType")] + // [TypeConverter(typeof(EnumDescriptionConverter))] + public SizeEnum PreType { get; set; } + + [Category("尺寸测量集合")] + [DisplayName("阈值")] + [Description("阈值")] + [JsonPropertyName("prePix")] + public int PrePix { get; set; } + + } + public class SizeTreatParam : NotifyProperty { @@ -923,16 +1013,16 @@ namespace DH.Commons.Enums } } - public string PrePath - { - get { return _prePath; } - set - { - if (_prePath.Equals(value)) return; - _prePath = value; - OnPropertyChanged(nameof(PrePath)); - } - } + //public string PrePath + //{ + // get { return _prePath; } + // set + // { + // if (_prePath.Equals(value)) return; + // _prePath = value; + // OnPropertyChanged(nameof(PrePath)); + // } + //} private CellLink[] cellLinks; @@ -987,7 +1077,7 @@ namespace DH.Commons.Enums [DisplayName("检测项标签")] [Description("检测标签Id")] //[TypeConverter(typeof(DetectionLabelConverter))] -#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 + public string LabelId { get; set; } diff --git a/DH.Commons/Helper/EnumHelper.cs b/DH.Commons/Helper/EnumHelper.cs index 4883448..0308390 100644 --- a/DH.Commons/Helper/EnumHelper.cs +++ b/DH.Commons/Helper/EnumHelper.cs @@ -674,31 +674,31 @@ namespace DH.Commons.Enums Warning = 8, } - public enum ResultState - { - [Description("NA")] - NA = -5, - [Description("尺寸NG")] - SizeNG = -4, - [Description("检测NG")] - DetectNG = -3, + //public enum ResultState + //{ + // [Description("NA")] + // NA = -5, + // [Description("尺寸NG")] + // SizeNG = -4, + // [Description("检测NG")] + // DetectNG = -3, - //[Description("检测不足TBD")] - // ShortageTBD = -2, - [Description("检测结果TBD")] - ResultTBD = -1, - [Description("OK")] - OK = 1, - // [Description("NG")] - // NG = 2, - //统计结果 - [Description("A类NG")] - A_NG = 25, - [Description("B类NG")] - B_NG = 26, - [Description("C类NG")] - C_NG = 27, - } + // //[Description("检测不足TBD")] + // // ShortageTBD = -2, + // [Description("检测结果TBD")] + // ResultTBD = -1, + // [Description("OK")] + // OK = 1, + // // [Description("NG")] + // // NG = 2, + // //统计结果 + // [Description("A类NG")] + // A_NG = 25, + // [Description("B类NG")] + // B_NG = 26, + // [Description("C类NG")] + // C_NG = 27, + //} public enum HikCameraType { [Description("HikCamera-Gige")] diff --git a/DH.Commons/Helper/OpenCVEngineTool.cs b/DH.Commons/Helper/OpenCVEngineTool.cs index 5226ecf..872b92d 100644 --- a/DH.Commons/Helper/OpenCVEngineTool.cs +++ b/DH.Commons/Helper/OpenCVEngineTool.cs @@ -571,8 +571,8 @@ namespace DH.Commons.Enums } - //分别基于像素(GetPixel和SetPixel)、基于内存、基于指针这三种方法增强图片对比度。 - // 第一种方法:像素提取法。速度慢 基于像素:400-600ms + //分别基于像素(GetPixel和SetPixel)、基于内存、基于指针这三种方法增强图片对比度 + // 第一种方法:像素提取法 速度慢 基于像素:400-600ms public static Bitmap MethodBaseOnPixel(Bitmap bitmap, int degree) { Color curColor; diff --git a/DH.Commons/Helper/UIHelper.cs b/DH.Commons/Helper/UIHelper.cs index 2ab9f8d..b44ee08 100644 --- a/DH.Commons/Helper/UIHelper.cs +++ b/DH.Commons/Helper/UIHelper.cs @@ -108,7 +108,7 @@ namespace DH.Commons.Enums                 DataGridViewCheckboxHeaderEventArgs ex = new DataGridViewCheckboxHeaderEventArgs(); ex.CheckedState = _checked; - object sender = new object();//此处不代表选择的列头checkbox,只是作为参数传递。因为列头checkbox是绘制出来的,无法获得它的实例 + object sender = new object();//此处不代表选择的列头checkbox,只是作为参数传递 因为列头checkbox是绘制出来的,无法获得它的实例                 if (OnCheckBoxClicked != null) { diff --git a/DH.Devices.Motion/MCDLL_NET.cs b/DH.Devices.Motion/MCDLL_NET.cs index d9d2101..04d2216 100644 --- a/DH.Devices.Motion/MCDLL_NET.cs +++ b/DH.Devices.Motion/MCDLL_NET.cs @@ -409,7 +409,7 @@ namespace MCDLL_NET /******************************************************************************************************************************************************************** - ·ʱǰѾλõϣᱻжΪ д¼ݡ + ·ʱǰѾλõϣᱻжΪ д¼ ********************************************************************************************************************************************************************/ @@ -1005,8 +1005,8 @@ namespace MCDLL_NET /// /// /// ͣʱ䣻 Χ 0 -1000msĬϣͣ - /// ע⣺ײԭ㻺ͣʱ䣬Ҫϻõĸٶٶȣ͵ٶٶȵĴ䡣 - /// ô˻ֹСֹͣʱжҪʱ䣬ҵԭʱڿм䡣 + /// ע⣺ײԭ㻺ͣʱ䣬Ҫϻõĸٶٶȣ͵ٶٶȵĴ + /// ô˻ֹСֹͣʱжҪʱ䣬ҵԭʱڿм /// վãĬϲΪ 0 /// [DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Search_Home_Stop_Time_Net")] diff --git a/DH.Devices.Motion/MotionBase.cs b/DH.Devices.Motion/MotionBase.cs index 9e8810c..d2f0ef1 100644 --- a/DH.Devices.Motion/MotionBase.cs +++ b/DH.Devices.Motion/MotionBase.cs @@ -444,17 +444,17 @@ namespace DH.Devices.Motion //[Category("回原点设置")] //[DisplayName("回原点模式")] - //[Description("HomeMode:回原点模式。0:一般模式 1:极限限位模式 2:外部触发模式")] + //[Description("HomeMode:回原点模式 0:一般模式 1:极限限位模式 2:外部触发模式")] //public int HomeMode { get; set; } = 0; //[Category("回原点设置")] //[DisplayName("回原点方向")] - //[Description("IsHomePositive:回原点方向。 true:正方向开始 false:负方向开始")] + //[Description("IsHomePositive:回原点方向 true:正方向开始 false:负方向开始")] //public bool IsHomePositive { get; set; } = true; //[Category("回原点设置")] //[DisplayName("是否自动回原点")] - //[Description("IsAutoGoHome:是否自动回原点。 true:是 false:否")] + //[Description("IsAutoGoHome:是否自动回原点 true:是 false:否")] //public bool IsAutoGoHome { get; set; } = false; //[Category("超时设置")] @@ -601,7 +601,7 @@ namespace DH.Devices.Motion [Category("回原点参数")] [DisplayName("碰撞原点缓停时间")] - [Description("SearchHomeStopTime:触发缓停时间,范围 0-1000ms,(默认:急停)。注意:设置碰撞原点缓停时间,需要配合回零设置的高速段速度,和低速度速度的搭配。设置大了会出现过冲的现象,设置小了停止的时候会有抖动,需要调节时间,尽量设置找到原点时候在开关中间。")] + [Description("SearchHomeStopTime:触发缓停时间,范围 0-1000ms,(默认:急停) 注意:设置碰撞原点缓停时间,需要配合回零设置的高速段速度,和低速度速度的搭配 设置大了会出现过冲的现象,设置小了停止的时候会有抖动,需要调节时间,尽量设置找到原点时候在开关中间 ")] public ushort SearchHomeStopTime { get; set; } = 0; diff --git a/DH.Devices.Motion/SLDMotion.cs b/DH.Devices.Motion/SLDMotion.cs index 3f2b361..72e5620 100644 --- a/DH.Devices.Motion/SLDMotion.cs +++ b/DH.Devices.Motion/SLDMotion.cs @@ -314,9 +314,9 @@ namespace DH.Devices.Motion // //设置物件检测有效电平 0是低电平 1是高电平 // rtn = CMCDLL_NET_Sorting.MCF_Sorting_Set_Input_Logic_Net((ushort)SortingInputSetting.BitInputNumber, 0); // //设置来料检测编码器 双转盘要设置两个轴 - // /*Bit_Input_Number:设置位号。 - // 取值: Bit_Input_0, Bit_Input_1。 - // Axis: 轴号。 + // /*Bit_Input_Number:设置位号 + // 取值: Bit_Input_0, Bit_Input_1 + // Axis: 轴号 // Source:跟随方式 // 取值:0:命令 // 1:编码器(默认) @@ -1655,7 +1655,7 @@ namespace DH.Devices.Motion #region IMonitor /// - /// 位置捕获监听,入料检测。 + /// 位置捕获监听,入料检测 /// 入料检测对射开关接到了HOME口,每当有新料到达入料检测传感器时,程序把当前位置当作原点,并调用函数 /// private void MonitorPieces() @@ -1796,7 +1796,7 @@ namespace DH.Devices.Motion // Picese_sizeStr += i.ToString()+":"+Piece_Size[i]+"\t"; // Picese_DistanceizeStr += i.ToString()+":"+ Piece_Distance_To_next[i]+"\t"; //} - // LogAsync(DateTime.Now, LogLevel.Information, $"转盘{station}产品入列 , {piecesCountDic[station]} size:{Piece_Size[Piece_Size.Length - 1]}。"); + // LogAsync(DateTime.Now, LogLevel.Information, $"转盘{station}产品入列 , {piecesCountDic[station]} size:{Piece_Size[Piece_Size.Length - 1]} "); // LogAsync(DateTime.Now, LogLevel.Information, $"转盘{station}产品入列 ,监听piece_find{tmpPieceNumber} 监听物件大小" + Picese_sizeStr+",物件间距"+ Picese_DistanceizeStr+"相机经过个数"+Piece_Cross_Camera); if (tmpPieceNumber != piecesCountDic[station] + 1) { diff --git a/DH.Devices.Vision/SimboDetection.cs b/DH.Devices.Vision/SimboDetection.cs index 7ef52ac..53587a6 100644 --- a/DH.Devices.Vision/SimboDetection.cs +++ b/DH.Devices.Vision/SimboDetection.cs @@ -104,9 +104,9 @@ namespace DH.Devices.Vision // json = "{\"FastDetResult\":[{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654843,\"rect\":[175,99,110,594]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654589,\"rect\":[2608,19,104,661]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654285,\"rect\":[1275,19,104,662]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.620762,\"rect\":[1510,95,107,600]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.617812,\"rect\":[2844,93,106,602]}]}"; // Console.WriteLine("检测结果JSON:" + json); -#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。 +#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型 HYoloResult detResult = JsonConvert.DeserializeObject(json); -#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。 +#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型 if (detResult == null) { return; @@ -234,15 +234,15 @@ namespace DH.Devices.Vision { originMat?.Dispose(); -#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。 +#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型 originMat = null; -#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。 +#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型 //maskMat?.Dispose(); // maskMat = null; detectMat?.Dispose(); -#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。 +#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型 detectMat = null; -#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。 +#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型 // maskWeighted?.Dispose(); // maskWeighted = null; // GC.Collect(); diff --git a/DH.Devices.Vision/SimboInstanceSegmentation.cs b/DH.Devices.Vision/SimboInstanceSegmentation.cs index 7f7936c..9ede8ff 100644 --- a/DH.Devices.Vision/SimboInstanceSegmentation.cs +++ b/DH.Devices.Vision/SimboInstanceSegmentation.cs @@ -127,9 +127,9 @@ namespace DH.Devices.Vision // json = "{\"FastDetResult\":[{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654843,\"rect\":[175,99,110,594]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654589,\"rect\":[2608,19,104,661]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654285,\"rect\":[1275,19,104,662]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.620762,\"rect\":[1510,95,107,600]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.617812,\"rect\":[2844,93,106,602]}]}"; // Console.WriteLine("检测结果JSON:" + json); -#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。 +#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型 SegResult detResult = JsonConvert.DeserializeObject(json); -#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。 +#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型 if (detResult == null) { return; @@ -259,9 +259,9 @@ namespace DH.Devices.Vision { originMat?.Dispose(); -#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。 +#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型 originMat = null; -#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。 +#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型 // GC.Collect(); diff --git a/DH.Devices.Vision/SimboObjectDetection.cs b/DH.Devices.Vision/SimboObjectDetection.cs index 3ad0d60..c8e425e 100644 --- a/DH.Devices.Vision/SimboObjectDetection.cs +++ b/DH.Devices.Vision/SimboObjectDetection.cs @@ -136,9 +136,9 @@ namespace DH.Devices.Vision // json = "{\"FastDetResult\":[{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654843,\"rect\":[175,99,110,594]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654589,\"rect\":[2608,19,104,661]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654285,\"rect\":[1275,19,104,662]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.620762,\"rect\":[1510,95,107,600]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.617812,\"rect\":[2844,93,106,602]}]}"; // Console.WriteLine("检测结果JSON:" + json); -#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。 +#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型 SegResult detResult = JsonConvert.DeserializeObject(json); -#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。 +#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型 if (detResult == null) { return; @@ -267,17 +267,17 @@ namespace DH.Devices.Vision if (detectMat != null) { detectMat.Dispose(); -#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。 +#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型 detectMat = null; -#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。 +#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型 } if (originMat != null) { originMat.Dispose(); -#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。 +#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型 originMat = null; -#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。 +#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型 } diff --git a/DH.Devices.Vision/SimboVisionMLBase.cs b/DH.Devices.Vision/SimboVisionMLBase.cs index 7e94e6e..0580f83 100644 --- a/DH.Devices.Vision/SimboVisionMLBase.cs +++ b/DH.Devices.Vision/SimboVisionMLBase.cs @@ -59,7 +59,7 @@ namespace DH.Devices.Vision // "rect": [421, 823, 6, 8] // }] //} -#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 + public List HYolo; public class Result @@ -67,12 +67,12 @@ namespace DH.Devices.Vision public double fScore; public int classId; -#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 + public string classname; //public double area; -#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 + public List rect; @@ -82,7 +82,7 @@ namespace DH.Devices.Vision } public class SegResult { -#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 + public List SegmentResult; public class Result @@ -90,12 +90,12 @@ namespace DH.Devices.Vision public double fScore; public int classId; -#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 + public string classname; public double area; -#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 + public List rect; diff --git a/DH.Devices.Vision/SimboVisionModel.cs b/DH.Devices.Vision/SimboVisionModel.cs index 0683cef..425f696 100644 --- a/DH.Devices.Vision/SimboVisionModel.cs +++ b/DH.Devices.Vision/SimboVisionModel.cs @@ -22,18 +22,18 @@ namespace DH.Devices.Vision /// /// 检测配置ID /// -#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 + public string DetectionId { get; set; } -#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 + public string DetectionName { get; set; } /// /// 深度学习模型 /// -#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。 + public SimboVisionMLBase StationMLEngine { get; set; } diff --git a/DH.Process/DH.Process.csproj b/DH.Process/DH.Process.csproj new file mode 100644 index 0000000..b842d35 --- /dev/null +++ b/DH.Process/DH.Process.csproj @@ -0,0 +1,19 @@ + + + + net8.0-windows + enable + enable + ..\ + output + true + AnyCPU;x64 + + + + + + + + + diff --git a/DH.Process/XKRS.Process.cs b/DH.Process/XKRS.Process.cs new file mode 100644 index 0000000..63ca25c --- /dev/null +++ b/DH.Process/XKRS.Process.cs @@ -0,0 +1,49 @@ +using DH.Commons.Enums; +using DH.Devices.Devices; +using System.ComponentModel; +using System.Drawing.Design; +using System.Text.Json.Serialization; + +namespace DH.Process +{ + + public class ProcessConfigBase + { + [JsonPropertyName("station_code")] + public string StationCode { get; set; } + + + #region 设备配置 + [Category("设备配置")] + [Description("相机配置")] + [DisplayName("相机配置")] + [JsonPropertyName("camera_config_collection")] + //[TypeConverter(typeof(CollectionCountConvert))] + //[Editor(typeof(InitialConfigCollectionEditor), typeof(UITypeEditor))] + public List CameraConfigCollection { get; set; } = new List(); + + + [Category("设备配置")] + [Description("模型配置")] + [DisplayName("模型配置")] + [JsonPropertyName("detection_config_collection")] + //[TypeConverter(typeof(CollectionCountConvert))] + //[Editor(typeof(InitialConfigCollectionEditor), typeof(UITypeEditor))] + public List DetectionConfigCollection { 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 + } +} diff --git a/DH.UI.Model.Winform/Canvas.Designer.cs b/DH.UI.Model.Winform/Canvas.Designer.cs index d5d2379..8afd04d 100644 --- a/DH.UI.Model.Winform/Canvas.Designer.cs +++ b/DH.UI.Model.Winform/Canvas.Designer.cs @@ -3,14 +3,14 @@ partial class Canvas { /// - /// 必需的设计器变量。 + /// 必需的设计器变量 /// private System.ComponentModel.IContainer components = null; /// - /// 清理所有正在使用的资源。 + /// 清理所有正在使用的资源 /// - /// 如果应释放托管资源,为 true;否则为 false。 + /// 如果应释放托管资源,为 true;否则为 false protected override void Dispose(bool disposing) { if (disposing && (components != null)) @@ -24,7 +24,7 @@ /// /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 + /// 使用代码编辑器修改此方法的内容 /// private void InitializeComponent() { diff --git a/DH.UI.Model.Winform/CanvasImage.Designer.cs b/DH.UI.Model.Winform/CanvasImage.Designer.cs index 1e2b61f..7ddec86 100644 --- a/DH.UI.Model.Winform/CanvasImage.Designer.cs +++ b/DH.UI.Model.Winform/CanvasImage.Designer.cs @@ -3,7 +3,7 @@ partial class CanvasImage { /// - /// 必需的设计器变量。 + /// 必需的设计器变量 /// private System.ComponentModel.IContainer components = null; @@ -11,7 +11,7 @@ /// /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 + /// 使用代码编辑器修改此方法的内容 /// private void InitializeComponent() { diff --git a/DH.UI.Model.Winform/CanvasImage.cs b/DH.UI.Model.Winform/CanvasImage.cs index e25b9a7..0e1203a 100644 --- a/DH.UI.Model.Winform/CanvasImage.cs +++ b/DH.UI.Model.Winform/CanvasImage.cs @@ -923,9 +923,9 @@ namespace DH.UI.Model.Winform #region Dispose /// - /// 清理所有正在使用的资源。 + /// 清理所有正在使用的资源 /// - /// 如果应释放托管资源,为 true;否则为 false。 + /// 如果应释放托管资源,为 true;否则为 false protected override void Dispose(bool disposing) { MAP?.Dispose(); diff --git a/DH.UI.Model.Winform/Ctrl/GridCtrl.Designer.cs b/DH.UI.Model.Winform/Ctrl/GridCtrl.Designer.cs index 1b26268..417e27d 100644 --- a/DH.UI.Model.Winform/Ctrl/GridCtrl.Designer.cs +++ b/DH.UI.Model.Winform/Ctrl/GridCtrl.Designer.cs @@ -3,14 +3,14 @@ partial class GridCtrl { /// - /// 必需的设计器变量。 + /// 必需的设计器变量 /// private System.ComponentModel.IContainer components = null; /// - /// 清理所有正在使用的资源。 + /// 清理所有正在使用的资源 /// - /// 如果应释放托管资源,为 true;否则为 false。 + /// 如果应释放托管资源,为 true;否则为 false protected override void Dispose(bool disposing) { if (disposing && (components != null)) @@ -24,7 +24,7 @@ /// /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 + /// 使用代码编辑器修改此方法的内容 /// private void InitializeComponent() { diff --git a/DH.UI.Model.Winform/Ctrl/IOIndicatorCtrl.Designer.cs b/DH.UI.Model.Winform/Ctrl/IOIndicatorCtrl.Designer.cs index f082d76..50c6cb5 100644 --- a/DH.UI.Model.Winform/Ctrl/IOIndicatorCtrl.Designer.cs +++ b/DH.UI.Model.Winform/Ctrl/IOIndicatorCtrl.Designer.cs @@ -3,14 +3,14 @@ partial class IOIndicatorCtrl { /// - /// 必需的设计器变量。 + /// 必需的设计器变量 /// private System.ComponentModel.IContainer components = null; /// - /// 清理所有正在使用的资源。 + /// 清理所有正在使用的资源 /// - /// 如果应释放托管资源,为 true;否则为 false。 + /// 如果应释放托管资源,为 true;否则为 false protected override void Dispose(bool disposing) { if (disposing && (components != null)) @@ -24,7 +24,7 @@ /// /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 + /// 使用代码编辑器修改此方法的内容 /// private void InitializeComponent() { diff --git a/DH.UI.Model.Winform/Element/ElementBase.cs b/DH.UI.Model.Winform/Element/ElementBase.cs index 0b529b4..3437b5e 100644 --- a/DH.UI.Model.Winform/Element/ElementBase.cs +++ b/DH.UI.Model.Winform/Element/ElementBase.cs @@ -864,30 +864,30 @@ namespace DH.UI.Model.Winform { if (disposing) { - // 释放托管状态(托管对象)。 + // 释放托管状态(托管对象) Pen?.Dispose(); } - // TODO: 释放未托管的资源(未托管的对象)并在以下内容中替代终结器。 - // TODO: 将大型字段设置为 null。 + // TODO: 释放未托管的资源(未托管的对象)并在以下内容中替代终结器 + // TODO: 将大型字段设置为 null disposedValue = true; } } - // TODO: 仅当以上 Dispose(bool disposing) 拥有用于释放未托管资源的代码时才替代终结器。 + // TODO: 仅当以上 Dispose(bool disposing) 拥有用于释放未托管资源的代码时才替代终结器 // ~ElementBase() // { - // // 请勿更改此代码。将清理代码放入以上 Dispose(bool disposing) 中。 + // // 请勿更改此代码 将清理代码放入以上 Dispose(bool disposing) 中 // Dispose(false); // } - // 添加此代码以正确实现可处置模式。 + // 添加此代码以正确实现可处置模式 public void Dispose() { - // 请勿更改此代码。将清理代码放入以上 Dispose(bool disposing) 中。 + // 请勿更改此代码 将清理代码放入以上 Dispose(bool disposing) 中 Dispose(true); - // TODO: 如果在以上内容中替代了终结器,则取消注释以下行。 + // TODO: 如果在以上内容中替代了终结器,则取消注释以下行 // GC.SuppressFinalize(this); } #endregion diff --git a/DH.UI.Model.Winform/GridCtrl.Designer.cs b/DH.UI.Model.Winform/GridCtrl.Designer.cs index bfc50ad..51350f2 100644 --- a/DH.UI.Model.Winform/GridCtrl.Designer.cs +++ b/DH.UI.Model.Winform/GridCtrl.Designer.cs @@ -3,14 +3,14 @@ partial class GridCtrl { /// - /// 必需的设计器变量。 + /// 必需的设计器变量 /// private System.ComponentModel.IContainer components = null; /// - /// 清理所有正在使用的资源。 + /// 清理所有正在使用的资源 /// - /// 如果应释放托管资源,为 true;否则为 false。 + /// 如果应释放托管资源,为 true;否则为 false protected override void Dispose(bool disposing) { if (disposing && (components != null)) @@ -24,7 +24,7 @@ /// /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 + /// 使用代码编辑器修改此方法的内容 /// private void InitializeComponent() { diff --git a/DH.UI.Model.Winform/IOIndicatorCtrl.Designer.cs b/DH.UI.Model.Winform/IOIndicatorCtrl.Designer.cs index 6d83432..96ec3c0 100644 --- a/DH.UI.Model.Winform/IOIndicatorCtrl.Designer.cs +++ b/DH.UI.Model.Winform/IOIndicatorCtrl.Designer.cs @@ -3,14 +3,14 @@ partial class IOIndicatorCtrl { /// - /// 必需的设计器变量。 + /// 必需的设计器变量 /// private System.ComponentModel.IContainer components = null; /// - /// 清理所有正在使用的资源。 + /// 清理所有正在使用的资源 /// - /// 如果应释放托管资源,为 true;否则为 false。 + /// 如果应释放托管资源,为 true;否则为 false protected override void Dispose(bool disposing) { if (disposing && (components != null)) @@ -24,7 +24,7 @@ /// /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 + /// 使用代码编辑器修改此方法的内容 /// private void InitializeComponent() { diff --git a/DHSoftware.sln b/DHSoftware.sln index 00408cf..e4ce813 100644 --- a/DHSoftware.sln +++ b/DHSoftware.sln @@ -39,6 +39,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XKRS.CanFly", "CanFly\XKRS. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CanFly.Canvas", "CanFly.Canvas\CanFly.Canvas.csproj", "{EA7E228B-DB5C-4BF1-832B-D51B7F7D5F35}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Process", "Process", "{FE1AEA36-9909-4E4F-8A88-37338ECCCE62}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DH.Process", "DH.Process\DH.Process.csproj", "{9C6D1290-26D9-4C5B-8BF5-A1F1E35368C5}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -127,6 +131,14 @@ Global {EA7E228B-DB5C-4BF1-832B-D51B7F7D5F35}.Release|Any CPU.Build.0 = Release|Any CPU {EA7E228B-DB5C-4BF1-832B-D51B7F7D5F35}.Release|x64.ActiveCfg = Release|x64 {EA7E228B-DB5C-4BF1-832B-D51B7F7D5F35}.Release|x64.Build.0 = Release|x64 + {9C6D1290-26D9-4C5B-8BF5-A1F1E35368C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9C6D1290-26D9-4C5B-8BF5-A1F1E35368C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9C6D1290-26D9-4C5B-8BF5-A1F1E35368C5}.Debug|x64.ActiveCfg = Debug|Any CPU + {9C6D1290-26D9-4C5B-8BF5-A1F1E35368C5}.Debug|x64.Build.0 = Debug|Any CPU + {9C6D1290-26D9-4C5B-8BF5-A1F1E35368C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9C6D1290-26D9-4C5B-8BF5-A1F1E35368C5}.Release|Any CPU.Build.0 = Release|Any CPU + {9C6D1290-26D9-4C5B-8BF5-A1F1E35368C5}.Release|x64.ActiveCfg = Release|Any CPU + {9C6D1290-26D9-4C5B-8BF5-A1F1E35368C5}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -145,6 +157,7 @@ Global {5AD3A29E-149A-4C37-9548-7638A36C8175} = {F77AF94C-280D-44C5-B7C0-FC86AA9EC504} {1FB768DB-843E-4C67-96B9-7684CF890D89} = {048B30B5-D075-4CE0-BF9F-CB6152E6D376} {EA7E228B-DB5C-4BF1-832B-D51B7F7D5F35} = {048B30B5-D075-4CE0-BF9F-CB6152E6D376} + {9C6D1290-26D9-4C5B-8BF5-A1F1E35368C5} = {FE1AEA36-9909-4E4F-8A88-37338ECCCE62} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {6FC1A8DF-636E-434C-981E-10F20FAD723B} diff --git a/DHSoftware/DHSoftware.csproj b/DHSoftware/DHSoftware.csproj index b04a06c..ff85bec 100644 --- a/DHSoftware/DHSoftware.csproj +++ b/DHSoftware/DHSoftware.csproj @@ -45,6 +45,7 @@ + diff --git a/DHSoftware/MainWindow.cs b/DHSoftware/MainWindow.cs index cf6233b..b94d385 100644 --- a/DHSoftware/MainWindow.cs +++ b/DHSoftware/MainWindow.cs @@ -6,6 +6,7 @@ using DH.Devices.Devices; using DH.Devices.Motion; using DH.Devices.PLC; using DH.Devices.Vision; +using DH.Process; using DHSoftware.Languages; using DHSoftware.Models; using DHSoftware.Utils; @@ -18,17 +19,22 @@ using System; using System.CodeDom; using System.Collections.Concurrent; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Diagnostics; using System.Drawing; using System.Linq; using System.Runtime.InteropServices; using System.Text; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using XKRS.UI.Device.Winform; using static AntdUI.Math3D; +using static DH.Commons.Enums.EnumHelper; using Camera = DHSoftware.Models.Camera; +using IOType = DH.Commons.Enums.IOType; + namespace DHSoftware { @@ -229,7 +235,7 @@ namespace DHSoftware SLDMotion sLDMotion = new SLDMotion(); private void MainWindow_Load(object sender, EventArgs e) { - + Json(); } private void MainWindow_FormClosed(object sender, FormClosedEventArgs e) @@ -278,21 +284,15 @@ namespace DHSoftware public volatile int ProductNum_OK = 0; private readonly object _cameraSummaryLock = new object(); public SimboVisionDriver? _visionEngine = null; - List DetectionConfigs = new List(); - List SimboStationMLEngineList = new List(); + ProcessConfigBase DHconfig; + // + // List SimboStationMLEngineList = new List(); Dictionary HalconToolDict = new Dictionary(); public List RecongnitionLabelList { get; set; } = new List(); public DateTime startTime; - private void HandleStartButton() + private void Json() { - CurrentMachine = true; - - //_visionEngine.Start(); - //[Category("深度学习检测配置")] - //[DisplayName("检测标签定义集合")] - //[Description("定义检测标签的集合,例如:Seg/Detection模式:断裂、油污、划伤...;Class模式:ok、ng、上面、下面、套环、正常...")] - //[TypeConverter(typeof(CollectionCountConvert))] - //[Editor(typeof(ComplexCollectionEditor), typeof(UITypeEditor))] + List DetectionConfigs = new List(); RecongnitionLabel recongnition = new RecongnitionLabel { LabelName = "youwu", @@ -315,7 +315,7 @@ namespace DHSoftware RecongnitionLabelList.Add(recongnition2); RecongnitionLabelList.Add(recongnition3); - + var det1 = new DetectionConfig("相机1", MLModelType.ObjectDetection, @"D:\PROJECTS\X015\Vision\Cam1.onnx", false, "Cam1"); var det2 = new DetectionConfig("相机2", MLModelType.ObjectDetection, @"D:\PROJECTS\X015\Vision\Cam2.onnx", false, "Cam2"); @@ -353,6 +353,13 @@ namespace DHSoftware det1.IsEnabled = true; det1.ShowLocation.X = 1; det1.ShowLocation.Y = 1; + det1.DetectionLableList = new List() + { new DetectionLable{ LabelName="xinquexian1",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian2",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian3",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian4",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1} , + }; + det2.CameraCollects = CameraCollects2; det2.ModelconfThreshold = Conf; @@ -362,7 +369,13 @@ namespace DHSoftware det2.IsEnabled = true; det2.ShowLocation.X = 2; det2.ShowLocation.Y = 1; - + det2.DetectionLableList = new List() + { new DetectionLable{ LabelName="xinquexian1",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian2",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian3",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian4",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + }; + det3.CameraCollects = CameraCollects3; det3.ModelconfThreshold = Conf; det3.ModelWidth = 640; @@ -371,6 +384,13 @@ namespace DHSoftware det3.IsEnabled = true; det3.ShowLocation.X = 3; det3.ShowLocation.Y = 1; + det3.DetectionLableList = new List() + { new DetectionLable{ LabelName="xinquexian1",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian2",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian3",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian4",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + }; + det4.CameraCollects = CameraCollects4; det4.ModelconfThreshold = Conf; @@ -380,6 +400,13 @@ namespace DHSoftware det4.IsEnabled = true; det4.ShowLocation.X = 4; det4.ShowLocation.Y = 1; + det4.DetectionLableList = new List() + { new DetectionLable{ LabelName="xinquexian1",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian2",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian3",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian4",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + }; + @@ -391,6 +418,23 @@ namespace DHSoftware det5.IsEnabled = true; det5.ShowLocation.X = 1; det5.ShowLocation.Y = 2; + det5.DetectionLableList = new List() + { new DetectionLable{ LabelName="xinquexian1",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian2",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian3",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian4",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + }; + det5.PreTreatCollects = new List() + { + new SizeTreatParam() + { + PreName="高度测量", + IsEnable=true, + PreType=SizeEnum.高度测量, + ResultShow="sssssss", + OutResultShow="sssssss", + }, + }; det6.CameraCollects = CameraCollects6; det6.ModelconfThreshold = Conf; @@ -400,6 +444,13 @@ namespace DHSoftware det6.IsEnabled = true; det6.ShowLocation.X = 2; det6.ShowLocation.Y = 2; + det6.DetectionLableList = new List() + { new DetectionLable{ LabelName="xinquexian1",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian2",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian3",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian4",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + }; + det7.CameraCollects = CameraCollects7; det7.ModelconfThreshold = Conf; @@ -409,6 +460,13 @@ namespace DHSoftware det7.IsEnabled = true; det7.ShowLocation.X = 3; det7.ShowLocation.Y = 2; + det7.DetectionLableList = new List() + { new DetectionLable{ LabelName="xinquexian1",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian2",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian3",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian4",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + }; + det8.CameraCollects = CameraCollects8; det8.ModelconfThreshold = Conf; @@ -416,8 +474,27 @@ namespace DHSoftware det8.ModelHeight = 640; det8.in_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam8.txt"; det8.IsEnabled = true; + det8.IsAddStation = true; det8.ShowLocation.X = 4; det8.ShowLocation.Y = 2; + det8.DetectionLableList = new List() + { new DetectionLable{ LabelName="xinquexian1",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian2",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian3",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + new DetectionLable{ LabelName="xinquexian4",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } , + }; + det8.PreTreatCollects = new List() + { + new SizeTreatParam() + { + PreName="高度测量", + IsEnable=true, + PreType=SizeEnum.高度测量, + ResultShow="sssssss", + OutResultShow="sssssss", + }, + }; + DetectionConfigs.Add(det1); DetectionConfigs.Add(det2); @@ -428,6 +505,32 @@ namespace DHSoftware DetectionConfigs.Add(det7); DetectionConfigs.Add(det8); + DHconfig = new ProcessConfigBase(); + DHconfig.StationCode = "小齿轮"; + DHconfig.DetectionConfigCollection = DetectionConfigs; + // DHconfig.ca = "小齿轮"; + + // **序列化** + string json = JsonSerializer.Serialize(DHconfig, new JsonSerializerOptions { WriteIndented = true }); + Console.WriteLine("序列化后的 JSON:\n" + json); + + var deserializedConfig = JsonSerializer.Deserialize(json); + Console.WriteLine("Station Code: " + deserializedConfig?.StationCode); + + } + private void HandleStartButton() + { + CurrentMachine = true; + + //_visionEngine.Start(); + //[Category("深度学习检测配置")] + //[DisplayName("检测标签定义集合")] + //[Description("定义检测标签的集合,例如:Seg/Detection模式:断裂、油污、划伤...;Class模式:ok、ng、上面、下面、套环、正常...")] + //[TypeConverter(typeof(CollectionCountConvert))] + //[Editor(typeof(ComplexCollectionEditor), typeof(UITypeEditor))] + + + Cameras.Clear(); HKCameras.Clear(); Dectection.Clear(); @@ -477,7 +580,7 @@ namespace DHSoftware #endif - DetectionConfigs.ForEach(detection => + DHconfig?.DetectionConfigCollection.ForEach(detection => { detection.CameraCollects.ForEach(cam => @@ -504,7 +607,7 @@ namespace DHSoftware _visionEngine = new SimboVisionDriver(); - _visionEngine.DetectionConfigs = DetectionConfigs; + _visionEngine.DetectionConfigs =DHconfig?.DetectionConfigCollection; _visionEngine.Init(); CtrlVisionRunBase ctrlVisionRun = new CtrlVisionRunBase(_visionEngine); @@ -1020,7 +1123,7 @@ namespace DHSoftware listCamBase.Add(cam1); listCamBase.Add(cam2); - SettingWindow1 settingWindow = new SettingWindow1(); + SettingWindow1 settingWindow = new SettingWindow1(DHconfig); settingWindow.Show(); //s.cameras = listCamBase; //s.Show(); diff --git a/DHSoftware/Program.cs b/DHSoftware/Program.cs index 1680c10..9979be0 100644 --- a/DHSoftware/Program.cs +++ b/DHSoftware/Program.cs @@ -9,7 +9,7 @@ namespace DHSoftware { private static MainWindow mainWindow; /// - /// 应用程序的主入口点。 + /// 应用程序的主入口点 /// [STAThread] static void Main() diff --git a/DHSoftware/Properties/Resources.Designer.cs b/DHSoftware/Properties/Resources.Designer.cs index 3e8ce5d..c2373de 100644 --- a/DHSoftware/Properties/Resources.Designer.cs +++ b/DHSoftware/Properties/Resources.Designer.cs @@ -1,10 +1,10 @@ //------------------------------------------------------------------------------ // -// 此代码由工具生成。 +// 此代码由工具生成 // 运行时版本:4.0.30319.42000 // // 对此文件的更改可能会导致不正确的行为,并且如果 -// 重新生成代码,这些更改将会丢失。 +// 重新生成代码,这些更改将会丢失 // //------------------------------------------------------------------------------ @@ -13,12 +13,12 @@ namespace DHSoftware.Properties { /// - /// 一个强类型的资源类,用于查找本地化的字符串等。 + /// 一个强类型的资源类,用于查找本地化的字符串等 /// // 此类是由 StronglyTypedResourceBuilder - // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的 // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen - // (以 /str 作为命令选项),或重新生成 VS 项目。 + // (以 /str 作为命令选项),或重新生成 VS 项目 [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] @@ -33,7 +33,7 @@ namespace DHSoftware.Properties { } /// - /// 返回此类使用的缓存的 ResourceManager 实例。 + /// 返回此类使用的缓存的 ResourceManager 实例 /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Resources.ResourceManager ResourceManager { @@ -48,7 +48,7 @@ namespace DHSoftware.Properties { /// /// 重写当前线程的 CurrentUICulture 属性,对 - /// 使用此强类型资源类的所有资源查找执行重写。 + /// 使用此强类型资源类的所有资源查找执行重写 /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Globalization.CultureInfo Culture { @@ -61,7 +61,7 @@ namespace DHSoftware.Properties { } /// - /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// 查找 System.Drawing.Bitmap 类型的本地化资源 /// internal static System.Drawing.Bitmap bg1 { get { @@ -71,7 +71,7 @@ namespace DHSoftware.Properties { } /// - /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// 查找 System.Drawing.Bitmap 类型的本地化资源 /// internal static System.Drawing.Bitmap bg2 { get { @@ -81,7 +81,7 @@ namespace DHSoftware.Properties { } /// - /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// 查找 System.Drawing.Bitmap 类型的本地化资源 /// internal static System.Drawing.Bitmap bg3 { get { @@ -91,7 +91,7 @@ namespace DHSoftware.Properties { } /// - /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// 查找 System.Drawing.Bitmap 类型的本地化资源 /// internal static System.Drawing.Bitmap head { get { @@ -101,7 +101,7 @@ namespace DHSoftware.Properties { } /// - /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// 查找 System.Drawing.Bitmap 类型的本地化资源 /// internal static System.Drawing.Bitmap head2 { get { @@ -111,7 +111,7 @@ namespace DHSoftware.Properties { } /// - /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// 查找 System.Drawing.Bitmap 类型的本地化资源 /// internal static System.Drawing.Bitmap logo { get { @@ -121,7 +121,7 @@ namespace DHSoftware.Properties { } /// - /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// 查找 System.Drawing.Bitmap 类型的本地化资源 /// internal static System.Drawing.Bitmap 关闭 { get { diff --git a/DHSoftware/Views/CamConfigFrm.Designer.cs b/DHSoftware/Views/CamConfigFrm.Designer.cs index 69a68a6..12cb5ea 100644 --- a/DHSoftware/Views/CamConfigFrm.Designer.cs +++ b/DHSoftware/Views/CamConfigFrm.Designer.cs @@ -4,14 +4,14 @@ { /// - /// 必需的设计器变量。 + /// 必需的设计器变量 /// private System.ComponentModel.IContainer components = null; /// - /// 清理所有正在使用的资源。 + /// 清理所有正在使用的资源 /// - /// 如果应释放托管资源,为 true;否则为 false。 + /// 如果应释放托管资源,为 true;否则为 false protected override void Dispose(bool disposing) { if (disposing && (components != null)) @@ -25,7 +25,7 @@ /// /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 + /// 使用代码编辑器修改此方法的内容 /// private void InitializeComponent() { diff --git a/DHSoftware/Views/CameraConfigControl.Designer.cs b/DHSoftware/Views/CameraConfigControl.Designer.cs index 7dc37bf..bc0580d 100644 --- a/DHSoftware/Views/CameraConfigControl.Designer.cs +++ b/DHSoftware/Views/CameraConfigControl.Designer.cs @@ -3,14 +3,14 @@ partial class CameraConfigControl { /// - /// 必需的设计器变量。 + /// 必需的设计器变量 /// private System.ComponentModel.IContainer components = null; /// - /// 清理所有正在使用的资源。 + /// 清理所有正在使用的资源 /// - /// 如果应释放托管资源,为 true;否则为 false。 + /// 如果应释放托管资源,为 true;否则为 false protected override void Dispose(bool disposing) { if (disposing && (components != null)) @@ -24,7 +24,7 @@ /// /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 + /// 使用代码编辑器修改此方法的内容 /// private void InitializeComponent() { diff --git a/DHSoftware/Views/CorrelatedCameraEdit.Designer.cs b/DHSoftware/Views/CorrelatedCameraEdit.Designer.cs index e87ed35..e87c6ea 100644 --- a/DHSoftware/Views/CorrelatedCameraEdit.Designer.cs +++ b/DHSoftware/Views/CorrelatedCameraEdit.Designer.cs @@ -3,14 +3,14 @@ partial class CorrelatedCameraEdit { /// - /// 必需的设计器变量。 + /// 必需的设计器变量 /// private System.ComponentModel.IContainer components = null; /// - /// 清理所有正在使用的资源。 + /// 清理所有正在使用的资源 /// - /// 如果应释放托管资源,为 true;否则为 false。 + /// 如果应释放托管资源,为 true;否则为 false protected override void Dispose(bool disposing) { if (disposing && (components != null)) @@ -24,7 +24,7 @@ /// /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 + /// 使用代码编辑器修改此方法的内容 /// private void InitializeComponent() { diff --git a/DHSoftware/Views/CtrlVisionDisplay.Designer.cs b/DHSoftware/Views/CtrlVisionDisplay.Designer.cs index b688314..7c2d31f 100644 --- a/DHSoftware/Views/CtrlVisionDisplay.Designer.cs +++ b/DHSoftware/Views/CtrlVisionDisplay.Designer.cs @@ -3,14 +3,14 @@ partial class CtrlVisionDisplay { /// - /// 必需的设计器变量。 + /// 必需的设计器变量 /// private System.ComponentModel.IContainer components = null; /// - /// 清理所有正在使用的资源。 + /// 清理所有正在使用的资源 /// - /// 如果应释放托管资源,为 true;否则为 false。 + /// 如果应释放托管资源,为 true;否则为 false protected override void Dispose(bool disposing) { if (disposing && (components != null)) @@ -24,7 +24,7 @@ /// /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 + /// 使用代码编辑器修改此方法的内容 /// private void InitializeComponent() { diff --git a/DHSoftware/Views/CtrlVisionRunBase.Designer.cs b/DHSoftware/Views/CtrlVisionRunBase.Designer.cs index 409aba4..2fac685 100644 --- a/DHSoftware/Views/CtrlVisionRunBase.Designer.cs +++ b/DHSoftware/Views/CtrlVisionRunBase.Designer.cs @@ -4,14 +4,14 @@ namespace XKRS.UI.Device.Winform partial class CtrlVisionRunBase { /// - /// 必需的设计器变量。 + /// 必需的设计器变量 /// private System.ComponentModel.IContainer components = null; /// - /// 清理所有正在使用的资源。 + /// 清理所有正在使用的资源 /// - /// 如果应释放托管资源,为 true;否则为 false。 + /// 如果应释放托管资源,为 true;否则为 false protected override void Dispose(bool disposing) { if (disposing && (components != null)) @@ -25,7 +25,7 @@ namespace XKRS.UI.Device.Winform /// /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 + /// 使用代码编辑器修改此方法的内容 /// private void InitializeComponent() { diff --git a/DHSoftware/Views/DefectRowEdit.Designer.cs b/DHSoftware/Views/DefectRowEdit.Designer.cs index 70f3f22..90ab6ea 100644 --- a/DHSoftware/Views/DefectRowEdit.Designer.cs +++ b/DHSoftware/Views/DefectRowEdit.Designer.cs @@ -3,14 +3,14 @@ partial class DefectRowEdit { /// - /// 必需的设计器变量。 + /// 必需的设计器变量 /// private System.ComponentModel.IContainer components = null; /// - /// 清理所有正在使用的资源。 + /// 清理所有正在使用的资源 /// - /// 如果应释放托管资源,为 true;否则为 false。 + /// 如果应释放托管资源,为 true;否则为 false protected override void Dispose(bool disposing) { if (disposing && (components != null)) @@ -24,7 +24,7 @@ /// /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 + /// 使用代码编辑器修改此方法的内容 /// private void InitializeComponent() { diff --git a/DHSoftware/Views/DetectConfigControl.Designer.cs b/DHSoftware/Views/DetectConfigControl.Designer.cs index b0fbaff..43f57ba 100644 --- a/DHSoftware/Views/DetectConfigControl.Designer.cs +++ b/DHSoftware/Views/DetectConfigControl.Designer.cs @@ -3,14 +3,14 @@ partial class DetectConfigControl { /// - /// 必需的设计器变量。 + /// 必需的设计器变量 /// private System.ComponentModel.IContainer components = null; /// - /// 清理所有正在使用的资源。 + /// 清理所有正在使用的资源 /// - /// 如果应释放托管资源,为 true;否则为 false。 + /// 如果应释放托管资源,为 true;否则为 false protected override void Dispose(bool disposing) { if (disposing && (components != null)) @@ -24,7 +24,7 @@ /// /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 + /// 使用代码编辑器修改此方法的内容 /// private void InitializeComponent() { diff --git a/DHSoftware/Views/DetectControl.Designer.cs b/DHSoftware/Views/DetectControl.Designer.cs index 8dd5cd4..3467a3b 100644 --- a/DHSoftware/Views/DetectControl.Designer.cs +++ b/DHSoftware/Views/DetectControl.Designer.cs @@ -3,14 +3,14 @@ partial class DetectControl { /// - /// 必需的设计器变量。 + /// 必需的设计器变量 /// private System.ComponentModel.IContainer components = null; /// - /// 清理所有正在使用的资源。 + /// 清理所有正在使用的资源 /// - /// 如果应释放托管资源,为 true;否则为 false。 + /// 如果应释放托管资源,为 true;否则为 false protected override void Dispose(bool disposing) { if (disposing && (components != null)) @@ -24,7 +24,7 @@ /// /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 + /// 使用代码编辑器修改此方法的内容 /// private void InitializeComponent() { @@ -41,9 +41,9 @@ preTable = new AntdUI.Table(); label3 = new AntdUI.Label(); btnPath = new AntdUI.Button(); - switch1 = new AntdUI.Switch(); + swtPre = new AntdUI.Switch(); label2 = new AntdUI.Label(); - iptPath = new AntdUI.Input(); + iptPrePath = new AntdUI.Input(); label1 = new AntdUI.Label(); tabPage2 = new AntdUI.TabPage(); btnLableDelete = new AntdUI.Button(); @@ -59,28 +59,26 @@ label6 = new AntdUI.Label(); switch5 = new AntdUI.Switch(); label12 = new AntdUI.Label(); - input1 = new AntdUI.Input(); + iptScore = new AntdUI.Input(); label5 = new AntdUI.Label(); flowPanel1 = new AntdUI.FlowPanel(); label11 = new AntdUI.Label(); - switch3 = new AntdUI.Switch(); + swIsAddStation = new AntdUI.Switch(); label10 = new AntdUI.Label(); stDetectType = new AntdUI.Select(); label9 = new AntdUI.Label(); btnCorrelatedCamera = new AntdUI.Button(); btnPath2 = new AntdUI.Button(); - switch2 = new AntdUI.Switch(); + swIsEnabled = new AntdUI.Switch(); label7 = new AntdUI.Label(); - iptPath2 = new AntdUI.Input(); + iptModelPath = new AntdUI.Input(); label8 = new AntdUI.Label(); tabPage3 = new AntdUI.TabPage(); tabPage4 = new AntdUI.TabPage(); - switch8 = new AntdUI.Switch(); btnSizeDel = new AntdUI.Button(); btnSizeAdd = new AntdUI.Button(); SizeTable = new AntdUI.Table(); label17 = new AntdUI.Label(); - label18 = new AntdUI.Label(); tabs1.SuspendLayout(); tabPage1.SuspendLayout(); tabPage2.SuspendLayout(); @@ -98,7 +96,6 @@ tabs1.Pages.Add(tabPage1); tabs1.Pages.Add(tabPage2); tabs1.Pages.Add(tabPage3); - tabs1.SelectedIndex = 2; tabs1.Size = new Size(915, 609); tabs1.Style = styleLine1; tabs1.TabIndex = 1; @@ -115,11 +112,11 @@ tabPage1.Controls.Add(preTable); tabPage1.Controls.Add(label3); tabPage1.Controls.Add(btnPath); - tabPage1.Controls.Add(switch1); + tabPage1.Controls.Add(swtPre); tabPage1.Controls.Add(label2); - tabPage1.Controls.Add(iptPath); + tabPage1.Controls.Add(iptPrePath); tabPage1.Controls.Add(label1); - tabPage1.Location = new Point(-909, -575); + tabPage1.Location = new Point(3, 31); tabPage1.Name = "tabPage1"; tabPage1.Size = new Size(909, 575); tabPage1.TabIndex = 0; @@ -222,14 +219,14 @@ btnPath.TabIndex = 7; btnPath.Text = "打开"; // - // switch1 + // swtPre // - switch1.CheckedText = "启用"; - switch1.Location = new Point(207, 33); - switch1.Name = "switch1"; - switch1.Size = new Size(82, 33); - switch1.TabIndex = 4; - switch1.UnCheckedText = "关闭"; + swtPre.CheckedText = "启用"; + swtPre.Location = new Point(207, 33); + swtPre.Name = "swtPre"; + swtPre.Size = new Size(82, 33); + swtPre.TabIndex = 4; + swtPre.UnCheckedText = "关闭"; // // label2 // @@ -239,22 +236,22 @@ label2.TabIndex = 3; label2.Text = "状 态"; // - // iptPath + // iptPrePath // - iptPath.Location = new Point(191, 79); - iptPath.Name = "iptPath"; - iptPath.PlaceholderText = "请点击打开按钮选择模型路径"; - iptPath.ReadOnly = true; - iptPath.Size = new Size(423, 42); - iptPath.TabIndex = 1; + iptPrePath.Location = new Point(191, 79); + iptPrePath.Name = "iptPrePath"; + iptPrePath.PlaceholderText = "请点击打开按钮选择预处理路径"; + iptPrePath.ReadOnly = true; + iptPrePath.Size = new Size(423, 42); + iptPrePath.TabIndex = 1; // // label1 // label1.Location = new Point(110, 89); label1.Name = "label1"; - label1.Size = new Size(75, 23); + label1.Size = new Size(86, 23); label1.TabIndex = 0; - label1.Text = "模型路径"; + label1.Text = "预处理路径"; // // tabPage2 // @@ -271,19 +268,19 @@ tabPage2.Controls.Add(label6); tabPage2.Controls.Add(switch5); tabPage2.Controls.Add(label12); - tabPage2.Controls.Add(input1); + tabPage2.Controls.Add(iptScore); tabPage2.Controls.Add(label5); tabPage2.Controls.Add(flowPanel1); tabPage2.Controls.Add(label11); - tabPage2.Controls.Add(switch3); + tabPage2.Controls.Add(swIsAddStation); tabPage2.Controls.Add(label10); tabPage2.Controls.Add(stDetectType); tabPage2.Controls.Add(label9); tabPage2.Controls.Add(btnCorrelatedCamera); tabPage2.Controls.Add(btnPath2); - tabPage2.Controls.Add(switch2); + tabPage2.Controls.Add(swIsEnabled); tabPage2.Controls.Add(label7); - tabPage2.Controls.Add(iptPath2); + tabPage2.Controls.Add(iptModelPath); tabPage2.Controls.Add(label8); tabPage2.Location = new Point(-909, -575); tabPage2.Name = "tabPage2"; @@ -416,14 +413,13 @@ label12.TabIndex = 36; label12.Text = "OK原图"; // - // input1 + // iptScore // - input1.Location = new Point(649, 24); - input1.Name = "input1"; - input1.PlaceholderText = ""; - input1.ReadOnly = true; - input1.Size = new Size(117, 42); - input1.TabIndex = 35; + iptScore.Location = new Point(649, 24); + iptScore.Name = "iptScore"; + iptScore.PlaceholderText = ""; + iptScore.Size = new Size(117, 42); + iptScore.TabIndex = 35; // // label5 // @@ -451,14 +447,14 @@ label11.TabIndex = 32; label11.Text = "关联相机"; // - // switch3 + // swIsAddStation // - switch3.CheckedText = "启用"; - switch3.Location = new Point(270, 26); - switch3.Name = "switch3"; - switch3.Size = new Size(82, 33); - switch3.TabIndex = 31; - switch3.UnCheckedText = "关闭"; + swIsAddStation.CheckedText = "启用"; + swIsAddStation.Location = new Point(270, 26); + swIsAddStation.Name = "swIsAddStation"; + swIsAddStation.Size = new Size(82, 33); + swIsAddStation.TabIndex = 31; + swIsAddStation.UnCheckedText = "关闭"; // // label10 // @@ -512,14 +508,14 @@ btnPath2.TabIndex = 20; btnPath2.Text = "打开"; // - // switch2 + // swIsEnabled // - switch2.CheckedText = "启用"; - switch2.Location = new Point(110, 26); - switch2.Name = "switch2"; - switch2.Size = new Size(82, 33); - switch2.TabIndex = 19; - switch2.UnCheckedText = "关闭"; + swIsEnabled.CheckedText = "启用"; + swIsEnabled.Location = new Point(110, 26); + swIsEnabled.Name = "swIsEnabled"; + swIsEnabled.Size = new Size(82, 33); + swIsEnabled.TabIndex = 19; + swIsEnabled.UnCheckedText = "关闭"; // // label7 // @@ -529,14 +525,14 @@ label7.TabIndex = 18; label7.Text = "状 态"; // - // iptPath2 + // iptModelPath // - iptPath2.Location = new Point(110, 75); - iptPath2.Name = "iptPath2"; - iptPath2.PlaceholderText = "请点击打开按钮选择模型路径"; - iptPath2.ReadOnly = true; - iptPath2.Size = new Size(656, 42); - iptPath2.TabIndex = 17; + iptModelPath.Location = new Point(110, 75); + iptModelPath.Name = "iptModelPath"; + iptModelPath.PlaceholderText = "请点击打开按钮选择模型路径"; + iptModelPath.ReadOnly = true; + iptModelPath.Size = new Size(656, 42); + iptModelPath.TabIndex = 17; // // label8 // @@ -549,7 +545,7 @@ // tabPage3 // tabPage3.Controls.Add(tabPage4); - tabPage3.Location = new Point(3, 31); + tabPage3.Location = new Point(-909, -575); tabPage3.Name = "tabPage3"; tabPage3.Size = new Size(909, 575); tabPage3.TabIndex = 3; @@ -557,27 +553,16 @@ // // tabPage4 // - tabPage4.Controls.Add(switch8); tabPage4.Controls.Add(btnSizeDel); tabPage4.Controls.Add(btnSizeAdd); tabPage4.Controls.Add(SizeTable); tabPage4.Controls.Add(label17); - tabPage4.Controls.Add(label18); tabPage4.Location = new Point(8, 8); tabPage4.Name = "tabPage4"; tabPage4.Size = new Size(909, 575); tabPage4.TabIndex = 1; tabPage4.Text = "预处理"; // - // switch8 - // - switch8.CheckedText = "启用"; - switch8.Location = new Point(120, 33); - switch8.Name = "switch8"; - switch8.Size = new Size(82, 33); - switch8.TabIndex = 11; - switch8.UnCheckedText = "关闭"; - // // btnSizeDel // btnSizeDel.BorderWidth = 2F; @@ -585,7 +570,7 @@ btnSizeDel.Ghost = true; btnSizeDel.IconRatio = 0.8F; btnSizeDel.IconSvg = resources.GetString("btnSizeDel.IconSvg"); - btnSizeDel.Location = new Point(747, 192); + btnSizeDel.Location = new Point(775, 192); btnSizeDel.Name = "btnSizeDel"; btnSizeDel.Size = new Size(80, 38); btnSizeDel.TabIndex = 10; @@ -598,7 +583,7 @@ btnSizeAdd.Ghost = true; btnSizeAdd.IconRatio = 0.8F; btnSizeAdd.IconSvg = resources.GetString("btnSizeAdd.IconSvg"); - btnSizeAdd.Location = new Point(747, 148); + btnSizeAdd.Location = new Point(775, 148); btnSizeAdd.Name = "btnSizeAdd"; btnSizeAdd.Size = new Size(80, 38); btnSizeAdd.TabIndex = 9; @@ -606,28 +591,21 @@ // // SizeTable // - SizeTable.Location = new Point(38, 118); + SizeTable.AutoSizeColumnsMode = AntdUI.ColumnsMode.Fill; + SizeTable.Location = new Point(38, 65); SizeTable.Name = "SizeTable"; - SizeTable.Size = new Size(686, 402); + SizeTable.Size = new Size(705, 455); SizeTable.TabIndex = 8; SizeTable.Text = "table1"; // // label17 // - label17.Location = new Point(38, 89); + label17.Location = new Point(38, 24); label17.Name = "label17"; label17.Size = new Size(91, 23); label17.TabIndex = 1; label17.Text = "配 置"; // - // label18 - // - label18.Location = new Point(38, 43); - label18.Name = "label18"; - label18.Size = new Size(91, 23); - label18.TabIndex = 3; - label18.Text = "状 态"; - // // DetectControl // AutoScaleDimensions = new SizeF(7F, 17F); @@ -635,6 +613,7 @@ Controls.Add(tabs1); Name = "DetectControl"; Size = new Size(915, 609); + Load += DetectControl_Load; tabs1.ResumeLayout(false); tabPage1.ResumeLayout(false); tabPage2.ResumeLayout(false); @@ -650,9 +629,9 @@ private AntdUI.TabPage tabPage2; private AntdUI.TabPage tabPage3; private AntdUI.Label label1; - private AntdUI.Input iptPath; + private AntdUI.Input iptPrePath; private AntdUI.Label label2; - private AntdUI.Switch switch1; + private AntdUI.Switch swtPre; private AntdUI.Button btnPath; private AntdUI.Label label3; private AntdUI.Button btnPreDelete; @@ -664,18 +643,18 @@ private AntdUI.Table PreOutTable; private AntdUI.Button btnCorrelatedCamera; private AntdUI.Button btnPath2; - private AntdUI.Switch switch2; + private AntdUI.Switch swIsEnabled; private AntdUI.Label label7; - private AntdUI.Input iptPath2; + private AntdUI.Input iptModelPath; private AntdUI.Label label8; private AntdUI.Select stDetectType; private AntdUI.Label label9; - private AntdUI.Switch switch3; + private AntdUI.Switch swIsAddStation; private AntdUI.Label label10; private AntdUI.Label label11; private AntdUI.FlowPanel flowPanel1; private AntdUI.Label label5; - private AntdUI.Input input1; + private AntdUI.Input iptScore; private AntdUI.Switch switch4; private AntdUI.Label label6; private AntdUI.Switch switch5; @@ -694,7 +673,5 @@ private AntdUI.Button btnSizeAdd; private AntdUI.Table SizeTable; private AntdUI.Label label17; - private AntdUI.Label label18; - private AntdUI.Switch switch8; } } diff --git a/DHSoftware/Views/DetectControl.cs b/DHSoftware/Views/DetectControl.cs index 7f0e54c..f774106 100644 --- a/DHSoftware/Views/DetectControl.cs +++ b/DHSoftware/Views/DetectControl.cs @@ -21,16 +21,198 @@ namespace DHSoftware.Views public partial class DetectControl : UserControl { Window window; + // DetectionConfig detectionConfig; + private DetectionConfig _config; + List relatedCameras = new List(); + + AntList PreTreatList; + AntList PreOutTreatList; + AntList DetectionLableList; + AntList SizeLableList; + PreTreatParam curPreTreat; + PreTreatParam curPreOutTreat; + DetectionLable curDetectionLable; + SizeTreatParam SizeParamLable; + public DetectionConfig detectionConfig + { + get => _config; + set + { + if (_config != null) + { + _config.PropertyChanged -= Config_PropertyChanged; // 解绑旧的 + } + + _config = value; + + if (_config != null) + { + _config.PropertyChanged += Config_PropertyChanged; // 绑定新的 + UpdateUI(); // 初始化 UI + } + } + } + private void Config_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + // 监听所有属性变化 + switch (e.PropertyName) + { + case nameof(DetectionConfig.IsAddStation): + swIsAddStation.Checked = _config.IsAddStation; + break; + case nameof(DetectionConfig.IsEnabled): + swIsEnabled.Checked = _config.IsEnabled; + break; + case nameof(DetectionConfig.ModelType): + stDetectType.SelectedIndex = (int)_config.ModelType-1; + break; + case nameof(DetectionConfig.ModelconfThreshold): + if (iptScore.InvokeRequired) + { + iptScore.Invoke(() => iptScore.Text = _config.ModelconfThreshold.ToString()); + } + else + { + iptScore.Text = _config.ModelconfThreshold.ToString(); + } + break; + + + case nameof(DetectionConfig.PreTreatCollects): + + break; + + } + } + + + private void UpdateUI() + { + if (_config == null) return; + + swIsAddStation.Checked = _config.IsAddStation; + swIsEnabled.Checked = _config.IsEnabled; + stDetectType.SelectedIndex = (int)_config.ModelType - 1; + iptScore.Text = _config.ModelconfThreshold.ToString(); + iptModelPath.Text = _config.ModelPath; + swtPre.Checked = _config.IsPreEnabled; + iptPrePath.Text = _config.HalconAlgorithemPath_Pre; + // textBoxName.Text = _config.Name; + // checkBoxEnableGPU.Checked = _config.IsEnableGPU; + } public DetectControl(Window _window) { window = _window; InitializeComponent(); + //this.detectionConfig = detectionConfig; //初始化表格列头 InitTableColumns(); - InitData(); - BindEventHandler(); - } + foreach (var item in MLModelTypes) + { + stDetectType.Items.Add(item.Key); + } + BindEventHandler(); + // 如果你的控件是通过设计器生成的,确保事件已经在设计器文件中绑定。 + swtPre.CheckedChanged += swtPre_CheckedChanged; // 确保控件的事件处理器被注册 + swIsAddStation.CheckedChanged += swIsAddStation_CheckedChanged; // 确保控件的事件处理器被注册 + swIsEnabled.CheckedChanged += swIsEnabled_CheckedChanged; // 确保控件的事件处理器被注册 + stDetectType.SelectedIndexChanged += stDetectType_SelectedIndexChanged; // 确保控件的事件处理器被注册 + iptScore.TextChanged += IptScore_TextChanged; + iptModelPath.TextChanged += IptModelPath_TextChanged; + } + private void IptScore_TextChanged(object sender, EventArgs e) + { + if (_config != null && !string.IsNullOrEmpty(iptScore.Text)) + { + if (float.TryParse(iptScore.Text, out float score) && _config.ModelconfThreshold != score) + { + _config.ModelconfThreshold = score; + } + else + { + iptScore.Text = _config.ModelconfThreshold.ToString(); + } + } + } + private void IptModelPath_TextChanged(object sender, EventArgs e) + { + if (_config != null && !string.IsNullOrEmpty(iptModelPath.Text)) + { + if ( _config.ModelPath != iptModelPath.Text) + { + _config.ModelPath = iptModelPath.Text; + } + else + { + iptModelPath.Text = _config.ModelPath; + } + } + } + private void stDetectType_SelectedIndexChanged(object sender, EventArgs e) + { + // 下拉选项变更事件处理 + + if (_config != null && stDetectType.SelectedIndex != -1) + { + // 防止循环更新 + if ((int)_config.ModelType != stDetectType.SelectedIndex + 1) + { + _config.ModelType = (MLModelType)(stDetectType.SelectedIndex + 1); + } + } + + } + private void swtPre_CheckedChanged(object sender, EventArgs e) + { + // 当用户改变控件的值时,更新数据模型的属性 + if (_config != null) + { + _config.IsPreEnabled = swtPre.Checked; + } + } + private void swIsAddStation_CheckedChanged(object sender, EventArgs e) + { + // 当用户改变控件的值时,更新数据模型的属性 + if (_config != null) + { + _config.IsAddStation = swIsAddStation.Checked; + } + } + private void swIsEnabled_CheckedChanged(object sender, EventArgs e) + { + // 当用户改变控件的值时,更新数据模型的属性 + if (_config != null) + { + _config.IsEnabled = swIsEnabled.Checked; + } + } + /// + /// 更新尺寸测量表格 + /// + private void UpdatePreTreatCollectsFromSizeTable() + { + // 假设 SizeLableList 是 SizeTable 的数据源 + List updatedPreTreatCollects = new List(); + + foreach (var sizeTreat in SizeLableList) + { + var preTreatCollect = new SizeTreatParam + { + IsEnable = sizeTreat.IsEnable, + PreName = sizeTreat.PreName, + PrePix = sizeTreat.PrePix, + PreType = sizeTreat.PreType, + ResultShow = sizeTreat.ResultShow, + OutResultShow = sizeTreat.OutResultShow + }; + + updatedPreTreatCollects.Add(preTreatCollect); + } + + // 将更新后的数据设置到 PreTreatCollects + detectionConfig.PreTreatCollects = updatedPreTreatCollects; + } private void BindEventHandler() { //预处理 @@ -46,6 +228,9 @@ namespace DHSoftware.Views //中处理 btnPath2.Click += BtnPath2_Click; btnCorrelatedCamera.Click += BtnCorrelatedCamera_Click; + + + btnPic.Click += BtnPic_Click; btnLableAdd.Click += BtnLableAdd_Click; btnLableDelete.Click += BtnLableDelete_Click; @@ -113,6 +298,8 @@ namespace DHSoftware.Views OnClose = () => { AntdUI.Message.info(window, "结束编辑", autoClose: 1); + + UpdatePreTreatCollectsFromSizeTable(); } }); break; @@ -120,6 +307,7 @@ namespace DHSoftware.Views var result = Modal.open(window, "删除警告!", "确认要删除选择的数据吗?", TType.Warn); if (result == DialogResult.OK) SizeLableList.Remove(sizeTreat); + UpdatePreTreatCollectsFromSizeTable(); break; case "进行测量": var sizeType = ((int)SizeParamLable.PreType).ToString(); @@ -150,7 +338,7 @@ namespace DHSoftware.Views MessageBox.Show("未定义的测量类型!"); break; } - + UpdatePreTreatCollectsFromSizeTable(); //使用clone可以防止table中的image被修改 //Preview.open(new Preview.Config(window, (Image)SizeParamLable.CellImages[0].Image.Clone())); break; @@ -237,7 +425,7 @@ namespace DHSoftware.Views //CellBadge = new CellBadge(SizeEnum.Circle.GetEnumDescription()), CellLinks = new CellLink[] { new CellButton(Guid.NewGuid().ToString(),"编辑",TTypeMini.Primary), - + new CellButton(Guid.NewGuid().ToString(),"删除",TTypeMini.Error), new CellButton(Guid.NewGuid().ToString(),"进行测量",TTypeMini.Primary) } @@ -260,7 +448,7 @@ namespace DHSoftware.Views } - List relatedCameras = new List(); + private void BtnCorrelatedCamera_Click(object? sender, EventArgs e) { @@ -274,37 +462,8 @@ namespace DHSoftware.Views if (form.submit) { flowPanel1.Controls.Clear(); - if (relatedCameras.Count > 0) - { - foreach (var item in relatedCameras) - { - var control = new AntdUI.Tag() - { - Font = new System.Drawing.Font("Microsoft YaHei UI", 9F), - Size = new Size(90, 42), - Text = item.CameraSourceId, - CloseIcon = true - }; - control.CloseChanged += (sender, e) => - { - var tag = sender as Tag; - foreach (var item in relatedCameras) - { - if (item.CameraSourceId.Equals(tag.Text)) - { - relatedCameras.Remove(item); - break; - } - } - return true; - - }; - // 通过主窗口设置DPI控制添加控件保持缩放比例 - window.AutoDpi(control); - flowPanel1.Controls.Add(control); - control.BringToFront(); - } - } + InitRelatedCamera(); + detectionConfig.CameraCollects=relatedCameras; } } @@ -329,8 +488,8 @@ namespace DHSoftware.Views { string filePath = openFileDialog.FileName; - iptPath2.Text = filePath; - + iptModelPath.Text = filePath; + _config.ModelPath = filePath; } } } @@ -398,7 +557,7 @@ namespace DHSoftware.Views { PreTreatParam preParam = new PreTreatParam() { - + CellLinks = new CellLink[] { new CellButton(Guid.NewGuid().ToString(),"编辑",TTypeMini.Primary), new CellButton(Guid.NewGuid().ToString(),"删除",TTypeMini.Error), @@ -500,37 +659,112 @@ namespace DHSoftware.Views } } - AntList PreTreatList; - AntList PreOutTreatList; - AntList DetectionLableList; - AntList SizeLableList; - PreTreatParam curPreTreat; - PreTreatParam curPreOutTreat; - DetectionLable curDetectionLable; - SizeTreatParam SizeParamLable; + + //加载相机 + private void InitRelatedCamera() + { + if (relatedCameras.Count > 0) + { + foreach (var item in relatedCameras) + { + var control = new AntdUI.Tag() + { + Font = new System.Drawing.Font("Microsoft YaHei UI", 9F), + Size = new Size(90, 42), + Text = item.CameraSourceId, + CloseIcon = true + }; + control.CloseChanged += (sender, e) => + { + var tag = sender as Tag; + foreach (var item in relatedCameras) + { + if (item.CameraSourceId.Equals(tag.Text)) + { + relatedCameras.Remove(item); + break; + } + } + detectionConfig.CameraCollects = relatedCameras; + return true; + + }; + // 通过主窗口设置DPI控制添加控件保持缩放比例 + window.AutoDpi(control); + flowPanel1.Controls.Add(control); + control.BringToFront(); + } + } + } + + private void InitData() { - PreTreatList = new AntList(); + relatedCameras = detectionConfig.CameraCollects; + InitRelatedCamera(); + // swIsAddStation. = detectionConfig.IsAddStation; + PreTreatList = new AntList(); + foreach (var item in detectionConfig.PreTreatParams) + { + PreTreatParam lable = item; + lable.CellLinks = new CellLink[] { + new CellButton(Guid.NewGuid().ToString(),"编辑",TTypeMini.Primary), + new CellButton(Guid.NewGuid().ToString(),"删除",TTypeMini.Error), + }; + PreTreatList.Add(lable); + } preTable.Binding(PreTreatList); PreOutTreatList = new AntList(); + foreach (var item in detectionConfig.OUTPreTreatParams) + { + PreTreatParam lable = item; + lable.CellLinks = new CellLink[] { + new CellButton(Guid.NewGuid().ToString(),"编辑",TTypeMini.Primary), + new CellButton(Guid.NewGuid().ToString(),"删除",TTypeMini.Error), + }; + PreOutTreatList.Add(lable); + } PreOutTable.Binding(PreOutTreatList); - foreach (var item in MLModelTypes) + + + DetectionLableList = new AntList(); + foreach (var item in detectionConfig.DetectionLableList) { - stDetectType.Items.Add(item.Key); + DetectionLable lable = item; + lable.CellLinks = new CellLink[] { + new CellButton(Guid.NewGuid().ToString(),"编辑",TTypeMini.Primary), + new CellButton(Guid.NewGuid().ToString(),"删除",TTypeMini.Error), + }; + DetectionLableList.Add(lable); } - DetectionLableList = new AntList(); lableTable.Binding(DetectionLableList); - SizeLableList = new AntList(); + // SizeLableList = new AntList(_config.PreTreatCollects); + foreach (var item in _config.PreTreatCollects) + { + + + item.CellLinks = new CellLink[] { + new CellButton(Guid.NewGuid().ToString(),"编辑",TTypeMini.Primary), + new CellButton(Guid.NewGuid().ToString(),"删除",TTypeMini.Error), + new CellButton(Guid.NewGuid().ToString(),"进行测量",TTypeMini.Primary) + }; + // SizeLableList.Add(item); + } + // 将 List 转换为 AntList + SizeLableList = new AntList(_config.PreTreatCollects); + + // 绑定转换后的数据到 SizeTable SizeTable.Binding(SizeLableList); + //SizeTable.Binding(_config.PreTreatCollects); } @@ -564,14 +798,16 @@ namespace DHSoftware.Views SizeTable.Columns = new ColumnCollection() { new ColumnCheck("Selected"){Fixed = true}, - new ColumnSwitch("IsEnable", "是否启用", ColumnAlign.Center), - new Column("PreName", "测量名称",ColumnAlign.Center), - new Column("PreType", "测量类型", ColumnAlign.Center), - new Column("PrePix", "阈值", ColumnAlign.Center), - new Column("ResultShow", "输入参数", ColumnAlign.Center), - new Column("OutResultShow", "输出参数", ColumnAlign.Center), - new Column("CellLinks", "操作", ColumnAlign.Center) + new ColumnSwitch("IsEnable", "是否启用") {Width = "10%" }, + new Column("PreName", "测量名称") { Width = "15%" }, + new Column("PreType", "测量类型") { Width = "10%" }, + new Column("PrePix", "阈值") { Width = "5%" }, + new Column("ResultShow", "输入参数") { Width = "15%" }, + new Column("OutResultShow", "输出参数") { Width = "15%" }, + new Column("CellLinks", "操作") { Width = "30%" } }; + + } private void btnPath_Click(object? sender, EventArgs e) @@ -590,7 +826,7 @@ namespace DHSoftware.Views { string filePath = openFileDialog.FileName; - iptPath.Text = filePath; + iptPrePath.Text = filePath; } } @@ -608,6 +844,12 @@ namespace DHSoftware.Views } + private void DetectControl_Load(object sender, EventArgs e) + { + InitData(); + + } + public static List> GetFilteredEnumDescriptionsAndValues() where T : Enum { return Enum.GetValues(typeof(T)) diff --git a/DHSoftware/Views/DetectionLableEdit.Designer.cs b/DHSoftware/Views/DetectionLableEdit.Designer.cs index d3382b5..d355a2a 100644 --- a/DHSoftware/Views/DetectionLableEdit.Designer.cs +++ b/DHSoftware/Views/DetectionLableEdit.Designer.cs @@ -3,14 +3,14 @@ partial class DetectionLableEdit { /// - /// 必需的设计器变量。 + /// 必需的设计器变量 /// private System.ComponentModel.IContainer components = null; /// - /// 清理所有正在使用的资源。 + /// 清理所有正在使用的资源 /// - /// 如果应释放托管资源,为 true;否则为 false。 + /// 如果应释放托管资源,为 true;否则为 false protected override void Dispose(bool disposing) { if (disposing && (components != null)) @@ -24,7 +24,7 @@ /// /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 + /// 使用代码编辑器修改此方法的内容 /// private void InitializeComponent() { diff --git a/DHSoftware/Views/PreTreatEdit.Designer.cs b/DHSoftware/Views/PreTreatEdit.Designer.cs index a5af8b4..f8fd38b 100644 --- a/DHSoftware/Views/PreTreatEdit.Designer.cs +++ b/DHSoftware/Views/PreTreatEdit.Designer.cs @@ -3,14 +3,14 @@ partial class PreTreatEdit { /// - /// 必需的设计器变量。 + /// 必需的设计器变量 /// private System.ComponentModel.IContainer components = null; /// - /// 清理所有正在使用的资源。 + /// 清理所有正在使用的资源 /// - /// 如果应释放托管资源,为 true;否则为 false。 + /// 如果应释放托管资源,为 true;否则为 false protected override void Dispose(bool disposing) { if (disposing && (components != null)) @@ -24,7 +24,7 @@ /// /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 + /// 使用代码编辑器修改此方法的内容 /// private void InitializeComponent() { diff --git a/DHSoftware/Views/PreTreatUserControl.Designer.cs b/DHSoftware/Views/PreTreatUserControl.Designer.cs index 49eda8e..d444fcf 100644 --- a/DHSoftware/Views/PreTreatUserControl.Designer.cs +++ b/DHSoftware/Views/PreTreatUserControl.Designer.cs @@ -3,14 +3,14 @@ partial class PreTreatUserControl { /// - /// 必需的设计器变量。 + /// 必需的设计器变量 /// private System.ComponentModel.IContainer components = null; /// - /// 清理所有正在使用的资源。 + /// 清理所有正在使用的资源 /// - /// 如果应释放托管资源,为 true;否则为 false。 + /// 如果应释放托管资源,为 true;否则为 false protected override void Dispose(bool disposing) { if (disposing && (components != null)) @@ -24,7 +24,7 @@ /// /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 + /// 使用代码编辑器修改此方法的内容 /// private void InitializeComponent() { diff --git a/DHSoftware/Views/SettingWindow1.Designer.cs b/DHSoftware/Views/SettingWindow1.Designer.cs index 75929e5..9c611af 100644 --- a/DHSoftware/Views/SettingWindow1.Designer.cs +++ b/DHSoftware/Views/SettingWindow1.Designer.cs @@ -102,6 +102,7 @@ menuItem1.IconSvg = "VideoCameraOutlined"; menuItem1.Text = "相机设置"; menuItem2.IconSvg = "AppstoreOutlined"; + menuItem2.ID = "Station"; menuItem2.Text = "工位设置"; menuItem3.IconSvg = "ControlOutlined"; menuItem3.Text = "运控设置"; @@ -161,6 +162,7 @@ Name = "SettingWindow1"; StartPosition = FormStartPosition.CenterScreen; Text = "SettingWinform"; + Load += SettingWindow1_Load; panel1.ResumeLayout(false); panel2.ResumeLayout(false); panel3.ResumeLayout(false); diff --git a/DHSoftware/Views/SettingWindow1.cs b/DHSoftware/Views/SettingWindow1.cs index 2429b38..bbe98a2 100644 --- a/DHSoftware/Views/SettingWindow1.cs +++ b/DHSoftware/Views/SettingWindow1.cs @@ -8,15 +8,20 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using AntdUI; +using AntdUIDemo.Models; +using DH.Process; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; +using Window = AntdUI.Window; namespace DHSoftware.Views { public partial class SettingWindow1 : Window { private UserControl currControl; - public SettingWindow1() + ProcessConfigBase DHconfig; + public SettingWindow1(ProcessConfigBase _DHconfig) { InitializeComponent(); - + DHconfig = _DHconfig; AntdUI.TooltipComponent tooltip = new AntdUI.TooltipComponent() { Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(134))), @@ -98,7 +103,115 @@ namespace DHSoftware.Views } bool isUpdatingTabs = false; - + private void InitDecetion() + { + MenuItem clickedItem = menu1.Items[1]; + switch (clickedItem.Text) + { + case "相机设置": + + break; + case "工位设置": + // 检查是否已存在同名 TabPage + //foreach (var tab in tabs1.Pages) + //{ + // if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}") + // { + // isUpdatingTabs = true; + // tabs1.SelectedTab = existingTab; // 直接跳转到已存在的 TabPage + // isUpdatingTabs = false; + // currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null; + // return; + // } + //} + foreach (var item in DHconfig.DetectionConfigCollection) + { + AddSubItem(clickedItem, item.Name); + DetectControl control = new DetectControl(this); + control.detectionConfig = item; + + if (control != null) + { + //容器添加控件,需要调整dpi + control.Dock = DockStyle.Fill; + AutoDpi(control); + AntdUI.TabPage tabPage = new AntdUI.TabPage() + { + Text = $"{clickedItem.Text}-{item.Name}", + }; + tabPage.Controls.Add(control); + tabs1.Pages.Add(tabPage); + isUpdatingTabs = true; + tabs1.SelectedTab = tabPage; + isUpdatingTabs = false; + currControl = control; + } + //tabs1.Pages[1]. + + } + + break; + + case "运控设置": + + break; + + + } + + } + private void LoadMenu(string filter = "") + { + menu1.Items.Clear(); + Dictionary> Menu_decetion = new Dictionary>(); + + + + string lang = AntdUI.Localization.CurrentLanguage; + var menuItems = DataUtil.Menu_decetion; + //var menuIcons = DataUtil.MenuIcons_zhcn; + //if (lang.StartsWith("en")) + //{ + // menuItems = DataUtil.MenuItems_enus; + // menuIcons = DataUtil.MenuIcons_enus; + //} + + foreach (var rootItem in Menu_decetion) + { + var rootKey = rootItem.Key.ToLower(); + var rootMenu = new AntdUI.MenuItem + { + Text = rootItem.Key, + //IconSvg = menuIcons.TryGetValue(rootItem.Key, out var icon) ? icon : "UnorderedListOutlined", + }; + bool rootVisible = false; // 用于标记是否显示根节点 + + foreach (var item in rootItem.Value) + { + var childText = item.Text.ToLower(); + + // 如果子节点包含搜索文本 + if (childText.Contains(filter)) + { + var menuItem = new AntdUI.MenuItem + { + Text = item.Text, + IconSvg = item.IconSvg, + Tag = item.Tag, + }; + rootMenu.Sub.Add(menuItem); + rootVisible = true; // 如果有子节点包含,则显示根节点 + } + } + + // 如果根节点包含搜索文本,或有可见的子节点,则显示根节点 + if (rootKey.Contains(filter) || rootVisible) + { + menu1.Items.Add(rootMenu); + } + } + } + private void menu1_MouseDown(object sender, MouseEventArgs e) { @@ -115,7 +228,7 @@ namespace DHSoftware.Views return; } - switch (clickedItem.PARENTITEM.Text) + switch (clickedItem.PARENTITEM.Text) { case "相机设置": @@ -157,11 +270,11 @@ namespace DHSoftware.Views case "运控设置": break; - - + + } } - } + } private MenuItem FindClickedItem(MenuItemCollection items, Point clickPoint) @@ -183,6 +296,11 @@ namespace DHSoftware.Views } return null; } + + private void SettingWindow1_Load(object sender, EventArgs e) + { + InitDecetion(); + } } } diff --git a/DHSoftware/Views/SettingWindow1.resx b/DHSoftware/Views/SettingWindow1.resx index 8b2ff64..af32865 100644 --- a/DHSoftware/Views/SettingWindow1.resx +++ b/DHSoftware/Views/SettingWindow1.resx @@ -1,7 +1,7 @@  @@ -24,8 +24,8 @@ + Windows 版本的列表 取消评论适当的元素, + Windows 将自动选择最兼容的环境 --> @@ -46,11 +46,11 @@ + 将应用程序设为感知长路径 请参阅 https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->