From 9b2ad9bafb0739f8ba1e76107011fada5e5883c3 Mon Sep 17 00:00:00 2001
From: C3204 <zhengyabo@lanpucloud.cn>
Date: 星期五, 10 四月 2026 16:23:08 +0800
Subject: [PATCH] 修复LB3D相机参数设置问题以及新增兰宝3D相机参数存储在本地以及初始化给相机参数。

---
 LB_SmartVision/VisionForm.cs |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 58 insertions(+), 1 deletions(-)

diff --git a/LB_SmartVision/VisionForm.cs b/LB_SmartVision/VisionForm.cs
index aa8fae8..a68e3f2 100644
--- a/LB_SmartVision/VisionForm.cs
+++ b/LB_SmartVision/VisionForm.cs
@@ -14,6 +14,7 @@
 using LB_SmartVision.ProcessRun;
 using LB_SmartVision.SQL;
 using LB_SmartVision.Tool;
+using LB_SmartVisionCameraDevice.PHM6000;
 using LB_SmartVisionCommon;
 using LB_SmartVisionLoginUI;
 using LB_VisionProcesses;
@@ -755,6 +756,15 @@
             LB_SmartVision.Tool.Tool.ReadStringConfig("User ID", out string User_ID);
             LB_SmartVision.Tool.Tool.ReadStringConfig("Password", out string Password);
             GlobalVar.strProductName = DateBaseName;
+            //鍔犺浇LB鐩告満鍙傛暟
+            if (LoadAllLBCameras(GlobalVar.allCamerasLBPath))
+            {
+                LogInfo("LB3D鐩告満閰嶇疆鏂囦欢鍔犺浇鎴愬姛锛�", LogInfoType.PASS);
+            }
+            else
+            {
+                LogInfo("LB3D鐩告満閰嶇疆鏂囦欢鍔犺浇澶辫触", LogInfoType.ERROR);
+            }
             //鍔犺浇閫氳
             foreach (BaseCommunicator com in GlobalVar.dicCommunicators.Values)
             {
@@ -1218,7 +1228,13 @@
                         camera.isGrabbing = false;
                     }
                 }
-
+                if (camera is LBCamera phmCamera)
+                {
+                    if (GlobalVar.allLBCameras.ContainsKey(camera.SN))
+                    {
+                        phmCamera.UpdateSensorConfig(GlobalVar.allLBCameras[camera.SN]);
+                    }
+                }
                 GlobalVar.dicCameras.TryAdd(CameraConnectionString.Key, camera);
             }
 
@@ -1557,6 +1573,47 @@
             catch { return false; }
         }
 
+        public bool LoadAllLBCameras(string allLBCamerasPath)
+        {
+            try
+            {
+                if (!File.Exists(allLBCamerasPath))
+                {
+                    Debug.WriteLine("鏂囦欢涓嶅瓨鍦ㄥ垱寤虹┖鏂囦欢");
+                    // 鑾峰彇涓嶅甫鏂囦欢鍚嶇殑鐩綍璺緞
+                    string directoryPath = Path.GetDirectoryName(allLBCamerasPath);
+                    SaveAllLBCameras();
+                    return true;
+                }
+                GlobalVar.allLBCameras = ConfigManager<ConcurrentDictionary<string, PHM6000SensorConfig>>.LoadConfig<ConcurrentDictionary<string, PHM6000SensorConfig>>(GlobalVar.allCamerasLBPath);
+            }
+            catch
+            {
+                return false;
+            }
+            return true;
+        }
+
+        public bool SaveAllLBCameras()
+        {
+            try
+            {
+                if (GlobalVar.allLBCameras.Count >= 0)
+                {
+                    ConfigManager<ConcurrentDictionary<string, PHM6000SensorConfig>>.SaveConfig<ConcurrentDictionary<string, PHM6000SensorConfig>>(GlobalVar.allLBCameras, GlobalVar.allCamerasLBPath);
+                }
+                else
+                {
+                    return false;
+                }
+            }
+            catch
+            {
+                return false;
+            }
+            return true;
+        }
+
         public bool LoadAllProcess(string allProcessConnectionStringPath)
         {
             try

--
Gitblit v1.9.3