From d1b72117058f1131046b6aa3add8e3ccfae033d8 Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 09 十一月 2026 10:36:07 +0800
Subject: [PATCH] docs: CAN 模拟器独立 TCP 服务进程设计规格(统一 CanDeviceDriver + 双工推送协议)

---
 HMI.UnitTest/MainWindow.xaml.cs |  180 ++++++++++++++++++++++++------------------------------------
 1 files changed, 72 insertions(+), 108 deletions(-)

diff --git a/HMI.UnitTest/MainWindow.xaml.cs b/HMI.UnitTest/MainWindow.xaml.cs
index 6378bc8..d0fbc30 100644
--- a/HMI.UnitTest/MainWindow.xaml.cs
+++ b/HMI.UnitTest/MainWindow.xaml.cs
@@ -2,16 +2,19 @@
 using HMI.Core.Api;
 using HMI.Core.Util;
 using HMI.Simple.Util;
+using HslCommunication.Core.Pipe;
+using HslCommunication.Profinet.Siemens;
 using log4net;
 using Panuon.WPF.UI;
+using PLCHelper;
 using Plugin.DataBoard;
 using Plugin.TestResult_WPF;
 using Plugin.TsExecution;
+using Plugin.UICollection;
 using System;
 using System.IO;
-using System.Threading;
-using System.Threading.Tasks;
 using System.Windows;
