alielie
2026-06-15 f08871fe7d148d667f2f11f80f64de71a0d9504c
HMI.UnitTest/MainWindow.xaml.cs
@@ -7,11 +7,11 @@
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 Util.ManualDebug;
namespace UnitTest
{
    /// <summary>
@@ -25,7 +25,12 @@
            ProductModelHelper.GetModelBySNR("cc123", out string model, out string msg);
            LangUtil.Load();
            InitializeComponent();
            RebuildDb();
            //RebuildDb();
            border2.Child = new TcpDebugger();
            //page.Children.Add(new UserControl1());
        }
@@ -123,38 +128,44 @@
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Task.Run(() =>
            var win = new ManualDebug()
            {
                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);
                }
            });
                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(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(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(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 +190,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 +223,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 +243,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;
        }
    }