From 919a8efe5f75b9d84ed79c91dfbea5263da8ce59 Mon Sep 17 00:00:00 2001
From: C3032 <C3032@BC3032>
Date: 星期五, 16 一月 2026 09:34:39 +0800
Subject: [PATCH] Merge branch 'feature/Camera3D'

---
 LB_VisionProcesses/Communicators/CommunicatorForm.cs |   84 ++++++++++++++++++++++++++++++++++++++----
 1 files changed, 76 insertions(+), 8 deletions(-)

diff --git a/LB_VisionProcesses/Communicators/CommunicatorForm.cs b/LB_VisionProcesses/Communicators/CommunicatorForm.cs
index 0de5c45..37d6ac5 100644
--- a/LB_VisionProcesses/Communicators/CommunicatorForm.cs
+++ b/LB_VisionProcesses/Communicators/CommunicatorForm.cs
@@ -56,11 +56,26 @@
 
         private void CommunicatorForm_Load(object sender, EventArgs e)
         {
+            // 鍒濆鍖栨暟鎹被鍨�
+            cmbDataType.Items.Clear();
+            cmbDataType.Items.AddRange(new string[] { "String", "Bool", "Byte", "Int", "DInt", "Real", "Double", "Word", "DWord" });
+            
+            // 缁戝畾绱㈠紩鏀瑰彉浜嬩欢
+            cmbDataType.SelectedIndexChanged += (s, ev) =>
+            {
+                if (communicator != null)
+                {
+                    communicator.CommunicatorConnections.Add("鏁版嵁绫诲瀷", cmbDataType.Text);
+                }
+            };
+
             // 浣跨敤 Enum.GetValues 鑾峰彇 enum 绫诲瀷鐨勬墍鏈夊��
             foreach (CommunicatorType type in Enum.GetValues(typeof(CommunicatorType)))
             {
                 cmbType.Items.Add(type.ToString());
             }
+
+            // ... (淇濇寔涓嶅彉)
 
             //閫夋嫨Com浼氳Е鍙慥alueChanged浜嬩欢锛屾病鏈夎緭鍏ラ�氳鍙g殑鎯呭喌涓嬮�夋嫨鍒�-1
             if (comConfig != null)
@@ -118,10 +133,13 @@
                 txtIP.Visible = false;
                 this.lblAddress.Visible = false;
                 this.txtAddress.Visible = false;
+                this.lblDataType.Visible = false;
+                this.cmbDataType.Visible = false;
 
 
                 lblIP.Text = "涓插彛鍙�";
-                lblIP.Text = "娉㈢壒鐜�";
+                lblIP.Text = "娉㈢壒鐜�"; // Bug: 杩欓噷 lblPort 搴旇琚缃负 "娉㈢壒鐜�"锛屼絾鍘熶唬鐮佸鐢ㄤ簡 lblIP? 涓嶏紝lblIP.Text琚浜嗕袱娆°��
+                lblPort.Text = "娉㈢壒鐜�"; // 淇鍘熶唬鐮佺殑娼滃湪Bug
 
                 cmbIP.Text = communicator.CommunicatorConnections["鍦板潃"].ToString();
                 txtPort.Text = communicator.CommunicatorConnections["绔彛"].ToString();
@@ -136,10 +154,12 @@
                 txtIP.Visible = true;
                 this.lblAddress.Visible = false;
                 this.txtAddress.Visible = false;
+                this.lblDataType.Visible = false;
+                this.cmbDataType.Visible = false;
 
 
                 lblIP.Text = "鐩戞帶鏂囦欢";
-                lblIP.Text = "鍐欏叆鏂囦欢";
+                lblPort.Text = "鍐欏叆鏂囦欢"; // 淇鍘熶唬鐮佸彲鑳界殑閿欒
 
                 txtIP.Text = communicator.CommunicatorConnections["鍦板潃"].ToString();
                 txtPort.Text = communicator.CommunicatorConnections["绔彛"].ToString();
@@ -153,12 +173,21 @@
                 txtIP.Visible = true;
                 this.lblAddress.Visible = true;
                 this.txtAddress.Visible = true;
+                this.lblDataType.Visible = true;
+                this.cmbDataType.Visible = true;
+                
                 lblIP.Text = "IP";
-                lblIP.Text = "妲�";
+                lblPort.Text = "妲�"; // 鍘熶唬鐮佽繖閲屾槸 lblIP.Text="妲�" 瑕嗙洊浜� "IP"
 
                 txtIP.Text = communicator.CommunicatorConnections["鍦板潃"].ToString();
                 txtPort.Text = communicator.CommunicatorConnections["绔彛"].ToString();
                 this.txtAddress.Text = communicator.CommunicatorConnections["鍙橀噺鍦板潃"]?.ToString();
+                
+                if (communicator.CommunicatorConnections.Contains("鏁版嵁绫诲瀷"))
+                    this.cmbDataType.Text = communicator.CommunicatorConnections["鏁版嵁绫诲瀷"].ToString();
+                else
+                    this.cmbDataType.Text = "String";
+
                 this.grpSetting.ForeColor = SystemColors.Control;
                 btnRuleSend.Visible = false;
             }
