From 3462941c01a6d6055988ae079576cac9cc6ebf65 Mon Sep 17 00:00:00 2001
From: C3204 <zhengyabo@lanpucloud.cn>
Date: 星期二, 06 一月 2026 16:15:11 +0800
Subject: [PATCH] Merge branch 'master' of http://lanpucloud.cn:1111/r/~zhengyabo/LB_TyreAppearanceInspectionSoftware

---
 LB_SmartVision/Forms/Pages/CommunicatorPage/CreateCommunicatorForm.cs |  144 +++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 130 insertions(+), 14 deletions(-)

diff --git a/LB_SmartVision/Forms/Pages/CommunicatorPage/CreateCommunicatorForm.cs b/LB_SmartVision/Forms/Pages/CommunicatorPage/CreateCommunicatorForm.cs
index 0865a23..a9fc8ab 100644
--- a/LB_SmartVision/Forms/Pages/CommunicatorPage/CreateCommunicatorForm.cs
+++ b/LB_SmartVision/Forms/Pages/CommunicatorPage/CreateCommunicatorForm.cs
@@ -1,4 +1,6 @@
-锘縰sing LB_VisionProcesses.Communicators;
+锘縰sing LB_SmartVisionCommon;
+using LB_VisionProcesses.Communicators;
+using LB_VisionProcesses.Communicators.SiemensS7;
 using LB_VisionProcesses.Communicators.TCom;
 using RJCP.IO.Ports;
 using System;
@@ -30,17 +32,18 @@
                 communicator = new UARTPort();
 
             rButtonUART.Checked = true;
+            uiLabelS7Type.Visible = false;
+            uiComboBoxS7Type.Visible = false;
             uiButtonCreate.Enabled = false;
         }
 
         private void uiButtonTest_Click(object sender, EventArgs e)
         {
             uiButtonCreate.Enabled = false;
-
             rButtonUART.Enabled = false;
             rButtonTCPServer.Enabled = false;
             rButtonTCPClient.Enabled = false;
-            rButtonMonitor.Enabled = false;
+            rButtonS7.Enabled = false;
 
             if (communicator != null)
                 communicator.Disconnect();
@@ -51,6 +54,8 @@
 
                 IP = uiComboBoxPort.Text;
                 PORT = uiTextBoxPort.Text;
+                communicator.CommunicatorConnections.Add("鍦板潃", IP);
+                communicator.CommunicatorConnections.Add("绔彛", PORT);
             }
             else if (rButtonTCPServer.Checked)
             {
@@ -58,6 +63,8 @@
 
                 IP = uiIPTextBox.Text;
                 PORT = uiTextBoxPort.Text;
+                communicator.CommunicatorConnections.Add("鍦板潃", IP);
+                communicator.CommunicatorConnections.Add("绔彛", PORT);
             }
             else if (rButtonTCPClient.Checked)
             {
@@ -65,23 +72,66 @@
 
                 IP = uiIPTextBox.Text;
                 PORT = uiTextBoxPort.Text;
+                communicator.CommunicatorConnections.Add("鍦板潃", IP);
+                communicator.CommunicatorConnections.Add("绔彛", PORT);
             }
-            else if (rButtonMonitor.Checked)
+            else if (rButtonS7.Checked)
             {
-                communicator = new LocalMonitor();
+                communicator = new SiemensLBS7();
 
                 IP = uiTextBoxPath.Text;
                 PORT = uiTextBoxPort.Text;
+                switch (uiComboBoxS7Type.Text)
+                {
+                    case "S7200":
+                        {
+                            cpuType = S7.Net.CpuType.S7200;
+                            break;
+                        }
+                    case "Logo0BA8":
+                        {
+                            cpuType = S7.Net.CpuType.Logo0BA8;
+                            break;
+                        }
+                    case "S7200Smart":
+                        {
+                            cpuType = S7.Net.CpuType.S7200Smart;
+                            break;
+                        }
+                    case "S7300":
+                        {
+                            cpuType = S7.Net.CpuType.S7300;
+                            break;
+                        }
+                    case "S7400":
+                        {
+                            cpuType = S7.Net.CpuType.S7400;
+                            break;
+                        }
+                    case "S71200":
+                        {
+                            cpuType = S7.Net.CpuType.S71200;
+                            break;
+                        }
+                    case "S71500":
+                        {
+                            cpuType = S7.Net.CpuType.S71500;
+                            break;
+                        }
+                    default:
+                        cpuType = S7.Net.CpuType.S71500;
+                        break;
+                }
+                communicator.CommunicatorConnections.Add("鍦板潃", IP);
+                communicator.CommunicatorConnections.Add("绔彛", PORT);
+                communicator.CommunicatorConnections.Add("鍨嬪彿", cpuType);
             }
             else
             {
                 MessageBox.Show("鏈�夋嫨閫氳绫诲瀷!", "寮傚父");
                 return;
             }
