徐孝锋 8 месяцев назад
Родитель
Сommit
6d55124ce9

+ 8 - 6
TeamAAS-VM/Services/ConfigService.cs

@@ -40,6 +40,8 @@ namespace TeamAAS_VP.Services
             // Feeder清料任务配置路径
             public static readonly string FeederClearanceTasksConfigurationPath = "..//Config//FeederClearanceTasksConfiguration.cfg";
             // 光源控制器配置路径
+            public static readonly string LightControllersConfigurationPath = "..//Config//LightControllersConfiguration.cfg";
+            // 电批配置路径(单设备)
             public static readonly string ScrewDriverConfigurationPath = "..//Config//ScrewDriverConfiguration.cfg";
             // 螺丝供料器(物料)配置路径
             public static readonly string ScrewFeedersConfigurationPath = "..//Config//ScrewFeedersConfiguration.cfg";
@@ -179,14 +181,14 @@ namespace TeamAAS_VP.Services
                 }
 
                 // 读取光源控制器配置
-                if (!File.Exists(ConfigPaths.ScrewDriverConfigurationPath))
+                if (!File.Exists(ConfigPaths.LightControllersConfigurationPath))
                 {
                     LightControllers = new ObservableCollection<LightControllerConfig>();
-                    FileHelper.WriteJsonFile(LightControllers, ConfigPaths.ScrewDriverConfigurationPath);
+                    FileHelper.WriteJsonFile(LightControllers, ConfigPaths.LightControllersConfigurationPath);
                 }
                 else
                 {
-                    LightControllers = FileHelper.ReadJsonFile<ObservableCollection<LightControllerConfig>>(ConfigPaths.ScrewDriverConfigurationPath);
+                    LightControllers = FileHelper.ReadJsonFile<ObservableCollection<LightControllerConfig>>(ConfigPaths.LightControllersConfigurationPath);
                 }
                 // load plc addresses
                 var plcAddressPath = "..//Config//PlcAddressConfiguration.cfg";
@@ -894,7 +896,7 @@ namespace TeamAAS_VP.Services
                 }
             }
             // 持久化更新后的光源控制器配置
-            FileHelper.WriteJsonFile(LightControllers, ConfigPaths.ScrewDriverConfigurationPath);
+            FileHelper.WriteJsonFile(LightControllers, ConfigPaths.LightControllersConfigurationPath);
             return controller;
         }
 
@@ -927,7 +929,7 @@ namespace TeamAAS_VP.Services
                     LightControllers.Add(c);
                 }
             }
-            FileHelper.WriteJsonFile(LightControllers, ConfigPaths.ScrewDriverConfigurationPath);
+            FileHelper.WriteJsonFile(LightControllers, ConfigPaths.LightControllersConfigurationPath);
             return result;
         }
 
@@ -980,7 +982,7 @@ namespace TeamAAS_VP.Services
                 var ch = LightControllers.SelectMany(c => c.ChannelConfigs).FirstOrDefault(x => x.GlobalIndex == globalIndex);
                 if (ch == null) return false;
                 ch.DefaultBrightness = brightness;
-                FileHelper.WriteJsonFile(LightControllers, ConfigPaths.ScrewDriverConfigurationPath);
+                FileHelper.WriteJsonFile(LightControllers, ConfigPaths.LightControllersConfigurationPath);
                 return true;
             }
         }

+ 4 - 0
TeamAAS-VM/ViewModels/DebugMod/FocusAnalyzerViewModel.cs

@@ -215,6 +215,10 @@ namespace TeamAAS_VP.ViewModels.DebugMod
                     try
                     {
                         var image = Camera.Grab();
+                        if (image==null)
+                        {
+                            return;
+                        }
                         _currentMat = ImageHelper.ICogImageConvertMat(image);
                         // 转换为 WPF 可显示的位图并更新 UI 绑定
                         CurrentImage = _currentMat.ToBitmapSource();