From d51d2b0013013416eda0fa668bc1bbb38a620cfa Mon Sep 17 00:00:00 2001 From: "zhengxuan.zhang" Date: Mon, 25 May 2026 13:33:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9CNC=E6=A0=B7=E5=BC=8F=20?= =?UTF-8?q?=E2=88=9A=20=E9=9A=90=E8=97=8F=E6=A0=B9=E8=8A=82=E7=82=B9?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=BF=9D=E5=AD=98=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?0=20=E4=BF=AE=E6=94=B9=E4=B8=BA=E4=BD=8D=E7=BD=AE1---N=20?= =?UTF-8?q?=E2=88=9A=20=E8=BF=90=E8=A1=8C=E5=AF=B9=E4=B8=80=E7=BA=A7?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E8=BF=9B=E8=A1=8C=E9=87=8D=E5=91=BD=E5=90=8D?= =?UTF-8?q?=20=E2=88=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Cnc/CncExecutionService.cs | 6 +- XplorePlane/Services/Cnc/CncProgramService.cs | 4 +- .../DetectorFramePipelineService.cs | 10 +- .../ViewModels/Cnc/CncEditorViewModel.cs | 39 +- XplorePlane/Views/Cnc/CncPageView.xaml | 509 +++++++++++------- XplorePlane/Views/Cnc/CncPageView.xaml.cs | 202 +++++-- .../ImageProcessing/PipelineEditorView.xaml | 4 +- XplorePlane/Views/Main/MainWindow.xaml | 2 +- 8 files changed, 497 insertions(+), 279 deletions(-) diff --git a/XplorePlane/Services/Cnc/CncExecutionService.cs b/XplorePlane/Services/Cnc/CncExecutionService.cs index 671037b..66aea22 100644 --- a/XplorePlane/Services/Cnc/CncExecutionService.cs +++ b/XplorePlane/Services/Cnc/CncExecutionService.cs @@ -722,9 +722,9 @@ namespace XplorePlane.Services.Cnc var manualImage = _mainViewportService?.LatestManualImage as BitmapSource; if (manualImage != null) { - _logger.ForModule().Info( - "[图像链路] TryGetSourceImage:从 MainViewportService.LatestManualImage 获取图像,尺寸 {W}x{H}", - manualImage.PixelWidth, manualImage.PixelHeight); + //_logger.ForModule().Info( + // "[图像链路] TryGetSourceImage:从 MainViewportService.LatestManualImage 获取图像,尺寸 {W}x{H}", + // manualImage.PixelWidth, manualImage.PixelHeight); return manualImage; } diff --git a/XplorePlane/Services/Cnc/CncProgramService.cs b/XplorePlane/Services/Cnc/CncProgramService.cs index 01edd34..d922e9b 100644 --- a/XplorePlane/Services/Cnc/CncProgramService.cs +++ b/XplorePlane/Services/Cnc/CncProgramService.cs @@ -374,8 +374,8 @@ namespace XplorePlane.Services.Cnc result.Add(indexedNode switch { ReferencePointNode referencePointNode => referencePointNode with { Name = $"\u53C2\u8003\u70B9_{referencePointNumber++}" }, - SavePositionNode savePositionNode => savePositionNode with { Name = $"\u4FDD\u5B58\u4F4D\u7F6E_{savePositionNumber++}" }, - InspectionModuleNode inspectionModuleNode => inspectionModuleNode with { Name = $"\u68C0\u6D4B\u6A21\u5757_{inspectionModuleNumber++}" }, + SavePositionNode savePositionNode => savePositionNode with { Name = $"\u4F4D\u7F6E{++savePositionNumber}" }, + InspectionModuleNode inspectionModuleNode => inspectionModuleNode with { Name = $"\u6A21\u5757{++inspectionModuleNumber}" }, _ => indexedNode }); } diff --git a/XplorePlane/Services/MainViewport/DetectorFramePipelineService.cs b/XplorePlane/Services/MainViewport/DetectorFramePipelineService.cs index 03c70f5..fbd1588 100644 --- a/XplorePlane/Services/MainViewport/DetectorFramePipelineService.cs +++ b/XplorePlane/Services/MainViewport/DetectorFramePipelineService.cs @@ -77,11 +77,11 @@ namespace XplorePlane.Services.MainViewport try { - _logger.Info( - "[图像链路] DetectorFramePipeline 收到帧 #{N},分辨率 {W}x{H},采集时间 {T},当前队列深度 AcquireQ={AQ} ProcessQ={PQ}", - args.FrameNumber, args.Width, args.Height, - args.CaptureTime.ToString("HH:mm:ss.fff"), - AcquireQueueCount, ProcessQueueCount); + //_logger.Info( + // "[图像链路] DetectorFramePipeline 收到帧 #{N},分辨率 {W}x{H},采集时间 {T},当前队列深度 AcquireQ={AQ} ProcessQ={PQ}", + // args.FrameNumber, args.Width, args.Height, + // args.CaptureTime.ToString("HH:mm:ss.fff"), + // AcquireQueueCount, ProcessQueueCount); var rawPixels = new ushort[args.ImageData.Length]; Array.Copy(args.ImageData, rawPixels, rawPixels.Length); diff --git a/XplorePlane/ViewModels/Cnc/CncEditorViewModel.cs b/XplorePlane/ViewModels/Cnc/CncEditorViewModel.cs index 13a55ea..fd9a1a4 100644 --- a/XplorePlane/ViewModels/Cnc/CncEditorViewModel.cs +++ b/XplorePlane/ViewModels/Cnc/CncEditorViewModel.cs @@ -1005,15 +1005,50 @@ namespace XplorePlane.ViewModels.Cnc result.Add(indexedNode switch { ReferencePointNode referencePointNode => referencePointNode with { Name = $"\u53C2\u8003\u70B9_{referencePointNumber++}" }, - SavePositionNode savePositionNode => savePositionNode with { Name = $"\u4FDD\u5B58\u4F4D\u7F6E_{savePositionNumber++}" }, - InspectionModuleNode inspectionModuleNode => inspectionModuleNode with { Name = $"\u68C0\u6D4B\u6A21\u5757_{inspectionModuleNumber++}" }, + // 保存位置:用户自定义名称时保留,否则用"位置N"(1-based) + SavePositionNode savePositionNode => IsDefaultSavePositionName(savePositionNode.Name) + ? savePositionNode with { Name = $"\u4F4D\u7F6E{++savePositionNumber}" } + : (CncNode)(savePositionNode with { Index = i }), + // 检测模块:用户自定义名称时保留,否则用"模块N"(1-based) + InspectionModuleNode inspectionModuleNode => IsDefaultInspectionModuleName(inspectionModuleNode.Name) + ? inspectionModuleNode with { Name = $"\u6A21\u5757{++inspectionModuleNumber}" } + : (CncNode)(inspectionModuleNode with { Index = i }), _ => indexedNode }); + // 无论是否重命名,计数器都要递增以保持后续编号连续 + if (indexedNode is SavePositionNode sp && !IsDefaultSavePositionName(sp.Name)) + savePositionNumber++; + if (indexedNode is InspectionModuleNode im && !IsDefaultInspectionModuleName(im.Name)) + inspectionModuleNumber++; } return result.AsReadOnly(); } + /// 判断是否为系统默认的保存位置名称("位置N" 格式) + private static bool IsDefaultSavePositionName(string name) + { + if (string.IsNullOrWhiteSpace(name)) return true; + if (name.StartsWith("\u4F4D\u7F6E", StringComparison.Ordinal)) + return int.TryParse(name[2..], out _); + // 兼容旧格式 "保存位置_N" + if (name.StartsWith("\u4FDD\u5B58\u4F4D\u7F6E_", StringComparison.Ordinal)) + return true; + return false; + } + + /// 判断是否为系统默认的检测模块名称("模块N" 或旧格式 "检测模块_N") + private static bool IsDefaultInspectionModuleName(string name) + { + if (string.IsNullOrWhiteSpace(name)) return true; + if (name.StartsWith("\u6A21\u5757", StringComparison.Ordinal)) + return int.TryParse(name[2..], out _); + // 兼容旧格式 "检测模块_N" + if (name.StartsWith("\u68C0\u6D4B\u6A21\u5757_", StringComparison.Ordinal)) + return true; + return false; + } + private static bool IsSavePositionChild(CncNodeType type) { return type is CncNodeType.InspectionMarker diff --git a/XplorePlane/Views/Cnc/CncPageView.xaml b/XplorePlane/Views/Cnc/CncPageView.xaml index 91487ce..a3d8dfa 100644 --- a/XplorePlane/Views/Cnc/CncPageView.xaml +++ b/XplorePlane/Views/Cnc/CncPageView.xaml @@ -20,18 +20,105 @@ - + - - + + Microsoft YaHei UI + + + + + + - + - - - - - + CornerRadius="6" + SnapsToDevicePixels="True"> + - - + - - - - - - - - - - - - - - -