From ef75346ebe57d56cec0c33ad5abd8b2aa218da95 Mon Sep 17 00:00:00 2001
From: C3204 <zhengyabo@lanpucloud.cn>
Date: 星期六, 18 四月 2026 12:29:32 +0800
Subject: [PATCH] 修改相机运动轴参数读取配置

---
 LB_SmartVision/Forms/Pages/MotionControlPage/MotionControlFormRead.cs |   33 +++++++++++++++++++++++++++------
 1 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/LB_SmartVision/Forms/Pages/MotionControlPage/MotionControlFormRead.cs b/LB_SmartVision/Forms/Pages/MotionControlPage/MotionControlFormRead.cs
index 2246dc2..561c60b 100644
--- a/LB_SmartVision/Forms/Pages/MotionControlPage/MotionControlFormRead.cs
+++ b/LB_SmartVision/Forms/Pages/MotionControlPage/MotionControlFormRead.cs
@@ -59,6 +59,7 @@
             }
             this.cmbSN.Items.Clear();
             this.cmbSN.Items.Add(strCameraSN);
+            this.cmbSN.SelectedIndex = 0;
             onlinePictureBox = new UserPictureBox(uiGroupBoxImage);
             this.uiGroupBoxImage.Controls.Clear();
             this.uiGroupBoxImage.Controls.Add(onlinePictureBox);
@@ -190,12 +191,13 @@
 
         private void btnAdd_Click(object sender, EventArgs e)
         {
-
-            using (var configForm = new ConfigForm(config, GlobalVar.allPlcSettingPath + "\\" + this.Name + ".json"))
+            config.CommunicatorsName = GlobalVar.currentCommunicators;
+            config.ProductName = GlobalVar.strProductName;
+            using (var configForm = new ConfigForm(config, GlobalVar.allMPlcDataPath + "\\" + this.cameraSN + ".json"))
             {
                 if (configForm.ShowDialog() == DialogResult.OK)
                 {
-                    config = S7ConfigService.LoadConfig(GlobalVar.allPlcSettingPath);
+                    config = S7ConfigService.LoadConfig(GlobalVar.allMPlcDataPath + "\\" + this.cameraSN + ".json");
                     LoadConfigAndSetupGrid();
                     UpdateConnectionStatus();
                 }
@@ -242,7 +244,7 @@
         }
         private void LoadConfigAndSetupGrid()
         {
-            config = S7ConfigService.LoadConfig(GlobalVar.allPlcSettingPath + "\\" + this.Name + ".json");
+            config = S7ConfigService.LoadConfig(GlobalVar.allMPlcDataPath + "\\" + this.cameraSN + ".json");
 
             if (GlobalVar.allPlcSettings.Keys.Contains(Name))
             {
@@ -252,7 +254,6 @@
             {
                 GlobalVar.allPlcSettings.TryAdd(Name, config);
             }
-            ConfigManager<Dictionary<string, Dictionary<string, PlcConfig>>>.SaveConfig<Dictionary<string, Dictionary<string, PlcConfig>>>(GlobalVar.dicMPlcData, GlobalVar.allMPlcDataPath);
             // 鏋勫缓 DataTable 鐢ㄤ簬灞曠ず淇″彿锛堟敮鎸佺紪杈戝�煎垪锛�
             signalTable = new DataTable();
             signalTable.Columns.Add("SignalName", typeof(string));
@@ -357,7 +358,27 @@
 
         private void btnSave_Click(object sender, EventArgs e)
         {
-            LoadConfigAndSetupGrid();
+            S7ConfigService.SaveConfig(config, GlobalVar.allMPlcDataPath + "\\" + this.cameraSN + ".json");
+            if (GlobalVar.dicMPlcDatas.ContainsKey(config.ProductName))
+            {
+                if (GlobalVar.dicMPlcDatas[config.ProductName].ContainsKey(this.cameraSN))
+                {
+                    GlobalVar.dicMPlcDatas[config.ProductName][this.cameraSN] = config;
+                }
+                else
+                {
+                    GlobalVar.dicMPlcDatas[config.ProductName].TryAdd(this.cameraSN, config);
+                }
+            }
+            else
+            {
+                Dictionary<string, PlcConfig> keyValuePairs = new Dictionary<string, PlcConfig>();
+                keyValuePairs.TryAdd(this.cameraSN, config);
+                GlobalVar.dicMPlcDatas.TryAdd(config.ProductName, keyValuePairs);
+            }
+            ConfigManager<Dictionary<string, Dictionary<string, PlcConfig>>>.SaveConfig<Dictionary<string, Dictionary<string, PlcConfig>>>(GlobalVar.dicMPlcDatas, GlobalVar.allMPlcDatasPath);
+            GlobalVar.dicMPlcDatas = ConfigManager<Dictionary<string, Dictionary<string, PlcConfig>>>.LoadConfig<Dictionary<string, Dictionary<string, PlcConfig>>>(GlobalVar.allMPlcDatasPath);
+            //LoadConfigAndSetupGrid();
         }
     }
 }

--
Gitblit v1.9.3