Commit c064edb2 顾剑亮

upload

1 个父辈 2f28bb24
正在显示 290 个修改的文件 包含 2570 行增加4051 行删除
{
"CurrentProjectSetting": null
}
\ No newline at end of file
此文件类型无法预览
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}
\ No newline at end of file
此文件类型无法预览
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Asa.RFID
{
/// <summary>
/// 读取所有RFID
/// </summary>
public class ReadAll2 : IReadAll
{
private HiStation[] _device;
private Dictionary<string, string> _id; //RFID编号
private string _logName;
public event IReadAll.ReceivedEvent Received;
public event IReadAll.ReceiveBufferEvent ReceiveBuffer;
/// <summary>
/// 读取所有RFID
/// </summary>
/// <param name="logName">日志名称</param>
public ReadAll2(string logName = "HFReader")
{
_logName = logName;
_id = new Dictionary<string, string>();
if (Common.log == null)
Common.log = log4net.LogManager.GetLogger(logName);
}
public void Start(int port)
{
}
/// <summary>
/// 开启
/// </summary>
/// <param name="ip"></param>
public void Start(string[] ip)
{
try
{
_id.Clear();
_device = new HiStation[ip.Length];
for (int i = 0; i < _device.Length; i++)
{
_id.Add(ip[i], "000");
_device[i] = new HiStation(_logName) { IP = ip[i] };
_device[i].Connected += ReadAll_Connected;
_device[i].Received += ReadAll_Received;
_device[i].Open();
}
Common.log.Info("Server Start");
}
catch (Exception ex)
{
Common.log.Error("Start", ex);
}
}
/// <summary>
/// 停止
/// </summary>
public void Stop()
{
if (_device != null)
{
for (int i = 0; i < _device.Length; i++)
{
try
{
_device[i].TriggerMode(false);
System.Threading.Thread.Sleep(50);
_device[i].Close();
}
catch (Exception ex)
{
Common.log.Error("Stop", ex);
}
}
}
_device = null;
Common.log.Info("Server Stop");
}
/// <summary>
/// 读取ID号
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
public string Read(string ip)
{
if (_id.TryGetValue(ip, out string value))
{
Common.log.Info("[" + ip + "]Read " + value);
return value;
}
else
{
Common.log.Info("[" + ip + "]Read 没有找到");
return "000";
}
}
/// <summary>
/// 清除缓存
/// </summary>
/// <param name="ip"></param>
public void Clear(string ip)
{
if (_id.ContainsKey(ip))
{
_id[ip] = "000";
Common.log.Info("[" + ip + "]Clear");
}
else
{
Common.log.Info("[" + ip + "]Clear 没有找到");
}
}
private void ReadAll_Connected(string ip)
{
int index = -1;
foreach (var ss in _id.Keys)
{
index++;
if (ss == ip)
break;
}
if (index != -1)
_device[index].TriggerMode(true);
}
private void ReadAll_Received(string ip, string uid, string data)
{
Common.log.Debug("Received IP=" + ip + " uid=" + uid + " data=" + data);
if (_id[ip] == data)
{
}
else
{
_id[ip] = data;
Received?.Invoke(ip, data);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Asa.RFID
{
/// <summary>
/// 读取所有RFID
/// </summary>
public class ReadAll : IReadAll
{
///// <summary>
///// 接收数据包事件
///// </summary>
///// <param name="ip"></param>
///// <param name="id"></param>
//public delegate void ReceivedEvent(string ip, string id);
///// <summary>
///// 接收数据包
///// </summary>
//public event ReceivedEvent Received;
///// <summary>
///// 接收网卡缓存事件
///// </summary>
///// <param name="ip"></param>
///// <param name="buffer"></param>
//public delegate void ReceiveBufferEvent(string ip, byte[] buffer);
///// <summary>
///// 接收网卡缓存
///// </summary>
//public event ReceiveBufferEvent ReceiveBuffer;
private bool _loop;
private Socket _server; //服务端
private List<Client> _client; //所有客户端
private Thread tListenClient; //监听客户端连接
private Dictionary<string, string> _id; //RFID编号
private log4net.ILog log = null;
private const int CLIENT_SLEEP = 10;
public event IReadAll.ReceivedEvent Received;
public event IReadAll.ReceiveBufferEvent ReceiveBuffer;
/// <summary>
/// 读取所有RFID
/// </summary>
/// <param name="logName">日志名称</param>
public ReadAll(string logName)
{
_id = new Dictionary<string, string>();
if (log == null)
log = log4net.LogManager.GetLogger(logName);
}
/// <summary>
/// 开启
/// </summary>
/// <param name="port">RFID设备的端口</param>
public void Start(int port = 13000)
{
try
{
IPEndPoint localEP = new IPEndPoint(IPAddress.Any, port);
_server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
_server.Bind(localEP);
_server.Listen(100);
_loop = true;
_client = new List<Client>();
tListenClient = new Thread(new ThreadStart(ListenClient));
tListenClient.Start();
log.Info("Server Start");
}
catch (Exception ex)
{
log.Error("Start", ex);
}
}
public void Start(string[] ip)
{
}
/// <summary>
/// 停止
/// </summary>
public void Stop()
{
_loop = false;
for (int i = 0; i < _client.Count; i++)
ClientClose(i);
try
{
_id.Clear();
_server.Close();
_client = null;
log.Info("Server Stop");
}
catch (Exception ex)
{
log.Error("Stop", ex);
}
}
/// <summary>
/// 读取ID号
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
public string Read(string ip)
{
if (_id.TryGetValue(ip, out string value))
{
log.Info("Read " + ip + " -> " + value);
return value;
}
else
{
log.Info("Read " + ip + " not exist, return 000");
return "000";
}
}
/// <summary>
/// 清除缓存
/// </summary>
/// <param name="ip"></param>
public void Clear(string ip)
{
if (_id.ContainsKey(ip))
{
_id[ip] = "000";
log.Info("Clear " + ip);
}
else
{
log.Info("Clear " + ip + " not exist");
}
}
private void ClientClose(int idx)
{
try
{
_client[idx].Loop = false;
_client[idx].IsConn = false;
_client[idx].Socket.Close();
log.Info(_client[idx].IP + " Close");
}
catch (Exception ex)
{
log.Error(_client[idx].IP + " ClientClose", ex);
}
}
private void ListenClient()
{
while (_loop)
{
try
{
Socket socket = _server.Accept(); //这边会暂停,不需要sleep
IPEndPoint ep = (IPEndPoint)socket.RemoteEndPoint;
Thread listen = new Thread(new ParameterizedThreadStart(ListenNet));
string ip = ep.Address.ToString();
//新的客户端
Client client = new Client
{
IP = ip,
Loop = true,
IsConn = true,
Socket = socket,
ListenNet = listen,
};
//重连后关闭旧连接
int idx = _client.FindIndex(s => s.IP.Equals(ip));
if (idx > -1)
{
_id[_client[idx].IP] = "000";
_client[idx].IsConn = false;
_client[idx].Loop = false;
_client[idx].Socket.Close();
log.Info(_client[idx].IP + " 重连,删除重复。");
_client.RemoveAt(idx);
}
//添加到数组
if (!_id.ContainsKey(client.IP))
_id.Add(client.IP, "000");
_client.Add(client);
log.Info(client.IP + " 连接");
listen.Start(_client.Count - 1);
}
catch (SocketException)
{
//关闭连接,退出阻塞Accept
log.Error("Socket Close");
}
catch (Exception ex)
{
log.Error("ListenClient", ex);
}
}
}
private void ListenNet(object obj)
{
const int LENGTH = 8; //实际使用8字节
Client client = _client[(int)obj];
List<byte> receive = new List<byte>();
byte[] buff = new byte[client.Socket.ReceiveBufferSize];
while (client.Loop)
{
Thread.Sleep(CLIENT_SLEEP);
try
{
if (!client.Loop) break;
if (client.Socket.Available > 0)
{
int count = client.Socket.Receive(buff);
byte[] temp = new byte[count];
Array.Copy(buff, 0, temp, 0, count);
//16进制字符串转字节数组
string s = Encoding.ASCII.GetString(temp);
s = s.Replace("\r", "");
s = s.Replace("\n", "");
log.Debug("ListenNet " + s);
temp = new byte[s.Length / 2];
for (int i = 0; i < temp.Length; i++)
{
temp[i] = Convert.ToByte(s.Substring(i * 2, 2), 16);
}
receive.AddRange(temp);
log.Debug("Receive[" + client.IP + "]: " + HexBuff(temp));
//Task.Run(() => ReceiveBuffer?.Invoke(client.IP, temp));
do
{
//查找包头
int idx = receive.FindIndex(n => n == 0x5A);
if (idx == -1)
{
log.Debug("清除缓存[" + client.IP + "]: " + HexBuff(receive));
receive.Clear();
break;
}
//长度不够,半个包
int len = idx + LENGTH;
if (len > receive.Count) break;
//查找包尾
if (receive[len - 3] == 0x4A) //一个系统的0,两个校验位
{
byte[] arr = new byte[LENGTH];
receive.CopyTo(idx, arr, 0, 4);
receive.CopyTo(idx + 4, arr, 4, 4);
log.Info("Packet[" + client.IP + "]: " + HexBuff(arr));
TriggerEvent(client.IP, arr);
//2020年6月5日
//Task.Run(() => TriggerEvent(client.IP, arr));
}
else
{
log.Debug("没有包尾[" + client.IP + "]: " + HexBuff(receive));
}
receive.RemoveRange(0, len);
} while (true);
}
}
catch (Exception ex)
{
log.Error(client.IP + " ListenNet", ex);
}
}
}
private void TriggerEvent(string ip, byte[] buff)
{
string s;
if (buff[1] == 0)
{
s = "000";
log.Info(ip + " byte 0");
}
else
{
s = (char)buff[1] + buff[2].ToString();
}
//添加到缓存
if (_id[ip].Equals(s))
{
log.Debug("相同ID[" + ip + "]: " + s);
}
else
{
_id[ip] = s;
log.Info("Trigger[" + ip + "]: " + s);
Task.Run(() => Received?.Invoke(ip, s));
}
}
private string HexBuff(byte[] buff)
{
string s = "";
if (buff == null) return s;
for (int i = 0; i < buff.Length; i++)
s += buff[i].ToString("X2") + " ";
return s;
}
private string HexBuff(List<byte> buff)
{
string s = "";
if (buff == null) return s;
for (int i = 0; i < buff.Count; i++)
s += buff[i].ToString("X2") + " ";
return s;
}
private class Client
{
public bool Loop;
public string IP;
public bool IsConn;
public Socket Socket;
public Thread ListenNet;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Asa.RFID
{
public static class Common
{
public static log4net.ILog log = null;
}
}
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID-HiStation\bin\Debug\Asa.RFID.HiStation.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID-HiStation\bin\Debug\Asa.RFID.HiStation.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID-HiStation\bin\Debug\Asa.RFID.IReadAll.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID-HiStation\bin\Debug\log4net.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID-HiStation\bin\Debug\Asa.RFID.IReadAll.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID-HiStation\obj\Debug\RFID-HiStation.csprojAssemblyReference.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID-HiStation\obj\Debug\RFID-HiStation.csproj.CoreCompileInputs.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID-HiStation\obj\Debug\RFID-HiStation.csproj.CopyComplete
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID-HiStation\obj\Debug\Asa.RFID.HiStation.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID-HiStation\obj\Debug\Asa.RFID.HiStation.pdb
D:\Neotel\RFID\RFID-HiStation\bin\Debug\Asa.RFID.HiStation.dll
D:\Neotel\RFID\RFID-HiStation\bin\Debug\Asa.RFID.HiStation.pdb
D:\Neotel\RFID\RFID-HiStation\bin\Debug\Asa.RFID.IReadAll.dll
D:\Neotel\RFID\RFID-HiStation\bin\Debug\log4net.dll
D:\Neotel\RFID\RFID-HiStation\bin\Debug\Asa.RFID.IReadAll.pdb
D:\Neotel\RFID\RFID-HiStation\obj\Debug\RFID-HiStation.csprojAssemblyReference.cache
D:\Neotel\RFID\RFID-HiStation\obj\Debug\RFID-HiStation.csproj.CoreCompileInputs.cache
D:\Neotel\RFID\RFID-HiStation\obj\Debug\RFID-HiStation.csproj.CopyComplete
D:\Neotel\RFID\RFID-HiStation\obj\Debug\Asa.RFID.HiStation.dll
D:\Neotel\RFID\RFID-HiStation\obj\Debug\Asa.RFID.HiStation.pdb
C:\Neotel\Program\RFID\RFID-HiStation\bin\Debug\Asa.RFID.HiStation.dll
C:\Neotel\Program\RFID\RFID-HiStation\bin\Debug\Asa.RFID.HiStation.pdb
C:\Neotel\Program\RFID\RFID-HiStation\bin\Debug\Asa.RFID.IReadAll.dll
C:\Neotel\Program\RFID\RFID-HiStation\bin\Debug\Asa.RFID.IReadAll.pdb
C:\Neotel\Program\RFID\RFID-HiStation\obj\Debug\RFID-HiStation.csprojAssemblyReference.cache
C:\Neotel\Program\RFID\RFID-HiStation\obj\Debug\RFID-HiStation.csproj.CoreCompileInputs.cache
C:\Neotel\Program\RFID\RFID-HiStation\obj\Debug\RFID-HiStation.csproj.CopyComplete
C:\Neotel\Program\RFID\RFID-HiStation\obj\Debug\Asa.RFID.HiStation.dll
C:\Neotel\Program\RFID\RFID-HiStation\obj\Debug\Asa.RFID.HiStation.pdb

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30011.22
VisualStudioVersion = 16.0.31112.23
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RFID", "RFID\RFID.csproj", "{CF083E56-FA69-4893-90C4-6D0430ADC03F}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RFIDReadAll", "RFIDReadAll\RFIDReadAll.csproj", "{81468FBA-FD2C-42E8-B116-B0D9AB1CBD7F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RFID_Debug", "RFID_Debug\RFID_Debug.csproj", "{44467E65-C850-4538-96E4-1335CCCB87BC}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{1D69196B-2321-4824-B684-50010DD43702}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RFID_HFReader", "RFID_HFReader\RFID_HFReader.csproj", "{E352E032-435C-4EB1-96B4-018BDC50B105}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RFID_HaoBin", "RFID_HaoBin\RFID_HaoBin.csproj", "{6B0B49DF-B379-49C6-9983-6C9076F99711}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RFID_HFReader_Debug", "RFID_HFReader_Debug\RFID_HFReader_Debug.csproj", "{5C55663B-DBDA-490B-A80F-0ABB173AEF88}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RFID_PuYue", "RFID_PuYue\RFID_PuYue.csproj", "{6AFA3060-1DFF-4AC0-B082-827C451E5FF7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RFID_Interface", "RFID_Interface\RFID_Interface.csproj", "{E7A36C72-093B-428E-A4E3-4739EE0BF4CC}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RFID_HaoBin_Debug", "RFID_HaoBin_Debug\RFID_HaoBin_Debug.csproj", "{9EB46CB8-79C8-4E19-B04B-EABE52C54E33}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RFID-HiStation", "RFID-HiStation\RFID-HiStation.csproj", "{4D5996F8-7206-480D-834A-BE1DB5FB05B2}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RFID_PuYue_Debug", "RFID_PuYue_Debug\RFID_PuYue_Debug.csproj", "{1ED209BC-07E5-48AC-AFD3-21E5E3D58B6E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CF083E56-FA69-4893-90C4-6D0430ADC03F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CF083E56-FA69-4893-90C4-6D0430ADC03F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF083E56-FA69-4893-90C4-6D0430ADC03F}.Debug|x86.ActiveCfg = Debug|Any CPU
{CF083E56-FA69-4893-90C4-6D0430ADC03F}.Debug|x86.Build.0 = Debug|Any CPU
{CF083E56-FA69-4893-90C4-6D0430ADC03F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CF083E56-FA69-4893-90C4-6D0430ADC03F}.Release|Any CPU.Build.0 = Release|Any CPU
{CF083E56-FA69-4893-90C4-6D0430ADC03F}.Release|x86.ActiveCfg = Release|Any CPU
{CF083E56-FA69-4893-90C4-6D0430ADC03F}.Release|x86.Build.0 = Release|Any CPU
{44467E65-C850-4538-96E4-1335CCCB87BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{44467E65-C850-4538-96E4-1335CCCB87BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{44467E65-C850-4538-96E4-1335CCCB87BC}.Debug|x86.ActiveCfg = Debug|Any CPU
{44467E65-C850-4538-96E4-1335CCCB87BC}.Debug|x86.Build.0 = Debug|Any CPU
{44467E65-C850-4538-96E4-1335CCCB87BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{44467E65-C850-4538-96E4-1335CCCB87BC}.Release|Any CPU.Build.0 = Release|Any CPU
{44467E65-C850-4538-96E4-1335CCCB87BC}.Release|x86.ActiveCfg = Release|Any CPU
{44467E65-C850-4538-96E4-1335CCCB87BC}.Release|x86.Build.0 = Release|Any CPU
{E352E032-435C-4EB1-96B4-018BDC50B105}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E352E032-435C-4EB1-96B4-018BDC50B105}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E352E032-435C-4EB1-96B4-018BDC50B105}.Debug|x86.ActiveCfg = Debug|x86
{E352E032-435C-4EB1-96B4-018BDC50B105}.Debug|x86.Build.0 = Debug|x86
{E352E032-435C-4EB1-96B4-018BDC50B105}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E352E032-435C-4EB1-96B4-018BDC50B105}.Release|Any CPU.Build.0 = Release|Any CPU
{E352E032-435C-4EB1-96B4-018BDC50B105}.Release|x86.ActiveCfg = Release|x86
{E352E032-435C-4EB1-96B4-018BDC50B105}.Release|x86.Build.0 = Release|x86
{5C55663B-DBDA-490B-A80F-0ABB173AEF88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5C55663B-DBDA-490B-A80F-0ABB173AEF88}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5C55663B-DBDA-490B-A80F-0ABB173AEF88}.Debug|x86.ActiveCfg = Debug|x86
{5C55663B-DBDA-490B-A80F-0ABB173AEF88}.Debug|x86.Build.0 = Debug|x86
{5C55663B-DBDA-490B-A80F-0ABB173AEF88}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5C55663B-DBDA-490B-A80F-0ABB173AEF88}.Release|Any CPU.Build.0 = Release|Any CPU
{5C55663B-DBDA-490B-A80F-0ABB173AEF88}.Release|x86.ActiveCfg = Release|x86
{5C55663B-DBDA-490B-A80F-0ABB173AEF88}.Release|x86.Build.0 = Release|x86
{E7A36C72-093B-428E-A4E3-4739EE0BF4CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E7A36C72-093B-428E-A4E3-4739EE0BF4CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E7A36C72-093B-428E-A4E3-4739EE0BF4CC}.Debug|x86.ActiveCfg = Debug|Any CPU
{E7A36C72-093B-428E-A4E3-4739EE0BF4CC}.Debug|x86.Build.0 = Debug|Any CPU
{E7A36C72-093B-428E-A4E3-4739EE0BF4CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E7A36C72-093B-428E-A4E3-4739EE0BF4CC}.Release|Any CPU.Build.0 = Release|Any CPU
{E7A36C72-093B-428E-A4E3-4739EE0BF4CC}.Release|x86.ActiveCfg = Release|Any CPU
{E7A36C72-093B-428E-A4E3-4739EE0BF4CC}.Release|x86.Build.0 = Release|Any CPU
{4D5996F8-7206-480D-834A-BE1DB5FB05B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4D5996F8-7206-480D-834A-BE1DB5FB05B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D5996F8-7206-480D-834A-BE1DB5FB05B2}.Debug|x86.ActiveCfg = Debug|Any CPU
{4D5996F8-7206-480D-834A-BE1DB5FB05B2}.Debug|x86.Build.0 = Debug|Any CPU
{4D5996F8-7206-480D-834A-BE1DB5FB05B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D5996F8-7206-480D-834A-BE1DB5FB05B2}.Release|Any CPU.Build.0 = Release|Any CPU
{4D5996F8-7206-480D-834A-BE1DB5FB05B2}.Release|x86.ActiveCfg = Release|Any CPU
{4D5996F8-7206-480D-834A-BE1DB5FB05B2}.Release|x86.Build.0 = Release|Any CPU
{81468FBA-FD2C-42E8-B116-B0D9AB1CBD7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{81468FBA-FD2C-42E8-B116-B0D9AB1CBD7F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{81468FBA-FD2C-42E8-B116-B0D9AB1CBD7F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{81468FBA-FD2C-42E8-B116-B0D9AB1CBD7F}.Release|Any CPU.Build.0 = Release|Any CPU
{1D69196B-2321-4824-B684-50010DD43702}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D69196B-2321-4824-B684-50010DD43702}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D69196B-2321-4824-B684-50010DD43702}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D69196B-2321-4824-B684-50010DD43702}.Release|Any CPU.Build.0 = Release|Any CPU
{6B0B49DF-B379-49C6-9983-6C9076F99711}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6B0B49DF-B379-49C6-9983-6C9076F99711}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B0B49DF-B379-49C6-9983-6C9076F99711}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6B0B49DF-B379-49C6-9983-6C9076F99711}.Release|Any CPU.Build.0 = Release|Any CPU
{6AFA3060-1DFF-4AC0-B082-827C451E5FF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6AFA3060-1DFF-4AC0-B082-827C451E5FF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6AFA3060-1DFF-4AC0-B082-827C451E5FF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6AFA3060-1DFF-4AC0-B082-827C451E5FF7}.Release|Any CPU.Build.0 = Release|Any CPU
{9EB46CB8-79C8-4E19-B04B-EABE52C54E33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9EB46CB8-79C8-4E19-B04B-EABE52C54E33}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9EB46CB8-79C8-4E19-B04B-EABE52C54E33}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9EB46CB8-79C8-4E19-B04B-EABE52C54E33}.Release|Any CPU.Build.0 = Release|Any CPU
{1ED209BC-07E5-48AC-AFD3-21E5E3D58B6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1ED209BC-07E5-48AC-AFD3-21E5E3D58B6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1ED209BC-07E5-48AC-AFD3-21E5E3D58B6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1ED209BC-07E5-48AC-AFD3-21E5E3D58B6E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A8311F25-CF54-49C8-8F94-BC7576D497F3}
SolutionGuid = {D46FD659-1323-49C4-96F9-F5DA44E899AB}
EndGlobalSection
EndGlobal
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Asa.RFID
{
/// <summary>
/// 读取所有RFID
/// </summary>
public class ReadAll1 : IReadAll
{
///// <summary>
///// 接收数据包事件
///// </summary>
///// <param name="ip"></param>
///// <param name="id"></param>
//public delegate void ReceivedEvent(string ip, string id);
///// <summary>
///// 接收数据包
///// </summary>
//public event ReceivedEvent Received;
///// <summary>
///// 接收网卡缓存事件
///// </summary>
///// <param name="ip"></param>
///// <param name="buffer"></param>
//public delegate void ReceiveBufferEvent(string ip, byte[] buffer);
///// <summary>
///// 接收网卡缓存
///// </summary>
//public event ReceiveBufferEvent ReceiveBuffer;
private bool _loop;
private Socket _server; //服务端
private List<Client> _client; //所有客户端
private Thread tListenClient; //监听客户端连接
private Dictionary<string, string> _id; //RFID编号
private log4net.ILog log = null;
private const int CLIENT_SLEEP = 10;
public event IReadAll.ReceivedEvent Received;
public event IReadAll.ReceiveBufferEvent ReceiveBuffer;
/// <summary>
/// 读取所有RFID
/// </summary>
/// <param name="logName">日志名称</param>
public ReadAll1(string logName)
{
_id = new Dictionary<string, string>();
if (log == null)
log = log4net.LogManager.GetLogger(logName);
}
/// <summary>
/// 开启
/// </summary>
/// <param name="port">RFID设备的端口</param>
public void Start(int port = 13000)
{
try
{
IPEndPoint localEP = new IPEndPoint(IPAddress.Any, port);
_server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
_server.Bind(localEP);
_server.Listen(100);
_loop = true;
_client = new List<Client>();
tListenClient = new Thread(new ThreadStart(ListenClient));
tListenClient.Start();
log.Info("Server Start");
}
catch (Exception ex)
{
log.Error("Start", ex);
}
}
public void Start(string[] ip)
{
}
/// <summary>
/// 停止
/// </summary>
public void Stop()
{
_loop = false;
for (int i = 0; i < _client.Count; i++)
ClientClose(i);
try
{
_id.Clear();
_server.Close();
_client = null;
log.Info("Server Stop");
}
catch (Exception ex)
{
log.Error("Stop", ex);
}
}
/// <summary>
/// 读取ID号
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
public string Read(string ip)
{
if (_id.TryGetValue(ip, out string value))
{
log.Info("Read " + ip + " -> " + value);
return value;
}
else
{
log.Info("Read " + ip + " not exist, return 000");
return "000";
}
}
/// <summary>
/// 清除缓存
/// </summary>
/// <param name="ip"></param>
public void Clear(string ip)
{
if (_id.ContainsKey(ip))
{
_id[ip] = "000";
log.Info("Clear " + ip);
}
else
{
log.Info("Clear " + ip + " not exist");
}
}
private void ClientClose(int idx)
{
try
{
_client[idx].Loop = false;
_client[idx].IsConn = false;
_client[idx].Socket.Close();
log.Info(_client[idx].IP + " Close");
}
catch (Exception ex)
{
log.Error(_client[idx].IP + " ClientClose", ex);
}
}
private void ListenClient()
{
while (_loop)
{
try
{
Socket socket = _server.Accept(); //这边会暂停,不需要sleep
IPEndPoint ep = (IPEndPoint)socket.RemoteEndPoint;
Thread listen = new Thread(new ParameterizedThreadStart(ListenNet));
string ip = ep.Address.ToString();
//新的客户端
Client client = new Client
{
IP = ip,
Loop = true,
IsConn = true,
Socket = socket,
ListenNet = listen,
};
//重连后关闭旧连接
int idx = _client.FindIndex(s => s.IP.Equals(ip));
if (idx > -1)
{
_id[_client[idx].IP] = "000";
_client[idx].IsConn = false;
_client[idx].Loop = false;
_client[idx].Socket.Close();
log.Info(_client[idx].IP + " 重连,删除重复。");
_client.RemoveAt(idx);
}
//添加到数组
if (!_id.ContainsKey(client.IP))
_id.Add(client.IP, "000");
_client.Add(client);
log.Info(client.IP + " 连接");
listen.Start(_client.Count - 1);
}
catch (SocketException)
{
//关闭连接,退出阻塞Accept
log.Error("Socket Close");
}
catch (Exception ex)
{
log.Error("ListenClient", ex);
}
}
}
private void ListenNet(object obj)
{
const int LENGTH = 8; //实际使用8字节
Client client = _client[(int)obj];
List<byte> receive = new List<byte>();
byte[] buff = new byte[client.Socket.ReceiveBufferSize];
while (client.Loop)
{
Thread.Sleep(CLIENT_SLEEP);
try
{
if (!client.Loop) break;
if (client.Socket.Available > 0)
{
int count = client.Socket.Receive(buff);
byte[] temp = new byte[count];
Array.Copy(buff, 0, temp, 0, count);
receive.AddRange(temp);
log.Debug("Receive[" + client.IP + "]: " + HexBuff(temp));
Task.Run(() => ReceiveBuffer?.Invoke(client.IP, temp));
do
{
//查找包头
int idx = receive.FindIndex(n => n == 0x5A);
if (idx == -1)
{
log.Debug("清除缓存[" + client.IP + "]: " + HexBuff(receive));
receive.Clear();
break;
}
//长度不够,半个包
int len = idx + LENGTH + 1; //一个系统自带的0
if (len > receive.Count) break;
//查找包尾
if (receive[len - 3] == 0x4A) //一个系统的0,两个校验位
{
byte[] arr = new byte[LENGTH];
receive.CopyTo(idx, arr, 0, 4);
receive.CopyTo(idx + 5, arr, 4, 4);
log.Info("Packet[" + client.IP + "]: " + HexBuff(arr));
TriggerEvent(client.IP, arr);
//2020年6月5日
//Task.Run(() => TriggerEvent(client.IP, arr));
}
else
{
log.Debug("没有包尾[" + client.IP + "]: " + HexBuff(receive));
}
receive.RemoveRange(0, len);
} while (true);
}
}
catch (Exception ex)
{
log.Error(client.IP + " ListenNet", ex);
}
}
}
private void TriggerEvent(string ip, byte[] buff)
{
string s;
if (buff[1] == 0)
{
s = "000";
log.Info(ip + " byte 0");
}
else
{
s = (char)buff[1] + buff[2].ToString();
}
//添加到缓存
if (_id[ip].Equals(s))
{
log.Debug("相同ID[" + ip + "]: " + s);
}
else
{
_id[ip] = s;
log.Info("Trigger[" + ip + "]: " + s);
Task.Run(() => Received?.Invoke(ip, s));
}
}
private string HexBuff(byte[] buff)
{
string s = "";
if (buff == null) return s;
for (int i = 0; i < buff.Length; i++)
s += buff[i].ToString("X2") + " ";
return s;
}
private string HexBuff(List<byte> buff)
{
string s = "";
if (buff == null) return s;
for (int i = 0; i < buff.Count; i++)
s += buff[i].ToString("X2") + " ";
return s;
}
private class Client
{
public bool Loop;
public string IP;
public bool IsConn;
public Socket Socket;
public Thread ListenNet;
}
}
}
此文件类型无法预览
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID\obj\Debug\RFID.csproj.CoreCompileInputs.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID\obj\Debug\RFID.csproj.CopyComplete
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID\obj\Debug\RFID.csprojAssemblyReference.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID\bin\Debug\Asa.RFID.HFRead.xml
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID\bin\Debug\Asa.RFID.HFRead.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID\bin\Debug\Asa.RFID.HFRead.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID\bin\Debug\Asa.RFID.IReadAll.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID\bin\Debug\Asa.RFID.IReadAll.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID\obj\Debug\Asa.RFID.HFRead.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID\obj\Debug\Asa.RFID.HFRead.pdb
using System;
namespace Asa.RFID
{
internal class Client
{
public bool Loop;
public string IP;
public bool IsConn;
public System.Collections.Generic.List<byte> Buffer;
public System.Net.Sockets.Socket Socket;
public System.Threading.Thread ListenNet;
public Client(string ip, System.Net.Sockets.Socket socket, System.Threading.Thread listenNet)
{
Loop = true;
IP = ip;
IsConn = true;
Buffer = new System.Collections.Generic.List<byte>();
Socket = socket;
ListenNet = listenNet;
}
}
}
......@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RFID")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
......@@ -20,7 +20,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("cf083e56-fa69-4893-90c4-6d0430adc03f")]
[assembly: Guid("81468fba-fd2c-42e8-b116-b0d9ab1cbd7f")]
// 程序集的版本信息由下列四个值组成:
//
......@@ -34,3 +34,5 @@ using System.Runtime.InteropServices;
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]
\ No newline at end of file
......@@ -4,11 +4,11 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{CF083E56-FA69-4893-90C4-6D0430ADC03F}</ProjectGuid>
<ProjectGuid>{81468FBA-FD2C-42E8-B116-B0D9AB1CBD7F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Asa.RFID</RootNamespace>
<AssemblyName>Asa.RFID.HFRead</AssemblyName>
<AssemblyName>Asa.RFID.ReadAll</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
......@@ -21,8 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Asa.RFID.HFRead.xml</DocumentationFile>
<LangVersion>8.0</LangVersion>
<DocumentationFile>bin\Debug\Asa.RFID.ReadAll.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
......@@ -31,14 +30,15 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\..\..\DLL\log4net.dll</HintPath>
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
......@@ -47,14 +47,13 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="HFReader1.cs" />
<Compile Include="Client.cs" />
<Compile Include="ReadAll.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Type.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RFID_Interface\RFID_Interface.csproj">
<Project>{e7a36c72-093b-428e-a4e3-4739ee0bf4cc}</Project>
<Name>RFID_Interface</Name>
</ProjectReference>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Asa.RFID
{
/// <summary>
/// 读取所有RFID
/// </summary>
public class ReadAll
{
private bool serverLoop;
private Socket server; //服务端
private List<Client> clientList; //所有客户端
private Thread tListenClient; //监听客户端连接
private Dictionary<string, string> rfidID; //RFID编号
private readonly Dictionary<DeviceType, DecodeDelegate> decode; //解码
private readonly log4net.ILog log;
private const int CLIENT_SLEEP = 10;
private const int DATA_LENGTH = 8;
private delegate void DecodeDelegate(Client client, byte[] buff);
public delegate void ReceivedEvent(string ip, string id);
public event ReceivedEvent Received;
/// <summary>
/// 读取所有RFID
/// </summary>
/// <param name="logName">日志名称</param>
public ReadAll(string logName = "RFID.ReadAll")
{
rfidID = new Dictionary<string, string>();
decode = new Dictionary<DeviceType, DecodeDelegate>
{
{ DeviceType.PuYue, DecodePuYue },
{ DeviceType.HaoBin, DecodeHaoBin }
};
if (log == null)
log = log4net.LogManager.GetLogger(logName);
log.Debug("ReadAll实例化");
}
/// <summary>
/// 设备类型
/// </summary>
public DeviceType Type { set; get; } = DeviceType.PuYue;
/// <summary>
/// 开始
/// </summary>
/// <param name="port">端口号</param>
public void Start(int port = 13000)
{
try
{
IPEndPoint localEP = new IPEndPoint(IPAddress.Any, port);
server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
server.Bind(localEP);
server.Listen(100);
serverLoop = true;
clientList = new List<Client>();
tListenClient = new Thread(new ThreadStart(ListenClient));
tListenClient.Start();
string s = string.Format("Server Start({0}) OK", port);
log.Info(s);
}
catch (Exception ex)
{
string s = string.Format("Start({0})", port);
log.Error(s, ex);
}
}
/// <summary>
/// 停止
/// </summary>
public void Stop()
{
serverLoop = false;
if (clientList == null) return;
for (int i = 0; i < clientList.Count; i++)
ClientClose(i);
try
{
rfidID.Clear();
server.Close();
server.Dispose();
clientList = null;
log.Info("Server Stop OK");
}
catch (Exception ex)
{
log.Error("Stop", ex);
}
}
/// <summary>
/// 读取
/// </summary>
/// <param name="ip">IP地址</param>
/// <param name="defaultID">没有找到时返回</param>
/// <returns></returns>
public string Read(string ip, string defaultID = "000")
{
if (rfidID.TryGetValue(ip, out string value))
{
string s = string.Format("Read({0}): {1}", ip, value);
log.Info(s);
return value;
}
else
{
string s = string.Format("Read: {0}没有连接,返回{1}", ip, defaultID);
log.Info(s);
return defaultID;
}
}
/// <summary>
/// 读取所有
/// </summary>
/// <param name="defaultID">没有数据时返回</param>
public Dictionary<string, string> Read(string defaultID = "000")
{
Dictionary<string, string> dic = new Dictionary<string, string>();
foreach (string key in rfidID.Keys)
{
if (rfidID[key] == "")
dic.Add(key, defaultID);
else
dic.Add(key, rfidID[key]);
}
return dic;
}
/// <summary>
/// 清除缓存
/// </summary>
/// <param name="ip">IP地址</param>
/// <param name="defaultID">设置初始ID</param>
public void Clear(string ip, string defaultID = "000")
{
if (rfidID.ContainsKey(ip))
{
rfidID[ip] = defaultID;
string s = string.Format("Clear({0}): ID={1}", ip, defaultID);
log.Info(s);
}
else
{
string s = string.Format("Clear: {0}没有连接", ip);
log.Info(s);
}
}
/// <summary>
/// 清除所有缓存
/// </summary>
/// <param name="defaultID">设置初始ID</param>
public void Clear(string defaultID = "000")
{
Dictionary<string, string> temp = new Dictionary<string, string>();
foreach (string key in rfidID.Keys)
{
temp.Add(key, defaultID);
}
rfidID.Clear();
rfidID = new Dictionary<string, string>(temp);
string s = string.Format("Clear All: ID={0}", defaultID);
log.Info(s);
}
private void ClientClose(int idx)
{
try
{
clientList[idx].Loop = false;
clientList[idx].IsConn = false;
clientList[idx].Socket.Close();
clientList[idx].Socket.Dispose();
string s = string.Format("关闭 ({0})", clientList[idx].IP);
log.Info(s);
}
catch (Exception ex)
{
string s = string.Format("ClientClose ({0})", clientList[idx].IP);
log.Error(s, ex);
}
}
private void ListenClient()
{
string s;
while (serverLoop)
{
try
{
Socket socket = server.Accept(); //这边会暂停,不需要sleep
IPEndPoint ep = (IPEndPoint)socket.RemoteEndPoint;
Thread listen = new Thread(new ParameterizedThreadStart(ListenNet));
string ip = ep.Address.ToString();
//新的客户端
Client client = new Client(ip, socket, listen);
//重连后关闭旧连接
int idx = clientList.FindIndex(ls => ls.IP.Equals(ip));
if (idx > -1)
{
rfidID[clientList[idx].IP] = "";
clientList[idx].IsConn = false;
clientList[idx].Loop = false;
clientList[idx].Socket.Close();
s = string.Format("({0}) 重连,删除重复", clientList[idx].IP);
log.Info(s);
clientList.RemoveAt(idx);
}
//添加到数组
if (!rfidID.ContainsKey(client.IP))
rfidID.Add(client.IP, "");
clientList.Add(client);
s = string.Format("({0}) 连接服务端", client.IP);
log.Info(s);
listen.Start(clientList.Count - 1);
}
catch (SocketException)
{
//关闭连接,退出阻塞Accept
log.Info("Socket Close");
}
catch (Exception ex)
{
log.Error("ListenClient", ex);
}
}
}
private void ListenNet(object obj)
{
Client client = clientList[(int)obj];
while (client.Loop)
{
Thread.Sleep(CLIENT_SLEEP);
try
{
if (!client.Loop) break;
int count = client.Socket.Available;
if (count > 0)
{
byte[] buff = new byte[count];
client.Socket.Receive(buff);
decode[Type].Invoke(client, buff);
}
}
catch (Exception ex)
{
string s = string.Format("ListenNet: {0}", client.IP);
log.Error(s, ex);
}
}
}
private void DecodeHaoBin(Client client, byte[] buff)
{
client.Buffer.AddRange(buff);
string s = string.Format("Net Receive({0}): {1}", client.IP, HexBuff(buff));
log.Debug(s);
while (client.Loop)
{
if (client.Buffer.Count == 0) break;
//查找包头
int idx = client.Buffer.FindIndex(n => n == 0x5A);
if (idx == -1)
{
s = string.Format("[{0}]没有找到包头5A,清除缓存,{1}", client.IP, HexBuff(client.Buffer));
log.Debug(s);
client.Buffer.Clear();
break;
}
//长度不够,半个包
//该设备会自带0,每块数据之间插入一个0,1块数据为4个字节
//这里只读2块数据,中间插入一个0
int len = idx + DATA_LENGTH + 1;
if (len > client.Buffer.Count) break;
//查找包尾
if (client.Buffer[len - 3] == 0x4A) //最后两个校验位
{
byte[] arr = new byte[DATA_LENGTH];
client.Buffer.CopyTo(idx, arr, 0, 4);
client.Buffer.CopyTo(idx + 5, arr, 4, 4);
client.Buffer.RemoveRange(0, len);
TriggerEvent(client.IP, arr);
}
else
{
s = string.Format("[{0}]没有找到包尾4A,{1}", client.IP, HexBuff(client.Buffer));
log.Debug(s);
client.Buffer.RemoveRange(0, idx + 1);
}
}
}
private void DecodePuYue(Client client, byte[] buff)
{
string s;
string hex = Encoding.ASCII.GetString(buff);
hex = hex.Replace("\r", "");
hex = hex.Replace("\n", "");
buff = new byte[hex.Length / 2];
for (int i = 0; i < buff.Length; i++)
buff[i] = Convert.ToByte(hex.Substring(i * 2, 2), 16);
client.Buffer.AddRange(buff);
s = string.Format("Net Receive({0}): {1}", client.IP, HexBuff(buff));
log.Debug(s);
while (client.Loop)
{
if (client.Buffer.Count == 0) break;
//查找包头
int idx = client.Buffer.FindIndex(n => n == 0x5A);
if (idx == -1)
{
s = string.Format("[{0}]没有找到包头5A,清除缓存,{1}", client.IP, HexBuff(client.Buffer));
log.Debug(s);
client.Buffer.Clear();
break;
}
//长度不够,半个包
int len = idx + DATA_LENGTH;
if (len > client.Buffer.Count) break;
//查找包尾
if (client.Buffer[len - 3] == 0x4A) //最后两个校验位
{
byte[] arr = new byte[DATA_LENGTH];
client.Buffer.CopyTo(idx, arr, 0, DATA_LENGTH);
client.Buffer.RemoveRange(0, len);
TriggerEvent(client.IP, arr);
}
else
{
s = string.Format("[{0}]没有找到包尾4A,{1}", client.IP, HexBuff(client.Buffer));
log.Debug(s);
client.Buffer.RemoveRange(0, idx + 1);
}
}
}
private void TriggerEvent(string ip, byte[] buff)
{
string s = "";
if (buff[1] >= 65 && buff[1] <= 90) //在A-Z范围
s = (char)buff[1] + buff[2].ToString();
log.Info("TriggerEvent ip=" + ip + " rfid=" + s);
//添加到缓存
if (rfidID[ip] == s)
{
log.Debug("相同ID[" + ip + "]: " + s);
}
else
{
rfidID[ip] = s;
if (Received != null)
{
log.Info("触发事件(" + ip + "): " + s);
Task.Run(() => Received.Invoke(ip, s));
}
}
}
private string HexBuff(byte[] buff)
{
string s = "";
if (buff == null) return s;
for (int i = 0; i < buff.Length; i++)
s += buff[i].ToString("X2") + " ";
return s;
}
private string HexBuff(List<byte> buff)
{
string s = "";
if (buff == null) return s;
for (int i = 0; i < buff.Count; i++)
s += buff[i].ToString("X2") + " ";
return s;
}
}
}
using System;
namespace Asa.RFID
{
/// <summary>
/// RFID读卡器类型
/// </summary>
public enum DeviceType
{
/// <summary>
/// 普阅(新)
/// </summary>
PuYue,
/// <summary>
/// 浩斌(旧)
/// </summary>
HaoBin
}
}
<?xml version="1.0"?>
<doc>
<assembly>
<name>Asa.RFID</name>
<name>Asa.RFID.ReadAll</name>
</assembly>
<members>
<member name="T:Asa.RFID.ReadAll">
......@@ -9,59 +9,69 @@
读取所有RFID
</summary>
</member>
<member name="T:Asa.RFID.ReadAll.ReceivedEvent">
<member name="M:Asa.RFID.ReadAll.#ctor(System.String)">
<summary>
接收数据包事件
读取所有RFID
</summary>
<param name="ip"></param>
<param name="id"></param>
<param name="logName">日志名称</param>
</member>
<member name="E:Asa.RFID.ReadAll.Received">
<member name="P:Asa.RFID.ReadAll.Type">
<summary>
接收数据包
设备类型
</summary>
</member>
<member name="T:Asa.RFID.ReadAll.ReceiveBufferEvent">
<member name="M:Asa.RFID.ReadAll.Start(System.Int32)">
<summary>
接收网卡缓存事件
开始
</summary>
<param name="ip"></param>
<param name="buffer"></param>
<param name="port">端口号</param>
</member>
<member name="E:Asa.RFID.ReadAll.ReceiveBuffer">
<member name="M:Asa.RFID.ReadAll.Stop">
<summary>
接收网卡缓存
停止
</summary>
</member>
<member name="M:Asa.RFID.ReadAll.#ctor(System.String)">
<member name="M:Asa.RFID.ReadAll.Read(System.String,System.String)">
<summary>
读取所有RFID
读取
</summary>
<param name="logName">日志名称</param>
<param name="ip">IP地址</param>
<param name="defaultID">没有找到时返回</param>
<returns></returns>
</member>
<member name="M:Asa.RFID.ReadAll.Start(System.Int32)">
<member name="M:Asa.RFID.ReadAll.Read(System.String)">
<summary>
开启
读取所有
</summary>
<param name="port">RFID设备的端口</param>
<param name="defaultID">没有数据时返回</param>
</member>
<member name="M:Asa.RFID.ReadAll.Stop">
<member name="M:Asa.RFID.ReadAll.Clear(System.String,System.String)">
<summary>
停止
清除缓存
</summary>
<param name="ip">IP地址</param>
<param name="defaultID">设置初始ID</param>
</member>
<member name="M:Asa.RFID.ReadAll.Read(System.String)">
<member name="M:Asa.RFID.ReadAll.Clear(System.String)">
<summary>
读取ID号
清除所有缓存
</summary>
<param name="ip"></param>
<returns></returns>
<param name="defaultID">设置初始ID</param>
</member>
<member name="M:Asa.RFID.ReadAll.Clear(System.String)">
<member name="T:Asa.RFID.DeviceType">
<summary>
清除缓存
RFID读卡器类型
</summary>
</member>
<member name="F:Asa.RFID.DeviceType.PuYue">
<summary>
普阅(新)
</summary>
</member>
<member name="F:Asa.RFID.DeviceType.HaoBin">
<summary>
浩斌(旧)
</summary>
<param name="ip"></param>
</member>
</members>
</doc>
此文件类型无法预览
此文件的差异太大,无法显示。
d69d24ca92ce59f253592160c011f48788aec243
C:\Neotel\Program\RFID\RFID\bin\Debug\Asa.RFID.ReadAll.xml
C:\Neotel\Program\RFID\RFID\bin\Debug\Asa.RFID.ReadAll.dll
C:\Neotel\Program\RFID\RFID\bin\Debug\Asa.RFID.ReadAll.pdb
C:\Neotel\Program\RFID\RFID\bin\Debug\log4net.dll
C:\Neotel\Program\RFID\RFID\bin\Debug\log4net.xml
C:\Neotel\Program\RFID\RFID\obj\Debug\RFID.csprojAssemblyReference.cache
C:\Neotel\Program\RFID\RFID\obj\Debug\RFID.csproj.CoreCompileInputs.cache
C:\Neotel\Program\RFID\RFID\obj\Debug\RFID.csproj.CopyComplete
C:\Neotel\Program\RFID\RFID\obj\Debug\Asa.RFID.ReadAll.dll
C:\Neotel\Program\RFID\RFID\obj\Debug\Asa.RFID.ReadAll.pdb
C:\Neotel\Program\RFID\RFID\bin\Debug\Asa.RFID.ReadAll.xml
C:\Neotel\Program\RFID\RFID\bin\Debug\Asa.RFID.ReadAll.dll
C:\Neotel\Program\RFID\RFID\bin\Debug\Asa.RFID.ReadAll.pdb
C:\Neotel\Program\RFID\RFID\bin\Debug\log4net.dll
C:\Neotel\Program\RFID\RFID\bin\Debug\log4net.xml
C:\Neotel\Program\RFID\RFID\obj\Debug\RFIDReadAll.csproj.CoreCompileInputs.cache
C:\Neotel\Program\RFID\RFID\obj\Debug\RFIDReadAll.csproj.CopyComplete
C:\Neotel\Program\RFID\RFID\obj\Debug\Asa.RFID.ReadAll.dll
C:\Neotel\Program\RFID\RFID\obj\Debug\Asa.RFID.ReadAll.pdb
C:\Neotel\Program\RFID\RFIDReadAll\bin\Debug\Asa.RFID.ReadAll.xml
C:\Neotel\Program\RFID\RFIDReadAll\bin\Debug\Asa.RFID.ReadAll.dll
C:\Neotel\Program\RFID\RFIDReadAll\bin\Debug\Asa.RFID.ReadAll.pdb
C:\Neotel\Program\RFID\RFIDReadAll\bin\Debug\log4net.dll
C:\Neotel\Program\RFID\RFIDReadAll\bin\Debug\log4net.xml
C:\Neotel\Program\RFID\RFIDReadAll\obj\Debug\RFIDReadAll.csproj.CoreCompileInputs.cache
C:\Neotel\Program\RFID\RFIDReadAll\obj\Debug\RFIDReadAll.csproj.CopyComplete
C:\Neotel\Program\RFID\RFIDReadAll\obj\Debug\Asa.RFID.ReadAll.dll
C:\Neotel\Program\RFID\RFIDReadAll\obj\Debug\Asa.RFID.ReadAll.pdb
C:\Neotel\Program\RFID\RFIDReadAll\obj\Debug\RFIDReadAll.csprojAssemblyReference.cache
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.12" targetFramework="net461" />
</packages>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="logs/ACStore-RC29-1.log"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n"/>
</layout>
</appender>
<root>
<level value="Debug"/>
<appender-ref ref="RollingLogFileAppender"/>
</root>
</log4net>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="logs/ACStore-RC29-1.log"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n"/>
</layout>
</appender>
<root>
<level value="Debug"/>
<appender-ref ref="RollingLogFileAppender"/>
</root>
</log4net>
</configuration>
\ No newline at end of file
此文件类型无法预览
此文件的差异太大,无法显示。
[2020-05-18 19:26:35,552][1]INFO aa
[2020-05-18 19:26:46,230][1]INFO Server Start
[2020-05-18 19:26:53,811][1]INFO Server Stop
[2020-05-18 19:26:53,836][3]ERROR Socket Close
[2020-05-18 20:01:28,262][1]INFO Server Start
[2020-05-18 20:02:26,513][1]INFO Server Start
[2020-05-18 20:02:31,438][1]INFO Server Stop
[2020-05-18 20:02:31,457][3]ERROR Socket Close
[2020-05-18 20:03:21,924][1]INFO Server Start
[2020-05-18 20:03:44,909][1]INFO Server Stop
[2020-05-18 20:03:44,926][3]ERROR Socket Close
[2020-05-18 20:05:17,709][1]INFO Server Start
[2020-05-18 20:05:20,758][1]INFO Server Stop
[2020-05-18 20:05:20,776][3]ERROR Socket Close
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Debug\bin\Debug\RFID_Debug.exe.config
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Debug\bin\Debug\RFID_Debug.exe
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Debug\bin\Debug\RFID_Debug.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Debug\obj\Debug\RFID_Debug.csprojAssemblyReference.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Debug\obj\Debug\RFID_Debug.Form1.resources
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Debug\obj\Debug\RFID_Debug.Properties.Resources.resources
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Debug\obj\Debug\RFID_Debug.csproj.GenerateResource.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Debug\obj\Debug\RFID_Debug.csproj.CoreCompileInputs.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Debug\obj\Debug\RFID_Debug.csproj.CopyComplete
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Debug\obj\Debug\RFID_Debug.exe
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Debug\obj\Debug\RFID_Debug.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Debug\bin\Debug\Asa.RFID.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Debug\bin\Debug\Asa.RFID.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Debug\bin\Debug\Asa.RFID.xml
using System;
namespace Asa.RFID
{
/// <summary>
/// RFID读卡器
/// </summary>
public class HFReaderAll
{
private Log log;
private string currIP;
private string[] _ip;
private HFReader[] reader;
private byte[][] buffer;
//private System.Threading.Thread tRecon;
//private System.Threading.Thread tSave;
//private System.Collections.Concurrent.ConcurrentQueue<string> log;
public delegate void GetValueEvent(string s);
public event GetValueEvent GetValue;
public delegate void StatusEvent(int idx, string ip, bool status);
public event StatusEvent ConnectStatus;
public event StatusEvent ScanStatus;
/// <summary>
/// RFID
/// </summary>
public HFReaderAll()
{
}
/// <summary>
/// 日志目录
/// </summary>
public string LogPath { set; get; } = "";
/// <summary>
/// 扫描模式,true自动,false查找
/// </summary>
public bool ScanMode { set; get; } = true;
/// <summary>
/// 打开所有
/// </summary>
/// <param name="ip"></param>
public void Open(params string[] ip)
{
log = new Log(LogPath, "RFID_ALL");
log.OutInfo("Call Open");
_ip = ip;
reader = new HFReader[ip.Length];
buffer = new byte[ip.Length][];
for (int i = 0; i < buffer.Length; i++)
buffer[i] = new byte[8];
Connect();
}
/// <summary>
/// 关闭所有
/// </summary>
public void Close()
{
log.OutInfo("ReaderAll Close");
if (reader == null) return;
for (int i = 0; i < reader.Length; i++)
{
if (reader[i] != null)
{
if (ScanMode)
reader[i].AutoScanMode(false);
//else
// reader[i].FindIDMode(false);
reader[i].Close();
log.OutInfo(reader[i].IP + " Close");
System.Threading.Thread.Sleep(10);
}
}
reader = null;
log.OutInfo("Close All OK");
log.Exit();
}
/// <summary>
/// 是否打开
/// </summary>
/// <returns></returns>
public bool[] IsOpen()
{
if (reader == null) return null;
bool[] rtn = new bool[reader.Length];
for (int i = 0; i < rtn.Length; i++)
{
if (reader[i] == null)
rtn[i] = false;
else
rtn[i] = reader[i].IsConn;
}
return rtn;
}
/// <summary>
/// 是否打开
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
public bool IsOpen(string ip)
{
int idx = Array.FindIndex(_ip, ss => ss == ip);
if (idx == -1) return false;
if (reader == null) return false;
if (reader[idx] == null)
return false;
else
return reader[idx].IsConn;
}
/// <summary>
/// 读取
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
public byte[] Read(string ip)
{
int idx = Array.FindIndex(_ip, ss => ss == ip);
if (idx == -1)
{
log.OutInfo("ip " + ip + " 没有找到");
return null;
}
return buffer[idx];
}
/// <summary>
/// 读取
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
public string ReadStr(string ip)
{
int idx = Array.FindIndex(_ip, ss => ss == ip);
if (idx == -1)
{
log.OutInfo("ip " + ip + " 没有找到");
return "";
}
string val;
if (buffer[idx][1] == 0)
val = "00";
else
val = (char)buffer[idx][1] + buffer[idx][2].ToString();
return val;
}
/// <summary>
/// 清零
/// </summary>
/// <param name="ip"></param>
public void Clear(string ip)
{
int idx = Array.FindIndex(_ip, ss => ss == ip);
if (idx == -1) return;
buffer[idx] = new byte[8];
reader[idx].AutoScanMode(false);
System.Threading.Thread.Sleep(100);
reader[idx].AutoScanMode(true);
}
private void Connect()
{
log.OutInfo("Call Connect");
try
{
for (int i = 0; i < reader.Length; i++)
{
reader[i] = new HFReader(_ip[i]);
reader[i].LogPath = LogPath;
reader[i].Received += Reader_Received;
reader[i].Open(ScanMode);
log.OutInfo(_ip[i] + " IsConn=" + reader[i].IsConn);
ConnectStatus?.Invoke(i, _ip[i], reader[i].IsConn);
}
for (int i = 0; i < reader.Length; i++)
{
if (reader[i].IsConn)
{
System.Threading.Thread.Sleep(100);
if (ScanMode)
{
bool rtn = reader[i].AutoScanMode(true);
log.OutInfo(_ip[i] + " ScanMode=auto, Return=" + rtn);
ScanStatus?.Invoke(i, _ip[i], rtn);
}
else
{
log.OutInfo(_ip[i] + " ScanMode=find");
}
}
else
{
reader[i].Close();
reader[i] = null;
log.OutInfo(_ip[i] + " Close");
ScanStatus?.Invoke(i, _ip[i], false);
}
}
}
catch (Exception ex)
{
log.OutError(ex.Message);
}
System.Threading.Thread.Sleep(50);
}
//private void Reconnect()
//{
// while (true)
// {
// for (int i = 0; i < reader.Length; i++)
// {
// try
// {
// System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping();
// System.Net.NetworkInformation.PingReply result = ping.Send(_ip[i], 1000);
// ping.Dispose();
// if (result.Status == System.Net.NetworkInformation.IPStatus.Success)
// {
// if (reader[i] == null)
// {
// reader[i] = new Reader(_ip[i]);
// reader[i].Received += Reader_Received;
// //reader[i].Connect(false);
// if (reader[i].IsConn)
// {
// System.Threading.Thread.Sleep(100);
// reader[i].AutoScanMode(true);
// }
// else
// {
// reader[i].Close();
// reader[i] = null;
// }
// }
// else
// {
// if (!reader[i].IsConn)
// {
// reader[i].Close();
// reader[i] = new Reader(_ip[i]);
// reader[i].Received += Reader_Received;
// //reader[i].Connect(false);
// if (reader[i].IsConn)
// {
// System.Threading.Thread.Sleep(100);
// reader[i].AutoScanMode(true);
// }
// else
// {
// reader[i].Close();
// reader[i] = null;
// }
// }
// }
// }
// else
// {
// //拔网线
// if (reader[i] != null && reader[i].IsConn)
// {
// reader[i].Close();
// reader[i] = null;
// }
// }
// }
// catch (Exception)
// { }
// System.Threading.Thread.Sleep(50);
// }
// System.Threading.Thread.Sleep(5000);
// }
//}
private void Reader_Received(string ip, byte[] buff)
{
try
{
int idx = Array.FindIndex(_ip, ss => ss == ip);
if (idx == -1)
{
log.OutInfo("ip " + ip + " 没有找到");
return;
}
Array.Copy(buff, buffer[idx], buff.Length);
string val;
if (buff[1] == 0)
val = "00";
else
val = (char)buff[1] + buff[2].ToString();
log.OutString(ip + " Received " + val);
//if (currIP != ip)
//{
// currIP = ip;
// GetValue?.Invoke(ip + ", " + val);
//}
}
catch (Exception ex)
{
log.OutError(ex.Message);
}
}
private void SaveLog()
{
//if (string.IsNullOrWhiteSpace(LogPath)) return;
//if (!LogPath.EndsWith("\\\\")) LogPath += "\\\\";
//if (!System.IO.Directory.Exists(LogPath))
// System.IO.Directory.CreateDirectory(LogPath);
//string _logFile = string.Format("{0}RFID_{1:yyyy-MM-dd}.log", LogPath, DateTime.Now);
//while (true)
//{
// System.Threading.Thread.Sleep(200);
// if (log.TryDequeue(out string result))
// {
// try
// {
// System.IO.File.AppendAllText(_logFile, result, System.Text.Encoding.UTF8);
// }
// catch (Exception)
// { }
// }
//}
}
}
}
using System;
using System.Reflection;
using System.Diagnostics;
namespace Asa.RFID
{
/// <summary>
/// 日志操作类
/// </summary>
internal class Log
{
private bool exit = false;
private int day = 0;
private string fileName;
private string filePath = "";
private System.Collections.Concurrent.ConcurrentQueue<string> _info;
private System.Threading.Thread tSave;
private readonly string _path;
private StackTrace trace;
private StackFrame frame;
private MethodBase method;
/// <summary>
/// 日志
/// </summary>
/// <param name="path">文件夹目录</param>
public Log(string path)
{
fileName = null;
if (string.IsNullOrWhiteSpace(path))
{
_path = "";
}
else
{
_path = path.EndsWith("\\") ? path : path + "\\";
if (!System.IO.Directory.Exists(_path))
System.IO.Directory.CreateDirectory(_path);
}
_info = new System.Collections.Concurrent.ConcurrentQueue<string>();
tSave = new System.Threading.Thread(new System.Threading.ThreadStart(SaveLog));
tSave.Start();
}
/// <summary>
/// 日志
/// </summary>
/// <param name="path">文件夹目录</param>
/// <param name="name">文件名</param>
public Log(string path, string name) : this(path)
{
fileName = name;
}
/// <summary>
/// 退出
/// </summary>
public void Exit()
{
exit = true;
}
/// <summary>
/// 输出错误信息
/// </summary>
/// <param name="s"></param>
public void OutError(string s)
{
if (string.IsNullOrWhiteSpace(s)) return;
trace = new StackTrace(true);
frame = trace.GetFrame(1);
string name = frame.GetFileName();
name = System.IO.Path.GetFileName(name);
string log = string.Format("[{0:HH:mm:ss.fff}] ERROR {1}({2},{3})\r\n",
DateTime.Now, name, frame.GetFileLineNumber(), frame.GetFileColumnNumber());
string[] arr = new string[trace.FrameCount - 1];
for (int i = 1; i < trace.FrameCount; i++) //0是本身Out
{
method = trace.GetFrame(i).GetMethod();
arr[arr.Length - i] = " " + method.DeclaringType.FullName + " -> " + method.ToString();
}
log += string.Join("\r\n", arr) + string.Format("\r\n {0}\r\n", s);
_info.Enqueue(log);
}
/// <summary>
/// 输出信息
/// </summary>
/// <param name="s"></param>
public void OutInfo(string s)
{
if (string.IsNullOrWhiteSpace(s)) return;
trace = new StackTrace(true);
frame = trace.GetFrame(1);
method = trace.GetFrame(1).GetMethod();
string name = frame.GetFileName();
name = System.IO.Path.GetFileName(name);
string s1 = method.DeclaringType.FullName;
string s2 = method.Name;
string log = string.Format("[{0:HH:mm:ss.fff}] INFO {1}({2},{3}) {4}->{5} {6}\r\n",
DateTime.Now, name, frame.GetFileLineNumber(), frame.GetFileColumnNumber(), s1, s2, s);
_info.Enqueue(log);
}
/// <summary>
/// 输出调试信息
/// </summary>
/// <param name="s"></param>
public void OutDebug(string s)
{
if (string.IsNullOrWhiteSpace(s)) return;
trace = new StackTrace(true);
frame = trace.GetFrame(1);
string name = frame.GetFileName();
name = System.IO.Path.GetFileName(name);
string log = string.Format("[{0:HH:mm:ss.fff}] DEBUG {1}({2},{3})\r\n",
DateTime.Now, name, frame.GetFileLineNumber(), frame.GetFileColumnNumber());
string[] arr = new string[trace.FrameCount];
for (int i = 0; i < trace.FrameCount; i++)
{
method = trace.GetFrame(i).GetMethod();
arr[arr.Length - i - 1] = " " + method.DeclaringType.FullName + " -> " + method.ToString();
}
log += string.Join("\r\n", arr) + string.Format("\r\n {0}\r\n", s);
_info.Enqueue(log);
}
/// <summary>
/// 输出字符串数据
/// </summary>
/// <param name="s"></param>
public void OutString(string s)
{
if (string.IsNullOrEmpty(s)) return;
string log = string.Format("[{0:HH:mm:ss.fff}] {1}\r\n", DateTime.Now, s);
_info.Enqueue(log);
}
private void SaveLog()
{
while (true)
{
System.Threading.Thread.Sleep(5);
if (_info.TryDequeue(out string result))
{
try
{
SaveFile(result);
}
catch (ObjectDisposedException odex)
{
break;
}
catch (Exception ex)
{
}
}
if (exit)
{
if (_info.Count == 0)
break;
}
}
}
private void SaveFile(string log)
{
if (_path == "") return;
if (day != DateTime.Now.Day)
{
if (fileName == null)
{
filePath = string.Format("{0}{1:yyyy-MM-dd}.log", _path, DateTime.Now);
}
else
{
filePath = string.Format("{0}{1:yyyy-MM-dd}\\", _path, DateTime.Now);
System.IO.Directory.CreateDirectory(filePath);
filePath += fileName + ".log";
}
day = DateTime.Now.Day;
}
byte[] array = System.Text.Encoding.UTF8.GetBytes(log);
System.IO.FileStream fs = System.IO.File.OpenWrite(filePath);
fs.Position = fs.Length;
fs.Write(array, 0, array.Length);
fs.Close();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E352E032-435C-4EB1-96B4-018BDC50B105}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Asa.RFID</RootNamespace>
<AssemblyName>Asa.RFID.HFReader</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Asa.RFID.HFReader.xml</DocumentationFile>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DocumentationFile>bin\Debug\Asa.RFID.xml</DocumentationFile>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>8.0</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>8.0</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="HFReader9CSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\DLL\RFID\HFReader9CSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Class2.cs" />
<Compile Include="Common.cs" />
<Compile Include="Log.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0"?>
<doc>
<assembly>
<name>Asa.RFID</name>
</assembly>
<members>
<member name="T:Asa.RFID.Reader">
<summary>
RFID读卡器
</summary>
</member>
<member name="T:Asa.RFID.Reader.Received_Event">
<summary>
接收事件
</summary>
<param name="ip"></param>
<param name="buff"></param>
</member>
<member name="E:Asa.RFID.Reader.Received">
<summary>
接收数据
</summary>
</member>
<member name="M:Asa.RFID.Reader.#ctor(System.String)">
<summary>
RFID读卡器
</summary>
</member>
<member name="P:Asa.RFID.Reader.IsConn">
<summary>
是否连接
</summary>
</member>
<member name="P:Asa.RFID.Reader.IsAutoScan">
<summary>
是否自动扫描
</summary>
</member>
<member name="P:Asa.RFID.Reader.IsExist">
<summary>
是否存在ID卡
</summary>
</member>
<member name="P:Asa.RFID.Reader.ErrCode">
<summary>
错误代码
</summary>
</member>
<member name="P:Asa.RFID.Reader.IP">
<summary>
IP地址
</summary>
</member>
<member name="P:Asa.RFID.Reader.LogPath">
<summary>
日志目录
</summary>
</member>
<member name="P:Asa.RFID.Reader.ID">
<summary>
ID号码
</summary>
</member>
<member name="M:Asa.RFID.Reader.Open(System.Boolean)">
<summary>
连接
</summary>
<param name="autoScan">自动扫描</param>
</member>
<member name="M:Asa.RFID.Reader.Close">
<summary>
关闭
</summary>
</member>
<member name="M:Asa.RFID.Reader.FindRFID">
<summary>
查找电子标签,扫描模式不能使用
</summary>
<returns></returns>
</member>
<member name="M:Asa.RFID.Reader.Read">
<summary>
读取电子标签
</summary>
<returns></returns>
</member>
<member name="M:Asa.RFID.Reader.Write(System.Byte[])">
<summary>
写入数据到电子标签,扫描模式不能使用
</summary>
<param name="buff">数据,必须小于等于112字节</param>
<returns></returns>
</member>
<member name="M:Asa.RFID.Reader.AutoScanMode(System.Boolean)">
<summary>
自动扫描模式
</summary>
<param name="open"></param>
<param name="open2"></param>
<returns></returns>
</member>
<member name="T:Asa.RFID.ReaderAll">
<summary>
RFID读卡器
</summary>
</member>
<member name="M:Asa.RFID.ReaderAll.#ctor">
<summary>
RFID
</summary>
</member>
<member name="P:Asa.RFID.ReaderAll.LogPath">
<summary>
日志目录
</summary>
</member>
<member name="P:Asa.RFID.ReaderAll.ScanMode">
<summary>
扫描模式,true自动,false查找
</summary>
</member>
<member name="M:Asa.RFID.ReaderAll.Open(System.String[])">
<summary>
打开所有
</summary>
<param name="ip"></param>
</member>
<member name="M:Asa.RFID.ReaderAll.Close">
<summary>
关闭所有
</summary>
</member>
<member name="M:Asa.RFID.ReaderAll.IsOpen">
<summary>
是否打开
</summary>
<returns></returns>
</member>
<member name="M:Asa.RFID.ReaderAll.IsOpen(System.String)">
<summary>
是否打开
</summary>
<param name="ip"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.ReaderAll.Read(System.String)">
<summary>
读取
</summary>
<param name="ip"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.ReaderAll.ReadStr(System.String)">
<summary>
读取
</summary>
<param name="ip"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.ReaderAll.Clear(System.String)">
<summary>
清零
</summary>
<param name="ip"></param>
</member>
<member name="T:Asa.RFID.IP">
<summary>
IP地址操作
</summary>
</member>
<member name="M:Asa.RFID.IP.Find(System.String)">
<summary>
查找IP地址
</summary>
<param name="localIP"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.IP.Modify(System.String,System.String,System.String)">
<summary>
修改IP地址,需要先查找IP
</summary>
<param name="localIP">本地IP</param>
<param name="beforeIP">修改前的IP</param>
<param name="afterIP">修改后的IP</param>
<returns></returns>
</member>
<member name="M:Asa.RFID.IP.GetLocal">
<summary>
获取本地IPv4地址
</summary>
<returns></returns>
</member>
<member name="T:Asa.RFID.Log">
<summary>
日志操作类
</summary>
</member>
<member name="M:Asa.RFID.Log.#ctor(System.String)">
<summary>
日志
</summary>
<param name="path">文件夹目录</param>
</member>
<member name="M:Asa.RFID.Log.#ctor(System.String,System.String)">
<summary>
日志
</summary>
<param name="path">文件夹目录</param>
<param name="name">文件名</param>
</member>
<member name="M:Asa.RFID.Log.Exit">
<summary>
退出
</summary>
</member>
<member name="M:Asa.RFID.Log.OutError(System.String)">
<summary>
输出错误信息
</summary>
<param name="s"></param>
</member>
<member name="M:Asa.RFID.Log.OutInfo(System.String)">
<summary>
输出信息
</summary>
<param name="s"></param>
</member>
<member name="M:Asa.RFID.Log.OutDebug(System.String)">
<summary>
输出调试信息
</summary>
<param name="s"></param>
</member>
<member name="M:Asa.RFID.Log.OutString(System.String)">
<summary>
输出字符串数据
</summary>
<param name="s"></param>
</member>
</members>
</doc>
C:\MY\DLL Coding\RFID\bin\Debug\Asa.RFID.xml
C:\MY\DLL Coding\RFID\bin\Debug\Asa.RFID.dll
C:\MY\DLL Coding\RFID\bin\Debug\Asa.RFID.pdb
C:\MY\DLL Coding\RFID\obj\Debug\Asa.RFID.dll
C:\MY\DLL Coding\RFID\obj\Debug\Asa.RFID.pdb
C:\MY\DLL Coding\RFID\bin\Debug\HFReader9CSharp.dll
C:\MY\DLL Coding\RFID\obj\Debug\RFID.csproj.CopyComplete
C:\MY\DLL Coding\RFID\obj\Debug\RFID.csprojAssemblyReference.cache
C:\SMD\DLL\RFID\bin\Debug\Asa.RFID.xml
C:\SMD\DLL\RFID\bin\Debug\Asa.RFID.dll
C:\SMD\DLL\RFID\bin\Debug\Asa.RFID.pdb
C:\SMD\DLL\RFID\bin\Debug\HFReader9CSharp.dll
C:\SMD\DLL\RFID\obj\Debug\RFID.csproj.CopyComplete
C:\SMD\DLL\RFID\obj\Debug\Asa.RFID.dll
C:\SMD\DLL\RFID\obj\Debug\Asa.RFID.pdb
C:\SMD\DLL\RFID\obj\Debug\RFID.csprojAssemblyReference.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID\bin\Debug\Asa.RFID.xml
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID\bin\Debug\Asa.RFID.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID\bin\Debug\Asa.RFID.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID\bin\Debug\HFReader9CSharp.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID\obj\Debug\RFID.csproj.CoreCompileInputs.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID\obj\Debug\RFID.csproj.CopyComplete
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID\obj\Debug\Asa.RFID.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID\obj\Debug\Asa.RFID.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID\obj\Debug\RFID.csprojAssemblyReference.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_old\bin\Debug\Asa.RFID.HFReader.xml
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_old\bin\Debug\Asa.RFID.HFReader.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_old\bin\Debug\Asa.RFID.HFReader.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_old\bin\Debug\HFReader9CSharp.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_old\obj\Debug\RFID_HFReader.csproj.CoreCompileInputs.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_old\obj\Debug\RFID_HFReader.csproj.CopyComplete
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_old\obj\Debug\Asa.RFID.HFReader.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_old\obj\Debug\Asa.RFID.HFReader.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader\bin\Debug\Asa.RFID.HFReader.xml
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader\bin\Debug\Asa.RFID.HFReader.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader\bin\Debug\Asa.RFID.HFReader.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader\obj\Debug\RFID_HFReader.csproj.CoreCompileInputs.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader\obj\Debug\RFID_HFReader.csproj.CopyComplete
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader\obj\Debug\Asa.RFID.HFReader.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader\obj\Debug\Asa.RFID.HFReader.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_old\bin\Debug\Asa.RFID.xml
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_old\bin\Debug\Asa.RFID.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_old\bin\Debug\Asa.RFID.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_old\obj\Debug\RFID_old.csprojAssemblyReference.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_old\obj\Debug\RFID_old.csproj.CoreCompileInputs.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_old\obj\Debug\RFID_old.csproj.CopyComplete
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_old\obj\Debug\Asa.RFID.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_old\obj\Debug\Asa.RFID.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_old\bin\Debug\HFReader9CSharp.dll
namespace RFID_Debug
{
partial class FrmMain
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.LstIP = new System.Windows.Forms.ListBox();
this.BtnOpen = new System.Windows.Forms.Button();
this.BtnChangeIP = new System.Windows.Forms.Button();
this.BtnGetIP = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.CboLocal = new System.Windows.Forms.ComboBox();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.textBox2 = new System.Windows.Forms.TextBox();
this.groupBox1.SuspendLayout();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.groupBox1.Controls.Add(this.button1);
this.groupBox1.Controls.Add(this.textBox1);
this.groupBox1.Controls.Add(this.LstIP);
this.groupBox1.Controls.Add(this.BtnOpen);
this.groupBox1.Controls.Add(this.BtnChangeIP);
this.groupBox1.Controls.Add(this.BtnGetIP);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.CboLocal);
this.groupBox1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(321, 449);
this.groupBox1.TabIndex = 3;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "设备";
//
// button1
//
this.button1.Location = new System.Drawing.Point(235, 379);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(80, 64);
this.button1.TabIndex = 11;
this.button1.Text = "打开所有";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(6, 63);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(223, 29);
this.textBox1.TabIndex = 10;
//
// LstIP
//
this.LstIP.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.LstIP.FormattingEnabled = true;
this.LstIP.IntegralHeight = false;
this.LstIP.ItemHeight = 21;
this.LstIP.Location = new System.Drawing.Point(6, 98);
this.LstIP.Name = "LstIP";
this.LstIP.Size = new System.Drawing.Size(223, 345);
this.LstIP.TabIndex = 7;
this.LstIP.SelectedIndexChanged += new System.EventHandler(this.LstIP_SelectedIndexChanged);
//
// BtnOpen
//
this.BtnOpen.Location = new System.Drawing.Point(235, 168);
this.BtnOpen.Name = "BtnOpen";
this.BtnOpen.Size = new System.Drawing.Size(80, 64);
this.BtnOpen.TabIndex = 5;
this.BtnOpen.Text = "打开设备";
this.BtnOpen.UseVisualStyleBackColor = true;
this.BtnOpen.Click += new System.EventHandler(this.BtnOpen_Click);
//
// BtnChangeIP
//
this.BtnChangeIP.Location = new System.Drawing.Point(235, 98);
this.BtnChangeIP.Name = "BtnChangeIP";
this.BtnChangeIP.Size = new System.Drawing.Size(80, 64);
this.BtnChangeIP.TabIndex = 4;
this.BtnChangeIP.Text = "修改设备IP";
this.BtnChangeIP.UseVisualStyleBackColor = true;
this.BtnChangeIP.Click += new System.EventHandler(this.BtnChangeIP_Click);
//
// BtnGetIP
//
this.BtnGetIP.Location = new System.Drawing.Point(235, 28);
this.BtnGetIP.Name = "BtnGetIP";
this.BtnGetIP.Size = new System.Drawing.Size(80, 64);
this.BtnGetIP.TabIndex = 1;
this.BtnGetIP.Text = "获取设备IP";
this.BtnGetIP.UseVisualStyleBackColor = true;
this.BtnGetIP.Click += new System.EventHandler(this.BtnGetIP_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 31);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(57, 21);
this.label1.TabIndex = 1;
this.label1.Text = "本地IP";
//
// CboLocal
//
this.CboLocal.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CboLocal.FormattingEnabled = true;
this.CboLocal.Location = new System.Drawing.Point(69, 28);
this.CboLocal.Name = "CboLocal";
this.CboLocal.Size = new System.Drawing.Size(160, 29);
this.CboLocal.TabIndex = 0;
//
// tabControl1
//
this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Location = new System.Drawing.Point(339, 12);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(594, 449);
this.tabControl1.TabIndex = 7;
//
// tabPage1
//
this.tabPage1.Controls.Add(this.textBox2);
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3, 3, 3, 3);
this.tabPage1.Size = new System.Drawing.Size(586, 423);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "tabPage1";
this.tabPage1.UseVisualStyleBackColor = true;
//
// textBox2
//
this.textBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.textBox2.Location = new System.Drawing.Point(6, 6);
this.textBox2.Multiline = true;
this.textBox2.Name = "textBox2";
this.textBox2.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.textBox2.Size = new System.Drawing.Size(305, 411);
this.textBox2.TabIndex = 0;
//
// FrmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(945, 473);
this.Controls.Add(this.tabControl1);
this.Controls.Add(this.groupBox1);
this.Name = "FrmMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "RFID_Debug";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmMain_FormClosing);
this.Load += new System.EventHandler(this.FrmMain_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button BtnOpen;
private System.Windows.Forms.Button BtnChangeIP;
private System.Windows.Forms.Button BtnGetIP;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox CboLocal;
private System.Windows.Forms.ListBox LstIP;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TextBox textBox2;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace RFID_Debug
{
public partial class FrmMain : Form
{
private bool[] _open;
private string[] _ip;
private Asa.RFID.HFReader[] reader;
private Asa.RFID.HFReaderAll readerAll;
private int sum = 0;
private string currIP = "";
//private Dictionary<string, string> buffer = new Dictionary<string, string>();
private System.Threading.Thread tSave;
private System.Collections.Concurrent.ConcurrentQueue<string> info = new System.Collections.Concurrent.ConcurrentQueue<string>();
public FrmMain()
{
InitializeComponent();
}
private void FrmMain_Load(object sender, EventArgs e)
{
CboLocal.Items.AddRange(Asa.RFID.IP.GetLocal());
if (CboLocal.Items.Count > 0)
CboLocal.SelectedIndex = 0;
}
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
{
if (tSave != null)
tSave.Abort();
if (reader != null)
{
for (int i = 0; i < reader.Length; i++)
{
reader[i].Close();
System.Threading.Thread.Sleep(10);
}
}
if (readerAll != null)
{
readerAll.Close();
readerAll = null;
}
}
private void BtnGetIP_Click(object sender, EventArgs e)
{
LstIP.Items.Clear();
_ip = Asa.RFID.IP.Find(CboLocal.Text);
LstIP.Items.AddRange(_ip);
_open = new bool[_ip.Length];
}
private void BtnChangeIP_Click(object sender, EventArgs e)
{
if (LstIP.SelectedIndex == -1) return;
bool rtn = Asa.RFID.IP.Modify(CboLocal.Text, LstIP.Text, textBox1.Text);
if (rtn)
MessageBox.Show("修改完成");
else
MessageBox.Show("修改失败", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
private void BtnOpen_Click(object sender, EventArgs e)
{
if (LstIP.SelectedIndex == -1) return;
//if (_open[LstIP.SelectedIndex]) return;
TabPage tab = new TabPage { Text = LstIP.Text };
UserControl1 ctl = new UserControl1(LstIP.Text);
tab.Controls.Add(ctl);
tabControl1.Controls.Add(tab);
//_open[LstIP.SelectedIndex] = true;
}
private void LstIP_SelectedIndexChanged(object sender, EventArgs e)
{
textBox1.Text = LstIP.Text;
}
private void button1_Click(object sender, EventArgs e)
{
string[] ip = new string[LstIP.Items.Count];
for (int i = 0; i < ip.Length; i++)
ip[i] = LstIP.Items[i].ToString();
readerAll = new Asa.RFID.HFReaderAll();
readerAll.LogPath = Application.StartupPath;
readerAll.GetValue += Ra_GetValue;
readerAll.Open(ip);
//readerAll.Open("192.168.210.114", "192.168.210.117");
}
private void Ra_GetValue(string s)
{
Invoke(new Action(() =>
{
if (s.Contains(LstIP.Items[0].ToString()))
textBox2.AppendText("======\r\n");
textBox2.AppendText(s + "\r\n");
}));
}
private void Reader_Received(string ip, byte[] buff)
{
try
{
//string val = (char)buff[1] + buff[2].ToString();
//if (ip == currIP) return;
//currIP = ip;
//string s = "";
//if (ip == LstIP.Items[0].ToString())
//{
// s = "========== ";
// sum = 0;
//}
//s += (++sum) + " " + ip + " ";
//s += val;
//info.Enqueue(s);
string s = "";
for (int i = 0; i < buff.Length; i++)
s += buff[i].ToString("X2") + " ";
Invoke(new Action(() => { textBox2.AppendText(s); }));
}
catch (Exception)
{ }
}
private void SaveLog()
{
string _logFile = string.Format("{0}\\RFID_{1:yyyy-MM-dd}.log", Application.StartupPath, DateTime.Now);
while (true)
{
System.Threading.Thread.Sleep(100);
if (info.TryDequeue(out string result))
System.IO.File.AppendAllText(_logFile, string.Format("[{0:HH:mm:ss.fff}] {1}\r\n", DateTime.Now, result), Encoding.UTF8);
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory>publish\</PublishUrlHistory>
<InstallUrlHistory />
<SupportUrlHistory />
<UpdateUrlHistory />
<BootstrapperUrlHistory />
<ErrorReportUrlHistory />
<FallbackCulture>zh-CN</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
</Project>
\ No newline at end of file
namespace RFID_Debug
{
partial class UserControl1
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.button1 = new System.Windows.Forms.Button();
this.BtnReadOne = new System.Windows.Forms.Button();
this.BtnReadAll = new System.Windows.Forms.Button();
this.TxtRead = new System.Windows.Forms.TextBox();
this.LblID = new System.Windows.Forms.Label();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.BtnNumAdd = new System.Windows.Forms.Button();
this.BtnNumMinus = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.BtnWrite = new System.Windows.Forms.Button();
this.NudNumber = new System.Windows.Forms.NumericUpDown();
this.CboType = new System.Windows.Forms.ComboBox();
this.BtnFind = new System.Windows.Forms.Button();
this.BtnClose = new System.Windows.Forms.Button();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NudNumber)).BeginInit();
this.SuspendLayout();
//
// groupBox2
//
this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox2.Controls.Add(this.button1);
this.groupBox2.Controls.Add(this.BtnReadOne);
this.groupBox2.Controls.Add(this.BtnReadAll);
this.groupBox2.Controls.Add(this.TxtRead);
this.groupBox2.Enabled = false;
this.groupBox2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox2.Location = new System.Drawing.Point(3, 47);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(489, 184);
this.groupBox2.TabIndex = 7;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "读取";
//
// button1
//
this.button1.Location = new System.Drawing.Point(292, 128);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(80, 31);
this.button1.TabIndex = 3;
this.button1.Text = "123";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// BtnReadOne
//
this.BtnReadOne.Location = new System.Drawing.Point(142, 128);
this.BtnReadOne.Name = "BtnReadOne";
this.BtnReadOne.Size = new System.Drawing.Size(130, 50);
this.BtnReadOne.TabIndex = 2;
this.BtnReadOne.Text = "读取使用字节";
this.BtnReadOne.UseVisualStyleBackColor = true;
this.BtnReadOne.Click += new System.EventHandler(this.BtnReadOne_Click);
//
// BtnReadAll
//
this.BtnReadAll.Location = new System.Drawing.Point(6, 128);
this.BtnReadAll.Name = "BtnReadAll";
this.BtnReadAll.Size = new System.Drawing.Size(130, 50);
this.BtnReadAll.TabIndex = 1;
this.BtnReadAll.Text = "读取所有字节";
this.BtnReadAll.UseVisualStyleBackColor = true;
this.BtnReadAll.Click += new System.EventHandler(this.BtnReadAll_Click);
//
// TxtRead
//
this.TxtRead.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.TxtRead.Location = new System.Drawing.Point(6, 28);
this.TxtRead.Multiline = true;
this.TxtRead.Name = "TxtRead";
this.TxtRead.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.TxtRead.Size = new System.Drawing.Size(477, 94);
this.TxtRead.TabIndex = 0;
//
// LblID
//
this.LblID.ForeColor = System.Drawing.Color.Red;
this.LblID.Location = new System.Drawing.Point(109, 3);
this.LblID.Name = "LblID";
this.LblID.Size = new System.Drawing.Size(381, 38);
this.LblID.TabIndex = 3;
//
// groupBox3
//
this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox3.Controls.Add(this.BtnNumAdd);
this.groupBox3.Controls.Add(this.BtnNumMinus);
this.groupBox3.Controls.Add(this.label3);
this.groupBox3.Controls.Add(this.BtnWrite);
this.groupBox3.Controls.Add(this.NudNumber);
this.groupBox3.Controls.Add(this.CboType);
this.groupBox3.Enabled = false;
this.groupBox3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox3.Location = new System.Drawing.Point(3, 237);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(489, 122);
this.groupBox3.TabIndex = 8;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "写入";
//
// BtnNumAdd
//
this.BtnNumAdd.Font = new System.Drawing.Font("宋体", 16F);
this.BtnNumAdd.Location = new System.Drawing.Point(402, 28);
this.BtnNumAdd.Name = "BtnNumAdd";
this.BtnNumAdd.Size = new System.Drawing.Size(75, 29);
this.BtnNumAdd.TabIndex = 5;
this.BtnNumAdd.Text = "+";
this.BtnNumAdd.UseVisualStyleBackColor = true;
this.BtnNumAdd.Click += new System.EventHandler(this.BtnNumAdd_Click);
//
// BtnNumMinus
//
this.BtnNumMinus.Font = new System.Drawing.Font("宋体", 16F);
this.BtnNumMinus.Location = new System.Drawing.Point(321, 28);
this.BtnNumMinus.Name = "BtnNumMinus";
this.BtnNumMinus.Size = new System.Drawing.Size(75, 29);
this.BtnNumMinus.TabIndex = 4;
this.BtnNumMinus.Text = "-";
this.BtnNumMinus.UseVisualStyleBackColor = true;
this.BtnNumMinus.Click += new System.EventHandler(this.BtnNumMinus_Click);
//
// label3
//
this.label3.AutoSize = true;
this.label3.ForeColor = System.Drawing.Color.Red;
this.label3.Location = new System.Drawing.Point(142, 78);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(0, 21);
this.label3.TabIndex = 3;
//
// BtnWrite
//
this.BtnWrite.Location = new System.Drawing.Point(6, 63);
this.BtnWrite.Name = "BtnWrite";
this.BtnWrite.Size = new System.Drawing.Size(130, 50);
this.BtnWrite.TabIndex = 2;
this.BtnWrite.Text = "写入";
this.BtnWrite.UseVisualStyleBackColor = true;
this.BtnWrite.Click += new System.EventHandler(this.BtnWrite_Click);
//
// NudNumber
//
this.NudNumber.Location = new System.Drawing.Point(235, 28);
this.NudNumber.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.NudNumber.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.NudNumber.Name = "NudNumber";
this.NudNumber.Size = new System.Drawing.Size(80, 29);
this.NudNumber.TabIndex = 1;
this.NudNumber.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// CboType
//
this.CboType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CboType.FormattingEnabled = true;
this.CboType.Items.AddRange(new object[] {
"A:料仓带包装料架",
"B:环形线料串",
"C:双层线其他规格料格",
"D:双层线7寸料格",
"E:环行线托盘"});
this.CboType.Location = new System.Drawing.Point(6, 28);
this.CboType.Name = "CboType";
this.CboType.Size = new System.Drawing.Size(223, 29);
this.CboType.TabIndex = 0;
//
// BtnFind
//
this.BtnFind.Enabled = false;
this.BtnFind.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.BtnFind.Location = new System.Drawing.Point(3, 3);
this.BtnFind.Name = "BtnFind";
this.BtnFind.Size = new System.Drawing.Size(100, 38);
this.BtnFind.TabIndex = 9;
this.BtnFind.Text = "查找RFID";
this.BtnFind.UseVisualStyleBackColor = true;
this.BtnFind.Click += new System.EventHandler(this.BtnFind_Click);
//
// BtnClose
//
this.BtnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.BtnClose.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.BtnClose.Location = new System.Drawing.Point(392, 3);
this.BtnClose.Name = "BtnClose";
this.BtnClose.Size = new System.Drawing.Size(100, 38);
this.BtnClose.TabIndex = 10;
this.BtnClose.Text = "关闭";
this.BtnClose.UseVisualStyleBackColor = true;
this.BtnClose.Click += new System.EventHandler(this.BtnClose_Click);
//
// UserControl1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.BtnClose);
this.Controls.Add(this.LblID);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.BtnFind);
this.Name = "UserControl1";
this.Size = new System.Drawing.Size(495, 362);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.NudNumber)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Label LblID;
private System.Windows.Forms.Button BtnReadOne;
private System.Windows.Forms.Button BtnReadAll;
private System.Windows.Forms.TextBox TxtRead;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Button BtnNumAdd;
private System.Windows.Forms.Button BtnNumMinus;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button BtnWrite;
private System.Windows.Forms.NumericUpDown NudNumber;
private System.Windows.Forms.ComboBox CboType;
private System.Windows.Forms.Button BtnFind;
private System.Windows.Forms.Button BtnClose;
private System.Windows.Forms.Button button1;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace RFID_Debug
{
public partial class UserControl1 : UserControl
{
private Asa.RFID.HFReader read;
public UserControl1()
{
InitializeComponent();
}
public UserControl1(string ip) : this()
{
CboType.SelectedIndex = 0;
read = new Asa.RFID.HFReader(ip);
read.Received += Read_Received;
read.Open(false);
if (read.IsConn)
{
read.AutoScanMode(false);
groupBox2.Enabled = true;
groupBox3.Enabled = true;
BtnFind.Enabled = true;
}
else
{
groupBox2.Enabled = false;
groupBox3.Enabled = false;
BtnFind.Enabled = false;
LblID.Text = "无法连接";
}
}
private void Read_Received(string ip, byte[] buff)
{
string s = (char)buff[1] + buff[2].ToString();
this.Invoke(new Action(() => { TxtRead.AppendText(s); }));
}
private void BtnFind_Click(object sender, EventArgs e)
{
bool rtn = read.FindRFID();
if (!rtn)
LblID.Text = "无法连接";
else
LblID.Text = "ID: " + read.ID;
}
private void BtnReadAll_Click(object sender, EventArgs e)
{
byte[] bb = read.Read();
if (bb == null)
{
TxtRead.Text = "";
}
else
{
string s = "";
for (int i = 0; i < bb.Length; i++)
s += bb[i].ToString("X2") + " ";
TxtRead.Text = s;
}
}
private void BtnReadOne_Click(object sender, EventArgs e)
{
byte[] bb = read.Read();
if (bb == null)
{
TxtRead.Text = "";
}
else
{
if (bb[0] == 0x5A && bb[5] == 0x4A)
{
TxtRead.Text = ((char)bb[1]).ToString() + bb[2];
}
else
{
TxtRead.Text = "格式不正确";
}
}
}
private void BtnWrite_Click(object sender, EventArgs e)
{
byte[] bb = new byte[8];
bb[0] = 0x5A;
bb[1] = Convert.ToByte(65 + CboType.SelectedIndex);
bb[2] = Convert.ToByte(NudNumber.Value);
bb[5] = 0x4A;
int sum = 0;
for (int i = 0; i < 6; i++)
sum += bb[i];
byte[] cc = BitConverter.GetBytes(sum);
bb[6] = cc[0];
bb[7] = cc[1];
bool rtn = read.Write(bb);
if (rtn)
label3.Text = ((char)bb[1]).ToString() + bb[2] + " OK";
else
label3.Text = "NG";
}
private void BtnNumMinus_Click(object sender, EventArgs e)
{
if (NudNumber.Value > NudNumber.Minimum)
NudNumber.Value--;
}
private void BtnNumAdd_Click(object sender, EventArgs e)
{
if (NudNumber.Value < NudNumber.Maximum)
NudNumber.Value++;
}
private void BtnClose_Click(object sender, EventArgs e)
{
read.Close();
Parent.Parent.Controls.Remove(Parent);
Parent.Dispose();
Dispose();
}
private void button1_Click(object sender, EventArgs e)
{
read.OpenCloseRF(false);
System.Threading.Thread.Sleep(100);
read.OpenCloseRF(true);
}
}
}
<?xml version="1.0"?>
<doc>
<assembly>
<name>Asa.RFID</name>
</assembly>
<members>
<member name="T:Asa.RFID.Reader">
<summary>
RFID读卡器
</summary>
</member>
<member name="T:Asa.RFID.Reader.Received_Event">
<summary>
接收事件
</summary>
<param name="ip"></param>
<param name="buff"></param>
</member>
<member name="E:Asa.RFID.Reader.Received">
<summary>
接收数据
</summary>
</member>
<member name="M:Asa.RFID.Reader.#ctor(System.String)">
<summary>
RFID读卡器
</summary>
</member>
<member name="P:Asa.RFID.Reader.IsConn">
<summary>
是否连接
</summary>
</member>
<member name="P:Asa.RFID.Reader.IsAutoScan">
<summary>
是否自动扫描
</summary>
</member>
<member name="P:Asa.RFID.Reader.IsExist">
<summary>
是否存在ID卡
</summary>
</member>
<member name="P:Asa.RFID.Reader.ErrCode">
<summary>
错误代码
</summary>
</member>
<member name="P:Asa.RFID.Reader.IP">
<summary>
IP地址
</summary>
</member>
<member name="P:Asa.RFID.Reader.LogPath">
<summary>
日志目录
</summary>
</member>
<member name="P:Asa.RFID.Reader.ID">
<summary>
ID号码
</summary>
</member>
<member name="M:Asa.RFID.Reader.Open(System.Boolean)">
<summary>
连接
</summary>
<param name="autoScan">自动扫描</param>
</member>
<member name="M:Asa.RFID.Reader.Close">
<summary>
关闭
</summary>
</member>
<member name="M:Asa.RFID.Reader.FindRFID">
<summary>
查找电子标签,扫描模式不能使用
</summary>
<returns></returns>
</member>
<member name="M:Asa.RFID.Reader.Read">
<summary>
读取电子标签
</summary>
<returns></returns>
</member>
<member name="M:Asa.RFID.Reader.Write(System.Byte[])">
<summary>
写入数据到电子标签,扫描模式不能使用
</summary>
<param name="buff">数据,必须小于等于112字节</param>
<returns></returns>
</member>
<member name="M:Asa.RFID.Reader.AutoScanMode(System.Boolean)">
<summary>
自动扫描模式
</summary>
<param name="open"></param>
<param name="open2"></param>
<returns></returns>
</member>
<member name="T:Asa.RFID.ReaderAll">
<summary>
RFID读卡器
</summary>
</member>
<member name="M:Asa.RFID.ReaderAll.#ctor">
<summary>
RFID
</summary>
</member>
<member name="P:Asa.RFID.ReaderAll.LogPath">
<summary>
日志目录
</summary>
</member>
<member name="P:Asa.RFID.ReaderAll.ScanMode">
<summary>
扫描模式,true自动,false查找
</summary>
</member>
<member name="M:Asa.RFID.ReaderAll.Open(System.String[])">
<summary>
打开所有
</summary>
<param name="ip"></param>
</member>
<member name="M:Asa.RFID.ReaderAll.Close">
<summary>
关闭所有
</summary>
</member>
<member name="M:Asa.RFID.ReaderAll.IsOpen">
<summary>
是否打开
</summary>
<returns></returns>
</member>
<member name="M:Asa.RFID.ReaderAll.IsOpen(System.String)">
<summary>
是否打开
</summary>
<param name="ip"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.ReaderAll.Read(System.String)">
<summary>
读取
</summary>
<param name="ip"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.ReaderAll.ReadStr(System.String)">
<summary>
读取
</summary>
<param name="ip"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.ReaderAll.Clear(System.String)">
<summary>
清零
</summary>
<param name="ip"></param>
</member>
<member name="T:Asa.RFID.IP">
<summary>
IP地址操作
</summary>
</member>
<member name="M:Asa.RFID.IP.Find(System.String)">
<summary>
查找IP地址
</summary>
<param name="localIP"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.IP.Modify(System.String,System.String,System.String)">
<summary>
修改IP地址,需要先查找IP
</summary>
<param name="localIP">本地IP</param>
<param name="beforeIP">修改前的IP</param>
<param name="afterIP">修改后的IP</param>
<returns></returns>
</member>
<member name="M:Asa.RFID.IP.GetLocal">
<summary>
获取本地IPv4地址
</summary>
<returns></returns>
</member>
<member name="T:Asa.RFID.Log">
<summary>
日志操作类
</summary>
</member>
<member name="M:Asa.RFID.Log.#ctor(System.String)">
<summary>
日志
</summary>
<param name="path">文件夹目录</param>
</member>
<member name="M:Asa.RFID.Log.#ctor(System.String,System.String)">
<summary>
日志
</summary>
<param name="path">文件夹目录</param>
<param name="name">文件名</param>
</member>
<member name="M:Asa.RFID.Log.Exit">
<summary>
退出
</summary>
</member>
<member name="M:Asa.RFID.Log.OutError(System.String)">
<summary>
输出错误信息
</summary>
<param name="s"></param>
</member>
<member name="M:Asa.RFID.Log.OutInfo(System.String)">
<summary>
输出信息
</summary>
<param name="s"></param>
</member>
<member name="M:Asa.RFID.Log.OutDebug(System.String)">
<summary>
输出调试信息
</summary>
<param name="s"></param>
</member>
<member name="M:Asa.RFID.Log.OutString(System.String)">
<summary>
输出字符串数据
</summary>
<param name="s"></param>
</member>
</members>
</doc>
C:\SMD\DLL\RFID_Debug\bin\Debug\RFID_Debug.exe.config
C:\SMD\DLL\RFID_Debug\bin\Debug\RFID_Debug.exe
C:\SMD\DLL\RFID_Debug\bin\Debug\RFID_Debug.pdb
C:\SMD\DLL\RFID_Debug\bin\Debug\Asa.RFID.dll
C:\SMD\DLL\RFID_Debug\bin\Debug\HFReader9CSharp.dll
C:\SMD\DLL\RFID_Debug\bin\Debug\Asa.RFID.pdb
C:\SMD\DLL\RFID_Debug\bin\Debug\Asa.RFID.xml
C:\SMD\DLL\RFID_Debug\obj\Debug\RFID_Debug.csprojAssemblyReference.cache
C:\SMD\DLL\RFID_Debug\obj\Debug\RFID_Debug.FrmMain.resources
C:\SMD\DLL\RFID_Debug\obj\Debug\RFID_Debug.Properties.Resources.resources
C:\SMD\DLL\RFID_Debug\obj\Debug\RFID_Debug.UserControl1.resources
C:\SMD\DLL\RFID_Debug\obj\Debug\RFID_Debug.csproj.GenerateResource.cache
C:\SMD\DLL\RFID_Debug\obj\Debug\RFID_Debug.csproj.CopyComplete
C:\SMD\DLL\RFID_Debug\obj\Debug\RFID_Debug.exe
C:\SMD\DLL\RFID_Debug\obj\Debug\RFID_Debug.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID_Debug\bin\Debug\RFID_Debug.exe.config
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID_Debug\bin\Debug\RFID_Debug.exe
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID_Debug\bin\Debug\RFID_Debug.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID_Debug\bin\Debug\Asa.RFID.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID_Debug\bin\Debug\HFReader9CSharp.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID_Debug\bin\Debug\Asa.RFID.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID_Debug\bin\Debug\Asa.RFID.xml
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID_Debug\obj\Debug\RFID_Debug.csprojAssemblyReference.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID_Debug\obj\Debug\RFID_Debug.FrmMain.resources
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID_Debug\obj\Debug\RFID_Debug.Properties.Resources.resources
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID_Debug\obj\Debug\RFID_Debug.UserControl1.resources
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID_Debug\obj\Debug\RFID_Debug.csproj.GenerateResource.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID_Debug\obj\Debug\RFID_Debug.csproj.CoreCompileInputs.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID_Debug\obj\Debug\RFID_Debug.csproj.CopyComplete
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID_Debug\obj\Debug\RFID_Debug.exe
D:\OneDrive - 上海挚锦科技有限公司\SMD\DLL\RFID_Debug\obj\Debug\RFID_Debug.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Debug_old\obj\Debug\RFID_Debug_old.csprojAssemblyReference.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Debug_old\obj\Debug\RFID_Debug.FrmMain.resources
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Debug_old\obj\Debug\RFID_Debug.Properties.Resources.resources
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Debug_old\obj\Debug\RFID_Debug.UserControl1.resources
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Debug_old\obj\Debug\RFID_Debug_old.csproj.GenerateResource.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Debug_old\obj\Debug\RFID_Debug_old.csproj.CoreCompileInputs.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Debug_old\obj\Debug\RFID_Debug.exe
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Debug_old\obj\Debug\RFID_Debug.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader_Debug\bin\Debug\RFID_HFReader_Debug.exe.config
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader_Debug\bin\Debug\RFID_HFReader_Debug.exe
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader_Debug\bin\Debug\RFID_HFReader_Debug.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader_Debug\bin\Debug\Asa.RFID.HFReader.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader_Debug\bin\Debug\log4net.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader_Debug\bin\Debug\HFReader9CSharp.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader_Debug\bin\Debug\Asa.RFID.HFReader.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader_Debug\bin\Debug\Asa.RFID.HFReader.xml
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader_Debug\obj\Debug\RFID_HFReader_Debug.csprojAssemblyReference.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader_Debug\obj\Debug\RFID_Debug.FrmMain.resources
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader_Debug\obj\Debug\RFID_Debug.Properties.Resources.resources
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader_Debug\obj\Debug\RFID_Debug.UserControl1.resources
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader_Debug\obj\Debug\RFID_HFReader_Debug.csproj.GenerateResource.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader_Debug\obj\Debug\RFID_HFReader_Debug.csproj.CoreCompileInputs.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader_Debug\obj\Debug\RFID_HFReader_Debug.csproj.CopyComplete
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader_Debug\obj\Debug\RFID_HFReader_Debug.exe
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_HFReader_Debug\obj\Debug\RFID_HFReader_Debug.pdb

using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace Asa.RFID
{
internal class HFReaderInfo
{
internal string IP;
internal string Mac;
internal int Port;
internal int Func;
internal byte[] Buffer;
internal byte[] ID;
internal byte ComAddr;
public HFReaderInfo()
{
Func = 0;
Buffer = new byte[28 * 4];
ID = new byte[8];
}
public HFReaderInfo(string ip) : this()
{
IP = ip;
string[] aa = ip.Split('.');
ComAddr = Convert.ToByte(aa[3]);
Port = 6000 + Convert.ToInt32(aa[3]);
}
}
/// <summary>
/// IP地址操作
/// </summary>
public static class IP
public static class HaoBinIP
{
private static List<HFReaderInfo> info = new List<HFReaderInfo>();
private static UdpClient udp;
......@@ -193,32 +165,30 @@ namespace Asa.RFID
}
public enum Error
internal class HFReaderInfo
{
OK = 0,
LengthError = 1,
OperationNotSupport = 2,
RfClosed = 5,
EEPROM = 6,
MultipleError = 7,
TimeOut = 10,
MoreUID = 11,
ISOError = 12,
NoElectronicTag = 14,
OperationError = 15,
BlockError = 16,
BlockLockedAndCntLock = 17,
BlockLockedAndCntWrite = 18,
BlockCntOperate = 19,
BlockCntLock = 20,
CommunicationError = 48,
RetCRCError = 49,
DataLengthError = 50,
CommunicationBusy = 51,
ExecuteCmdBusy = 52,
ComPortOpened = 53,
ComPortClose = 54,
InvalidHandle = 55,
InvalidPort = 56
internal string IP;
internal string Mac;
internal int Port;
internal int Func;
internal byte[] Buffer;
internal byte[] ID;
internal byte ComAddr;
public HFReaderInfo()
{
Func = 0;
Buffer = new byte[28 * 4];
ID = new byte[8];
}
public HFReaderInfo(string ip) : this()
{
IP = ip;
string[] aa = ip.Split('.');
ComAddr = Convert.ToByte(aa[3]);
Port = 6000 + Convert.ToInt32(aa[3]);
}
}
}
\ No newline at end of file
}
......@@ -10,14 +10,14 @@ namespace Asa.RFID
/// <summary>
/// RFID读卡器
/// </summary>
public class HFReader
public class HaoBin
{
private Log log;
//private Log log;
private byte[] _buff; //8字节缓存
private byte[] _uid; //卡片ID
private bool loop;
private bool empty;
private int port;
private byte addr;
private int portIndex;
......@@ -41,13 +41,13 @@ namespace Asa.RFID
/// <summary>
/// RFID读卡器
/// </summary>
public HFReader(string ip)
public HaoBin(string ip)
{
IP = ip;
_buff = new byte[8];
_uid = new byte[8];
//_receive = new System.Collections.Concurrent.ConcurrentQueue<byte>();
}
/// <summary>
......@@ -102,7 +102,7 @@ namespace Asa.RFID
/// <param name="autoScan">自动扫描</param>
public void Open(bool autoScan)
{
log = new Log(LogPath, "RFID_" + IP);
//log = new Log(LogPath, "RFID_" + IP);
Connect();
System.Threading.Thread.Sleep(100);
OpenCloseRF(false);
......@@ -122,19 +122,19 @@ namespace Asa.RFID
public void Close()
{
loop = false;
log.OutString("Call Close");
//log.OutString("Call Close");
try
{
System.Threading.Thread.Sleep(100);
IsConn = false;
ErrCode = ReaderA.StaticClassReaderA.CloseNetPort(portIndex);
log.OutString("CloseNetPort[" + ErrCode + "] " + (Error)ErrCode);
//log.OutString("CloseNetPort[" + ErrCode + "] " + (Error)ErrCode);
}
catch (Exception ex)
{
log.OutError(ex.Message);
//log.OutError(ex.Message);
}
log.Exit();
//log.Exit();
}
/// <summary>
......@@ -187,7 +187,7 @@ namespace Asa.RFID
public byte[] Read()
{
string s = "";
log.OutString("Call Read");
//log.OutString("Call Read");
try
{
......@@ -198,7 +198,7 @@ namespace Asa.RFID
for (int i = 0; i < buff.Length; i++)
s += buff[i].ToString("X2") + " ";
log.OutString(s);
//log.OutString(s);
return buff;
}
else if (IsExist)
......@@ -207,7 +207,7 @@ namespace Asa.RFID
for (int i = 0; i < _buff.Length; i++)
s += _buff[i].ToString("X2") + " ";
log.OutString(s);
//log.OutString(s);
return _buff;
}
else
......@@ -217,7 +217,7 @@ namespace Asa.RFID
}
catch (Exception ex)
{
log.OutError(ex.Message);
//log.OutError(ex.Message);
return null;
}
}
......@@ -267,7 +267,7 @@ namespace Asa.RFID
/// <returns></returns>
public bool AutoScanMode(bool open)
{
log.OutString("Call AutoScanMode");
//log.OutString("Call AutoScanMode");
byte[] scanModeData = new byte[11];
......@@ -326,7 +326,7 @@ namespace Asa.RFID
try
{
ErrCode = ReaderA.StaticClassReaderA.SetScanMode(ref addr, scanModeData, portIndex);
log.OutString("SetScanMode[" + ErrCode + "] Mode=" + open.ToString() + " " + (Error)ErrCode);
//log.OutString("SetScanMode[" + ErrCode + "] Mode=" + open.ToString() + " " + (Error)ErrCode);
if (ErrCode == 0)
{
IsAutoScan = open;
......@@ -340,7 +340,7 @@ namespace Asa.RFID
catch (Exception ex)
{
IsAutoScan = false;
log.OutError(ex.Message);
//log.OutError(ex.Message);
}
return IsAutoScan;
}
......@@ -365,14 +365,14 @@ namespace Asa.RFID
private void Connect()
{
IsConn = false;
log.OutString("Call Connect");
//log.OutString("Call Connect");
//IP合法
string pattern = @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$";
bool rtn = System.Text.RegularExpressions.Regex.IsMatch(IP, pattern);
if (!rtn)
{
log.OutString("IP不合法," + IP);
//log.OutString("IP不合法," + IP);
return;
}
......@@ -382,7 +382,7 @@ namespace Asa.RFID
ping.Dispose();
if (result.Status != System.Net.NetworkInformation.IPStatus.Success)
{
log.OutString("Ping " + IP + " 请求没有响应");
//log.OutString("Ping " + IP + " 请求没有响应");
return;
}
......@@ -390,36 +390,36 @@ namespace Asa.RFID
addr = Convert.ToByte(arr[3]);
port = 6000 + Convert.ToInt32(arr[3]);
portIndex = 0;
log.OutString("Connect ip=" + IP + ", port=" + port + ", addr=" + addr);
//log.OutString("Connect ip=" + IP + ", port=" + port + ", addr=" + addr);
try
{
ErrCode = ReaderA.StaticClassReaderA.OpenNetPort(port, IP, ref addr, ref portIndex);
IsConn = ErrCode == 0;
//AutoScanMode(false);
log.OutString("Connect[" + ErrCode + "] IsConn=" + IsConn + " " + (Error)ErrCode);
//log.OutString("Connect[" + ErrCode + "] IsConn=" + IsConn + " " + (Error)ErrCode);
}
catch (Exception ex)
{
IsConn = false;
log.OutError(ex.Message);
//log.OutError(ex.Message);
}
}
public void OpenCloseRF(bool rtn)
private void OpenCloseRF(bool rtn)
{
if (rtn)
{
ErrCode = ReaderA.StaticClassReaderA.OpenRf(ref addr, portIndex);
log.OutInfo("OpenRf[" + ErrCode + "] " + (Error)ErrCode);
//log.OutInfo("OpenRf[" + ErrCode + "] " + (Error)ErrCode);
}
else
{
ErrCode = ReaderA.StaticClassReaderA.CloseRf(ref addr, portIndex);
log.OutInfo("CloseRf[" + ErrCode + "] " + (Error)ErrCode);
//log.OutInfo("CloseRf[" + ErrCode + "] " + (Error)ErrCode);
}
}
private void ReadRFID()
......@@ -448,7 +448,7 @@ namespace Asa.RFID
byte errorCode = 0;
ErrCode = ReaderA.StaticClassReaderA.ReadMultipleBlock(ref addr, ref state, _uid, blockNum, blockCount, blockSecStatus, data, ref errorCode, portIndex);
log.OutInfo("ReadRFID[" + ErrCode + "] " + (Error)ErrCode);
//log.OutInfo("ReadRFID[" + ErrCode + "] " + (Error)ErrCode);
if (ErrCode == 0)
{
......@@ -555,7 +555,7 @@ namespace Asa.RFID
{
dataLen = 0;
ErrCode = ReaderA.StaticClassReaderA.ReadScanModeData(data, ref dataLen, portIndex);
log.OutString("ReadScanModeData[" + ErrCode + "] Len=" + dataLen + " " + (Error)ErrCode);
//log.OutString("ReadScanModeData[" + ErrCode + "] Len=" + dataLen + " " + (Error)ErrCode);
if (ErrCode == 0)
{
......@@ -590,7 +590,7 @@ namespace Asa.RFID
//AutoScanMode(false);
IsConn = false;
ErrCode = ReaderA.StaticClassReaderA.CloseNetPort(portIndex);
log.OutString("CloseNetPort[" + ErrCode + "] " + (Error)ErrCode);
//log.OutString("CloseNetPort[" + ErrCode + "] " + (Error)ErrCode);
System.Threading.Thread.Sleep(100);
Connect();
......@@ -606,7 +606,7 @@ namespace Asa.RFID
string s = "AutoScan ";
for (int i = 0; i < temp.Length; i++)
s += temp[i].ToString("X2") + " ";
log.OutString(s);
//log.OutString(s);
for (int i = 0; i < temp.Length; i++)
{
......@@ -615,14 +615,14 @@ namespace Asa.RFID
start = true;
end = false;
idx = 0;
log.OutString("Start 5A");
//log.OutString("Start 5A");
}
else if (temp[i] == 0x4A && start)
{
start = false;
end = true;
bb[idx++] = temp[i];
log.OutString("End 4A");
//log.OutString("End 4A");
}
if (start)
......@@ -631,18 +631,18 @@ namespace Asa.RFID
{
start = false;
end = false;
log.OutString("idx+1=" + (idx + 1).ToString());
//log.OutString("idx+1=" + (idx + 1).ToString());
}
else
{
bb[idx++] = temp[i];
log.OutString("bb[" + (idx - 1).ToString() + "]=" + temp[i].ToString("X2"));
//log.OutString("bb[" + (idx - 1).ToString() + "]=" + temp[i].ToString("X2"));
}
}
if (end)
{
log.OutString("idx=" + idx);
//log.OutString("idx=" + idx);
if (idx == 7) //中间有个00
{
_buff[0] = bb[0];
......@@ -657,7 +657,7 @@ namespace Asa.RFID
string ss = "Receive ";
for (int j = 0; j < _buff.Length; j++)
ss += _buff[j].ToString("X2") + " ";
log.OutString(ss);
//log.OutString(ss);
Received?.Invoke(IP, _buff);
}
end = false;
......@@ -668,7 +668,7 @@ namespace Asa.RFID
{
IsConn = false;
loop = false;
log.OutError(ex.Message);
//log.OutError(ex.Message);
}
}
......
......@@ -5,12 +5,12 @@ using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("RFID-HiStation")]
[assembly: AssemblyTitle("RFID_HaoBin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RFID-HiStation")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyProduct("RFID_HaoBin")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
......@@ -20,7 +20,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("4d5996f8-7206-480d-834a-be1db5fb05b2")]
[assembly: Guid("6b0b49df-b379-49c6-9983-6c9076f99711")]
// 程序集的版本信息由下列四个值组成:
//
......
......@@ -4,11 +4,11 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{4D5996F8-7206-480D-834A-BE1DB5FB05B2}</ProjectGuid>
<ProjectGuid>{6B0B49DF-B379-49C6-9983-6C9076F99711}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Asa.RFID</RootNamespace>
<AssemblyName>Asa.RFID.HiStation</AssemblyName>
<AssemblyName>Asa.RFID.HaoBin</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
......@@ -21,6 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Asa.RFID.HaoBin.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
......@@ -31,8 +32,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\..\..\..\DLL\log4net.dll</HintPath>
<Reference Include="HFReader9CSharp">
<HintPath>..\..\..\DLL\RFID\HFReader9CSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
......@@ -44,17 +45,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Class2.cs" />
<Compile Include="Class3.cs" />
<Compile Include="Common.cs" />
<Compile Include="DeviceIP.cs" />
<Compile Include="HaoBin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RFID_Interface\RFID_Interface.csproj">
<Project>{e7a36c72-093b-428e-a4e3-4739ee0bf4cc}</Project>
<Name>RFID_Interface</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
<?xml version="1.0"?>
<doc>
<assembly>
<name>Asa.RFID.HFReader</name>
<name>Asa.RFID.HaoBin</name>
</assembly>
<members>
<member name="T:Asa.RFID.HFReader">
<member name="M:Asa.RFID.HaoBinIP.Find(System.String)">
<summary>
查找IP地址
</summary>
<param name="localIP"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.HaoBinIP.Modify(System.String,System.String,System.String)">
<summary>
修改IP地址,需要先查找IP
</summary>
<param name="localIP">本地IP</param>
<param name="beforeIP">修改前的IP</param>
<param name="afterIP">修改后的IP</param>
<returns></returns>
</member>
<member name="M:Asa.RFID.HaoBinIP.GetLocal">
<summary>
获取本地IPv4地址
</summary>
<returns></returns>
</member>
<member name="T:Asa.RFID.HaoBin">
<summary>
RFID读卡器
</summary>
</member>
<member name="T:Asa.RFID.HFReader.Received_Event">
<member name="T:Asa.RFID.HaoBin.Received_Event">
<summary>
接收事件
</summary>
<param name="ip"></param>
<param name="buff"></param>
</member>
<member name="E:Asa.RFID.HFReader.Received">
<member name="E:Asa.RFID.HaoBin.Received">
<summary>
接收数据
</summary>
</member>
<member name="M:Asa.RFID.HFReader.#ctor(System.String)">
<member name="M:Asa.RFID.HaoBin.#ctor(System.String)">
<summary>
RFID读卡器
</summary>
</member>
<member name="P:Asa.RFID.HFReader.IsConn">
<member name="P:Asa.RFID.HaoBin.IsConn">
<summary>
是否连接
</summary>
</member>
<member name="P:Asa.RFID.HFReader.IsAutoScan">
<member name="P:Asa.RFID.HaoBin.IsAutoScan">
<summary>
是否自动扫描
</summary>
</member>
<member name="P:Asa.RFID.HFReader.IsExist">
<member name="P:Asa.RFID.HaoBin.IsExist">
<summary>
是否存在ID卡
</summary>
</member>
<member name="P:Asa.RFID.HFReader.ErrCode">
<member name="P:Asa.RFID.HaoBin.ErrCode">
<summary>
错误代码
</summary>
</member>
<member name="P:Asa.RFID.HFReader.IP">
<member name="P:Asa.RFID.HaoBin.IP">
<summary>
IP地址
</summary>
</member>
<member name="P:Asa.RFID.HFReader.LogPath">
<member name="P:Asa.RFID.HaoBin.LogPath">
<summary>
日志目录
</summary>
</member>
<member name="P:Asa.RFID.HFReader.ID">
<member name="P:Asa.RFID.HaoBin.ID">
<summary>
ID号码
</summary>
</member>
<member name="M:Asa.RFID.HFReader.Open(System.Boolean)">
<member name="M:Asa.RFID.HaoBin.Open(System.Boolean)">
<summary>
连接
</summary>
<param name="autoScan">自动扫描</param>
</member>
<member name="M:Asa.RFID.HFReader.Close">
<member name="M:Asa.RFID.HaoBin.Close">
<summary>
关闭
</summary>
</member>
<member name="M:Asa.RFID.HFReader.FindRFID">
<member name="M:Asa.RFID.HaoBin.FindRFID">
<summary>
查找电子标签,扫描模式不能使用
</summary>
<returns></returns>
</member>
<member name="M:Asa.RFID.HFReader.Read">
<member name="M:Asa.RFID.HaoBin.Read">
<summary>
读取电子标签
</summary>
<returns></returns>
</member>
<member name="M:Asa.RFID.HFReader.Write(System.Byte[])">
<member name="M:Asa.RFID.HaoBin.Write(System.Byte[])">
<summary>
写入数据到电子标签,扫描模式不能使用
</summary>
<param name="buff">数据,必须小于等于112字节</param>
<returns></returns>
</member>
<member name="M:Asa.RFID.HFReader.AutoScanMode(System.Boolean)">
<member name="M:Asa.RFID.HaoBin.AutoScanMode(System.Boolean)">
<summary>
自动扫描模式
</summary>
......@@ -99,143 +121,5 @@
<param name="open2"></param>
<returns></returns>
</member>
<member name="T:Asa.RFID.HFReaderAll">
<summary>
RFID读卡器
</summary>
</member>
<member name="M:Asa.RFID.HFReaderAll.#ctor">
<summary>
RFID
</summary>
</member>
<member name="P:Asa.RFID.HFReaderAll.LogPath">
<summary>
日志目录
</summary>
</member>
<member name="P:Asa.RFID.HFReaderAll.ScanMode">
<summary>
扫描模式,true自动,false查找
</summary>
</member>
<member name="M:Asa.RFID.HFReaderAll.Open(System.String[])">
<summary>
打开所有
</summary>
<param name="ip"></param>
</member>
<member name="M:Asa.RFID.HFReaderAll.Close">
<summary>
关闭所有
</summary>
</member>
<member name="M:Asa.RFID.HFReaderAll.IsOpen">
<summary>
是否打开
</summary>
<returns></returns>
</member>
<member name="M:Asa.RFID.HFReaderAll.IsOpen(System.String)">
<summary>
是否打开
</summary>
<param name="ip"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.HFReaderAll.Read(System.String)">
<summary>
读取
</summary>
<param name="ip"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.HFReaderAll.ReadStr(System.String)">
<summary>
读取
</summary>
<param name="ip"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.HFReaderAll.Clear(System.String)">
<summary>
清零
</summary>
<param name="ip"></param>
</member>
<member name="T:Asa.RFID.IP">
<summary>
IP地址操作
</summary>
</member>
<member name="M:Asa.RFID.IP.Find(System.String)">
<summary>
查找IP地址
</summary>
<param name="localIP"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.IP.Modify(System.String,System.String,System.String)">
<summary>
修改IP地址,需要先查找IP
</summary>
<param name="localIP">本地IP</param>
<param name="beforeIP">修改前的IP</param>
<param name="afterIP">修改后的IP</param>
<returns></returns>
</member>
<member name="M:Asa.RFID.IP.GetLocal">
<summary>
获取本地IPv4地址
</summary>
<returns></returns>
</member>
<member name="T:Asa.RFID.Log">
<summary>
日志操作类
</summary>
</member>
<member name="M:Asa.RFID.Log.#ctor(System.String)">
<summary>
日志
</summary>
<param name="path">文件夹目录</param>
</member>
<member name="M:Asa.RFID.Log.#ctor(System.String,System.String)">
<summary>
日志
</summary>
<param name="path">文件夹目录</param>
<param name="name">文件名</param>
</member>
<member name="M:Asa.RFID.Log.Exit">
<summary>
退出
</summary>
</member>
<member name="M:Asa.RFID.Log.OutError(System.String)">
<summary>
输出错误信息
</summary>
<param name="s"></param>
</member>
<member name="M:Asa.RFID.Log.OutInfo(System.String)">
<summary>
输出信息
</summary>
<param name="s"></param>
</member>
<member name="M:Asa.RFID.Log.OutDebug(System.String)">
<summary>
输出调试信息
</summary>
<param name="s"></param>
</member>
<member name="M:Asa.RFID.Log.OutString(System.String)">
<summary>
输出字符串数据
</summary>
<param name="s"></param>
</member>
</members>
</doc>
C:\Neotel\Program\RFID\RFID_HaoBin\bin\Debug\Asa.RFID.HaoBin.xml
C:\Neotel\Program\RFID\RFID_HaoBin\bin\Debug\Asa.RFID.HaoBin.dll
C:\Neotel\Program\RFID\RFID_HaoBin\bin\Debug\Asa.RFID.HaoBin.pdb
C:\Neotel\Program\RFID\RFID_HaoBin\obj\Debug\RFID_HaoBin.csprojAssemblyReference.cache
C:\Neotel\Program\RFID\RFID_HaoBin\obj\Debug\RFID_HaoBin.csproj.CoreCompileInputs.cache
C:\Neotel\Program\RFID\RFID_HaoBin\obj\Debug\Asa.RFID.HaoBin.dll
C:\Neotel\Program\RFID\RFID_HaoBin\obj\Debug\Asa.RFID.HaoBin.pdb
C:\Neotel\Program\RFID\RFID_HaoBin\bin\Debug\HFReader9CSharp.dll
C:\Neotel\Program\RFID\RFID_HaoBin\obj\Debug\RFID_HaoBin.csproj.CopyComplete
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
\ No newline at end of file

namespace Asa.RFID
{
partial class FrmMain
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.CboLocal = new System.Windows.Forms.ComboBox();
this.BtnGetIP = new System.Windows.Forms.Button();
this.BtnOpen = new System.Windows.Forms.Button();
this.LstIP = new System.Windows.Forms.ListBox();
this.button1 = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button();
this.CboLetter = new System.Windows.Forms.ComboBox();
this.NudNumber = new System.Windows.Forms.NumericUpDown();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.button3 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.NudNumber)).BeginInit();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 15);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(41, 12);
this.label1.TabIndex = 0;
this.label1.Text = "本地IP";
//
// CboLocal
//
this.CboLocal.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CboLocal.FormattingEnabled = true;
this.CboLocal.Location = new System.Drawing.Point(59, 12);
this.CboLocal.Name = "CboLocal";
this.CboLocal.Size = new System.Drawing.Size(109, 20);
this.CboLocal.TabIndex = 1;
//
// BtnGetIP
//
this.BtnGetIP.Location = new System.Drawing.Point(12, 38);
this.BtnGetIP.Name = "BtnGetIP";
this.BtnGetIP.Size = new System.Drawing.Size(75, 23);
this.BtnGetIP.TabIndex = 2;
this.BtnGetIP.Text = "获取设备";
this.BtnGetIP.UseVisualStyleBackColor = true;
this.BtnGetIP.Click += new System.EventHandler(this.BtnGetIP_Click);
//
// BtnOpen
//
this.BtnOpen.Enabled = false;
this.BtnOpen.Location = new System.Drawing.Point(93, 38);
this.BtnOpen.Name = "BtnOpen";
this.BtnOpen.Size = new System.Drawing.Size(75, 23);
this.BtnOpen.TabIndex = 3;
this.BtnOpen.Text = "打开设备";
this.BtnOpen.UseVisualStyleBackColor = true;
this.BtnOpen.Click += new System.EventHandler(this.BtnOpen_Click);
//
// LstIP
//
this.LstIP.FormattingEnabled = true;
this.LstIP.ItemHeight = 12;
this.LstIP.Location = new System.Drawing.Point(12, 67);
this.LstIP.Name = "LstIP";
this.LstIP.Size = new System.Drawing.Size(156, 136);
this.LstIP.TabIndex = 4;
//
// button1
//
this.button1.Enabled = false;
this.button1.Location = new System.Drawing.Point(174, 38);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 5;
this.button1.Text = "读取ID";
this.button1.UseVisualStyleBackColor = true;
//
// label2
//
this.label2.Location = new System.Drawing.Point(174, 9);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(156, 26);
this.label2.TabIndex = 6;
this.label2.Text = "label2";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// button2
//
this.button2.Enabled = false;
this.button2.Location = new System.Drawing.Point(255, 38);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 7;
this.button2.Text = "读取数据包";
this.button2.UseVisualStyleBackColor = true;
//
// CboLetter
//
this.CboLetter.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CboLetter.Font = new System.Drawing.Font("宋体", 9.5F);
this.CboLetter.FormattingEnabled = true;
this.CboLetter.Location = new System.Drawing.Point(174, 67);
this.CboLetter.Name = "CboLetter";
this.CboLetter.Size = new System.Drawing.Size(75, 21);
this.CboLetter.TabIndex = 8;
//
// NudNumber
//
this.NudNumber.Location = new System.Drawing.Point(255, 67);
this.NudNumber.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.NudNumber.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.NudNumber.Name = "NudNumber";
this.NudNumber.Size = new System.Drawing.Size(75, 21);
this.NudNumber.TabIndex = 9;
this.NudNumber.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// checkBox1
//
this.checkBox1.Location = new System.Drawing.Point(174, 94);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(156, 23);
this.checkBox1.TabIndex = 10;
this.checkBox1.Text = "写入数字自动加1";
this.checkBox1.UseVisualStyleBackColor = true;
//
// button3
//
this.button3.Enabled = false;
this.button3.Location = new System.Drawing.Point(174, 123);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(156, 23);
this.button3.TabIndex = 11;
this.button3.Text = "button3";
this.button3.UseVisualStyleBackColor = true;
//
// FrmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(339, 214);
this.Controls.Add(this.button3);
this.Controls.Add(this.checkBox1);
this.Controls.Add(this.NudNumber);
this.Controls.Add(this.CboLetter);
this.Controls.Add(this.button2);
this.Controls.Add(this.label2);
this.Controls.Add(this.button1);
this.Controls.Add(this.LstIP);
this.Controls.Add(this.BtnOpen);
this.Controls.Add(this.BtnGetIP);
this.Controls.Add(this.CboLocal);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FrmMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "浩斌RFID读写";
this.Load += new System.EventHandler(this.FrmMain_Load);
((System.ComponentModel.ISupportInitialize)(this.NudNumber)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox CboLocal;
private System.Windows.Forms.Button BtnGetIP;
private System.Windows.Forms.Button BtnOpen;
private System.Windows.Forms.ListBox LstIP;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.ComboBox CboLetter;
private System.Windows.Forms.NumericUpDown NudNumber;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.Button button3;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Asa.RFID
{
public partial class FrmMain : Form
{
private string[] _ip;
public FrmMain()
{
InitializeComponent();
}
private void FrmMain_Load(object sender, EventArgs e)
{
string[] letter = new string[26];
for (int i = 0; i < letter.Length; i++)
letter[i] = ((char)(65 + i)).ToString();
CboLetter.Items.AddRange(letter);
CboLetter.SelectedIndex = 0;
CboLocal.Items.AddRange(HaoBinIP.GetLocal());
if (CboLocal.Items.Count > 0)
CboLocal.SelectedIndex = 0;
}
private void BtnGetIP_Click(object sender, EventArgs e)
{
LstIP.Items.Clear();
_ip = HaoBinIP.Find(CboLocal.Text);
LstIP.Items.AddRange(_ip);
BtnOpen.Enabled = _ip.Length > 0;
}
private void BtnOpen_Click(object sender, EventArgs e)
{
if (LstIP.SelectedIndex == -1) return;
}
}
}
......@@ -4,7 +4,7 @@ using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace RFID_Debug
namespace Asa.RFID
{
static class Program
{
......
......@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RFID_Debug")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
......@@ -20,7 +20,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("44467e65-c850-4538-96e4-1335cccb87bc")]
[assembly: Guid("9eb46cb8-79c8-4e19-b04b-eabe52c54e33")]
// 程序集的版本信息由下列四个值组成:
//
......
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace Asa.RFID.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Asa.RFID.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace Asa.RFID.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}
......@@ -4,29 +4,14 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{5C55663B-DBDA-490B-A80F-0ABB173AEF88}</ProjectGuid>
<ProjectGuid>{9EB46CB8-79C8-4E19-B04B-EABE52C54E33}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>RFID_Debug</RootNamespace>
<AssemblyName>RFID_HFReader_Debug</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<RootNamespace>Asa.RFID</RootNamespace>
<AssemblyName>RFID_Debug</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
......@@ -37,8 +22,6 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
......@@ -48,33 +31,8 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>8.0</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>8.0</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\..\..\..\DLL\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
......@@ -88,7 +46,6 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="FrmMain.cs">
<SubType>Form</SubType>
</Compile>
......@@ -97,12 +54,6 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UserControl1.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UserControl1.Designer.cs">
<DependentUpon>UserControl1.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="FrmMain.resx">
<DependentUpon>FrmMain.cs</DependentUpon>
</EmbeddedResource>
......@@ -114,10 +65,8 @@
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="UserControl1.resx">
<DependentUpon>UserControl1.cs</DependentUpon>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
......@@ -132,26 +81,10 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RFID_HFReader\RFID_HFReader.csproj">
<Project>{e352e032-435c-4eb1-96b4-018bdc50b105}</Project>
<Name>RFID_HFReader</Name>
<ProjectReference Include="..\RFID_HaoBin\RFID_HaoBin.csproj">
<Project>{6b0b49df-b379-49c6-9983-6c9076f99711}</Project>
<Name>RFID_HaoBin</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.6 %28x86 和 x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0"?>
<doc>
<assembly>
<name>Asa.RFID.HFReader</name>
<name>Asa.RFID.HaoBin</name>
</assembly>
<members>
<member name="T:Asa.RFID.HFReader">
<member name="M:Asa.RFID.HaoBinIP.Find(System.String)">
<summary>
查找IP地址
</summary>
<param name="localIP"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.HaoBinIP.Modify(System.String,System.String,System.String)">
<summary>
修改IP地址,需要先查找IP
</summary>
<param name="localIP">本地IP</param>
<param name="beforeIP">修改前的IP</param>
<param name="afterIP">修改后的IP</param>
<returns></returns>
</member>
<member name="M:Asa.RFID.HaoBinIP.GetLocal">
<summary>
获取本地IPv4地址
</summary>
<returns></returns>
</member>
<member name="T:Asa.RFID.HaoBin">
<summary>
RFID读卡器
</summary>
</member>
<member name="T:Asa.RFID.HFReader.Received_Event">
<member name="T:Asa.RFID.HaoBin.Received_Event">
<summary>
接收事件
</summary>
<param name="ip"></param>
<param name="buff"></param>
</member>
<member name="E:Asa.RFID.HFReader.Received">
<member name="E:Asa.RFID.HaoBin.Received">
<summary>
接收数据
</summary>
</member>
<member name="M:Asa.RFID.HFReader.#ctor(System.String)">
<member name="M:Asa.RFID.HaoBin.#ctor(System.String)">
<summary>
RFID读卡器
</summary>
</member>
<member name="P:Asa.RFID.HFReader.IsConn">
<member name="P:Asa.RFID.HaoBin.IsConn">
<summary>
是否连接
</summary>
</member>
<member name="P:Asa.RFID.HFReader.IsAutoScan">
<member name="P:Asa.RFID.HaoBin.IsAutoScan">
<summary>
是否自动扫描
</summary>
</member>
<member name="P:Asa.RFID.HFReader.IsExist">
<member name="P:Asa.RFID.HaoBin.IsExist">
<summary>
是否存在ID卡
</summary>
</member>
<member name="P:Asa.RFID.HFReader.ErrCode">
<member name="P:Asa.RFID.HaoBin.ErrCode">
<summary>
错误代码
</summary>
</member>
<member name="P:Asa.RFID.HFReader.IP">
<member name="P:Asa.RFID.HaoBin.IP">
<summary>
IP地址
</summary>
</member>
<member name="P:Asa.RFID.HFReader.LogPath">
<member name="P:Asa.RFID.HaoBin.LogPath">
<summary>
日志目录
</summary>
</member>
<member name="P:Asa.RFID.HFReader.ID">
<member name="P:Asa.RFID.HaoBin.ID">
<summary>
ID号码
</summary>
</member>
<member name="M:Asa.RFID.HFReader.Open(System.Boolean)">
<member name="M:Asa.RFID.HaoBin.Open(System.Boolean)">
<summary>
连接
</summary>
<param name="autoScan">自动扫描</param>
</member>
<member name="M:Asa.RFID.HFReader.Close">
<member name="M:Asa.RFID.HaoBin.Close">
<summary>
关闭
</summary>
</member>
<member name="M:Asa.RFID.HFReader.FindRFID">
<member name="M:Asa.RFID.HaoBin.FindRFID">
<summary>
查找电子标签,扫描模式不能使用
</summary>
<returns></returns>
</member>
<member name="M:Asa.RFID.HFReader.Read">
<member name="M:Asa.RFID.HaoBin.Read">
<summary>
读取电子标签
</summary>
<returns></returns>
</member>
<member name="M:Asa.RFID.HFReader.Write(System.Byte[])">
<member name="M:Asa.RFID.HaoBin.Write(System.Byte[])">
<summary>
写入数据到电子标签,扫描模式不能使用
</summary>
<param name="buff">数据,必须小于等于112字节</param>
<returns></returns>
</member>
<member name="M:Asa.RFID.HFReader.AutoScanMode(System.Boolean)">
<member name="M:Asa.RFID.HaoBin.AutoScanMode(System.Boolean)">
<summary>
自动扫描模式
</summary>
......@@ -99,143 +121,5 @@
<param name="open2"></param>
<returns></returns>
</member>
<member name="T:Asa.RFID.HFReaderAll">
<summary>
RFID读卡器
</summary>
</member>
<member name="M:Asa.RFID.HFReaderAll.#ctor">
<summary>
RFID
</summary>
</member>
<member name="P:Asa.RFID.HFReaderAll.LogPath">
<summary>
日志目录
</summary>
</member>
<member name="P:Asa.RFID.HFReaderAll.ScanMode">
<summary>
扫描模式,true自动,false查找
</summary>
</member>
<member name="M:Asa.RFID.HFReaderAll.Open(System.String[])">
<summary>
打开所有
</summary>
<param name="ip"></param>
</member>
<member name="M:Asa.RFID.HFReaderAll.Close">
<summary>
关闭所有
</summary>
</member>
<member name="M:Asa.RFID.HFReaderAll.IsOpen">
<summary>
是否打开
</summary>
<returns></returns>
</member>
<member name="M:Asa.RFID.HFReaderAll.IsOpen(System.String)">
<summary>
是否打开
</summary>
<param name="ip"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.HFReaderAll.Read(System.String)">
<summary>
读取
</summary>
<param name="ip"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.HFReaderAll.ReadStr(System.String)">
<summary>
读取
</summary>
<param name="ip"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.HFReaderAll.Clear(System.String)">
<summary>
清零
</summary>
<param name="ip"></param>
</member>
<member name="T:Asa.RFID.IP">
<summary>
IP地址操作
</summary>
</member>
<member name="M:Asa.RFID.IP.Find(System.String)">
<summary>
查找IP地址
</summary>
<param name="localIP"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.IP.Modify(System.String,System.String,System.String)">
<summary>
修改IP地址,需要先查找IP
</summary>
<param name="localIP">本地IP</param>
<param name="beforeIP">修改前的IP</param>
<param name="afterIP">修改后的IP</param>
<returns></returns>
</member>
<member name="M:Asa.RFID.IP.GetLocal">
<summary>
获取本地IPv4地址
</summary>
<returns></returns>
</member>
<member name="T:Asa.RFID.Log">
<summary>
日志操作类
</summary>
</member>
<member name="M:Asa.RFID.Log.#ctor(System.String)">
<summary>
日志
</summary>
<param name="path">文件夹目录</param>
</member>
<member name="M:Asa.RFID.Log.#ctor(System.String,System.String)">
<summary>
日志
</summary>
<param name="path">文件夹目录</param>
<param name="name">文件名</param>
</member>
<member name="M:Asa.RFID.Log.Exit">
<summary>
退出
</summary>
</member>
<member name="M:Asa.RFID.Log.OutError(System.String)">
<summary>
输出错误信息
</summary>
<param name="s"></param>
</member>
<member name="M:Asa.RFID.Log.OutInfo(System.String)">
<summary>
输出信息
</summary>
<param name="s"></param>
</member>
<member name="M:Asa.RFID.Log.OutDebug(System.String)">
<summary>
输出调试信息
</summary>
<param name="s"></param>
</member>
<member name="M:Asa.RFID.Log.OutString(System.String)">
<summary>
输出字符串数据
</summary>
<param name="s"></param>
</member>
</members>
</doc>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
\ No newline at end of file
C:\Neotel\Program\RFID\RFID_HaoBin_Debug\bin\Debug\RFID_Debug.exe.config
C:\Neotel\Program\RFID\RFID_HaoBin_Debug\bin\Debug\RFID_Debug.exe
C:\Neotel\Program\RFID\RFID_HaoBin_Debug\bin\Debug\RFID_Debug.pdb
C:\Neotel\Program\RFID\RFID_HaoBin_Debug\bin\Debug\Asa.RFID.HaoBin.dll
C:\Neotel\Program\RFID\RFID_HaoBin_Debug\bin\Debug\Asa.RFID.HaoBin.pdb
C:\Neotel\Program\RFID\RFID_HaoBin_Debug\bin\Debug\Asa.RFID.HaoBin.xml
C:\Neotel\Program\RFID\RFID_HaoBin_Debug\obj\Debug\RFID_HaoBin_Debug.csprojAssemblyReference.cache
C:\Neotel\Program\RFID\RFID_HaoBin_Debug\obj\Debug\Asa.RFID.FrmMain.resources
C:\Neotel\Program\RFID\RFID_HaoBin_Debug\obj\Debug\Asa.RFID.Properties.Resources.resources
C:\Neotel\Program\RFID\RFID_HaoBin_Debug\obj\Debug\RFID_HaoBin_Debug.csproj.GenerateResource.cache
C:\Neotel\Program\RFID\RFID_HaoBin_Debug\obj\Debug\RFID_HaoBin_Debug.csproj.CoreCompileInputs.cache
C:\Neotel\Program\RFID\RFID_HaoBin_Debug\obj\Debug\RFID_HaoBin_Debug.csproj.CopyComplete
C:\Neotel\Program\RFID\RFID_HaoBin_Debug\obj\Debug\RFID_Debug.exe
C:\Neotel\Program\RFID\RFID_HaoBin_Debug\obj\Debug\RFID_Debug.pdb
C:\Neotel\Program\RFID\RFID_HaoBin_Debug\bin\Debug\HFReader9CSharp.dll
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Asa.RFID
{
public interface IReadAll
{
public delegate void ReceivedEvent(string ip, string id);
public event ReceivedEvent Received;
public delegate void ReceiveBufferEvent(string ip, byte[] buffer);
public event ReceiveBufferEvent ReceiveBuffer;
public void Start(int port);
public void Start(string[] ip);
public void Stop();
public string Read(string ip);
public void Clear(string ip);
}
}
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Interface\bin\Debug\Asa.RFID.IReadAll.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Interface\bin\Debug\Asa.RFID.IReadAll.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Interface\obj\Debug\RFID_Interface.csproj.CoreCompileInputs.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Interface\obj\Debug\Asa.RFID.IReadAll.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\RFID\RFID_Interface\obj\Debug\Asa.RFID.IReadAll.pdb
D:\Neotel\RFID\RFID_Interface\bin\Debug\Asa.RFID.IReadAll.dll
D:\Neotel\RFID\RFID_Interface\bin\Debug\Asa.RFID.IReadAll.pdb
D:\Neotel\RFID\RFID_Interface\obj\Debug\RFID_Interface.csprojAssemblyReference.cache
D:\Neotel\RFID\RFID_Interface\obj\Debug\RFID_Interface.csproj.CoreCompileInputs.cache
D:\Neotel\RFID\RFID_Interface\obj\Debug\Asa.RFID.IReadAll.dll
D:\Neotel\RFID\RFID_Interface\obj\Debug\Asa.RFID.IReadAll.pdb
C:\Neotel\Program\RFID\RFID_Interface\bin\Debug\Asa.RFID.IReadAll.dll
C:\Neotel\Program\RFID\RFID_Interface\bin\Debug\Asa.RFID.IReadAll.pdb
C:\Neotel\Program\RFID\RFID_Interface\obj\Debug\RFID_Interface.csprojAssemblyReference.cache
C:\Neotel\Program\RFID\RFID_Interface\obj\Debug\RFID_Interface.csproj.CoreCompileInputs.cache
C:\Neotel\Program\RFID\RFID_Interface\obj\Debug\Asa.RFID.IReadAll.dll
C:\Neotel\Program\RFID\RFID_Interface\obj\Debug\Asa.RFID.IReadAll.pdb
......@@ -5,12 +5,12 @@ using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("RFID_Interface")]
[assembly: AssemblyTitle("RFID_PuYue")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RFID_Interface")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyProduct("RFID_PuYue")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
......@@ -20,7 +20,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("e7a36c72-093b-428e-a4e3-4739ee0bf4cc")]
[assembly: Guid("6afa3060-1dff-4ac0-b082-827c451e5ff7")]
// 程序集的版本信息由下列四个值组成:
//
......
......@@ -11,18 +11,17 @@ namespace Asa.RFID
/// <summary>
/// HiStation RFID
/// </summary>
public class HiStation
public class PuYue
{
private Thread tRecon; //重连线程
private Thread tListen; //监听网络
private Socket _client; //客户端
private bool _loop; //循环
private short _mark; //事务处理标识
private bool _dataMode; //自动发送数据模式
private bool _dataMode = true; //自动发送数据模式
private bool _conOnce;
private bool _intact;
private bool _total; //完整的
private List<byte> _fullCmd;
private List<byte> _receive;
//private log4net.ILog Common.log;
private readonly byte[] FRAME_HEAD = Encoding.ASCII.GetBytes("1234");
private readonly byte[] FRAME_END = new byte[] { 0x0D, 0x0A };
......@@ -51,14 +50,14 @@ namespace Asa.RFID
/// HiStation RFID
/// </summary>
/// <param name="logName">日志名称</param>
public HiStation(string logName = "HFReader")
public PuYue(string logName = "HiStation")
{
_mark = 0;
_dataMode = false;
_conOnce = false;
_conOnce = true;
_receive = new List<byte>();
if (Common.log == null)
Common.log = log4net.LogManager.GetLogger(logName);
//if (Common.log == null)
// Common.log = log4net.LogManager.GetLogger(logName);
//Common.log.Info("=====Init=====");
}
/// <summary>
......@@ -76,14 +75,22 @@ namespace Asa.RFID
/// </summary>
public void Open()
{
_loop = true;
IsConn = false;
tRecon = new Thread(new ThreadStart(Reconn)) { Name = "Reconnect" };
tListen = new Thread(new ThreadStart(Listen)) { Name = "Listen" };
tRecon.Start();
tListen.Start();
Common.log.Info(string.Format("Open[{0}] OK", IP));
//_loop = true;
//IsConn = false;
//tRecon = new Thread(new ThreadStart(Reconn)) { Name = "Reconnect" };
//tListen = new Thread(new ThreadStart(Listen)) { Name = "Listen" };
//tRecon.Start();
//tListen.Start();
//Common.log.Info(string.Format("Open[{0}] OK", IP));
IsConn = Connect();
if (IsConn)
{
_loop = true;
tListen = new Thread(new ThreadStart(Listen)) { Name = "Listen" };
tListen.Start();
}
//Common.log.Info(string.Format("Open[{0}] {1}", IP, IsConn));
}
/// <summary>
......@@ -103,11 +110,11 @@ namespace Asa.RFID
_client.Shutdown(SocketShutdown.Both);
_client.Close();
}
Common.log.Info(string.Format("Close[{0}] OK", IP));
//Common.log.Info(string.Format("Close[{0}] OK", IP));
}
catch (Exception ex)
{
Common.log.Error(string.Format("Close[{0}] ERROR", IP), ex);
//Common.log.Error(string.Format("Close[{0}] ERROR", IP), ex);
}
finally
{
......@@ -121,43 +128,15 @@ namespace Asa.RFID
public void Init()
{
_dataMode = false;
Write(0, 1); //设备地址1
Wait();
Write(1, 2); //波特率
Wait();
Write(2, 0); //禁止AFI
Wait();
Write(3, 20); //盘点超时时间,20*5ms
Wait();
Write(4, 1); //命令触发
Wait();
Write(5, 1); //操作模式
Wait();
Write(6, 0x20); //寄存器地址
Wait();
Write(7, 4); //寄存器数量
Wait();
Write(8, 10); //触发时间,10*5ms
Wait();
Write(9, 1); //输出格式
Wait();
Write(10, 0x1234); //数据帧枕头
Wait();
Write(11, 9); //记录保持时间,9*5ms
Wait();
//设备地址1,波特率,禁止AFI,盘点超时时间(20*5ms),命令触发,操作模式,寄存器地址,寄存器数量,触发时间(10*5ms),输出格式,数据帧枕头,记录保持时间(9*5ms)
short[] address = new short[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
short[] value = new short[] { 1, 2, 0, 20, 1, 1, 0x20, 4, 10, 1, 0x1234, 9 };
for (int i = 0; i < address.Length; i++)
{
Write(address[i], value[i]);
bool rtn = Wait();
if (!rtn) break;
}
}
/// <summary>
......@@ -166,19 +145,60 @@ namespace Asa.RFID
/// <param name="auto"></param>
public void TriggerMode(bool auto)
{
if (auto)
_dataMode = false;
Write(4, (short)(auto ? 0 : 1));
if (Wait())
_dataMode = auto;
}
public bool GetAutoMode()
{
_dataMode = false;
bool rtn = false;
Read(4, 1);
if (Wait())
{
_dataMode = false;
Write(4, 0);
Wait();
_dataMode = true;
byte n = _fullCmd[_fullCmd.Count - 1];
rtn = n == 0;
_dataMode = rtn;
}
else
return rtn;
}
public bool ReadData(out string value)
{
_dataMode = false;
bool rtn = false;
value = "";
Read(0x20, 4);
if (Wait())
{
_dataMode = false;
Write(4, 1);
if (_fullCmd[7] == 0x03)
{
value = (char)_fullCmd[10] + _fullCmd[11].ToString();
rtn = true;
}
else
{
//Common.log.Info("0x03功能码不匹配");
}
}
return rtn;
}
public bool WriteData(string id)
{
_dataMode = false;
bool rtn = false;
Write(id);
if (Wait())
{
if (_fullCmd[7] == 0x10)
rtn = true;
//else
// Common.log.Info("0x10功能码不匹配");
}
return rtn;
}
......@@ -186,6 +206,7 @@ namespace Asa.RFID
/// <summary>
/// 监听网络
/// </summary>
......@@ -205,8 +226,8 @@ namespace Asa.RFID
int count = _client.Receive(buff);
byte[] temp = new byte[count];
Array.Copy(buff, 0, temp, 0, count);
Common.log.Debug("Receive[" + IP + "]: " + HexBuff(temp));
//Common.log.Debug("Receive[" + IP + "]: " + HexBuff(temp));
_receive.AddRange(temp);
while (_receive.Count > 6)
{
......@@ -215,23 +236,12 @@ namespace Asa.RFID
DataProcess();
else
CmdProcess();
//if (_receive[0] == FRAME_HEAD[0] && _receive[1] == FRAME_HEAD[1] && _receive[2] == FRAME_HEAD[2] && _receive[3] == FRAME_HEAD[3])
// DataProcess();
//else
// CmdProcess();
}
}
}
catch (Exception ex)
{
Common.log.Error(string.Format("Listen[{0}] ERROR", IP), ex);
//Common.log.Error(string.Format("Listen[{0}] ERROR", IP), ex);
IsConn = false;
}
}
......@@ -244,6 +254,7 @@ namespace Asa.RFID
{
try
{
for (int i = 0; i < _receive.Count - 4; i++)
{
if (_receive[i] == FRAME_HEAD[0] && _receive[i + 1] == FRAME_HEAD[1] &&
......@@ -255,7 +266,7 @@ namespace Asa.RFID
{
string uid = Encoding.ASCII.GetString(_receive.ToArray(), i + 4, 16);
string data = Encoding.ASCII.GetString(_receive.ToArray(), i + 20, 16);
Common.log.Debug(string.Format("解析完成[{0}] uid={1} data={2}", IP, uid, data));
//Common.log.Debug(string.Format("解析完成[{0}] uid={1} data={2}", IP, uid, data));
string ID;
if (data.Length > 6)
......@@ -267,7 +278,7 @@ namespace Asa.RFID
}
else
{
Common.log.Error(string.Format("解析错误[{0}]", IP));
//Common.log.Error(string.Format("解析错误[{0}]", IP));
}
_receive.RemoveRange(0, i + 38);
}
......@@ -280,7 +291,7 @@ namespace Asa.RFID
}
catch (Exception ex)
{
Common.log.Error(string.Format("DataProcess[{0}] ERROR", IP), ex);
//Common.log.Error(string.Format("DataProcess[{0}] ERROR", IP), ex);
}
}
......@@ -303,8 +314,9 @@ namespace Asa.RFID
len += _receive[i + 5];
if (_receive.Count >= len)
{
_intact = true;
_fullCmd = _receive.GetRange(0, len);
_receive.RemoveRange(0, len);
_total = true;
}
else
{
......@@ -320,7 +332,7 @@ namespace Asa.RFID
}
catch (Exception ex)
{
Common.log.Error(string.Format("CmdProcess[{0}] ERROR", IP), ex);
//Common.log.Error(string.Format("CmdProcess[{0}] ERROR", IP), ex);
}
}
......@@ -331,14 +343,21 @@ namespace Asa.RFID
{
while (_loop)
{
if (IsConn != _conOnce)
if (IsConn)
{
_conOnce = IsConn;
Connected?.Invoke(IP);
if (!_conOnce)
{
Connected?.Invoke(IP);
_conOnce = true;
}
}
if (!IsConn)
else
{
if (_conOnce)
{
Connected?.Invoke(IP);
_conOnce = false;
}
Thread.Sleep(500);
if (!_loop) break;
IsConn = Connect();
......@@ -361,18 +380,18 @@ namespace Asa.RFID
{
//建立连接
_client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
_client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 500);
_client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 500);
_client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 1000);
_client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 1000);
_client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.NoDelay, 1);
_client.Connect(System.Net.IPAddress.Parse(IP), 502);
Thread.Sleep(100); //需要等待一会才能获取连接状态
Common.log.Info("Socket[" + IP + "] Connected");
//Common.log.Info("Socket[" + IP + "] Connected");
}
}
catch (Exception ex)
{
rtn = false;
Common.log.Error(string.Format("Connect[{0}] ERROR", IP), ex);
//Common.log.Error(string.Format("Connect[{0}] ERROR", IP), ex);
}
return rtn;
}
......@@ -389,7 +408,7 @@ namespace Asa.RFID
bool rtn = System.Text.RegularExpressions.Regex.IsMatch(ip, pattern);
if (!rtn)
{
Common.log.Info(string.Format("非法的IP地址[{0}]", IP));
//Common.log.Info(string.Format("非法的IP地址[{0}]", IP));
return false;
}
......@@ -399,7 +418,7 @@ namespace Asa.RFID
ping.Dispose();
if (result.Status != System.Net.NetworkInformation.IPStatus.Success)
{
Common.log.Info(string.Format("Ping[{0}]请求没有响应", IP));
//Common.log.Info(string.Format("Ping[{0}]请求没有响应", IP));
return false;
}
......@@ -421,15 +440,6 @@ namespace Asa.RFID
return s;
}
/// <summary>
/// 读取保持寄存器,0x03功能码
/// </summary>
......@@ -437,6 +447,7 @@ namespace Asa.RFID
/// <param name="count"></param>
private void Read(short address, short count)
{
if (!IsConn) return;
byte[] temp;
byte[] buffer = new byte[12];
......@@ -464,15 +475,15 @@ namespace Asa.RFID
try
{
_intact = false;
Common.log.Debug("Read[" + IP + "] " + HexBuff(buffer));
_total = false;
//Common.log.Debug("Read[" + IP + "] " + HexBuff(buffer));
if (_client != null)
_client.Send(buffer);
}
catch (Exception ex)
{
IsConn = false;
Common.log.Error(string.Format("Read[{0}] ERROR", IP), ex);
//Common.log.Error(string.Format("Read[{0}] ERROR", IP), ex);
}
}
......@@ -484,6 +495,7 @@ namespace Asa.RFID
/// <param name="value"></param>
private void Write(short address, short value)
{
if (!IsConn) return;
byte[] temp;
byte[] buffer = new byte[15];
......@@ -516,15 +528,65 @@ namespace Asa.RFID
try
{
_intact = false;
Common.log.Debug("Write[" + IP + "] " + HexBuff(buffer));
_total = false;
//Common.log.Debug("Write[" + IP + "] " + HexBuff(buffer));
if (_client != null)
_client.Send(buffer);
}
catch (Exception ex)
{
IsConn = false;
Common.log.Error(string.Format("Write[{0}] ERROR", IP), ex);
//Common.log.Error(string.Format("Write[{0}] ERROR", IP), ex);
}
}
private void Write(string value)
{
if (!IsConn) return;
byte[] temp;
byte[] buffer = new byte[21];
GetMark();
temp = BitConverter.GetBytes(_mark); //事务处理标识
buffer[0] = temp[1]; //高位
buffer[1] = temp[0]; //低位
buffer[2] = 0;
buffer[3] = 0; //协议标识
buffer[4] = 0;
buffer[5] = 15; //后面字节数
buffer[6] = 0xFF; //主设备
buffer[7] = 0x10; //功能码
buffer[8] = 0;
buffer[9] = 0x20; //地址
buffer[10] = 0;
buffer[11] = 4; //寄存器个数
buffer[12] = 8; //数据长度
buffer[13] = 0x5A;
buffer[14] = (byte)value[0];
buffer[15] = Convert.ToByte(value.Substring(1));
buffer[16] = 0;
buffer[17] = 0;
buffer[18] = 0x4A;
buffer[19] = 0;
buffer[20] = 0;
try
{
_total = false;
//Common.log.Debug("Write[" + IP + "] " + HexBuff(buffer));
if (_client != null)
_client.Send(buffer);
}
catch (Exception ex)
{
IsConn = false;
//Common.log.Error(string.Format("Write[{0}] ERROR", IP), ex);
}
}
......@@ -536,17 +598,23 @@ namespace Asa.RFID
_mark++;
}
private void Wait()
private bool Wait()
{
bool result = true;
int count = 0;
do
{
Thread.Sleep(5);
count += 5;
if (count == 2000)
{
result = false;
break;
}
}
while (!_intact);
while (!_total);
return result;
}
}
......
......@@ -4,15 +4,14 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E7A36C72-093B-428E-A4E3-4739EE0BF4CC}</ProjectGuid>
<ProjectGuid>{6AFA3060-1DFF-4AC0-B082-827C451E5FF7}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Asa.RFID</RootNamespace>
<AssemblyName>Asa.RFID.IReadAll</AssemblyName>
<AssemblyName>Asa.RFID.PuYue</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
......@@ -22,6 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Asa.RFID.PuYue.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
......@@ -42,7 +42,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Interface.cs" />
<Compile Include="PuYue.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
......
此文件类型无法预览
此文件类型无法预览
<?xml version="1.0"?>
<doc>
<assembly>
<name>Asa.RFID.PuYue</name>
</assembly>
<members>
<member name="T:Asa.RFID.PuYue">
<summary>
HiStation RFID
</summary>
</member>
<member name="T:Asa.RFID.PuYue.Connected_Event">
<summary>
连接事件
</summary>
</member>
<member name="E:Asa.RFID.PuYue.Connected">
<summary>
已连接时触发
</summary>
</member>
<member name="T:Asa.RFID.PuYue.Received_Event">
<summary>
接收事件
</summary>
<param name="ip"></param>
<param name="uid"></param>
<param name="data"></param>
</member>
<member name="E:Asa.RFID.PuYue.Received">
<summary>
接收到数据事件
</summary>
</member>
<member name="M:Asa.RFID.PuYue.#ctor(System.String)">
<summary>
HiStation RFID
</summary>
<param name="logName">日志名称</param>
</member>
<member name="P:Asa.RFID.PuYue.IP">
<summary>
IP地址
</summary>
</member>
<member name="P:Asa.RFID.PuYue.IsConn">
<summary>
是否连接
</summary>
</member>
<member name="M:Asa.RFID.PuYue.Open">
<summary>
打开设备
</summary>
</member>
<member name="M:Asa.RFID.PuYue.Close">
<summary>
关闭设备
</summary>
</member>
<member name="M:Asa.RFID.PuYue.Init">
<summary>
初始化(用于修改硬件参数,不用每次调用)
</summary>
</member>
<member name="M:Asa.RFID.PuYue.TriggerMode(System.Boolean)">
<summary>
触发模式
</summary>
<param name="auto"></param>
</member>
<member name="M:Asa.RFID.PuYue.Listen">
<summary>
监听网络
</summary>
</member>
<member name="M:Asa.RFID.PuYue.DataProcess">
<summary>
数据处理
</summary>
</member>
<member name="M:Asa.RFID.PuYue.CmdProcess">
<summary>
命令处理
</summary>
</member>
<member name="M:Asa.RFID.PuYue.Reconn">
<summary>
重连
</summary>
</member>
<member name="M:Asa.RFID.PuYue.Connect">
<summary>
建立Socket连接
</summary>
<returns></returns>
</member>
<member name="M:Asa.RFID.PuYue.CheckIP(System.String)">
<summary>
检查IP
</summary>
<param name="ip"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.PuYue.HexBuff(System.Byte[])">
<summary>
16进制转换
</summary>
<param name="buff"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.PuYue.Read(System.Int16,System.Int16)">
<summary>
读取保持寄存器,0x03功能码
</summary>
<param name="address"></param>
<param name="count"></param>
</member>
<member name="M:Asa.RFID.PuYue.Write(System.Int16,System.Int16)">
<summary>
写入保持寄存器,0x10功能码
</summary>
<param name="address"></param>
<param name="value"></param>
</member>
</members>
</doc>
此文件类型无法预览
此文件类型无法预览
C:\Neotel\Program\RFID\RFID_PuYue\bin\Debug\Asa.RFID.PuYue.xml
C:\Neotel\Program\RFID\RFID_PuYue\bin\Debug\Asa.RFID.PuYue.dll
C:\Neotel\Program\RFID\RFID_PuYue\bin\Debug\Asa.RFID.PuYue.pdb
C:\Neotel\Program\RFID\RFID_PuYue\obj\Debug\RFID_PuYue.csproj.CoreCompileInputs.cache
C:\Neotel\Program\RFID\RFID_PuYue\obj\Debug\Asa.RFID.PuYue.dll
C:\Neotel\Program\RFID\RFID_PuYue\obj\Debug\Asa.RFID.PuYue.pdb
C:\Neotel\Program\RFID\RFID_PuYue\obj\Debug\RFID_PuYue.csprojAssemblyReference.cache
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
\ No newline at end of file

