From 72cad5efd3a2aef5c23066380ee451f265dcf84c Mon Sep 17 00:00:00 2001 From: zhangxy Date: Thu, 14 Aug 2025 13:34:31 +0800 Subject: [PATCH] =?UTF-8?q?1.=E8=B0=83=E6=95=B4=E6=A0=87=E7=AD=BE=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SocketExample/TCPWindowV2.xaml | 52 ++++++++++++++++--------------- SocketExample/TCPWindowV2.xaml.cs | 23 +++++--------- 2 files changed, 34 insertions(+), 41 deletions(-) diff --git a/SocketExample/TCPWindowV2.xaml b/SocketExample/TCPWindowV2.xaml index 6eed3a0..56a95e1 100644 --- a/SocketExample/TCPWindowV2.xaml +++ b/SocketExample/TCPWindowV2.xaml @@ -8,7 +8,7 @@ xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" xmlns:local="clr-namespace:SocketExample" mc:Ignorable="d" - Title="RFID读写器多终端监控软件v1.091" Height="680" Width="1180" + Title="RFID读写器多终端监控软件v1.093" Height="680" Width="1180" Background="Transparent" AllowsTransparency="True" WindowStyle="None" WindowStartupLocation="CenterScreen"> @@ -187,38 +187,39 @@ - - - - - - - - - - - + + + + + + + + + + + + - - - - + + + + - + - + - + - + @@ -227,11 +228,12 @@ - - - - - + + + + + + diff --git a/SocketExample/TCPWindowV2.xaml.cs b/SocketExample/TCPWindowV2.xaml.cs index b48bf42..026dfba 100644 --- a/SocketExample/TCPWindowV2.xaml.cs +++ b/SocketExample/TCPWindowV2.xaml.cs @@ -30,6 +30,7 @@ using K4os.Compression.LZ4.Streams.Abstractions; using Mesnac.Log; using Microsoft.Xaml.Behaviors.Core; using Mysqlx.Crud; +using Org.BouncyCastle.Utilities; using Org.BouncyCastle.Utilities.Encoders; using TouchSocket.Core; using TouchSocket.Sockets; @@ -276,7 +277,7 @@ namespace SocketExample string commandState = readStateString.Substring(6, 2);//获取命令 if (commandState != "81") - Infotext += $"({currentTime})客户端接收到信息:\n{hexString}\n"; + Infotext += $"\n({currentTime})客户端接收到信息:\n{hexString}\n"; int i = Convert.ToInt32(dataLength, 16); if (i != 0) @@ -291,9 +292,6 @@ namespace SocketExample Array.Copy(data, 5, newData, 5, 4); Array.Copy(data, 5, newData, 6, data.Length - 5); Timeinfo = $"{time}";//获取时间 - string NewDataString = BitConverter.ToString(newData).Replace("-", " "); - - int startTemp = 33; //Infotext += $"({currentTime})客户端接收到EPC信息:\n{EPCASC}\n\n"; @@ -301,13 +299,11 @@ namespace SocketExample ObservableCollection items = new ObservableCollection(); for (int j = 0; j < taglist.Count; j++) { - int TempLength = taglist[j].EPCstring.Length * 3 - 1; - EPCinfo = NewDataString.Substring(startTemp, TempLength); + EPCinfo = BitConverter.ToString(taglist[j].EPC).Replace("-", ""); items.Add(new TagItem(hexString, taglist[j].EPCstring, EPCinfo, taglist[j].RSSI.ToString(), taglist[j].Count.ToString(), Timeinfo)); - startTemp += 16 + TempLength; string year = DateTime.Now.ToString("yyyy-MM-dd"); EnsureFolderExists($"日志文件夹/{year}/{Text}"); - path = $"日志文件夹/{year}/{Text}/" + Text + "(" + IPtext + ")" + ".txt"; + path = $"日志文件夹/{year}/{Text}/" + Text + "标签(" + IPtext + ")" + ".txt"; EnsureTxtExists(path, Text, IPtext, Porttext); writeToTxt(path, $"接收消息:{hexString}\nEPC:{taglist[j].EPCstring}\nHEX:{EPCinfo}\nRSSI:{taglist[j].RSSI.ToString()} Count:{taglist[j].Count.ToString()} Time:{Timeinfo}\n____________________________"); path = ""; @@ -328,22 +324,17 @@ namespace SocketExample try { Timeinfo = $"{time}";//获取时间 - - int startTemp = 33; - //Infotext += $"({currentTime})客户端接收到EPC信息:\n{EPCASC}\n\n"; List taglist = GetTagInfos(data); ObservableCollection items = new ObservableCollection(); for (int j = 0; j < taglist.Count; j++) { - int TempLength = taglist[j].EPCstring.Length * 3 - 1; - EPCinfo = hexString.Substring(startTemp, TempLength); + EPCinfo = BitConverter.ToString(taglist[j].EPC).Replace("-", ""); items.Add(new TagItem(hexString, taglist[j].EPCstring, EPCinfo, taglist[j].RSSI.ToString(), taglist[j].Count.ToString(), Timeinfo)); - startTemp += 16 + TempLength; string year = DateTime.Now.ToString("yyyy-MM-dd"); EnsureFolderExists($"日志文件夹/{year}/{Text}"); - path = $"日志文件夹/{year}/{Text}/" + Text + "(" + IPtext + ")" + ".txt"; + path = $"日志文件夹/{year}/{Text}/" + Text + "标签(" + IPtext + ")" + ".txt"; EnsureTxtExists(path, Text, IPtext, Porttext); writeToTxt(path, $"接收消息:{hexString}\nEPC:{taglist[j].EPCstring}\nHEX:{EPCinfo}\nRSSI:{taglist[j].RSSI.ToString()} Count:{taglist[j].Count.ToString()} Time:{Timeinfo}\n____________________________"); path = ""; @@ -570,7 +561,7 @@ namespace SocketExample TagItems = items; string year = DateTime.Now.ToString("yyyy-MM-dd"); EnsureFolderExists($"日志文件夹/{year}/{Text}"); - path = $"日志文件夹/{year}/{Text}/" + Text + "(" + IPtext + ")" + ".txt"; + path = $"日志文件夹/{year}/{Text}/" + Text + "标签(" + IPtext + ")" + ".txt"; EnsureTxtExists(path, Text, IPtext, Porttext); writeToTxt(path, $"接收消息:{hexString}\nEPC:{EPCASC}\nHEX:{EPCinfo}\nRSSI:{RSSIinfo} Count:{Countinfo} Time:{Timeinfo}\n____________________________"); path = "";