|
|
|
@ -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)
|
|
|
|
|