diff --git a/XplorePlane/App.xaml.cs b/XplorePlane/App.xaml.cs index e8505ef..955dcc6 100644 --- a/XplorePlane/App.xaml.cs +++ b/XplorePlane/App.xaml.cs @@ -32,7 +32,6 @@ using XP.Common.Logging.Interfaces; using XP.Common.Module; using XP.Hardware.Detector.Module; using XP.Hardware.Detector.Services; -using XP.Hardware.Detector.Services; using XP.Hardware.MotionControl.Module; using XP.Hardware.Plc.Abstractions; using XP.Hardware.PLC; @@ -69,7 +68,7 @@ namespace XplorePlane { protected override void OnStartup(StartupEventArgs e) { - // 设置 Telerik Windows11 主题,缩尝 Ribbon 整体尺寸 + // 设置 Telerik Windows11 主题,缩小 Ribbon 整体尺寸 StyleManager.ApplicationTheme = new Windows11Theme(); // 强制使用中文 UI,确保 ImageProcessing 库显示中文 @@ -79,10 +78,10 @@ namespace XplorePlane CultureInfo.DefaultThreadCurrentCulture = zhCN; CultureInfo.DefaultThreadCurrentUICulture = zhCN; - // 酝置 Serilog 日志系统 + // 配置 Serilog 日志系统 ConfigureLogging(); - // 杕获未处睆的异常 + // 捕获未处理的异常 AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; DispatcherUnhandledException += OnDispatcherUnhandledException; @@ -118,24 +117,24 @@ namespace XplorePlane private void ConfigureLogging() { - // 加载 Serilog 酝置 | Load Serilog configuration + // 加载 Serilog 配置 | Load Serilog configuration SerilogConfig serilogConfig = LoggingConfigLoader.LoadSerilogConfig(); // 初始化 Serilog(全局唯一)| Initialize Serilog (global singleton) SerilogInitializer.Initialize(serilogConfig); - // 记录应用坯动日志 | Log application startup + // 记录应用启动日志 | Log application startup Log.Information("========================================"); - Log.Information("XplorePlane 应用程庝坯动"); + Log.Information("XplorePlane 应用程序启动"); Log.Information("========================================"); } protected override void OnExit(ExitEventArgs e) { Log.Information("========================================"); - Log.Information("XplorePlane 应用程庝退出"); + Log.Information("XplorePlane 应用程序退出"); Log.Information("========================================"); - // 释放全局状思朝务资溝 + // 释放全局状态服务资源 try { var bootstrapper = AppBootstrapper.Instance; @@ -143,15 +142,15 @@ namespace XplorePlane { var appStateService = bootstrapper.Container.Resolve(); appStateService?.Dispose(); - Log.Information("全局状思朝务资溝已释放"); + Log.Information("全局状态服务资源已释放"); } } catch (Exception ex) { - Log.Error(ex, "全局状思朝务资溝释放失败"); + Log.Error(ex, "全局状态服务资源释放失败"); } - // 释放射线溝资溝 + // 释放射线源资源 try { var bootstrapper = AppBootstrapper.Instance; @@ -159,15 +158,15 @@ namespace XplorePlane { var raySourceService = bootstrapper.Container.Resolve(); raySourceService?.Dispose(); - Log.Information("射线溝资溝已释放"); + Log.Information("射线源资源已释放"); } } catch (Exception ex) { - Log.Error(ex, "射线溝资溝释放失败"); + Log.Error(ex, "射线源资源释放失败"); } - // 先坜止导航相机实时采集,冝释放资溝,靿兝回调死锝 + // 先停止导航相机实时采集,再释放资源,避免回调死锁 try { var bootstrapper = AppBootstrapper.Instance; @@ -183,7 +182,7 @@ namespace XplorePlane Log.Error(ex, "导航相机 ViewModel 释放失败"); } - // 释放导航相机朝务资溝 + // 释放导航相机服务资源 try { var bootstrapper = AppBootstrapper.Instance; @@ -191,15 +190,15 @@ namespace XplorePlane { var cameraService = bootstrapper.Container.Resolve(); cameraService?.Dispose(); - Log.Information("导航相机朝务资溝已释放"); + Log.Information("导航相机服务资源已释放"); } } catch (Exception ex) { - Log.Error(ex, "导航相机朝务资溝释放失败"); + Log.Error(ex, "导航相机服务资源释放失败"); } - // 释放主界面探测器帧浝水线资溝 + // 释放主界面探测器帧流水线资源 try { var bootstrapper = AppBootstrapper.Instance; @@ -207,31 +206,31 @@ namespace XplorePlane { var detectorFramePipelineService = bootstrapper.Container.Resolve(); detectorFramePipelineService?.Dispose(); - Log.Information("主界面探测器帧浝水线资溝已释放"); + Log.Information("主界面探测器帧流水线资源已释放"); } } catch (Exception ex) { - Log.Error(ex, "主界面探测器帧浝水线资溝释放失败"); + Log.Error(ex, "主界面探测器帧流水线资源释放失败"); } - // 释放SQLite数杮库资溝 | Release SQLite database resources + // 释放SQLite数据库资源 | Release SQLite database resources try { var bootstrapper = AppBootstrapper.Instance; if (bootstrapper != null) { - var dbContext = bootstrapper.Container.Resolve(); // 从 Prism 容器获坖 IDbContext 实例(坕例)| Get IDbContext instance from Prism container (singleton) + var dbContext = bootstrapper.Container.Resolve(); // 从 Prism 容器获取 IDbContext 实例(单例)| Get IDbContext instance from Prism container (singleton) dbContext?.Dispose(); - Log.Information("数杮库资溝已戝功释放 | Database resources released successfully"); + Log.Information("数据库资源已成功释放 | Database resources released successfully"); } } catch (Exception ex) { - Log.Error(ex, "数杮库资溝释放失败,忽略该错误继续退出 | Database resource release failed, ignoring error and continuing exit"); + Log.Error(ex, "数据库资源释放失败,忽略该错误继续退出 | Database resource release failed, ignoring error and continuing exit"); } - // 释放 PLC 资溝 + // 释放 PLC 资源 try { var bootstrapper = AppBootstrapper.Instance; @@ -239,15 +238,15 @@ namespace XplorePlane { var plcService = bootstrapper.Container.Resolve(); plcService?.Dispose(); - Log.Information("PLC 资溝已释放"); + Log.Information("PLC 资源已释放"); } } catch (Exception ex) { - Log.Error(ex, "PLC 资溝释放失败"); + Log.Error(ex, "PLC 资源释放失败"); } - // 释放探测器资溝 + // 释放探测器资源 try { var bootstrapper = AppBootstrapper.Instance; @@ -255,15 +254,15 @@ namespace XplorePlane { var detectorService = bootstrapper.Container.Resolve(); detectorService?.Dispose(); - Log.Information("探测器资溝已释放"); + Log.Information("探测器资源已释放"); } } catch (Exception ex) { - Log.Error(ex, "探测器资溝释放失败"); + Log.Error(ex, "探测器资源释放失败"); } - // 释放录制朝务资溝 + // 释放录制服务资源 try { var bootstrapper = AppBootstrapper.Instance; @@ -271,24 +270,24 @@ namespace XplorePlane { var recordingService = bootstrapper.Container.Resolve(); recordingService?.Dispose(); - Log.Information("录制朝务资溝已释放"); + Log.Information("录制服务资源已释放"); } } catch (Exception ex) { - Log.Error(ex, "录制朝务资溝释放失败"); + Log.Error(ex, "录制服务资源释放失败"); } Log.CloseAndFlush(); base.OnExit(e); } /// - /// 处睆未杕获的异常 + /// 处理未捕获的异常 /// private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e) { var exception = e.ExceptionObject as Exception; - Log.Fatal(exception, "应用程庝坑生未处睆的异常"); + Log.Fatal(exception, "应用程序发生未处理的异常"); MessageBox.Show( $"A fatal error has occurred:\n\n{exception?.Message}\n\nPlease check the log file for details.", @@ -298,11 +297,11 @@ namespace XplorePlane } /// - /// 处睆 UI 线程未杕获的异常 + /// 处理 UI 线程未捕获的异常 /// private void OnDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { - Log.Error(e.Exception, "UI 线程坑生未处睆的异常"); + Log.Error(e.Exception, "UI 线程发生未处理的异常"); MessageBox.Show( $"An error has occurred:\n\n{e.Exception.Message}\n\nPlease check the log file for details.", @@ -310,7 +309,7 @@ namespace XplorePlane MessageBoxButton.OK, MessageBoxImage.Error); - // 标记为已处睆,防止应用程庝崩溃 + // 标记为已处理,防止应用程序崩溃 e.Handled = true; } } @@ -332,7 +331,7 @@ namespace XplorePlane protected override Window CreateShell() { - // 杝剝初始化模块,确保硬件朝务在 MainWindow XAML 解枝剝已注册 + // 提前初始化模块,确保硬件服务在 MainWindow XAML 解析前已注册 if (!_modulesInitialized) { base.InitializeModules(); @@ -348,26 +347,26 @@ namespace XplorePlane var shell = Container.Resolve(); - // 主窗坣加载完戝坎冝连接相机,确保所有模块和原生 DLL 已完戝初始化 + // 主窗体加载完成后再连接相机,确保所有模块和原生 DLL 已完成初始化 shell.Loaded += async (s, e) => { - // [DEV] 导航相机连接已屝蔽,开坑阶段跳过以加快坯动速度 + // [DEV] 导航相机连接已屏蔽,开发阶段跳过以加快启动速度 // TryConnectCamera(); - // 初始化主界面探测器帧浝水线,开始接收探测器图僝事件 + // 初始化主界面探测器帧流水线,开始接收探测器图像事件 try { _ = Container.Resolve(); } catch (Exception ex) { - Log.Error(ex, "初始化主界面探测器帧浝水线失败"); + Log.Error(ex, "初始化主界面探测器帧流水线失败"); } - // 若酝置为模拟探测器,自动初始化并坯动采集(无需用户手动擝作) + // 若配置为模拟探测器,自动初始化并启动采集(无需用户手动操作) await TryAutoStartSimulatedDetectorAsync(); - // [DEV] 相机状思通知已屝蔽 + // [DEV] 相机状态通知已屏蔽 // try // { // var cameraVm = Container.Resolve(); @@ -388,9 +387,8 @@ namespace XplorePlane } /// -<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< private async System.Threading.Tasks.Task TryAutoStartSimulatedDetectorAsync() { @@ -410,27 +408,26 @@ namespace XplorePlane Log.Error("SimulatedDetector 自动初始化失败:{Msg}", initResult.ErrorMessage); return; } - Log.Information("[SimulatedDetector] 初始化戝功,坯动连续采集..."); + Log.Information("[SimulatedDetector] 初始化成功,启动连续采集..."); var startResult = await detectorService.StartAcquisitionAsync(); if (!startResult.IsSuccess) { - Log.Error("SimulatedDetector 坯动采集失败:{Msg}", startResult.ErrorMessage); + Log.Error("SimulatedDetector 启动采集失败:{Msg}", startResult.ErrorMessage); return; } - Log.Information("[SimulatedDetector] 连续采集已坯动,帧将以 5 fps 挝续坑布"); + Log.Information("[SimulatedDetector] 连续采集已启动,帧将以 5 fps 持续发布"); } catch (Exception ex) { - Log.Error(ex, "SimulatedDetector 自动坯动异常"); + Log.Error(ex, "SimulatedDetector 自动启动异常"); } } /// -====================================AUTO GENERATED BY CONFLICT EXTENSION==================================== - /// 执行授权检查,授权失败时显示错误消杯 | Perform license check, show error message on failure + /// 执行授权检查,授权失败时显示错误消息 | Perform license check, show error message on failure /// - /// 授权是坦戝功 | Whether authorization succeeded + /// 授权是否成功 | Whether authorization succeeded private bool PerformLicenseCheck() { try @@ -449,7 +446,7 @@ namespace XplorePlane return false; } - // 临时测试模弝专属:订阅倒计时事件并杝示 | Temporary test mode only: subscribe countdown events and notify + // 临时测试模式专属:订阅倒计时事件并提示 | Temporary test mode only: subscribe countdown events and notify if (licenseService.LicenseMode == XP.Common.License.Enums.LicenseMode.TemporaryTest) { licenseService.TestModeWarning5Min += OnTestModeWarning5Min; @@ -457,8 +454,8 @@ namespace XplorePlane licenseService.TestModeTimeout += OnTestModeTimeout; MessageBox.Show( - "当剝为临时测试模弝,软件将在15分钟坎自动关闭。\nCurrently in temporary test mode, the software will automatically shut down after 15 minutes.", - "临时测试模弝 | Temporary Test Mode", + "当前为临时测试模式,软件将在15分钟后自动关闭。\nCurrently in temporary test mode, the software will automatically shut down after 15 minutes.", + "临时测试模式 | Temporary Test Mode", MessageBoxButton.OK, MessageBoxImage.Information); } @@ -468,7 +465,7 @@ namespace XplorePlane } catch (Exception ex) { - Log.Error(ex, "授权检查过程中坑生异常 | Exception during authorization check"); + Log.Error(ex, "授权检查过程中发生异常 | Exception during authorization check"); MessageBox.Show( $"授权检查异常 | Authorization check exception: {ex.Message}", "授权失败 | Authorization Failed", @@ -479,54 +476,53 @@ namespace XplorePlane } /// - /// 处睆临时测试模弝剩余5分钟警告 | Handle temporary test mode 5-minute warning + /// 处理临时测试模式剩余5分钟警告 | Handle temporary test mode 5-minute warning /// private void OnTestModeWarning5Min(object? sender, EventArgs e) { Application.Current.Dispatcher.Invoke(() => { - Log.Warning("临时测试模弝剩余5分钟 | Temporary test mode: 5 minutes remaining"); + Log.Warning("临时测试模式剩余5分钟 | Temporary test mode: 5 minutes remaining"); MessageBox.Show( - "临时测试模弝将在5分钟坎到期,请尽快保存您的工作。\nTemporary test mode will expire in 5 minutes, please save your work.", - "测试模弝杝醒 | Test Mode Reminder", + "临时测试模式将在5分钟后到期,请尽快保存您的工作。\nTemporary test mode will expire in 5 minutes, please save your work.", + "测试模式提醒 | Test Mode Reminder", MessageBoxButton.OK, MessageBoxImage.Information); }); } /// - /// 处睆临时测试模弝剩余1分钟警告 | Handle temporary test mode 1-minute warning + /// 处理临时测试模式剩余1分钟警告 | Handle temporary test mode 1-minute warning /// private void OnTestModeWarning1Min(object? sender, EventArgs e) { Application.Current.Dispatcher.Invoke(() => { - Log.Warning("临时测试模弝剩余1分钟 | Temporary test mode: 1 minute remaining"); + Log.Warning("临时测试模式剩余1分钟 | Temporary test mode: 1 minute remaining"); MessageBox.Show( - "临时测试模弝将在1分钟坎到期,软件坳将关闭,请立坳保存您的工作。\nTemporary test mode will expire in 1 minute, the software will shut down soon. Please save your work immediately.", - "测试模弝坳将到期 | Test Mode Expiring", + "临时测试模式将在1分钟后到期,软件即将关闭,请立即保存您的工作。\nTemporary test mode will expire in 1 minute, the software will shut down soon. Please save your work immediately.", + "测试模式即将到期 | Test Mode Expiring", MessageBoxButton.OK, MessageBoxImage.Warning); }); } /// - /// 处睆临时测试模弝超时事件(执行正常关闭浝程)| Handle temporary test mode timeout event (perform graceful shutdown) + /// 处理临时测试模式超时事件(执行正常关闭流程)| Handle temporary test mode timeout event (perform graceful shutdown) /// private void OnTestModeTimeout(object? sender, EventArgs e) { Application.Current.Dispatcher.Invoke(() => { - Log.Warning("临时测试模弝已超时,执行正常关闭浝程 | Temporary test mode timed out, performing graceful shutdown"); - // 使用正常关闭浝程,确保资溝正确释放 | Use graceful shutdown to ensure proper resource release + Log.Warning("临时测试模式已超时,执行正常关闭流程 | Temporary test mode timed out, performing graceful shutdown"); + // 使用正常关闭流程,确保资源正确释放 | Use graceful shutdown to ensure proper resource release Application.Current.MainWindow?.Close(); }); } /// ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>AUTO GENERATED BY CONFLICT EXTENSION>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Feature/TURBO-621-License /// 在主线程上检索并连接导航相机。 - /// pylon SDK 覝求在主线程(STA)上擝作,丝能放到坎坰线程。 + /// pylon SDK 要求在主线程(STA)上操作,不能放到后台线程。 /// private void TryConnectCamera() { @@ -540,7 +536,7 @@ namespace XplorePlane catch (DeviceNotFoundException) { Log.Warning("未检测到导航相机"); - _cameraError = "未检测到导航相机,请检查连接坎針坯软件。"; + _cameraError = "未检测到导航相机,请检查连接后重启软件。"; } catch (Exception ex) { @@ -550,7 +546,7 @@ namespace XplorePlane } /// - /// 模块已在 CreateShell 中杝剝初始化,此处跳过靿兝針夝加载 + /// 模块已在 CreateShell 中提前初始化,此处跳过避免重复加载 /// protected override void InitializeModules() { @@ -566,7 +562,7 @@ namespace XplorePlane // 注册 Serilog 的 ILogger 实例 containerRegistry.RegisterInstance(Log.Logger); - // 注册 XP.Common.ILoggerService 适酝器 + // 注册 XP.Common.ILoggerService 适配器 containerRegistry.RegisterSingleton(); // 注册视图和视图模型 @@ -575,44 +571,44 @@ namespace XplorePlane containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); - // 注册图僝处睆朝务与视图 + // 注册图像处理服务与视图 containerRegistry.RegisterSingleton(); containerRegistry.Register(); - // 注册浝水线朝务(坕例,共享 IImageProcessingService) + // 注册流水线服务(单例,共享 IImageProcessingService) containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); - // 注册全局状思朝务(坕例) + // 注册全局状态服务(单例) containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); containerRegistry.Register(); containerRegistry.Register(); - // 注册检测酝方朝务(坕例) + // 注册检测配方服务(单例) containerRegistry.RegisterSingleton(); - // 注册浝水线 ViewModel(毝次解枝创建新实例) + // 注册流水线 ViewModel(每次解析创建新实例) containerRegistry.Register(); containerRegistry.Register(); - // 注册硬件库的 ViewModel(供 ViewModelLocator 自动装酝) + // 注册硬件库的 ViewModel(供 ViewModelLocator 自动装配) containerRegistry.Register(); - // 注册 SQLite 酝置和数杮库上下文(FilamentLifetimeService 依赖) + // 注册 SQLite 配置和数据库上下文(FilamentLifetimeService 依赖) var sqliteConfig = DatabaseConfigLoader.LoadSqliteConfig(); containerRegistry.RegisterInstance(sqliteConfig); containerRegistry.RegisterSingleton(); - // 注册通用模块的朝务(本地化〝Dump) + // 注册通用模块的服务(本地化、Dump) containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(() => DumpConfigLoader.LoadDumpConfig()); containerRegistry.RegisterSingleton(); - // ── CNC / 矩阵编排 / 测針数杮朝务(坕例)── + // ── CNC / 矩阵编排 / 测量数据服务(单例)── containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); @@ -620,11 +616,11 @@ namespace XplorePlane containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); - // ── 主界面实时图僝 / 探测器坌队列朝务(坕例)── + // ── 主界面实时图像 / 探测器双队列服务(单例)── containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); - // ── CNC / 矩阵 ViewModel(瞬思)── + // ── CNC / 矩阵 ViewModel(瞬态)── containerRegistry.Register(); containerRegistry.Register(); containerRegistry.Register(); @@ -635,21 +631,21 @@ namespace XplorePlane containerRegistry.RegisterForNavigation(); containerRegistry.Register(); - // ── 导航相机朝务(坕例)── + // ── 导航相机服务(单例)── containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(() => new CameraFactory().CreateController("Basler")); containerRegistry.RegisterSingleton(); - // ── 录制朝务(坕例)── + // ── 录制服务(单例)── containerRegistry.RegisterSingleton(); - Log.Information("依赖注入容器酝置完戝"); + Log.Information("依赖注入容器配置完成"); } protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog) { - // 所有模块朝务已在 RegisterTypes 中手动注册 + // 所有模块服务已在 RegisterTypes 中手动注册 // CommonModule: ILocalizationService, IDumpService // RaySourceModule: IRaySourceService, IRaySourceFactory, IFilamentLifetimeService