From c48b29f9997cd8985ab898c1979b8194e4119c76 Mon Sep 17 00:00:00 2001
From: C3032 <C3032@BC3032>
Date: 星期二, 13 一月 2026 08:49:16 +0800
Subject: [PATCH] 在UserManagementEditPage.cs界面为修改按钮添加了指令,实现用户信息的修改 在HistoricalDataEditPage.cs界面为导出按钮添加了指令,还未完成

---
 LB_SmartVision/Forms/Pages/CommunicatorPage/CommunicatorForm.cs |   92 +++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 87 insertions(+), 5 deletions(-)

diff --git a/LB_SmartVision/Forms/Pages/CommunicatorPage/CommunicatorForm.cs b/LB_SmartVision/Forms/Pages/CommunicatorPage/CommunicatorForm.cs
index c582b42..0e70eb0 100644
--- a/LB_SmartVision/Forms/Pages/CommunicatorPage/CommunicatorForm.cs
+++ b/LB_SmartVision/Forms/Pages/CommunicatorPage/CommunicatorForm.cs
@@ -1,18 +1,38 @@
 锘縰sing LB_VisionProcesses.Communicators;
+using LB_VisionProcesses.Communicators.SiemensS7;
 using LB_VisionProcesses.Communicators.TCom;
 using ReaLTaiizor.Forms;
 using RJCP.IO.Ports;
+using S7.Net;
 using System.Diagnostics;
+using System.Linq;
 
 namespace LB_SmartVision.Forms.Pages.CommunicatorPage
 {
-    public partial class CommunicatorForm : MaterialForm
+    public delegate void CommunicatorChange(BaseCommunicator communicator);
+    public partial class CommunicatorForm : Form
     {
         BaseCommunicator communicator { get; set; }
+
+        public event CommunicatorChange CommunicatorChanged;
+
+        private void communicatorChanged(BaseCommunicator communicator)
+        {
+            if (CommunicatorChanged != null)
+            {
+                CommunicatorChanged(communicator);
+            }
+        }
 
         public CommunicatorForm()
         {
             InitializeComponent();
+            cmbType.Items.Clear();
+
+            if (communicator != null && !string.IsNullOrEmpty(communicator.CommunicatorConnections["鍨嬪彿"]?.ToString()))
+            {
+                cmbType.Items.Add(communicator.CommunicatorConnections["鍨嬪彿"]?.ToString());
+            }
         }
 
         public CommunicatorForm(BaseCommunicator communicator, string name)
@@ -24,6 +44,14 @@
             cmbIP.Enabled = false;
             txtIP.Enabled = false;
             txtPort.Enabled = false;
+
+
+            lblType.Visible = false;
+            lblAddress.Visible = false;
+            cmbType.Visible = false;
+            txtAddress.Visible = false;
+
+
             this.Text = name;
 
             if (communicator is UARTPort)
@@ -39,28 +67,61 @@
                 txtIP.Visible = false;
                 cmbIP.Visible = true;
 
+                this.btnRuleSend.Visible = true;
+
+
+                lblType.Visible = false;
+                lblAddress.Visible = false;
+                cmbType.Visible = false;
+                txtAddress.Visible = false;
+
                 lblIP.Text = "COM鍙�";
                 lblPort.Text = "娉㈢壒鐜�";
             }
             else if (communicator is TCPClient || communicator is TCPServer)
             {
                 txtIP.Text = communicator.CommunicatorConnections["鍦板潃"]?.ToString();
-                txtPort.Text = communicator.CommunicatorConnections["绔彛"]?.ToString();
+                txtPort.SelectedText = communicator.CommunicatorConnections["绔彛"]?.ToString();
                 txtIP.Visible = true;
                 cmbIP.Visible = false;
+
+                this.btnRuleSend.Visible = false;
+
+
+                lblType.Visible = false;
+                lblAddress.Visible = false;
+                cmbType.Visible = false;
+                txtAddress.Visible = false;
 
                 lblIP.Text = "鍦板潃";
                 lblPort.Text = "绔彛";
             }
-            else if (communicator is LocalMonitor)
+            else if (communicator is SiemensLBS7)
             {
                 txtIP.Text = communicator.CommunicatorConnections["鍦板潃"]?.ToString();
                 txtPort.Text = communicator.CommunicatorConnections["绔彛"]?.ToString();
+                cmbType.Items.Clear();
+
+                if (!string.IsNullOrEmpty(communicator.CommunicatorConnections["鍨嬪彿"]?.ToString()))
+                {
+                    cmbType.Items.Add(communicator.CommunicatorConnections["鍨嬪彿"]?.ToString());
+                    cmbType.Text = communicator.CommunicatorConnections["鍨嬪彿"]?.ToString();
+                }
+                if (!string.IsNullOrEmpty(communicator.CommunicatorConnections["鍙橀噺鍦板潃"]?.ToString()))
+                {
+                    txtAddress.Text = communicator.CommunicatorConnections["鍙橀噺鍦板潃"]?.ToString();
+                }
                 txtIP.Visible = true;
                 cmbIP.Visible = false;
+                this.btnRuleSend.Visible = false;
 
-                lblIP.Text = "鐩戞帶鏂囦欢";
-                lblPort.Text = "鍐欏叆鏂囦欢";
+                lblType.Visible = true;
+                lblAddress.Visible = true;
+                cmbType.Visible = true;
+                txtAddress.Visible = true;
+
+                lblIP.Text = "IP";
+                lblPort.Text = "妲�";
             }
 
             this.communicator = communicator;
@@ -78,6 +139,14 @@
                     return;
                 //鍙栨秷鍥炶皟鍑芥暟
                 communicator.MessageReceived -= ShowReceiveMsg;
+                if (communicator != null)
+                {
+                    communicatorChanged(communicator);
+                    if (GlobalVar.dicCommunicators != null && GlobalVar.dicCommunicators.Keys.Count > 0 && GlobalVar.dicCommunicators.Keys.Contains(communicator.CommunicatorName))
+                    {
+                        GlobalVar.dicCommunicators[communicator.CommunicatorName] = communicator;
+                    }
+                }
             }
             catch (Exception ex)
             {
@@ -185,5 +254,18 @@
             if (communicator.SendMessage(SendMsg))
                 ShowSendMsg(SendMsg);
         }
+
+        private void txtAddress_TextChanged(object sender, EventArgs e)
+        {
+            if (communicator != null && !communicator.CommunicatorConnections.Contains("鍙橀噺鍦板潃"))
+            {
+                communicator.CommunicatorConnections.Add("鍙橀噺鍦板潃", txtAddress.Text);
+            }
+            else if (communicator != null)
+            {
+                communicator.CommunicatorConnections["鍙橀噺鍦板潃"] = txtAddress.Text;
+                communicatorChanged(communicator);
+            }
+        }
     }
 }

--
Gitblit v1.9.3