@@ -168,12 +197,14 @@
                 btnRuleSend.Enabled = false;
                 this.lblAddress.Visible = false;
                 this.txtAddress.Visible = false;
+                this.lblDataType.Visible = false;
+                this.cmbDataType.Visible = false;
 
                 cmbIP.Visible = false;
                 txtIP.Visible = true;
 
                 lblIP.Text = " IP";
-                lblIP.Text = "绔彛";
+                lblPort.Text = "绔彛";
 
                 txtIP.Text = communicator.CommunicatorConnections["鍦板潃"].ToString();
                 txtPort.Text = communicator.CommunicatorConnections["绔彛"].ToString();
@@ -198,6 +229,13 @@
             {
                 communicator.CommunicatorConnections.Add("鍦板潃", cmbIP.SelectedItem.ToString());
                 communicator.CommunicatorConnections.Add("绔彛", txtPort.Text);
+            }
+            else if (communicator is SiemensLBS7)
+            {
+                communicator.CommunicatorConnections.Add("鍦板潃", txtIP.Text);
+                communicator.CommunicatorConnections.Add("绔彛", txtPort.Text);
+                communicator.CommunicatorConnections.Add("鍙橀噺鍦板潃", txtAddress.Text);
+                communicator.CommunicatorConnections.Add("鏁版嵁绫诲瀷", cmbDataType.Text);
             }
             else
             {
@@ -263,14 +301,37 @@
             MessageBox.Show(result ? "鏂紑鎴愬姛" : "鏂紑澶辫触,鍘熷洜鏄�:" + communicator.Msg);
         }
 
+        private void ShowLogMsg(string msg)
+        {
+            // 濡傛灉褰撳墠涓嶆槸 UI 绾跨▼锛屽垯閫氳繃 Invoke 灏嗘搷浣滆皟搴﹀埌 UI 绾跨▼
+            if (this.InvokeRequired)
+            {
+                this.Invoke(new Action<string>((message) =>
+                {
+                    this.txtReceiveMsg.AppendText("[" + DateTime.Now.ToString("HH:mm:ss.fff") + "] " + message + "\r\n");
+                    this.txtReceiveMsg.ScrollToCaret();
+                }), msg);
+            }
+            else
+            {
+                this.txtReceiveMsg.AppendText("[" + DateTime.Now.ToString("HH:mm:ss.fff") + "] " + msg + "\r\n");
+                this.txtReceiveMsg.ScrollToCaret();
+            }
+        }
+
         private void btnSend_Click(object sender, EventArgs e)
         {
             if (communicator == null)
                 return;
 
-            communicator.SendMessage(txtSendMsg.Text);
-
-            ShowSendMsg(txtSendMsg.Text);
+            if (communicator.SendMessage(txtSendMsg.Text))
+            {
+                ShowSendMsg(txtSendMsg.Text);
+            }
+            else
+            {
+                ShowLogMsg(communicator.Msg);
+            }
         }
 
         private void btnRuleSend_Click(object sender, EventArgs e)
@@ -287,7 +348,14 @@
             //HexByte = strToHexByte(strSendMsg + crcString);
             SendMsg = SendMsg + crcString;
 
-            communicator.SendMessage(SendMsg);
+            if (communicator.SendMessage(SendMsg))
+            {
+                ShowSendMsg(SendMsg);
+            }
+            else
+            {
+                ShowLogMsg(communicator.Msg);
+            }
         }
 
         private void btnRun_Click(object sender, EventArgs e)

--
Gitblit v1.9.3