+using System.Xml.Linq;
 namespace UnitTest
 {
     /// <summary>
@@ -22,11 +25,32 @@
         private ILog log = LogManager.GetLogger("UnitTest");
         public MainWindow()
         {
-            ProductModelHelper.GetModelBySNR("cc123", out string model, out string msg);
-            LangUtil.Load();
-            InitializeComponent();
-            RebuildDb();
+            //ProductModelHelper.GetModelBySNR("cc123", out string model, out string msg);
+            //LangUtil.Load();
+            //InitializeComponent();
+            ////RebuildDb();
+            //border2.Child = new TcpDebugger();
+
+            var client = new SiemensS7Net(SiemensPLCS.S1500);
+            PipeTcpNet pipeTcpNet = new PipeTcpNet("127.0.0.1", 102);
+            pipeTcpNet.ConnectTimeOut = 200;
+            pipeTcpNet.ReceiveTimeOut = 200;
+            client.CommunicationPipe = pipeTcpNet;
+            client.ConnectServer();
+
+            var ss = new IntReader(client, "DB10.DBW100", 0);
+            ss.DataChanged += Ss_DataChanged;
+            ss.Run();
+
+
+
+
             //page.Children.Add(new UserControl1());
+        }
+
+        private void Ss_DataChanged(object sender, DataChangedArg<int> e)
+        {
+            MessageBox.Show($"{e.oldValue} => {e.newValue}");
         }
 
         TcpClientWrapper tcpClient;
@@ -123,38 +147,45 @@
 
         private void Button_Click(object sender, RoutedEventArgs e)
         {
-            Task.Run(() =>
-            {
-                for (int j = 0; j < 1000; j++)
-                {
-                    string status = (j % 2 == 0) ? "Passed" : "Failed";
-                    string d = (j % 2 == 0) ? "9" : "9999999999999999999999999999999999999999999999999999999999999999995";
-                    tsExecution.AddTestData(0, $"ConnectivityCANRec,2,3,4,{d},6,{status}");
-                    Thread.Sleep(5);
-                }
-            });
+            //var win = new ManualDebug()
+            //{
+            //    seqPath = "C:\\Users\\chrry\\Desktop\\鎵嬪姩璋冭瘯绀轰緥.seq"
+            //};
 
-            Task.Run(() =>
-            {
-                for (int j = 0; j < 1000; j++)
-                {
-                    string status = (j % 2 == 0) ? "Passed" : "Failed";
-                    string d = (j % 2 == 0) ? "9" : "9999999999999999999999999999999999999999999999999999999999999999995";
-                    tsExecution.AddTestData(1, $"ConnectivityCANRec,2,3,4,{d},6,{status}");
-                    Thread.Sleep(5);
-                }
-            });
+            //win.Show();
 
-            Task.Run(() =>
-            {
-                for (int j = 0; j < 1000; j++)
-                {
-                    string status = (j % 2 == 0) ? "Passed" : "Failed";
-                    string d = (j % 2 == 0) ? "9" : "9999999999999999999999999999999999999999999999999999999999999999995";
-                    tsExecution.AddTestData(2, $"ConnectivityCANRec,2,3,4,{d},6,{status}");
-                    Thread.Sleep(5);
-                }
-            });
+            //Task.Run(() =>
+            //{
+            //    for (int j = 0; j < 1000; j++)
+            //    {
+            //        string status = (j % 2 == 0) ? "Passed" : "Failed";
+            //        string d = (j % 2 == 0) ? "9" : "9999999999999999999999999999999999999999999999999999999999999999995";
+            //        tsExecution.AddTestData(0, $"ConnectivityCANRec,2,3,4,{d},6,{status}");
+            //        Thread.Sleep(5);
+            //    }
+            //});
+
+            //Task.Run(() =>
+            //{
+            //    for (int j = 0; j < 1000; j++)
+            //    {
+            //        string status = (j % 2 == 0) ? "Passed" : "Failed";
+            //        string d = (j % 2 == 0) ? "9" : "9999999999999999999999999999999999999999999999999999999999999999995";
+            //        tsExecution.AddTestData(1, $"ConnectivityCANRec,2,3,4,{d},6,{status}");
+            //        Thread.Sleep(5);
+            //    }
+            //});
+
+            //Task.Run(() =>
+            //{
+            //    for (int j = 0; j < 1000; j++)
+            //    {
+            //        string status = (j % 2 == 0) ? "Passed" : "Failed";
+            //        string d = (j % 2 == 0) ? "9" : "9999999999999999999999999999999999999999999999999999999999999999995";
+            //        tsExecution.AddTestData(2, $"ConnectivityCANRec,2,3,4,{d},6,{status}");
+            //        Thread.Sleep(5);
+            //    }
+            //});
 
             //Task.Run(() =>
             //{
@@ -179,7 +210,7 @@
             //});
 
             //tsExecution.UpdatePositionStatus(0, "Passed");
-            tsExecution.UpdatePositionStatus(0, "Failed");
+            //tsExecution.UpdatePositionStatus(0, "Failed");
             //tsExecution.UpdatePositionProcessValue(0, 12);
             //tsExecution.PausePosition(0);
             //tsExecution.SetPositionBarcode(0, "123456789");
@@ -212,73 +243,6 @@
             Console.WriteLine($"{e.Data}");
         }
 
-        private void Client_OnData(object sender, PipeDataEventArgs e)
-        {
-            Dispatcher.Invoke(() =>
-            {
-                console.Text += e.Data;
-            });
-        }
-
-        private void Button_Click2(object sender, RoutedEventArgs e)
-        {
-            var allStart = DateTime.Now;
-            for (int i = 0; i < 100; i++)
-            {
-                var start = DateTime.Now;
-                if (client.SendMessage("ping", out string res))
-                {
-                    var interval = (DateTime.Now - start).TotalMilliseconds;
-                    Console.WriteLine($"{interval}: {res}");
-                }
-            }
-            Console.WriteLine($"Total: {(DateTime.Now - allStart).TotalMilliseconds}");
-        }
-
-        private void Button_Click3(object sender, RoutedEventArgs e)
-        {
-            try
-            {
-                var allStart = DateTime.Now;
-                for (int i = 0; i < 500; i++)
-                {
-                    var start = DateTime.Now;
-                    string data = input.Text;
-                    string str = $"{{\"command\":5,\"value\":{data},\"id\":\"DITag0\"}}\r\n";
-                    string res = tcpClient.SendMessage(str);
-                    var interval = (DateTime.Now - start).TotalMilliseconds;
-                    Console.WriteLine($"{interval}: {res}");
-                }
-                Console.WriteLine($"Total: {(DateTime.Now - allStart).TotalMilliseconds}");
-            }
-            catch (Exception ex)
-            {
-
-            }
-        }
-
-        private void Button_Click4(object sender, RoutedEventArgs e)
-        {
-            try
-            {
-                var allStart = DateTime.Now;
-                for (int i = 0; i < 500; i++)
-                {
-                    var start = DateTime.Now;
-                    string data = input.Text;
-                    string str = $"{{\"command\":5,\"value\":{data},\"id\":\"DITag0\"}}";
-                    client.SendMessage(str, out string res);
-                    var interval = (DateTime.Now - start).TotalMilliseconds;
-                    Console.WriteLine($"{interval}: {res}");
-                }
-                Console.WriteLine($"Total: {(DateTime.Now - allStart).TotalMilliseconds}");
-
-            }
-            catch (Exception ex)
-            {
-                Console.WriteLine(ex.StackTrace);
-            }
-        }
 
         private void HandlePlugin(object obj)
         {
@@ -299,10 +263,10 @@
 
         private void Window_Loaded(object sender, RoutedEventArgs e)
         {
-            var plugin = new TsExecution();
-            HandlePlugin(plugin);
-            border.Child = plugin;
-            tsExecution = plugin;
+            //var plugin = new TsExecution();
+            //HandlePlugin(plugin);
+            //border.Child = plugin;
+            //tsExecution = plugin;
             this.Loaded -= Window_Loaded;
         }
     }

--
Gitblit v1.9.1