-
-            communicator.CommunicatorConnections.Add("鍦板潃", IP);
-            communicator.CommunicatorConnections.Add("绔彛", PORT);
-            if (communicator.Connect())
+            if (!communicator.Connect())
             {
                 uiButtonCreate.Enabled = true;
                 communicator.Disconnect();
@@ -92,10 +142,11 @@
 
         public string IP = string.Empty;
         public string PORT = string.Empty;
+        public S7.Net.CpuType cpuType = S7.Net.CpuType.S71500;
 
         private void uiButtonCreate_Click(object sender, EventArgs e)
         {
-            if (communicator.Connect())
+            if (!communicator.Connect())
             {
                 bCreate = true;
                 this.Close();
@@ -131,6 +182,10 @@
                 uiLabelPort.Text = "娉㈢壒鐜�";
                 uiTextBoxPort.Visible = true;
 
+                uiLabelS7Type.Visible = false;
+                uiComboBoxS7Type.Visible = false;
+
+
                 uiButtonCreate.Enabled = false;
             }
         }
@@ -153,6 +208,9 @@
                 uiLabelPort.Text = "绔彛";
                 uiTextBoxPort.Visible = true;
 
+                uiLabelS7Type.Visible = false;
+                uiComboBoxS7Type.Visible = false;
+
                 uiButtonCreate.Enabled = false;
             }
         }
@@ -174,26 +232,39 @@
                 uiLabelPort.Visible = true;
                 uiLabelPort.Text = "绔彛";
                 uiTextBoxPort.Visible = true;
+
+                uiLabelS7Type.Visible = false;
+                uiComboBoxS7Type.Visible = false;
+
             }
         }
 
-        private void rButtonMonitor_CheckedChanged(object sender, EventArgs e)
+        private void rButtonS7_CheckedChanged(object sender, EventArgs e)
         {
             uiButtonCreate.Enabled = false;
             if (communicator != null)
                 communicator.Disconnect();
 
-            if (rButtonMonitor.Checked)
+            if (rButtonS7.Checked)
             {
                 uiLabelIP.Visible = true;
-                uiLabelIP.Text = "鐩戞帶鏂囦欢";
+                uiLabelIP.Text = "鍦板潃";
                 uiIPTextBox.Visible = false;
                 uiComboBoxPort.Visible = false;
                 uiTextBoxPath.Visible = true;
 
                 uiLabelPort.Visible = true;
-                uiLabelPort.Text = "鍐欏叆鏂囦欢";
+                uiLabelPort.Text = "妲�";
                 uiTextBoxPort.Visible = true;
+
+                uiLabelS7Type.Visible = true;
+                uiComboBoxS7Type.Visible = true;
+                uiComboBoxS7Type.Items.Clear();
+
+                foreach (var c in Enum.GetValues(typeof(S7.Net.CpuType)))
+                {
+                    uiComboBoxS7Type.Items.Add(c.ToString());
+                }
             }
         }
 
@@ -219,5 +290,50 @@
         {
             uiButtonCreate.Enabled = false;
         }
+
+        private void uiComboBoxS7Type_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            switch (uiComboBoxS7Type.Text)
+            {
+                case "S7200":
+                    {
+                        cpuType = S7.Net.CpuType.S7200;
+                        break;
+                    }
+                case "Logo0BA8":
+                    {
+                        cpuType = S7.Net.CpuType.Logo0BA8;
+                        break;
+                    }
+                case "S7200Smart":
+                    {
+                        cpuType = S7.Net.CpuType.S7200Smart;
+                        break;
+                    }
+                case "S7300":
+                    {
+                        cpuType = S7.Net.CpuType.S7300;
+                        break;
+                    }
+                case "S7400":
+                    {
+                        cpuType = S7.Net.CpuType.S7400;
+                        break;
+                    }
+                case "S71200":
+                    {
+                        cpuType = S7.Net.CpuType.S71200;
+                        break;
+                    }
+                case "S71500":
+                    {
+                        cpuType = S7.Net.CpuType.S71500;
+                        break;
+                    }
+                default:
+                    cpuType = S7.Net.CpuType.S71500;
+                    break;
+            }
+        }
     }
 }

--
Gitblit v1.9.3