1.日志系统:日期->客户端,每日更新

2.功率读取
master
zhangxy 3 days ago
parent 9779057f59
commit ccf83ec06b

@ -168,7 +168,25 @@
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" HorizontalAlignment="Center" Content="GPIO状态"></Label>
<Label Content="功率状态" FontSize="14" FontWeight="Bold" FontStyle="Oblique" HorizontalAlignment="Center" Grid.Row="0"/>
<StackPanel Orientation="Horizontal" Grid.Row="1">
<Label Content="读功率:" FontSize="14"/>
<Label Content="{Binding ReadPowerState}" FontSize="14"></Label>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="2">
<Label Content="写功率:" FontSize="14"/>
<Label Content="{Binding WritePowerState}" FontSize="14"></Label>
</StackPanel>
</Grid>
</Border>
<Border BorderBrush="Black" BorderThickness="0.5">
<Grid Margin="0 0 0 2">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" HorizontalAlignment="Center" Content="GPIO状态" FontSize="14" FontWeight="Bold" FontStyle="Oblique"></Label>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
@ -243,7 +261,7 @@
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="版本信息" HorizontalAlignment="Center"/>
<Label Grid.Row="0" Content="版本信息" HorizontalAlignment="Center" FontSize="14" FontWeight="Bold" FontStyle="Oblique"/>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
@ -251,9 +269,9 @@
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Content="模块型号:" HorizontalAlignment="Left"/>
<Label Grid.Column="0" Content="模块型号:" HorizontalAlignment="Left" FontSize="14" />
<Label Grid.Column="1" Content="{Binding moduleInfo}"></Label>
<Label Grid.Column="2" Content="主板固件号:" HorizontalAlignment="Left"/>
<Label Grid.Column="2" Content="主板固件号:" HorizontalAlignment="Left" FontSize="14" />
<Label Grid.Column="3" Content="{Binding motherboardFirmware}"></Label>
</Grid>

@ -8,6 +8,7 @@ using System.IO;
using System.IO.Ports;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
@ -64,6 +65,10 @@ namespace SocketExample
private string _epcasc;//ASC2码 EPC信息
public string EPCinfo { get => _epcinfo; set { _epcinfo = value; OnPropertyChanged(); } }
public string EPCASC { get => _epcasc; set { _epcasc = value; OnPropertyChanged(); } }
private string _readpowerstate;
public string ReadPowerState { get => _readpowerstate; set { _readpowerstate = value; OnPropertyChanged(); } }
private string _writepowerstate;
public string WritePowerState { get => _writepowerstate; set { _writepowerstate = value; OnPropertyChanged(); } }
private string _gpo1;
private string _gpo2;
private string _gpo3;
@ -104,7 +109,6 @@ namespace SocketExample
public LinkCommand clearcomn;//清空命令
public PanelItem(int index)
{
Text = $"客户端{index + 1}";
@ -201,9 +205,11 @@ namespace SocketExample
EPCinfo = hexString.Substring(startTemp, TempLength);
items.Add(new TagItem(taglist[j].EPCstring, EPCinfo, taglist[j].RSSI.ToString(), taglist[j].Count.ToString(), Timeinfo));
startTemp += 16 + TempLength;
writeToTxt(path, $"EPC:{taglist[j].EPCstring}\nHEX:{EPCinfo}\nRSSI:{taglist[j].RSSI.ToString()} Count:{taglist[j].Count.ToString()} Time:{Timeinfo}\n____________________________");
string year = DateTime.Now.ToString("yyyy-MM-dd");
EnsureFolderExists($"日志文件夹/{year}");
EnsureFolderExists($"日志文件夹/{year}/{Text}");
path = $"日志文件夹/{year}/{Text}/" + path;
writeToTxt(path, $"EPC:{taglist[j].EPCstring}\nHEX:{EPCinfo}\nRSSI:{taglist[j].RSSI.ToString()} Count:{taglist[j].Count.ToString()} Time:{Timeinfo}\n____________________________");
//LogService.Instance.Debug("");
}
@ -275,6 +281,29 @@ namespace SocketExample
}
}
break;
case "72":
//获取功率信息
try
{
string tempReadstate = "";
string tempWritestate = "";
for (int n = 0;n < (Convert.ToInt32(dataLength,16)/5);n++)
{
tempReadstate += $"A{n+1}:{Convert.ToInt32(readStateString.Substring(12+10*n,4),16).ToString()} ";
tempWritestate += $"A{n + 1}:{Convert.ToInt32(readStateString.Substring(16 + 10 * n, 4), 16).ToString()} ";
}
ReadPowerState = tempReadstate;
WritePowerState = tempWritestate;
tempReadstate = "";
tempWritestate = "";
}
catch
{
}
break;
case "70":
//获取设备信息
switch (option)
@ -353,6 +382,11 @@ namespace SocketExample
Thread.Sleep(500);
data = strToToHexByte("AA 55 00 72 72 0D");//获取功率状态
client.Send(data);
Thread.Sleep(500);
data = strToToHexByte("AA 55 02 02 03 E8 EB 0D");//获取1000ms内标签信息
client.Send(data);
return EasyTask.CompletedTask;
@ -397,9 +431,12 @@ namespace SocketExample
{
try
{
ip = IPAddress.Parse(IPtext);
port = int.Parse(Porttext);
Infotext += $"{Text}";
client = new TcpClient();
//连接事件
client.Connected += onConnected;
//断连事件
@ -531,9 +568,18 @@ namespace SocketExample
public class LinkCommand : ICommand //command方法实现
{
private Action _excute;
private Action<int> _excutewithindex;
public LinkCommand(Action action) {
_excute = action;
}
public LinkCommand(Action<int> action)
{
_excutewithindex = action;
}
public event EventHandler CanExecuteChanged;
public bool CanExecute(object parameter)

Loading…
Cancel
Save