namespace RFID_PuYue_Debug
{
partial class FrmMain
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.TxtIP = new System.Windows.Forms.TextBox();
this.BtnOpen = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.BtnInit = new System.Windows.Forms.Button();
this.BtnAutoMode = new System.Windows.Forms.Button();
this.BtnManual = new System.Windows.Forms.Button();
this.CboLetter = new System.Windows.Forms.ComboBox();
this.NudNumber = new System.Windows.Forms.NumericUpDown();
this.BtnWrite = new System.Windows.Forms.Button();
this.LblMode = new System.Windows.Forms.Label();
this.BtnRead = new System.Windows.Forms.Button();
this.LblRfid = new System.Windows.Forms.Label();
this.ChkAutoAdd = new System.Windows.Forms.CheckBox();
this.TxtRead = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.NudNumber)).BeginInit();
this.SuspendLayout();
//
// TxtIP
//
this.TxtIP.Font = new System.Drawing.Font("宋体", 10F);
this.TxtIP.Location = new System.Drawing.Point(35, 12);
this.TxtIP.Name = "TxtIP";
this.TxtIP.Size = new System.Drawing.Size(137, 23);
this.TxtIP.TabIndex = 0;
this.TxtIP.Text = "192.168.1.7";
//
// BtnOpen
//
this.BtnOpen.Font = new System.Drawing.Font("宋体", 11F);
this.BtnOpen.Location = new System.Drawing.Point(12, 41);
this.BtnOpen.Name = "BtnOpen";
this.BtnOpen.Size = new System.Drawing.Size(160, 30);
this.BtnOpen.TabIndex = 1;
this.BtnOpen.Text = "打开";
this.BtnOpen.UseVisualStyleBackColor = true;
this.BtnOpen.Click += new System.EventHandler(this.BtnOpen_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 15);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(17, 12);
this.label1.TabIndex = 2;
this.label1.Text = "IP";
//
// BtnInit
//
this.BtnInit.Enabled = false;
this.BtnInit.Font = new System.Drawing.Font("宋体", 11F);
this.BtnInit.Location = new System.Drawing.Point(12, 113);
this.BtnInit.Name = "BtnInit";
this.BtnInit.Size = new System.Drawing.Size(160, 30);
this.BtnInit.TabIndex = 3;
this.BtnInit.Text = "初始化";
this.BtnInit.UseVisualStyleBackColor = true;
this.BtnInit.Click += new System.EventHandler(this.BtnInit_Click);
//
// BtnAutoMode
//
this.BtnAutoMode.Enabled = false;
this.BtnAutoMode.Font = new System.Drawing.Font("宋体", 11F);
this.BtnAutoMode.Location = new System.Drawing.Point(12, 149);
this.BtnAutoMode.Name = "BtnAutoMode";
this.BtnAutoMode.Size = new System.Drawing.Size(160, 30);
this.BtnAutoMode.TabIndex = 5;
this.BtnAutoMode.Text = "设置为自动模式";
this.BtnAutoMode.UseVisualStyleBackColor = true;
this.BtnAutoMode.Click += new System.EventHandler(this.BtnAutoMode_Click);
//
// BtnManual
//
this.BtnManual.Enabled = false;
this.BtnManual.Font = new System.Drawing.Font("宋体", 11F);
this.BtnManual.Location = new System.Drawing.Point(12, 185);
this.BtnManual.Name = "BtnManual";
this.BtnManual.Size = new System.Drawing.Size(160, 30);
this.BtnManual.TabIndex = 4;
this.BtnManual.Text = "设置为手动模式";
this.BtnManual.UseVisualStyleBackColor = true;
this.BtnManual.Click += new System.EventHandler(this.BtnManual_Click);
//
// CboLetter
//
this.CboLetter.Font = new System.Drawing.Font("宋体", 11F);
this.CboLetter.FormattingEnabled = true;
this.CboLetter.Location = new System.Drawing.Point(178, 84);
this.CboLetter.Name = "CboLetter";
this.CboLetter.Size = new System.Drawing.Size(77, 23);
this.CboLetter.TabIndex = 6;
//
// NudNumber
//
this.NudNumber.Font = new System.Drawing.Font("宋体", 10F);
this.NudNumber.Location = new System.Drawing.Point(261, 84);
this.NudNumber.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.NudNumber.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.NudNumber.Name = "NudNumber";
this.NudNumber.Size = new System.Drawing.Size(77, 23);
this.NudNumber.TabIndex = 7;
this.NudNumber.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// BtnWrite
//
this.BtnWrite.Enabled = false;
this.BtnWrite.Font = new System.Drawing.Font("宋体", 11F);
this.BtnWrite.Location = new System.Drawing.Point(178, 149);
this.BtnWrite.Name = "BtnWrite";
this.BtnWrite.Size = new System.Drawing.Size(160, 66);
this.BtnWrite.TabIndex = 8;
this.BtnWrite.Text = "写入";
this.BtnWrite.UseVisualStyleBackColor = true;
this.BtnWrite.Click += new System.EventHandler(this.BtnWrite_Click);
//
// LblMode
//
this.LblMode.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
this.LblMode.Font = new System.Drawing.Font("宋体", 11F);
this.LblMode.ForeColor = System.Drawing.Color.Blue;
this.LblMode.Location = new System.Drawing.Point(12, 77);
this.LblMode.Margin = new System.Windows.Forms.Padding(3);
this.LblMode.Name = "LblMode";
this.LblMode.Size = new System.Drawing.Size(160, 30);
this.LblMode.TabIndex = 9;
this.LblMode.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// BtnRead
//
this.BtnRead.Enabled = false;
this.BtnRead.Font = new System.Drawing.Font("宋体", 11F);
this.BtnRead.Location = new System.Drawing.Point(178, 12);
this.BtnRead.Name = "BtnRead";
this.BtnRead.Size = new System.Drawing.Size(160, 30);
this.BtnRead.TabIndex = 10;
this.BtnRead.Text = "读取";
this.BtnRead.UseVisualStyleBackColor = true;
this.BtnRead.Click += new System.EventHandler(this.BtnRead_Click);
//
// LblRfid
//
this.LblRfid.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
this.LblRfid.Font = new System.Drawing.Font("宋体", 11F);
this.LblRfid.ForeColor = System.Drawing.Color.Blue;
this.LblRfid.Location = new System.Drawing.Point(178, 48);
this.LblRfid.Margin = new System.Windows.Forms.Padding(3);
this.LblRfid.Name = "LblRfid";
this.LblRfid.Size = new System.Drawing.Size(160, 30);
this.LblRfid.TabIndex = 11;
this.LblRfid.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// ChkAutoAdd
//
this.ChkAutoAdd.Font = new System.Drawing.Font("宋体", 11F);
this.ChkAutoAdd.Location = new System.Drawing.Point(178, 113);
this.ChkAutoAdd.Name = "ChkAutoAdd";
this.ChkAutoAdd.Size = new System.Drawing.Size(160, 30);
this.ChkAutoAdd.TabIndex = 12;
this.ChkAutoAdd.Text = "写入数字自动加1";
this.ChkAutoAdd.UseVisualStyleBackColor = true;
//
// TxtRead
//
this.TxtRead.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.TxtRead.Location = new System.Drawing.Point(344, 12);
this.TxtRead.Multiline = true;
this.TxtRead.Name = "TxtRead";
this.TxtRead.ReadOnly = true;
this.TxtRead.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.TxtRead.Size = new System.Drawing.Size(308, 202);
this.TxtRead.TabIndex = 13;
//
// FrmMain
//
this.AcceptButton = this.BtnWrite;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(664, 226);
this.Controls.Add(this.TxtRead);
this.Controls.Add(this.ChkAutoAdd);
this.Controls.Add(this.LblRfid);
this.Controls.Add(this.BtnRead);
this.Controls.Add(this.LblMode);
this.Controls.Add(this.BtnWrite);
this.Controls.Add(this.CboLetter);
this.Controls.Add(this.NudNumber);
this.Controls.Add(this.BtnAutoMode);
this.Controls.Add(this.BtnManual);
this.Controls.Add(this.BtnInit);
this.Controls.Add(this.label1);
this.Controls.Add(this.BtnOpen);
this.Controls.Add(this.TxtIP);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "FrmMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "普阅RFID设置";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmMain_FormClosing);
this.Load += new System.EventHandler(this.FrmMain_Load);
((System.ComponentModel.ISupportInitialize)(this.NudNumber)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox TxtIP;
private System.Windows.Forms.Button BtnOpen;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button BtnInit;
private System.Windows.Forms.Button BtnAutoMode;
private System.Windows.Forms.Button BtnManual;
private System.Windows.Forms.ComboBox CboLetter;
private System.Windows.Forms.NumericUpDown NudNumber;
private System.Windows.Forms.Button BtnWrite;
private System.Windows.Forms.Label LblMode;
private System.Windows.Forms.Button BtnRead;
private System.Windows.Forms.Label LblRfid;
private System.Windows.Forms.CheckBox ChkAutoAdd;
private System.Windows.Forms.TextBox TxtRead;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace RFID_PuYue_Debug
{
public partial class FrmMain : Form
{
private Asa.RFID.PuYue rfid;
private bool autoMode;
public FrmMain()
{
InitializeComponent();
}
private void SetEnabled(bool enabled)
{
BtnInit.Enabled = enabled;
BtnAutoMode.Enabled = enabled;
BtnManual.Enabled = enabled;
if (!autoMode)
{
BtnWrite.Enabled = enabled;
BtnRead.Enabled = enabled;
}
}
private void Rfid_Received(string ip, string uid, string data)
{
this.Invoke(new Action(() =>
{
TxtRead.AppendText(string.Format("[{0:HH:mm:ss.fff}] UID:{1} NO.{2}\r\n", DateTime.Now, uid, data));
}));
}
private void FrmMain_Load(object sender, EventArgs e)
{
string[] letter = new string[26];
for (int i = 0; i < letter.Length; i++)
letter[i] = ((char)(65 + i)).ToString();
CboLetter.Items.AddRange(letter);
CboLetter.SelectedIndex = 0;
rfid = new Asa.RFID.PuYue();
rfid.Received += Rfid_Received;
}
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
{
if (rfid.IsConn)
rfid.Close();
}
private void BtnOpen_Click(object sender, EventArgs e)
{
if (rfid.IsConn)
rfid.Close();
else
{
rfid.IP = TxtIP.Text;
rfid.Open();
}
if(rfid.IsConn)
{
BtnOpen.Text = "关闭";
autoMode = rfid.GetAutoMode();
SetEnabled(true);
LblMode.Text = "当前模式" + (autoMode ? "自动" : "手动");
}
else
{
BtnOpen.Text = "打开";
SetEnabled(false);
}
}
private void BtnInit_Click(object sender, EventArgs e)
{
rfid.Init();
MessageBox.Show("OK");
}
private void BtnAutoMode_Click(object sender, EventArgs e)
{
rfid.TriggerMode(true);
BtnWrite.Enabled = false;
BtnRead.Enabled = false;
LblMode.Text = "当前模式自动";
MessageBox.Show(BtnAutoMode.Text);
}
private void BtnManual_Click(object sender, EventArgs e)
{
rfid.TriggerMode(false);
BtnWrite.Enabled = true;
BtnRead.Enabled = true;
LblMode.Text = "当前模式手动";
MessageBox.Show(BtnManual.Text);
}
private void BtnWrite_Click(object sender, EventArgs e)
{
string id = CboLetter.Text + NudNumber.Value;
bool rtn = rfid.WriteData(id);
if (rtn)
{
LblRfid.Text = "Write:" + id;
if (ChkAutoAdd.Checked)
NudNumber.Value++;
}
else
LblRfid.Text = "Write Error";
}
private void BtnRead_Click(object sender, EventArgs e)
{
bool rtn = rfid.ReadData(out string id);
if (rtn)
LblRfid.Text = "Read:" + id;
else
LblRfid.Text = "Read Error";
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace RFID_Debug
namespace RFID_PuYue_Debug
{
public static class Common
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FrmMain());
}
}
}
......@@ -5,12 +5,12 @@ using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("RFID")]
[assembly: AssemblyTitle("RFID_HiStation_Debug")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RFID")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyProduct("RFID_HiStation_Debug")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
......@@ -20,7 +20,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("e352e032-435c-4eb1-96b4-018bdc50b105")]
[assembly: Guid("1ed209bc-07e5-48ac-afd3-21e5e3d58b6e")]
// 程序集的版本信息由下列四个值组成:
//
......@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
......@@ -8,10 +8,9 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace RFID_Debug.Properties
{
namespace RFID_PuYue_Debug.Properties
{
/// <summary>
/// 强类型资源类,用于查找本地化字符串等。
/// </summary>
......@@ -44,7 +43,7 @@ namespace RFID_Debug.Properties
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RFID_Debug.Properties.Resources", typeof(Resources).Assembly);
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RFID_HiStation_Debug.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
......@@ -52,8 +51,8 @@ namespace RFID_Debug.Properties
}
/// <summary>
/// 覆盖当前线程的 CurrentUICulture 属性
/// 使用此强类型的资源类的资源查找
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
......
......@@ -8,10 +8,9 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace RFID_Debug.Properties
{
namespace RFID_PuYue_Debug.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
......
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1ED209BC-07E5-48AC-AFD3-21E5E3D58B6E}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>RFID_HiStation_Debug</RootNamespace>
<AssemblyName>RFID_HiStation_Debug</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FrmMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmMain.Designer.cs">
<DependentUpon>FrmMain.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="FrmMain.resx">
<DependentUpon>FrmMain.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\RFID\RFID_PuYue\RFID_PuYue.csproj">
<Project>{6afa3060-1dff-4ac0-b082-827c451e5ff7}</Project>
<Name>RFID_PuYue</Name>
</ProjectReference>
<ProjectReference Include="..\RFID-HiStation\RFID-HiStation.csproj">
<Project>{4d5996f8-7206-480d-834a-be1db5fb05b2}</Project>
<Name>RFID-HiStation</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
<?xml version="1.0"?>
<doc>
<assembly>
<name>Asa.RFID.PuYue</name>
</assembly>
<members>
<member name="T:Asa.RFID.PuYue">
<summary>
HiStation RFID
</summary>
</member>
<member name="T:Asa.RFID.PuYue.Connected_Event">
<summary>
连接事件
</summary>
</member>
<member name="E:Asa.RFID.PuYue.Connected">
<summary>
已连接时触发
</summary>
</member>
<member name="T:Asa.RFID.PuYue.Received_Event">
<summary>
接收事件
</summary>
<param name="ip"></param>
<param name="uid"></param>
<param name="data"></param>
</member>
<member name="E:Asa.RFID.PuYue.Received">
<summary>
接收到数据事件
</summary>
</member>
<member name="M:Asa.RFID.PuYue.#ctor(System.String)">
<summary>
HiStation RFID
</summary>
<param name="logName">日志名称</param>
</member>
<member name="P:Asa.RFID.PuYue.IP">
<summary>
IP地址
</summary>
</member>
<member name="P:Asa.RFID.PuYue.IsConn">
<summary>
是否连接
</summary>
</member>
<member name="M:Asa.RFID.PuYue.Open">
<summary>
打开设备
</summary>
</member>
<member name="M:Asa.RFID.PuYue.Close">
<summary>
关闭设备
</summary>
</member>
<member name="M:Asa.RFID.PuYue.Init">
<summary>
初始化(用于修改硬件参数,不用每次调用)
</summary>
</member>
<member name="M:Asa.RFID.PuYue.TriggerMode(System.Boolean)">
<summary>
触发模式
</summary>
<param name="auto"></param>
</member>
<member name="M:Asa.RFID.PuYue.Listen">
<summary>
监听网络
</summary>
</member>
<member name="M:Asa.RFID.PuYue.DataProcess">
<summary>
数据处理
</summary>
</member>
<member name="M:Asa.RFID.PuYue.CmdProcess">
<summary>
命令处理
</summary>
</member>
<member name="M:Asa.RFID.PuYue.Reconn">
<summary>
重连
</summary>
</member>
<member name="M:Asa.RFID.PuYue.Connect">
<summary>
建立Socket连接
</summary>
<returns></returns>
</member>
<member name="M:Asa.RFID.PuYue.CheckIP(System.String)">
<summary>
检查IP
</summary>
<param name="ip"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.PuYue.HexBuff(System.Byte[])">
<summary>
16进制转换
</summary>
<param name="buff"></param>
<returns></returns>
</member>
<member name="M:Asa.RFID.PuYue.Read(System.Int16,System.Int16)">
<summary>
读取保持寄存器,0x03功能码
</summary>
<param name="address"></param>
<param name="count"></param>
</member>
<member name="M:Asa.RFID.PuYue.Write(System.Int16,System.Int16)">
<summary>
写入保持寄存器,0x10功能码
</summary>
<param name="address"></param>
<param name="value"></param>
</member>
</members>
</doc>
[2021-06-18 13:03:48,977][1][HiStation:60]INFO =====Init=====
[2021-03-18 15:15:53,132][1][HiStation:60]INFO =====Init=====
[2021-04-09 19:08:02,697][1][HiStation:60]INFO =====Init=====
[2021-06-17 10:01:00,549][1][HiStation:60]INFO =====Init=====
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.12.0" newVersion="2.0.12.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<log4net>
<logger name="HiStation">
<level value="Debug"/>
<appender-ref ref="HiStation"/>
</logger>
<appender name="HiStation" type="log4net.Appender.RollingFileAppender">
<param name="File" value="Log\\HiStation.log" />
<param name="Encoding" value="UTF-8"/>
<param name="AppendToFile" value="true" />
<param name="RollingStyle" value="Date" />
<param name="DatePattern" value="yyyy-MM-dd" />
<param name="MaxSizeRollBackups" value="100" />
<param name="MaxFileSize" value="10240" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="[%d][%t][%c:%L]%-5p %m%n" />
</layout>
</appender>
</log4net>
</configuration>
\ No newline at end of file
此文件类型无法预览
此文件的差异太大,无法显示。
此文件类型无法预览
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.6.1", FrameworkDisplayName = ".NET Framework 4.6.1")]
C:\Neotel\Program\RFID\RFID_HiStation_Debug\bin\Debug\RFID_HiStation_Debug.exe.config
C:\Neotel\Program\RFID\RFID_HiStation_Debug\bin\Debug\RFID_HiStation_Debug.exe
C:\Neotel\Program\RFID\RFID_HiStation_Debug\bin\Debug\RFID_HiStation_Debug.pdb
C:\Neotel\Program\RFID\RFID_HiStation_Debug\obj\Debug\RFID_HiStation_Debug.csprojAssemblyReference.cache
C:\Neotel\Program\RFID\RFID_HiStation_Debug\obj\Debug\RFID_HiStation_Debug.FrmMain.resources
C:\Neotel\Program\RFID\RFID_HiStation_Debug\obj\Debug\RFID_HiStation_Debug.Properties.Resources.resources
C:\Neotel\Program\RFID\RFID_HiStation_Debug\obj\Debug\RFID_HiStation_Debug.csproj.GenerateResource.cache
C:\Neotel\Program\RFID\RFID_HiStation_Debug\obj\Debug\RFID_HiStation_Debug.csproj.CoreCompileInputs.cache
C:\Neotel\Program\RFID\RFID_HiStation_Debug\obj\Debug\RFID_HiStation_Debug.exe
C:\Neotel\Program\RFID\RFID_HiStation_Debug\obj\Debug\RFID_HiStation_Debug.pdb
C:\Neotel\Program\RFID\RFID_HiStation_Debug\bin\Debug\Asa.RFID.HiStation.dll
C:\Neotel\Program\RFID\RFID_HiStation_Debug\bin\Debug\log4net.dll
C:\Neotel\Program\RFID\RFID_HiStation_Debug\bin\Debug\Asa.RFID.IReadAll.dll
C:\Neotel\Program\RFID\RFID_HiStation_Debug\bin\Debug\Asa.RFID.HiStation.pdb
C:\Neotel\Program\RFID\RFID_HiStation_Debug\bin\Debug\log4net.xml
C:\Neotel\Program\RFID\RFID_HiStation_Debug\bin\Debug\Asa.RFID.IReadAll.pdb
C:\Neotel\Program\RFID\RFID_HiStation_Debug\obj\Debug\RFID_HiStation_Debug.exe.config
C:\Neotel\Program\RFID\RFID_HiStation_Debug\obj\Debug\RFID_HiStation_Debug.csproj.CopyComplete
C:\Neotel\Program\RFID\RFID_HiStation_Debug\bin\Debug\log4net.config
C:\Neotel\Program\RFIDOld\RFID_HiStation_Debug\bin\Debug\log4net.config
C:\Neotel\Program\RFIDOld\RFID_HiStation_Debug\bin\Debug\RFID_HiStation_Debug.exe.config
C:\Neotel\Program\RFIDOld\RFID_HiStation_Debug\bin\Debug\RFID_HiStation_Debug.exe
C:\Neotel\Program\RFIDOld\RFID_HiStation_Debug\bin\Debug\RFID_HiStation_Debug.pdb
C:\Neotel\Program\RFIDOld\RFID_HiStation_Debug\bin\Debug\Asa.RFID.HiStation.dll
C:\Neotel\Program\RFIDOld\RFID_HiStation_Debug\bin\Debug\Asa.RFID.PuYue.dll
C:\Neotel\Program\RFIDOld\RFID_HiStation_Debug\bin\Debug\log4net.dll
C:\Neotel\Program\RFIDOld\RFID_HiStation_Debug\bin\Debug\Asa.RFID.IReadAll.dll
C:\Neotel\Program\RFIDOld\RFID_HiStation_Debug\bin\Debug\Asa.RFID.PuYue.pdb
C:\Neotel\Program\RFIDOld\RFID_HiStation_Debug\bin\Debug\Asa.RFID.PuYue.xml
C:\Neotel\Program\RFIDOld\RFID_HiStation_Debug\bin\Debug\Asa.RFID.HiStation.pdb
C:\Neotel\Program\RFIDOld\RFID_HiStation_Debug\bin\Debug\log4net.xml
C:\Neotel\Program\RFIDOld\RFID_HiStation_Debug\bin\Debug\Asa.RFID.IReadAll.pdb
C:\Neotel\Program\RFIDOld\RFID_HiStation_Debug\obj\Debug\RFID_HiStation_Debug.csprojAssemblyReference.cache
C:\Neotel\Program\RFIDOld\RFID_HiStation_Debug\obj\Debug\RFID_HiStation_Debug.exe.config
C:\Neotel\Program\RFIDOld\RFID_HiStation_Debug\obj\Debug\RFID_HiStation_Debug.FrmMain.resources
C:\Neotel\Program\RFIDOld\RFID_HiStation_Debug\obj\Debug\RFID_HiStation_Debug.Properties.Resources.resources
C:\Neotel\Program\RFIDOld\RFID_HiStation_Debug\obj\Debug\RFID_HiStation_Debug.csproj.GenerateResource.cache
C:\Neotel\Program\RFIDOld\RFID_HiStation_Debug\obj\Debug\RFID_HiStation_Debug.csproj.CoreCompileInputs.cache
C:\Neotel\Program\RFIDOld\RFID_HiStation_Debug\obj\Debug\RFID_HiStation_Debug.csproj.CopyComplete
C:\Neotel\Program\RFIDOld\RFID_HiStation_Debug\obj\Debug\RFID_HiStation_Debug.exe
C:\Neotel\Program\RFIDOld\RFID_HiStation_Debug\obj\Debug\RFID_HiStation_Debug.pdb
C:\Neotel\Program\RFID\RFID_PuYue_Debug\obj\Debug\RFID_HiStation_Debug.csprojAssemblyReference.cache
C:\Neotel\Program\RFID\RFID_PuYue_Debug\obj\Debug\RFID_HiStation_Debug.FrmMain.resources
C:\Neotel\Program\RFID\RFID_PuYue_Debug\obj\Debug\RFID_HiStation_Debug.Properties.Resources.resources
C:\Neotel\Program\RFID\RFID_PuYue_Debug\obj\Debug\RFID_HiStation_Debug.csproj.GenerateResource.cache
C:\Neotel\Program\RFID\RFID_PuYue_Debug\obj\Debug\RFID_HiStation_Debug.csproj.CoreCompileInputs.cache
C:\Neotel\Program\RFID\RFID_PuYue_Debug\obj\Debug\RFID_HiStation_Debug.exe
C:\Neotel\Program\RFID\RFID_PuYue_Debug\obj\Debug\RFID_HiStation_Debug.pdb
C:\Neotel\Program\RFID\RFID_PuYue_Debug\bin\Debug\RFID_HiStation_Debug.exe.config
C:\Neotel\Program\RFID\RFID_PuYue_Debug\bin\Debug\RFID_HiStation_Debug.exe
C:\Neotel\Program\RFID\RFID_PuYue_Debug\bin\Debug\RFID_HiStation_Debug.pdb
C:\Neotel\Program\RFID\RFID_PuYue_Debug\bin\Debug\Asa.RFID.PuYue.dll
C:\Neotel\Program\RFID\RFID_PuYue_Debug\bin\Debug\log4net.dll
C:\Neotel\Program\RFID\RFID_PuYue_Debug\bin\Debug\Asa.RFID.PuYue.pdb
C:\Neotel\Program\RFID\RFID_PuYue_Debug\bin\Debug\Asa.RFID.PuYue.xml
C:\Neotel\Program\RFID\RFID_PuYue_Debug\bin\Debug\log4net.xml
C:\Neotel\Program\RFID\RFID_PuYue_Debug\obj\Debug\RFID_HiStation_Debug.csproj.CopyComplete
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.12.0" newVersion="2.0.12.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
\ No newline at end of file
C:\Neotel\Program\RFID\RFID_PuYue_Debug\bin\Debug\RFID_HiStation_Debug.exe.config
C:\Neotel\Program\RFID\RFID_PuYue_Debug\bin\Debug\RFID_HiStation_Debug.exe
C:\Neotel\Program\RFID\RFID_PuYue_Debug\bin\Debug\RFID_HiStation_Debug.pdb
C:\Neotel\Program\RFID\RFID_PuYue_Debug\bin\Debug\Asa.RFID.PuYue.dll
C:\Neotel\Program\RFID\RFID_PuYue_Debug\bin\Debug\log4net.dll
C:\Neotel\Program\RFID\RFID_PuYue_Debug\bin\Debug\Asa.RFID.PuYue.pdb
C:\Neotel\Program\RFID\RFID_PuYue_Debug\bin\Debug\Asa.RFID.PuYue.xml
C:\Neotel\Program\RFID\RFID_PuYue_Debug\bin\Debug\log4net.xml
C:\Neotel\Program\RFID\RFID_PuYue_Debug\obj\Debug\RFID_PuYue_Debug.csprojAssemblyReference.cache
C:\Neotel\Program\RFID\RFID_PuYue_Debug\obj\Debug\RFID_PuYue_Debug.FrmMain.resources
C:\Neotel\Program\RFID\RFID_PuYue_Debug\obj\Debug\RFID_HiStation_Debug.Properties.Resources.resources
C:\Neotel\Program\RFID\RFID_PuYue_Debug\obj\Debug\RFID_PuYue_Debug.csproj.GenerateResource.cache
C:\Neotel\Program\RFID\RFID_PuYue_Debug\obj\Debug\RFID_PuYue_Debug.csproj.CoreCompileInputs.cache
C:\Neotel\Program\RFID\RFID_PuYue_Debug\obj\Debug\RFID_PuYue_Debug.csproj.CopyComplete
C:\Neotel\Program\RFID\RFID_PuYue_Debug\obj\Debug\RFID_HiStation_Debug.exe
C:\Neotel\Program\RFID\RFID_PuYue_Debug\obj\Debug\RFID_HiStation_Debug.pdb
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.12" targetFramework="net461" />
</packages>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
\ No newline at end of file
namespace RFID_Debug

namespace Test
{
partial class Form1
{
......@@ -28,81 +29,25 @@
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.button3 = new System.Windows.Forms.Button();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(190, 154);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "启动";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(190, 183);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 1;
this.button2.Text = "停止";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(12, 12);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.textBox1.Size = new System.Drawing.Size(172, 223);
this.textBox1.TabIndex = 2;
//
// button3
//
this.button3.Location = new System.Drawing.Point(190, 212);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 3;
this.button3.Text = "清除";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(190, 127);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(75, 21);
this.textBox2.TabIndex = 4;
this.textBox2.Text = "13000";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(12, 328);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(425, 21);
this.textBox3.TabIndex = 5;
this.textBox1.Size = new System.Drawing.Size(507, 384);
this.textBox1.TabIndex = 1;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(569, 361);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.button3);
this.ClientSize = new System.Drawing.Size(567, 450);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Form1";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
this.Load += new System.EventHandler(this.Form1_Load);
......@@ -113,12 +58,7 @@
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
}
}
......@@ -8,78 +8,34 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace RFID_Debug
namespace Test
{
public partial class Form1 : Form
{
private Asa.RFID.HFReader1 read;
private Asa.RFID.ReadAll read;
public Form1()
{
InitializeComponent();
}
private string HexBuff(byte[] buff)
{
string s = "";
if (buff == null) return s;
for (int i = 0; i < buff.Length; i++)
s += buff[i].ToString("X2") + " ";
return s;
}
private void Form1_Load(object sender, EventArgs e)
{
read = new Asa.RFID.HFReader1("RollingLogFileAppender");
//read.Received += Read_Received;
read.ReceiveBuffer += Read_ReceiveBuffer;
}
private void Read_ReceiveBuffer(string ip, byte[] buffer)
{
Invoke(new Action(() => { textBox3.Text = HexBuff(buffer); }));
}
private void Read_Log(string ip, string log)
{
string s = ip + " " + log + "\r\n";
Invoke(new Action(() =>
{
textBox1.AppendText(s);
textBox1.ScrollToCaret();
}));
read = new Asa.RFID.ReadAll("log");
read.Type = Asa.RFID.DeviceType.HaoBin;
read.Received += Read_Received;
read.Start();
}
private void Read_Received(string ip, string id)
{
string s = ip + " " + id + "\r\n";
Invoke(new Action(() =>
{
textBox1.AppendText(s);
textBox1.ScrollToCaret();
}));
string s = string.Format("{0}: {1}\r\n", ip, id);
Invoke(new Action(() => { textBox1.AppendText(s); }));
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
if (int.TryParse(textBox2.Text, out int result))
read.Start(result);
}
private void button2_Click(object sender, EventArgs e)
{
read.Stop();
}
private void button3_Click(object sender, EventArgs e)
{
read.Clear("192.168.210.114");
}
}
}
using log4net.Config;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace RFID_Debug
namespace Test
{
static class Program
{
......@@ -15,7 +14,6 @@ namespace RFID_Debug
[STAThread]
static void Main()
{
XmlConfigurator.Configure();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
......
......@@ -5,12 +5,12 @@ using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("RFID_Debug")]
[assembly: AssemblyTitle("Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RFID_Debug")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyProduct("Test")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
......@@ -20,7 +20,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("5c55663b-dbda-490b-a80f-0abb173aef88")]
[assembly: Guid("1d69196b-2321-4824-b684-50010dd43702")]
// 程序集的版本信息由下列四个值组成:
//
......@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
......@@ -8,10 +8,9 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace RFID_Debug.Properties
{
namespace Test.Properties
{
/// <summary>
/// 强类型资源类,用于查找本地化字符串等。
/// </summary>
......@@ -44,7 +43,7 @@ namespace RFID_Debug.Properties
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RFID_Debug.Properties.Resources", typeof(Resources).Assembly);
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Test.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
......@@ -52,8 +51,8 @@ namespace RFID_Debug.Properties
}
/// <summary>
/// 覆盖当前线程的 CurrentUICulture 属性
/// 使用此强类型的资源类的资源查找
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
......
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
......@@ -8,10 +8,9 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace RFID_Debug.Properties
{
namespace Test.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
......
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
......@@ -4,10 +4,10 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{44467E65-C850-4538-96E4-1335CCCB87BC}</ProjectGuid>
<ProjectGuid>{1D69196B-2321-4824-B684-50010DD43702}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>RFID_Debug</RootNamespace>
<AssemblyName>RFID_Debug</AssemblyName>
<RootNamespace>Test</RootNamespace>
<AssemblyName>Test</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
......@@ -22,8 +22,6 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
......@@ -33,13 +31,8 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\DLL\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
......@@ -87,14 +80,15 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RFID\RFID.csproj">
<Project>{cf083e56-fa69-4893-90c4-6d0430adc03f}</Project>
<Name>RFID</Name>
<ProjectReference Include="..\RFIDReadAll\RFIDReadAll.csproj">
<Project>{81468fba-fd2c-42e8-b116-b0d9ab1cbd7f}</Project>
<Name>RFIDReadAll</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="log4net.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>
\ No newline at end of file
此文件类型无法预览
此文件类型无法预览
<?xml version="1.0"?>
<doc>
<assembly>
<name>Asa.RFID.HFRead</name>
<name>Asa.RFID.ReadAll</name>
</assembly>
<members>
<member name="T:Asa.RFID.ReadAll1">
<member name="T:Asa.RFID.ReadAll">
<summary>
读取所有RFID
</summary>
</member>
<member name="M:Asa.RFID.ReadAll1.#ctor(System.String)">
<member name="M:Asa.RFID.ReadAll.#ctor(System.String)">
<summary>
读取所有RFID
</summary>
<param name="logName">日志名称</param>
</member>
<member name="M:Asa.RFID.ReadAll1.Start(System.Int32)">
<member name="P:Asa.RFID.ReadAll.Type">
<summary>
开启
设备类型
</summary>
<param name="port">RFID设备的端口</param>
</member>
<member name="M:Asa.RFID.ReadAll1.Stop">
<member name="M:Asa.RFID.ReadAll.Start(System.Int32)">
<summary>
开始
</summary>
<param name="port">端口号</param>
</member>
<member name="M:Asa.RFID.ReadAll.Stop">
<summary>
停止
</summary>
</member>
<member name="M:Asa.RFID.ReadAll1.Read(System.String)">
<member name="M:Asa.RFID.ReadAll.Read(System.String,System.String)">
<summary>
读取ID号
读取
</summary>
<param name="ip"></param>
<param name="ip">IP地址</param>
<param name="defaultID">没有找到时返回</param>
<returns></returns>
</member>
<member name="M:Asa.RFID.ReadAll1.Clear(System.String)">
<member name="M:Asa.RFID.ReadAll.Read(System.String)">
<summary>
读取所有
</summary>
<param name="defaultID">没有数据时返回</param>
</member>
<member name="M:Asa.RFID.ReadAll.Clear(System.String,System.String)">
<summary>
清除缓存
</summary>
<param name="ip"></param>
<param name="ip">IP地址</param>
<param name="defaultID">设置初始ID</param>
</member>
<member name="M:Asa.RFID.ReadAll.Clear(System.String)">
<summary>
清除所有缓存
</summary>
<param name="defaultID">设置初始ID</param>
</member>
<member name="T:Asa.RFID.DeviceType">
<summary>
RFID读卡器类型
</summary>
</member>
<member name="F:Asa.RFID.DeviceType.PuYue">
<summary>
普阅(新)
</summary>
</member>
<member name="F:Asa.RFID.DeviceType.HaoBin">
<summary>
浩斌(旧)
</summary>
</member>
</members>
</doc>
[2021-06-17 09:59:42,685][1][log:47]DEBUG ReadAll实例化
[2021-06-17 09:59:42,747][1][log:74]INFO Server Start(13000) OK
[2021-06-17 09:59:48,974][1][log:98]INFO Server Stop OK
[2021-06-17 09:59:48,975][4][log:242]INFO Socket Close
[2021-03-27 16:13:31,339][1][log:47]DEBUG ReadAll实例化
[2021-03-27 16:13:31,383][1][log:74]INFO Server Start(13000) OK
[2021-03-27 16:13:50,404][4][log:236]INFO (127.0.0.1) 连接服务端
[2021-03-27 16:13:59,173][5][log:281]DEBUG Net Receive(127.0.0.1): 12 34 E0 04 01 50 E3 C9 5C 87 5A 46 69 00 00 4A 00 00
[2021-03-27 16:14:34,841][5][log:281]DEBUG Net Receive(127.0.0.1): 12 34 E0 04 01 50 E3 C9 5C 87 5A 46 69 00 00 4A 00 00
[2021-03-27 16:15:12,294][5][log:315]DEBUG [127.0.0.1]没有找到包尾4A,12 34 E0 04 01 50 E3 C9 5C 87 5A 46 69 00 00 4A 00 00 12 34 E0 04 01 50 E3 C9 5C 87 5A 46 69 00 00 4A 00 00
[2021-03-27 16:15:48,175][5][log:281]DEBUG Net Receive(127.0.0.1): 12 34 E0 04 01 50 E3 C9 5C 87 5A 46 69 00 00 00 4A 00 00
[2021-03-27 16:19:38,668][5][log:315]DEBUG [127.0.0.1]没有找到包尾4A,46 69 00 00 4A 00 00 12 34 E0 04 01 50 E3 C9 5C 87 5A 46 69 00 00 4A 00 00 12 34 E0 04 01 50 E3 C9 5C 87 5A 46 69 00 00 00 4A 00 00
[2021-03-27 16:19:39,575][5][log:386]INFO 触发事件(127.0.0.1): F105
[2021-03-27 16:20:19,728][5][log:281]DEBUG Net Receive(127.0.0.1): 12 34 E0 04 01 50 E3 C9 5C 87 5A 46 68 00 00 00 4A 00 00
[2021-03-27 16:20:19,728][5][log:386]INFO 触发事件(127.0.0.1): F104
[2021-03-27 16:20:43,633][5][log:281]DEBUG Net Receive(127.0.0.1): 12 34 E0 04 01 50 E3 C9 5C 87 5A 46 67 00 00 00 4A 00 00
[2021-03-27 16:20:43,633][5][log:386]INFO 触发事件(127.0.0.1): F103
[2021-03-27 16:20:49,569][1][log:194]INFO 关闭 (127.0.0.1)
[2021-03-27 16:20:49,570][1][log:98]INFO Server Stop OK
[2021-03-27 16:20:49,581][4][log:242]INFO Socket Close
[2021-03-27 21:01:24,098][1][log:47]DEBUG ReadAll实例化
[2021-03-27 21:01:24,165][1][log:74]INFO Server Start(13000) OK
[2021-03-27 21:01:26,065][1][log:98]INFO Server Stop OK
[2021-03-27 21:01:26,093][4][log:242]INFO Socket Close
[2021-04-09 19:07:29,922][1][log:47]DEBUG ReadAll实例化
[2021-04-09 19:07:29,964][1][log:74]INFO Server Start(13000) OK
[2021-04-09 19:07:31,691][1][log:98]INFO Server Stop OK
[2021-04-09 19:07:31,691][4][log:242]INFO Socket Close
此文件类型无法预览
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
\ No newline at end of file
此文件类型无法预览
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<log4net>
<logger name="log">
<level value="Debug"/>
<appender-ref ref="log"/>
</logger>
<appender name="log" type="log4net.Appender.RollingFileAppender">
<param name="File" value="Log\\Log.log" />
<param name="Encoding" value="UTF-8"/>
<param name="AppendToFile" value="true" />
<param name="RollingStyle" value="Date" />
<param name="DatePattern" value="yyyy-MM-dd" />
<param name="MaxSizeRollBackups" value="100" />
<param name="MaxFileSize" value="10240" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="[%d][%t][%c:%L]%-5p %m%n" />
</layout>
</appender>
</log4net>
</configuration>
\ No newline at end of file
此文件类型无法预览
此文件的差异太大,无法显示。
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<log4net>
<logger name="log">
<level value="Debug"/>
<appender-ref ref="log"/>
</logger>
<appender name="log" type="log4net.Appender.RollingFileAppender">
<param name="File" value="Log\\Log.log" />
<param name="Encoding" value="UTF-8"/>
<param name="AppendToFile" value="true" />
<param name="RollingStyle" value="Date" />
<param name="DatePattern" value="yyyy-MM-dd" />
<param name="MaxSizeRollBackups" value="100" />
<param name="MaxFileSize" value="10240" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="[%d][%t][%c:%L]%-5p %m%n" />
</layout>
</appender>
</log4net>
</configuration>
\ No newline at end of file
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.6.1", FrameworkDisplayName = ".NET Framework 4.6.1")]
此文件类型无法预览
24ce1aa6a316819df4a558044ac149df07d79ca9
C:\Neotel\Program\RFID\Test\bin\Debug\log4net.xml
C:\Neotel\Program\RFID\Test\bin\Debug\Test.exe.config
C:\Neotel\Program\RFID\Test\bin\Debug\Test.exe
C:\Neotel\Program\RFID\Test\bin\Debug\Test.pdb
C:\Neotel\Program\RFID\Test\bin\Debug\Asa.RFID.ReadAll.dll
C:\Neotel\Program\RFID\Test\bin\Debug\log4net.dll
C:\Neotel\Program\RFID\Test\bin\Debug\Asa.RFID.ReadAll.pdb
C:\Neotel\Program\RFID\Test\bin\Debug\Asa.RFID.ReadAll.xml
C:\Neotel\Program\RFID\Test\obj\Debug\Test.csprojAssemblyReference.cache
C:\Neotel\Program\RFID\Test\obj\Debug\Test.Form1.resources
C:\Neotel\Program\RFID\Test\obj\Debug\Test.Properties.Resources.resources
C:\Neotel\Program\RFID\Test\obj\Debug\Test.csproj.GenerateResource.cache
C:\Neotel\Program\RFID\Test\obj\Debug\Test.csproj.CoreCompileInputs.cache
C:\Neotel\Program\RFID\Test\obj\Debug\Test.csproj.CopyComplete
C:\Neotel\Program\RFID\Test\obj\Debug\Test.exe
C:\Neotel\Program\RFID\Test\obj\Debug\Test.pdb
C:\Neotel\Program\RFID\Test\bin\Debug\log4net.config
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件的差异太大,无法显示。
此文件的差异太大,无法显示。
此文件的差异太大,无法显示。
此文件的差异太大,无法显示。
此文件的差异太大,无法显示。
此文件的差异太大,无法显示。
此文件的差异太大,无法显示。
此文件的差异太大,无法显示。
此文件类型无法预览
此文件类型无法预览
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!