diff --git a/HighWayIot.Common/HighWayIot.Common.csproj b/HighWayIot.Common/HighWayIot.Common.csproj
index d634007..5e4abaa 100644
--- a/HighWayIot.Common/HighWayIot.Common.csproj
+++ b/HighWayIot.Common/HighWayIot.Common.csproj
@@ -51,6 +51,7 @@
+
diff --git a/HighWayIot.Common/MsgUtil.cs b/HighWayIot.Common/MsgUtil.cs
index 12a5e20..09f6d99 100644
--- a/HighWayIot.Common/MsgUtil.cs
+++ b/HighWayIot.Common/MsgUtil.cs
@@ -25,139 +25,6 @@ namespace HighWayIot.Common
private MsgUtil() { }
- #region 数据解析公共方法
- ///
- /// 字节数组转换成结构体
- ///
- ///
- ///
- ///
- ///
- public static object BytesToStruct(byte[] buf, int len, Type type)
- {
- object rtn;
- IntPtr buffer = Marshal.AllocHGlobal(len);
- Marshal.Copy(buf, 0, buffer, len);
- try
- {
- rtn = Marshal.PtrToStructure(buffer, type);
- Marshal.FreeHGlobal(buffer);
- }
- catch (Exception)
- {
- return null;
- }
- return rtn;
- }
-
- public string StringToHexString(string s, Encoding encode)
- {
-
- byte[] b = encode.GetBytes(s); //按照指定编码将string编程字节数组
- string result = string.Empty;
- for (int i = 0; i < b.Length; i++) //逐字节变为16进制字符,以%隔开
- {
- result += "%" + Convert.ToString(b[i], 16);
- }
- return result;
- }
-
- ////
- /// 结构体转byte数组
- ///
- /// 要转换的结构体
- /// 转换后的byte数组
- public static byte[] StructToBytes(object structObj)
- {
- //得到结构体的大小
- int size = Marshal.SizeOf(structObj);
- //创建byte数组
- byte[] bytes = new byte[size];
- //分配结构体大小的内存空间
- IntPtr structPtr = Marshal.AllocHGlobal(size);
- //将结构体拷到分配好的内存空间
- Marshal.StructureToPtr(structObj, structPtr, false);
- //从内存空间拷到byte数组
- Marshal.Copy(structPtr, bytes, 0, size);
- //释放内存空间
- Marshal.FreeHGlobal(structPtr);
- //返回byte数组
- return bytes;
- }
-
-
- #endregion
- #region 消息验证方法
-
- ///
- /// CS和校验
- ///
- ///
- ///
- public byte Check_CS(byte[] Abyte)
- {
- byte result = new byte();
- try
- {
- int num = 0;
- for (int i = 0; i < Abyte.Length; i++)
- {
- num = (num + Abyte[i]) % 256;
- }
- result = (byte)num;
- }
- catch
- {
- result = 0;
- }
- return result;
- }
-
- ///
- /// BCC异或取反校验
- ///
- ///
- ///
- public string getBCC(byte[] data)
- {
- String ret = "";
- byte[] BCC = new byte[1];
- for (int i = 0; i < data.Length; i++)
- {
- BCC[0] = (byte)(BCC[0] ^ data[i]);
- }
- String hex = ((~BCC[0]) & 0xFF).ToString("X");//取反操作
- if (hex.Length == 1)
- {
- hex = '0' + hex;
- }
- ret += hex.ToUpper();
- return ret;
- }
-
- static int BytesToInt(byte[] b, int length)
- {
- int temp = 0;
- for (int i = 0; i <= length - 1 && i < 4; i++)
- {
- temp += (int)(b[i] << (i * 8));
- }
- return temp;
- }
-
- public static byte[] CalculateVerify(byte[] pMessage, int iLength)
- {
- UInt16 i;
- int iVerify = 0;
-
- iVerify = pMessage[0];
- for (i = 0; i < iLength - 1; i++)
- {
- iVerify = iVerify + pMessage[i + 1];
- }
- return BitConverter.GetBytes(Convert.ToUInt16(iVerify));
- }
- #endregion
public byte[] HexStrTorbytes(string strHex)//e.g. " 01 01" ---> { 0x01, 0x01}
{
strHex = strHex.Replace(" ", "");
@@ -203,25 +70,13 @@ namespace HighWayIot.Common
}
return str;
}
- public string ConverToString(byte[] data)
- {
- string str;
- StringBuilder stb = new StringBuilder();
- for (int i = 0; i < data.Length; i++)
- {
- if ((int)data[i] > 15)
- {
- stb.Append(Convert.ToString(data[i], 16).ToUpper()); //添加字符串
- }
- else //如果是小于0F需要加个零
- {
- stb.Append("0" + Convert.ToString(data[i], 16).ToUpper());
- }
- }
- str = stb.ToString();
- return str;
- }
+ ///
+ /// byte数组转换成十六进制字符串
+ ///
+ ///
+ ///
+ ///
public string bytesToHexStr(byte[] bytes, int iLen)
{
StringBuilder sb = new StringBuilder();
@@ -293,219 +148,4 @@ namespace HighWayIot.Common
}
}
}
-
- #region 消息公用的头尾
-
- ///
- /// 能源通讯协议结构体
- ///
-
- public enum CallbackSendData
- {
- _LoginIn = 0XA1,
- _SetTime = 0X08,
- _HeartBeat = 0XA4,
- _ERealFlag = 0XB3,
- _SRealFlag = 0XB4,
- _TRealFlag = 0XB5,
- _IRealFlag = 0XB6,
-
- _EFlag = 0XC3,
- _SFlag = 0XC4,
- _TFlag = 0XC5,
- _IFlag = 0XC6,
- }
- public struct struFrame
- {
- //帧开始
- public byte BeginChar_State;
- //采集器类型
- public byte Collection_Type;
- //采集器地址
- public byte[] Collection_Addr;
- //命令序列号
- public byte[] Command_Id;
- //起始符
- public byte StartChar_State;
- //控制码
- public byte Ctrl_State;
- //数据长度
- public byte[] DataLen_State;
- //数据域
- public byte[] Data_State;
- //校验码
- public byte CSChar_State;
- //结束符
- public byte EndChar_State;
- //终端类型
- public byte flagDTN;
- //逻辑编号
- public byte[] addrDNL;
- //主站地址
- public byte flagMSTA;
- //帧内序号
- public byte flagISEQ;
- //帧序号
- public byte flagFSEQ;
- //控制码
- public byte flagCtrl;
- //传送方向
- public byte flagCtrlD;
- //异常标志
- public byte flagCtrlE;
- //功能标志
- public byte flagCtrlF;
- //数据长度
- public int lenData;
- //数据字符串
- public byte[] strData;
-
- public object userData;
- public string tName;
-
- public object userData2;
- //public bool isCtrl;
- //public bool isData;
-
- public bool isTimeCorrectting;
-
- };
-
-
-
- ///
- /// 头文件
- ///
- [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
- public struct Head
- {
- public byte start; //起始
- public short addr; //软件地址
- public byte mstaseq; //主站地址与命令序号
- public byte control; //控制码
- public short length; //数据长度
- }
- ///
- /// 结尾
- ///
- [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
- public struct Tail
- {
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
- public byte[] verifica; //校验码
- public byte end; //结束码
- }
- #endregion
- #region 与MES通讯协议
- //识别一条EPC数据 125+3
- [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
- public struct ReadEPC
- {
- public Head head;
- public int num;//合并编号
- public Tail tail;
- }
-
- ///
- /// 写入反馈 125+5
- ///
- [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
- public struct RecWrite
- {
- public Head head;
- public int num;//合并编号
- public byte state;//1成功,0失败,2写失败,读成功
- public Tail tail;
- }
- //
- [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
-
- public struct RecDataCell
- {
- public byte len;//Data长度
- public byte[] data;//len 长度个字节数据
- }
- ///
- /// 自报数据 125+6
- ///
- [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
-
- public struct RecAutoData
- {
- public Head head;
- public int num;//合并编号
- public RecDataCell recDatas;//自报数据
- public Tail tail;
- }
-
- ///
- ///心跳 101
- ///
- [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
-
- public struct Heart
- {
- public Head head;
- public Tail tail;
- }
- #endregion
- #region 与上层应用层 消息指令
- ///
- /// 收到的消息指令
- ///
- enum RecAppMsgType
- {
- _ReadEpc = 125 + 3,
- _ReadData = 125 + 4,
- _WirteData = 125 + 5,
- _AutoSendData,
-
- _HeartBeat = 101,
- _ReadEquipState = 125 + 102,
- _SendGetSoftState = 125 + 103,
-
- }
-
- ///
- /// 发送的消息指令
- ///
- enum RetAppMsgType
- {
- _RetEpc = 125 + 3,
- _RetData = 125 + 4,
- _RetDataBack = 125 + 5,
- _RetAutoSendData,
-
- _RetEquipState = 125 + 102,
- _RetGetSoftState = 125 + 103,
- }
- #endregion
-
-
- #region 与设备层 适配层消息指令
- //收到设备层消息
- enum RecEquipMsgType
- {
- _GetEquipInfo = 0X01, //收到适配软件所需设备信息
- _GetSensor = 0x02, //收到适配软件传感器信息
- _EPCinfo = 0x03, //收到设备返回数据 将数据发送MES 并保存数据库
- _SendData = 0x04, //收到读取到的数据 收到数据后,上传给MES,并保存数据库
- _RecGetData = 0x05, //收到写入的数据是否成功反馈
- _RecAutoData = 0x06, //收到设备自报数据
-
- _HeartBeat = 101, //心跳
- _EquipState, //设备状态
- }
- //发送给设备层消息
- enum RetEquipMsgType
- {
- _RetEquipInfo = 0X01, //获取适配软件所需设备信息
- _RetSensor = 0x02, //获取适配软件传感器信息
- _GetEPCinfo = 0x03, //向设备发送命令,识别EPC数据
- _GetData = 0x04, //向设备发送命令,读取数据
- _WirteData = 0x05, //向设备发送命令,写入数据
- _RetAutoData = 0x06, //收到设备自爆数据反馈
-
- }
- #endregion
}
diff --git a/HighWayIot.Common/XmlUtil.cs b/HighWayIot.Common/XmlUtil.cs
new file mode 100644
index 0000000..aef480d
--- /dev/null
+++ b/HighWayIot.Common/XmlUtil.cs
@@ -0,0 +1,105 @@
+using HighWayIot.Log4net;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml;
+
+namespace HighWayIot.Common
+{
+ ///
+ /// XML读写类
+ ///
+ public class XmlUtil
+ {
+ private static readonly Lazy lazy = new Lazy(() => new XmlUtil());
+
+ public static XmlUtil Instance
+ {
+ get
+ {
+ return lazy.Value;
+ }
+ }
+
+ ///
+ /// XML读写实例
+ ///
+ XmlDocument xmlDocument = new XmlDocument();
+
+ ///
+ /// 运行时路径
+ ///
+ private string Path = System.Environment.CurrentDirectory;
+
+ ///
+ /// 客户端配置读取
+ ///
+ ///
+ public List ClientReader()
+ {
+ List list = new List();
+
+ xmlDocument.Load($"{Path}\\RFIDConfiguration.xml");
+ XmlNode root = xmlDocument.DocumentElement;
+ XmlNode node = root.SelectSingleNode("Clients");
+ foreach (XmlNode role in node)
+ {
+ XmlAttribute clientIp = (XmlAttribute)role.Attributes.GetNamedItem("ip");
+ XmlAttribute clientPort = (XmlAttribute)role.Attributes.GetNamedItem("port");
+ XmlAttribute clientID = (XmlAttribute)role.Attributes.GetNamedItem("ID");
+ list.Add(new ClientsConfig()
+ {
+ IP = clientIp.Value,
+ Port = clientPort.Value,
+ ID = clientID.Value
+ });
+ }
+
+ return list;
+ }
+
+ ///
+ /// 读取服务端配置
+ ///
+ ///
+ public string ServerReader()
+ {
+ xmlDocument.Load($"{Path}\\RFIDConfiguration.xml");
+ XmlNode root = xmlDocument.DocumentElement;
+ XmlNode node = root.SelectSingleNode("Server");
+ XmlAttribute ip = (XmlAttribute)node.Attributes.GetNamedItem("ip");
+ XmlAttribute port = (XmlAttribute)node.Attributes.GetNamedItem("port");
+ string res = ip.Value + ":" + port.Value;
+ return res;
+ }
+
+ }
+
+
+ public class ClientsConfig
+ {
+ ///
+ /// IP
+ ///
+ public string IP { get; set; }
+
+ ///
+ /// 端口号
+ ///
+ public string Port { get; set; }
+
+ ///
+ /// ID
+ ///
+ public string ID { get; set; }
+ }
+
+ public class ExportPathConfig
+ {
+ public string ExportConfig { get; set; }
+
+ public string Config { get; set; }
+ }
+}
diff --git a/HighWayIot.Repository/HighWayIot.Repository.csproj b/HighWayIot.Repository/HighWayIot.Repository.csproj
index eb7eed9..14fc31d 100644
--- a/HighWayIot.Repository/HighWayIot.Repository.csproj
+++ b/HighWayIot.Repository/HighWayIot.Repository.csproj
@@ -1,5 +1,6 @@
+
Debug
@@ -34,11 +35,17 @@
4
+
+ ..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll
+
+
+ ..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll
+
..\HighWayIot.Library\Oracle.ManagedDataAccess.dll
-
- ..\packages\SqlSugar.5.1.4.166\lib\SqlSugar.dll
+
+ ..\packages\SqlSugar.5.1.4.200\lib\SqlSugar.dll
@@ -47,6 +54,15 @@
+
+ ..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\lib\net46\System.Data.SQLite.dll
+
+
+ ..\packages\System.Data.SQLite.EF6.1.0.119.0\lib\net46\System.Data.SQLite.EF6.dll
+
+
+ ..\packages\System.Data.SQLite.Linq.1.0.119.0\lib\net46\System.Data.SQLite.Linq.dll
+
..\packages\System.IO.Pipelines.5.0.2\lib\net461\System.IO.Pipelines.dll
@@ -101,4 +117,14 @@
+
+
+ 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HighWayIot.Repository/app.config b/HighWayIot.Repository/app.config
index 836792e..8e5858e 100644
--- a/HighWayIot.Repository/app.config
+++ b/HighWayIot.Repository/app.config
@@ -1,13 +1,43 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HighWayIot.Repository/packages.config b/HighWayIot.Repository/packages.config
index 759d0ad..62cbe2b 100644
--- a/HighWayIot.Repository/packages.config
+++ b/HighWayIot.Repository/packages.config
@@ -1,7 +1,12 @@
-
+
+
+
+
+
+
diff --git a/HighWayIot.TouchSocket/Entity/BaseMessagePack.cs b/HighWayIot.TouchSocket/Entity/BaseMessagePack.cs
new file mode 100644
index 0000000..e4ab1c7
--- /dev/null
+++ b/HighWayIot.TouchSocket/Entity/BaseMessagePack.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HighWayIot.TouchSocket.Entity
+{
+ public class BaseMessagePack
+ {
+ ///
+ /// 功能码
+ ///
+ public byte[] FunctionCode { get; set; } = new byte[2];
+
+ ///
+ /// 长度(版本号、序列号、时间戳、数据内容)
+ ///
+ public byte[] Length { get; set; } = new byte[2];
+
+ ///
+ /// 版本号(协议版本号,初始值为1)
+ ///
+ public byte VersionCode { get; set; }
+
+ ///
+ /// 报文序列号(循环加1)
+ ///
+ public byte[] SerialCode { get; set; } = new byte[4];
+
+ ///
+ /// 时间戳(毫秒)
+ ///
+ public byte[] TimeStamp { get; set; } = new byte[8];
+
+ ///
+ /// 数据内容
+ ///
+ public byte[] DataContent { get; set; }
+
+ ///
+ /// 校验和(功能码到内容结束为sum,255-(sum%255)。)
+ ///
+ public byte CheckSum { get; set; }
+ }
+}
diff --git a/HighWayIot.TouchSocket/HighWayIot.TouchSocket.csproj b/HighWayIot.TouchSocket/HighWayIot.TouchSocket.csproj
index 0fffefd..9477bfa 100644
--- a/HighWayIot.TouchSocket/HighWayIot.TouchSocket.csproj
+++ b/HighWayIot.TouchSocket/HighWayIot.TouchSocket.csproj
@@ -103,6 +103,7 @@
+
diff --git a/HighWayIot.TouchSocket/ServerBufferAnalysis.cs b/HighWayIot.TouchSocket/ServerBufferAnalysis.cs
index eb3af6b..6842d38 100644
--- a/HighWayIot.TouchSocket/ServerBufferAnalysis.cs
+++ b/HighWayIot.TouchSocket/ServerBufferAnalysis.cs
@@ -1,114 +1,235 @@
using HighWayIot.Log4net;
using HighWayIot.Repository.domain;
using HighWayIot.Repository.service.Impl;
+using HighWayIot.TouchSocket.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Reflection;
using System.Text;
using System.Threading.Tasks;
+using System.Windows.Forms;
+using TouchSocket.Core;
namespace HighWayIot.TouchSocket
{
+ ///
+ /// 服务端接收报文分析
+ ///
public class ServerBufferAnalysis
{
private static LogHelper logHelper = LogHelper.Instance;
+ List tempData = new List();
+
///
- /// 心跳报文分析
+ /// 基础数据转包
///
- ///
- public static void HeartbeatSocket(byte[] bytes)
+ public void BaseServerBufferAnalysis(byte[] message)
{
- if (int.TryParse(Encoding.ASCII.GetString(bytes, 4, 4), out int deviceno))
+ BaseMessagePack unpackEntity = new BaseMessagePack();
+ int index = 1;
+ //报文完整性验证
+ if (!MessageCheck(message))
{
- BaseHeartbeatServiceImpl sql = new BaseHeartbeatServiceImpl();
- if (sql.UpdateHeartbeatInfo(deviceno) == 0)
+ tempData.AddRange(message.ToList());
+ message = tempData.ToArray();
+ if (!MessageCheck(message))
{
- RFIDHeartbeat heartbeat = new RFIDHeartbeat()
- {
- DeviceNo = deviceno,
- BeatTime = DateTime.Now,
- };
- sql.AddHeartbeatInfo(heartbeat);
+ return;
+ }
+ else
+ {
+ tempData.Clear();
}
}
- else
+
+ //功能码
+ Array.Copy(message, index, unpackEntity.FunctionCode, 0, 2);
+ Array.Reverse(unpackEntity.FunctionCode);
+ index += 2;
+
+ //报文字节长度
+ Array.Copy(message, index, unpackEntity.Length, 0, 2);
+ Array.Reverse(unpackEntity.Length);
+ index += 2;
+
+ //版本号
+ unpackEntity.VersionCode = message[index];
+ index++;
+
+ //报文序列号
+ Array.Copy(message, index, unpackEntity.SerialCode, 0, 4);
+ Array.Reverse(unpackEntity.SerialCode);
+ index += 4;
+
+ //时间戳
+ Array.Copy(message, index, unpackEntity.TimeStamp, 0, 8);
+ Array.Reverse(unpackEntity.TimeStamp);
+ index += 8;
+
+ //数据内容
+ int dataLength = BitConverter.ToUInt16(unpackEntity.Length, 0) - 13;
+ unpackEntity.DataContent = new byte[dataLength];
+ Array.Copy(message, index, unpackEntity.DataContent, 0, dataLength);
+ index += dataLength;
+
+ //校验值
+ unpackEntity.CheckSum = message[index];
+
+ //核对校验值
+ byte[] checkBytes = new byte[message.Length - 4];
+ Array.Copy(message, 1, checkBytes, 0, message.Length - 4);
+ if (unpackEntity.CheckSum != CalculateCheckSum(checkBytes))
{
- logHelper.Error("心跳报文编号数值转换出现错误!");
+ logHelper.Error("报文校验失败!");
+ return;
}
+
+ //到工厂分类解析
+ MessageFactory(unpackEntity);
}
///
- /// RFID发送设备状态
+ /// 报文完整性验证
///
- ///
- public static void RFIDStatusSocket(byte[] bytes)
+ ///
+ /// true为通过 false为失败
+ private bool MessageCheck(byte[] message)
{
- if (int.TryParse(Encoding.ASCII.GetString(bytes, 4, 4), out int deviceno) &&
- int.TryParse(Encoding.ASCII.GetString(bytes, 9, 1), out int state))
+ bool result = true;
+ if (message[0] != 0x3A || message[message.Length - 1] != 0x0A || message[message.Length - 2] != 0x0D)
{
- BaseStateServiceImpl sql = new BaseStateServiceImpl();
- RFIDState rFIDState = new RFIDState()
- {
- DeviceNo = deviceno,
- DeviceState = state == 1 ? true : false,
- LogTime = DateTime.Now,
- };
- sql.AddStateInfo(rFIDState);
+ result = false;
}
- else
- {
- logHelper.Error("设备状态报文编号数值转换出现错误!");
- }
- }
-
- ///
- /// RFID发送条码
- ///
- ///
- public static void RFIDCodeSocket(byte[] bytes)
- {
- string readKind = Encoding.ASCII.GetString(bytes, 4, 2);
- if (int.TryParse(Encoding.ASCII.GetString(bytes, 7, 4), out int deviceno))
- {
- RFIDContent rFIDContent = new RFIDContent()
- {
- DeviceNo = deviceno,
- ReadKind = readKind,
- LogTime = DateTime.Now,
- };
- string content = "";
- if (readKind == "NB" || readKind == "GR")
- {
- content = Encoding.ASCII.GetString(bytes, 12, 16);
- }
- else if (readKind == "MR")
- {
- content = Encoding.ASCII.GetString(bytes, 12, bytes.Length - 12 - 2); // 减去条码内容之前和之后内容的长度
- }
- rFIDContent.Content = content;
- BaseContentServiceImpl sql = new BaseContentServiceImpl();
- sql.AddContentInfo(rFIDContent);
- }
- else
- {
- logHelper.Error("条码发送报文编号数值转换出现错误!");
- }
- }
-
- ///
- /// 将一个数组拆成另外一个数组
- ///
- /// 原始数组,被拆分的数组
- /// 从原始数组第几个元素开始
- /// 目标数组的长度
- /// 目标数组开始的元素序号,默认为0
- ///
- public static byte[] SplitByteArray(byte[] originbyte, int oringinstartindex, int destbytelength, int destbytestartindex = 0)
- {
- byte[] result = new byte[destbytelength];
- System.Array.Copy(originbyte, oringinstartindex, result, destbytestartindex, destbytelength);
return result;
}
+
+ ///
+ /// 和校验
+ ///
+ ///
+ ///
+ ///
+ public byte CalculateCheckSum(byte[] bytes)
+ {
+ int length = bytes.Length;
+ int check = 0;
+ for (int i = 0; i < length; i++)
+ {
+ check += bytes[i];
+ }
+ byte result = (byte)(255 - (check % 255));
+ return result;
+ }
+
+ ///
+ /// 消息分类工厂
+ ///
+ private void MessageFactory(BaseMessagePack messagePack)
+ {
+ int functionCode = BitConverter.ToUInt16(messagePack.FunctionCode, 0);
+ if (functionCode == 0) //心跳报文
+ {
+
+ }
+ if (functionCode == 1) //连接注册请求报文
+ {
+
+ }
+ if (functionCode == 600) //读码应答报文
+ {
+
+ }
+ if (functionCode == 610) //状态上报报文
+ {
+
+ }
+
+ }
+
+ /////
+ ///// 心跳报文分析
+ /////
+ /////
+ //public static void HeartbeatSocket(byte[] bytes)
+ //{
+ // if (int.TryParse(Encoding.ASCII.GetString(bytes, 4, 4), out int deviceno))
+ // {
+ // BaseHeartbeatServiceImpl sql = new BaseHeartbeatServiceImpl();
+ // if (sql.UpdateHeartbeatInfo(deviceno) == 0)
+ // {
+ // RFIDHeartbeat heartbeat = new RFIDHeartbeat()
+ // {
+ // DeviceNo = deviceno,
+ // BeatTime = DateTime.Now,
+ // };
+ // sql.AddHeartbeatInfo(heartbeat);
+ // }
+ // }
+ // else
+ // {
+ // logHelper.Error("心跳报文编号数值转换出现错误!");
+ // }
+ //}
+
+ /////
+ ///// RFID发送设备状态
+ /////
+ /////
+ //public static void RFIDStatusSocket(byte[] bytes)
+ //{
+ // if (int.TryParse(Encoding.ASCII.GetString(bytes, 4, 4), out int deviceno) &&
+ // int.TryParse(Encoding.ASCII.GetString(bytes, 9, 1), out int state))
+ // {
+ // BaseStateServiceImpl sql = new BaseStateServiceImpl();
+ // RFIDState rFIDState = new RFIDState()
+ // {
+ // DeviceNo = deviceno,
+ // DeviceState = state == 1 ? true : false,
+ // LogTime = DateTime.Now,
+ // };
+ // sql.AddStateInfo(rFIDState);
+ // }
+ // else
+ // {
+ // logHelper.Error("设备状态报文编号数值转换出现错误!");
+ // }
+ //}
+
+ /////
+ ///// RFID发送条码
+ /////
+ /////
+ //public static void RFIDCodeSocket(byte[] bytes)
+ //{
+ // string readKind = Encoding.ASCII.GetString(bytes, 4, 2);
+ // if (int.TryParse(Encoding.ASCII.GetString(bytes, 7, 4), out int deviceno))
+ // {
+ // RFIDContent rFIDContent = new RFIDContent()
+ // {
+ // DeviceNo = deviceno,
+ // ReadKind = readKind,
+ // LogTime = DateTime.Now,
+ // };
+ // string content = "";
+ // if (readKind == "NB" || readKind == "GR")
+ // {
+ // content = Encoding.ASCII.GetString(bytes, 12, 16);
+ // }
+ // else if (readKind == "MR")
+ // {
+ // content = Encoding.ASCII.GetString(bytes, 12, bytes.Length - 12 - 2); // 减去条码内容之前和之后内容的长度
+ // }
+ // rFIDContent.Content = content;
+ // BaseContentServiceImpl sql = new BaseContentServiceImpl();
+ // sql.AddContentInfo(rFIDContent);
+ // }
+ // else
+ // {
+ // logHelper.Error("条码发送报文编号数值转换出现错误!");
+ // }
+ //}
+
}
}
diff --git a/HighWayIot.TouchSocket/TcpClientServer.cs b/HighWayIot.TouchSocket/TcpClientServer.cs
index a182f87..66e27f2 100644
--- a/HighWayIot.TouchSocket/TcpClientServer.cs
+++ b/HighWayIot.TouchSocket/TcpClientServer.cs
@@ -11,6 +11,9 @@ using TouchSocket.Sockets;
namespace HighWayIot.TouchSocket
{
+ ///
+ /// 用于格口盘点
+ ///
public class TcpClientServer
{
private static readonly Lazy lazy = new Lazy(() => new TcpClientServer());
@@ -84,6 +87,11 @@ namespace HighWayIot.TouchSocket
//载入配置
await tcpClient.SetupAsync(new TouchSocketConfig()
.SetRemoteIPHost($"{ip}:{port}")
+ .ConfigurePlugins(a =>
+ {
+ a.UseTcpReconnection()//添加TcpClientPlugin插件
+ .UsePolling(TimeSpan.FromSeconds(1));
+ })
.ConfigureContainer(a =>
{
a.AddConsoleLogger();//添加一个日志注入
diff --git a/HighWayIot.TouchSocket/TcpServer.cs b/HighWayIot.TouchSocket/TcpServer.cs
index 40ac63a..d5cbb86 100644
--- a/HighWayIot.TouchSocket/TcpServer.cs
+++ b/HighWayIot.TouchSocket/TcpServer.cs
@@ -4,12 +4,16 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
using TouchSocket.Core;
using TouchSocket.Sockets;
namespace HighWayIot.TouchSocket
{
+ ///
+ /// 消息接收
+ ///
public class TcpServer
{
private static readonly Lazy lazy = new Lazy(() => new TcpServer());
@@ -18,6 +22,8 @@ namespace HighWayIot.TouchSocket
private static LogHelper logHelper = LogHelper.Instance;
+ private ServerBufferAnalysis _serverBufferAnalysis = new ServerBufferAnalysis();
+
public ServerState State
{
get => service.ServerState;
@@ -31,9 +37,11 @@ namespace HighWayIot.TouchSocket
TcpService service = new TcpService();
+ Dictionary Ids = new Dictionary();
+
public int ConnectCount = 0;
- public bool ServerStart(string ip, string port)
+ public bool ServerStart(string host)
{
service = new TcpService();
try
@@ -62,11 +70,7 @@ namespace HighWayIot.TouchSocket
};//有客户端断开连接
service.Received = (client, e) =>
{
- ////从客户端收到信息
- //var mes = Encoding.ASCII.GetString(e.ByteBlock.Buffer, 0, e.ByteBlock.Len);//注意:数据长度是byteBlock.Len
- //logHelper.Info($"已从{client.IP}:{client.Port}接收到信息:{mes}");
-
- BufferMemory(ServerBufferAnalysis.SplitByteArray(e.ByteBlock.Span.ToArray(), 0, e.ByteBlock.Length));
+ _serverBufferAnalysis.BaseServerBufferAnalysis(e.ByteBlock.Span.ToArray());
return EasyTask.CompletedTask;
};
@@ -76,7 +80,7 @@ namespace HighWayIot.TouchSocket
{
option.Add(new TcpListenOption()
{
- IpHost = ip + ":" + port,
+ IpHost = host,
Name = "Server",//名称用于区分监听
ServiceSslOption = null,//可以针对当前监听,单独启用ssl加密
Adapter = () => new NormalDataHandlingAdapter(),//可以单独对当前地址监听,配置适配器
@@ -102,6 +106,25 @@ namespace HighWayIot.TouchSocket
}
}
+ ///
+ /// 信息发送
+ ///
+ ///
+ ///
+ public bool SendMessage(byte[] message, string id)
+ {
+ try
+ {
+ service.SendAsync(id, message).GetAwaiter().GetResult();
+ return true;
+ }
+ catch (Exception ex)
+ {
+ logHelper.Error("发送信息失败! 错误代码" + ex.ToString());
+ return false;
+ }
+ }
+
public bool ServerStop()
{
try
@@ -131,27 +154,5 @@ namespace HighWayIot.TouchSocket
return false;
}
}
-
- private void BufferMemory(byte[] bytes)
- {
- byte[] identify = new byte[2] { bytes[1], bytes[2] };
- if (identify[0] == 0x30 && identify[1] == 0x31)
- {
- ServerBufferAnalysis.HeartbeatSocket(bytes);
- }
- else if (identify[0] == 0x30 && identify[1] == 0x34)
- {
- ServerBufferAnalysis.RFIDStatusSocket(bytes);
- }
- else if (identify[0] == 0x35 && identify[1] == 0x33)
- {
- ServerBufferAnalysis.RFIDCodeSocket(bytes);
- }
- else
- {
- logHelper.Error("未知数据格式!");
- }
- }
-
}
}
diff --git a/HighWayIot.TouchSocket/app.config b/HighWayIot.TouchSocket/app.config
index d720a62..80e4145 100644
--- a/HighWayIot.TouchSocket/app.config
+++ b/HighWayIot.TouchSocket/app.config
@@ -12,7 +12,7 @@
-
+
diff --git a/HighWayIot/App.config b/HighWayIot/App.config
index 4b24e62..444e112 100644
--- a/HighWayIot/App.config
+++ b/HighWayIot/App.config
@@ -15,7 +15,7 @@
-
+
diff --git a/RFIDSocket/App.config b/RFIDSocket/App.config
index afc50cd..25e1590 100644
--- a/RFIDSocket/App.config
+++ b/RFIDSocket/App.config
@@ -1,15 +1,52 @@
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/RFIDSocket/Configuration.xml b/RFIDSocket/Configuration.xml
index 98e01e8..e4445ea 100644
--- a/RFIDSocket/Configuration.xml
+++ b/RFIDSocket/Configuration.xml
@@ -11,3 +11,4 @@
192.168.0.7:1500
100
+
diff --git a/RFIDSocket/RFIDConfiguration.xml b/RFIDSocket/RFIDConfiguration.xml
new file mode 100644
index 0000000..5ff7d40
--- /dev/null
+++ b/RFIDSocket/RFIDConfiguration.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/RFIDSocket/RFIDSocket.Designer.cs b/RFIDSocket/RFIDSocket.Designer.cs
index 13a99bd..6e76cd3 100644
--- a/RFIDSocket/RFIDSocket.Designer.cs
+++ b/RFIDSocket/RFIDSocket.Designer.cs
@@ -30,11 +30,12 @@
{
this.components = new System.ComponentModel.Container();
this.CotentData = new System.Windows.Forms.DataGridView();
+ this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.deviceNoDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.readKindDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.contentDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.logTimeDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.rFIDContentBindingSource = new System.Windows.Forms.BindingSource(this.components);
- this.IPText = new System.Windows.Forms.TextBox();
- this.SetAddress = new System.Windows.Forms.Button();
- this.label1 = new System.Windows.Forms.Label();
- this.PortText = new System.Windows.Forms.TextBox();
this.MonitorOnOff = new System.Windows.Forms.Button();
this.label4 = new System.Windows.Forms.Label();
this.MonitorState = new System.Windows.Forms.Label();
@@ -47,6 +48,8 @@
this.label3 = new System.Windows.Forms.Label();
this.LogStart = new System.Windows.Forms.Button();
this.ControlGrupbox = new System.Windows.Forms.GroupBox();
+ this.label1 = new System.Windows.Forms.Label();
+ this.comboBox1 = new System.Windows.Forms.ComboBox();
this.BinAudlt = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.ConnectCountLabel = new System.Windows.Forms.Label();
@@ -69,11 +72,6 @@
this.label8 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
- this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.deviceNoDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.readKindDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.contentDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.logTimeDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.CotentData)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.rFIDContentBindingSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.rFIDStateBindingSource)).BeginInit();
@@ -110,60 +108,63 @@
this.CotentData.RowHeadersVisible = false;
this.CotentData.RowHeadersWidth = 51;
this.CotentData.RowTemplate.Height = 17;
- this.CotentData.Size = new System.Drawing.Size(775, 703);
+ this.CotentData.Size = new System.Drawing.Size(774, 799);
this.CotentData.TabIndex = 0;
//
+ // ID
+ //
+ this.ID.DataPropertyName = "ID";
+ this.ID.HeaderText = "编号";
+ this.ID.Name = "ID";
+ this.ID.ReadOnly = true;
+ this.ID.Width = 40;
+ //
+ // deviceNoDataGridViewTextBoxColumn
+ //
+ this.deviceNoDataGridViewTextBoxColumn.DataPropertyName = "DeviceNo";
+ this.deviceNoDataGridViewTextBoxColumn.HeaderText = "格口";
+ this.deviceNoDataGridViewTextBoxColumn.MinimumWidth = 6;
+ this.deviceNoDataGridViewTextBoxColumn.Name = "deviceNoDataGridViewTextBoxColumn";
+ this.deviceNoDataGridViewTextBoxColumn.ReadOnly = true;
+ this.deviceNoDataGridViewTextBoxColumn.Width = 40;
+ //
+ // readKindDataGridViewTextBoxColumn
+ //
+ this.readKindDataGridViewTextBoxColumn.DataPropertyName = "ReadKind";
+ this.readKindDataGridViewTextBoxColumn.HeaderText = "读码结果";
+ this.readKindDataGridViewTextBoxColumn.MinimumWidth = 6;
+ this.readKindDataGridViewTextBoxColumn.Name = "readKindDataGridViewTextBoxColumn";
+ this.readKindDataGridViewTextBoxColumn.ReadOnly = true;
+ this.readKindDataGridViewTextBoxColumn.Width = 60;
+ //
+ // contentDataGridViewTextBoxColumn
+ //
+ this.contentDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.contentDataGridViewTextBoxColumn.DataPropertyName = "Content";
+ this.contentDataGridViewTextBoxColumn.HeaderText = "条码内容";
+ this.contentDataGridViewTextBoxColumn.MinimumWidth = 6;
+ this.contentDataGridViewTextBoxColumn.Name = "contentDataGridViewTextBoxColumn";
+ this.contentDataGridViewTextBoxColumn.ReadOnly = true;
+ //
+ // logTimeDataGridViewTextBoxColumn
+ //
+ this.logTimeDataGridViewTextBoxColumn.DataPropertyName = "LogTime";
+ this.logTimeDataGridViewTextBoxColumn.HeaderText = "读取时间";
+ this.logTimeDataGridViewTextBoxColumn.MinimumWidth = 6;
+ this.logTimeDataGridViewTextBoxColumn.Name = "logTimeDataGridViewTextBoxColumn";
+ this.logTimeDataGridViewTextBoxColumn.ReadOnly = true;
+ this.logTimeDataGridViewTextBoxColumn.Width = 105;
+ //
// rFIDContentBindingSource
//
this.rFIDContentBindingSource.DataSource = typeof(HighWayIot.Repository.domain.RFIDContent);
//
- // IPText
- //
- this.IPText.Location = new System.Drawing.Point(117, 28);
- this.IPText.Margin = new System.Windows.Forms.Padding(2);
- this.IPText.MaxLength = 20;
- this.IPText.Name = "IPText";
- this.IPText.Size = new System.Drawing.Size(98, 21);
- this.IPText.TabIndex = 7;
- this.IPText.Text = "127.0.0.1";
- //
- // SetAddress
- //
- this.SetAddress.Location = new System.Drawing.Point(268, 15);
- this.SetAddress.Margin = new System.Windows.Forms.Padding(2);
- this.SetAddress.Name = "SetAddress";
- this.SetAddress.Size = new System.Drawing.Size(105, 45);
- this.SetAddress.TabIndex = 6;
- this.SetAddress.Text = "确认服务端地址";
- this.SetAddress.UseVisualStyleBackColor = true;
- this.SetAddress.Click += new System.EventHandler(this.SetPort_Click);
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(12, 32);
- this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(101, 12);
- this.label1.TabIndex = 1;
- this.label1.Text = "服务端IP:端口号";
- //
- // PortText
- //
- this.PortText.Location = new System.Drawing.Point(219, 28);
- this.PortText.Margin = new System.Windows.Forms.Padding(2);
- this.PortText.MaxLength = 6;
- this.PortText.Name = "PortText";
- this.PortText.Size = new System.Drawing.Size(45, 21);
- this.PortText.TabIndex = 0;
- this.PortText.Text = "1234";
- //
// MonitorOnOff
//
- this.MonitorOnOff.Location = new System.Drawing.Point(5, 64);
+ this.MonitorOnOff.Location = new System.Drawing.Point(5, 19);
this.MonitorOnOff.Margin = new System.Windows.Forms.Padding(2);
this.MonitorOnOff.Name = "MonitorOnOff";
- this.MonitorOnOff.Size = new System.Drawing.Size(159, 45);
+ this.MonitorOnOff.Size = new System.Drawing.Size(165, 45);
this.MonitorOnOff.TabIndex = 7;
this.MonitorOnOff.Text = "启动监听";
this.MonitorOnOff.UseVisualStyleBackColor = true;
@@ -172,7 +173,7 @@
// label4
//
this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(13, 118);
+ this.label4.Location = new System.Drawing.Point(19, 81);
this.label4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(65, 12);
@@ -183,7 +184,7 @@
//
this.MonitorState.AutoSize = true;
this.MonitorState.BackColor = System.Drawing.Color.Transparent;
- this.MonitorState.Location = new System.Drawing.Point(82, 118);
+ this.MonitorState.Location = new System.Drawing.Point(88, 81);
this.MonitorState.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.MonitorState.Name = "MonitorState";
this.MonitorState.Size = new System.Drawing.Size(17, 12);
@@ -218,7 +219,7 @@
// PgDn
//
this.PgDn.Dock = System.Windows.Forms.DockStyle.Right;
- this.PgDn.Location = new System.Drawing.Point(682, 17);
+ this.PgDn.Location = new System.Drawing.Point(276, 17);
this.PgDn.Margin = new System.Windows.Forms.Padding(2);
this.PgDn.Name = "PgDn";
this.PgDn.Size = new System.Drawing.Size(96, 45);
@@ -256,10 +257,10 @@
//
// LogStart
//
- this.LogStart.Location = new System.Drawing.Point(268, 64);
+ this.LogStart.Location = new System.Drawing.Point(275, 20);
this.LogStart.Margin = new System.Windows.Forms.Padding(2);
this.LogStart.Name = "LogStart";
- this.LogStart.Size = new System.Drawing.Size(105, 45);
+ this.LogStart.Size = new System.Drawing.Size(95, 43);
this.LogStart.TabIndex = 16;
this.LogStart.Text = "日志查询";
this.LogStart.UseVisualStyleBackColor = true;
@@ -268,6 +269,8 @@
// ControlGrupbox
//
this.ControlGrupbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.ControlGrupbox.Controls.Add(this.label1);
+ this.ControlGrupbox.Controls.Add(this.comboBox1);
this.ControlGrupbox.Controls.Add(this.BinAudlt);
this.ControlGrupbox.Controls.Add(this.label2);
this.ControlGrupbox.Controls.Add(this.ConnectCountLabel);
@@ -275,22 +278,38 @@
this.ControlGrupbox.Controls.Add(this.MonitorOnOff);
this.ControlGrupbox.Controls.Add(this.label4);
this.ControlGrupbox.Controls.Add(this.MonitorState);
- this.ControlGrupbox.Controls.Add(this.IPText);
- this.ControlGrupbox.Controls.Add(this.PortText);
- this.ControlGrupbox.Controls.Add(this.SetAddress);
- this.ControlGrupbox.Controls.Add(this.label1);
- this.ControlGrupbox.Location = new System.Drawing.Point(799, 12);
+ this.ControlGrupbox.Location = new System.Drawing.Point(798, 12);
this.ControlGrupbox.Name = "ControlGrupbox";
- this.ControlGrupbox.Size = new System.Drawing.Size(375, 163);
+ this.ControlGrupbox.Size = new System.Drawing.Size(375, 144);
this.ControlGrupbox.TabIndex = 17;
this.ControlGrupbox.TabStop = false;
this.ControlGrupbox.Text = "控制面板";
//
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Font = new System.Drawing.Font("宋体", 12F);
+ this.label1.Location = new System.Drawing.Point(18, 111);
+ this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(87, 16);
+ this.label1.TabIndex = 27;
+ this.label1.Text = "线体选择:";
+ //
+ // comboBox1
+ //
+ this.comboBox1.Font = new System.Drawing.Font("宋体", 12F);
+ this.comboBox1.FormattingEnabled = true;
+ this.comboBox1.Location = new System.Drawing.Point(110, 107);
+ this.comboBox1.Name = "comboBox1";
+ this.comboBox1.Size = new System.Drawing.Size(146, 24);
+ this.comboBox1.TabIndex = 26;
+ //
// BinAudlt
//
- this.BinAudlt.Location = new System.Drawing.Point(218, 114);
+ this.BinAudlt.Location = new System.Drawing.Point(175, 20);
this.BinAudlt.Name = "BinAudlt";
- this.BinAudlt.Size = new System.Drawing.Size(151, 43);
+ this.BinAudlt.Size = new System.Drawing.Size(95, 43);
this.BinAudlt.TabIndex = 25;
this.BinAudlt.Text = "格口盘点";
this.BinAudlt.UseVisualStyleBackColor = true;
@@ -299,7 +318,7 @@
// label2
//
this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(13, 140);
+ this.label2.Location = new System.Drawing.Point(118, 81);
this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(65, 12);
@@ -310,7 +329,7 @@
//
this.ConnectCountLabel.AutoSize = true;
this.ConnectCountLabel.BackColor = System.Drawing.Color.Transparent;
- this.ConnectCountLabel.Location = new System.Drawing.Point(82, 140);
+ this.ConnectCountLabel.Location = new System.Drawing.Point(187, 81);
this.ConnectCountLabel.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.ConnectCountLabel.Name = "ConnectCountLabel";
this.ConnectCountLabel.Size = new System.Drawing.Size(11, 12);
@@ -324,23 +343,22 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.MainReadGroupBox.AutoSize = true;
this.MainReadGroupBox.Controls.Add(this.CotentData);
- this.MainReadGroupBox.Location = new System.Drawing.Point(12, 83);
+ this.MainReadGroupBox.Location = new System.Drawing.Point(12, 12);
this.MainReadGroupBox.Name = "MainReadGroupBox";
- this.MainReadGroupBox.Size = new System.Drawing.Size(781, 723);
+ this.MainReadGroupBox.Size = new System.Drawing.Size(780, 819);
this.MainReadGroupBox.TabIndex = 18;
this.MainReadGroupBox.TabStop = false;
- this.MainReadGroupBox.Text = "数据监控(此界面做多200条,全部数据在日志查询中查询)";
+ this.MainReadGroupBox.Text = "数据监控(此界面最多200条,全部数据在日志查询中查询)";
//
// PageGroupBox
//
- this.PageGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
+ this.PageGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.PageGroupBox.Controls.Add(this.panel1);
this.PageGroupBox.Controls.Add(this.PgDn);
this.PageGroupBox.Controls.Add(this.PgUp);
- this.PageGroupBox.Location = new System.Drawing.Point(12, 12);
+ this.PageGroupBox.Location = new System.Drawing.Point(798, 162);
this.PageGroupBox.Name = "PageGroupBox";
- this.PageGroupBox.Size = new System.Drawing.Size(781, 65);
+ this.PageGroupBox.Size = new System.Drawing.Size(375, 65);
this.PageGroupBox.TabIndex = 0;
this.PageGroupBox.TabStop = false;
this.PageGroupBox.Text = "页码控制";
@@ -351,7 +369,7 @@
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(98, 17);
this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(584, 45);
+ this.panel1.Size = new System.Drawing.Size(178, 45);
this.panel1.TabIndex = 16;
//
// panel2
@@ -359,7 +377,7 @@
this.panel2.Anchor = System.Windows.Forms.AnchorStyles.None;
this.panel2.Controls.Add(this.PageRange);
this.panel2.Controls.Add(this.label3);
- this.panel2.Location = new System.Drawing.Point(197, 3);
+ this.panel2.Location = new System.Drawing.Point(-3, 3);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(190, 39);
this.panel2.TabIndex = 16;
@@ -379,9 +397,9 @@
this.groupBox1.Controls.Add(this.label8);
this.groupBox1.Controls.Add(this.label7);
this.groupBox1.Controls.Add(this.label5);
- this.groupBox1.Location = new System.Drawing.Point(799, 181);
+ this.groupBox1.Location = new System.Drawing.Point(798, 233);
this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(375, 625);
+ this.groupBox1.Size = new System.Drawing.Size(375, 598);
this.groupBox1.TabIndex = 19;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "状态面板";
@@ -450,7 +468,7 @@
this.groupBox3.Location = new System.Drawing.Point(6, 202);
this.groupBox3.Margin = new System.Windows.Forms.Padding(3, 15, 3, 3);
this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(363, 423);
+ this.groupBox3.Size = new System.Drawing.Size(363, 390);
this.groupBox3.TabIndex = 6;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "异常统计(最近200条)";
@@ -470,7 +488,7 @@
this.ErrorCountDataGridView.ReadOnly = true;
this.ErrorCountDataGridView.RowHeadersVisible = false;
this.ErrorCountDataGridView.RowTemplate.Height = 17;
- this.ErrorCountDataGridView.Size = new System.Drawing.Size(357, 403);
+ this.ErrorCountDataGridView.Size = new System.Drawing.Size(357, 370);
this.ErrorCountDataGridView.TabIndex = 0;
//
// BinNo
@@ -543,56 +561,12 @@
this.label5.TabIndex = 0;
this.label5.Text = "工作状态:";
//
- // ID
- //
- this.ID.DataPropertyName = "ID";
- this.ID.HeaderText = "编号";
- this.ID.Name = "ID";
- this.ID.ReadOnly = true;
- this.ID.Width = 40;
- //
- // deviceNoDataGridViewTextBoxColumn
- //
- this.deviceNoDataGridViewTextBoxColumn.DataPropertyName = "DeviceNo";
- this.deviceNoDataGridViewTextBoxColumn.HeaderText = "格口";
- this.deviceNoDataGridViewTextBoxColumn.MinimumWidth = 6;
- this.deviceNoDataGridViewTextBoxColumn.Name = "deviceNoDataGridViewTextBoxColumn";
- this.deviceNoDataGridViewTextBoxColumn.ReadOnly = true;
- this.deviceNoDataGridViewTextBoxColumn.Width = 40;
- //
- // readKindDataGridViewTextBoxColumn
- //
- this.readKindDataGridViewTextBoxColumn.DataPropertyName = "ReadKind";
- this.readKindDataGridViewTextBoxColumn.HeaderText = "读码结果";
- this.readKindDataGridViewTextBoxColumn.MinimumWidth = 6;
- this.readKindDataGridViewTextBoxColumn.Name = "readKindDataGridViewTextBoxColumn";
- this.readKindDataGridViewTextBoxColumn.ReadOnly = true;
- this.readKindDataGridViewTextBoxColumn.Width = 60;
- //
- // contentDataGridViewTextBoxColumn
- //
- this.contentDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.contentDataGridViewTextBoxColumn.DataPropertyName = "Content";
- this.contentDataGridViewTextBoxColumn.HeaderText = "条码内容";
- this.contentDataGridViewTextBoxColumn.MinimumWidth = 6;
- this.contentDataGridViewTextBoxColumn.Name = "contentDataGridViewTextBoxColumn";
- this.contentDataGridViewTextBoxColumn.ReadOnly = true;
- //
- // logTimeDataGridViewTextBoxColumn
- //
- this.logTimeDataGridViewTextBoxColumn.DataPropertyName = "LogTime";
- this.logTimeDataGridViewTextBoxColumn.HeaderText = "读取时间";
- this.logTimeDataGridViewTextBoxColumn.MinimumWidth = 6;
- this.logTimeDataGridViewTextBoxColumn.Name = "logTimeDataGridViewTextBoxColumn";
- this.logTimeDataGridViewTextBoxColumn.ReadOnly = true;
- this.logTimeDataGridViewTextBoxColumn.Width = 105;
- //
// RFIDSocket
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoScroll = true;
- this.ClientSize = new System.Drawing.Size(1186, 817);
+ this.ClientSize = new System.Drawing.Size(1185, 842);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.PageGroupBox);
this.Controls.Add(this.MainReadGroupBox);
@@ -625,14 +599,10 @@
#endregion
private System.Windows.Forms.DataGridView CotentData;
- private System.Windows.Forms.Button SetAddress;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.TextBox PortText;
private System.Windows.Forms.Button MonitorOnOff;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label MonitorState;
private System.Windows.Forms.Timer TableTimer;
- private System.Windows.Forms.TextBox IPText;
private System.Windows.Forms.BindingSource rFIDContentBindingSource;
private System.Windows.Forms.BindingSource rFIDStateBindingSource;
private System.Windows.Forms.BindingSource rFIDHeartbeatBindingSource;
@@ -669,6 +639,8 @@
private System.Windows.Forms.DataGridViewTextBoxColumn readKindDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn contentDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn logTimeDataGridViewTextBoxColumn;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.ComboBox comboBox1;
}
}
diff --git a/RFIDSocket/RFIDSocket.cs b/RFIDSocket/RFIDSocket.cs
index d589d98..12ec5f6 100644
--- a/RFIDSocket/RFIDSocket.cs
+++ b/RFIDSocket/RFIDSocket.cs
@@ -1,4 +1,5 @@
-using HighWayIot.Repository.domain;
+using HighWayIot.Common;
+using HighWayIot.Repository.domain;
using HighWayIot.TouchSocket;
using System;
using System.Collections.Generic;
@@ -21,10 +22,7 @@ namespace RFIDSocket
private static ServerDataAnalysis RFIDData = ServerDataAnalysis.Instance;
- Configuration Config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
-
- string Port = string.Empty;
- string IP = string.Empty;
+ XmlUtil _xmlUtil = XmlUtil.Instance;
int PageNo = 1;
@@ -50,12 +48,6 @@ namespace RFIDSocket
MonitorState.Text = "开";
MonitorState.BackColor = Color.LightGreen;
}
-
- IPText.Text = ConfigurationManager.AppSettings["IpSetting"];
- PortText.Text = ConfigurationManager.AppSettings["PortSetting"];
-
- Port = PortText.Text;
- IP = IPText.Text;
}
///
@@ -67,7 +59,7 @@ namespace RFIDSocket
{
if (Server.State != ServerState.Running)
{
- if (Server.ServerStart(IP, Port))
+ if (Server.ServerStart(_xmlUtil.ServerReader()))
{
MessageBox.Show("监听服务启动成功!如更改ip端口号请重新启动监听");
TableTimer.Enabled = true;
@@ -91,21 +83,6 @@ namespace RFIDSocket
}
}
- ///
- /// 服务端IP端口设置
- ///
- ///
- ///
- private void SetPort_Click(object sender, EventArgs e)
- {
- Config.AppSettings.Settings["IpSetting"].Value = IPText.Text;
- Config.AppSettings.Settings["PortSetting"].Value = PortText.Text;
- Config.Save();
- Port = PortText.Text;
- IP = IPText.Text;
- MessageBox.Show("服务端IP端口号设置成功");
- }
-
///
/// Timer刷新
///
diff --git a/RFIDSocket/RFIDSocket.csproj b/RFIDSocket/RFIDSocket.csproj
index 131bad9..5d1bc89 100644
--- a/RFIDSocket/RFIDSocket.csproj
+++ b/RFIDSocket/RFIDSocket.csproj
@@ -1,5 +1,6 @@
+
Debug
@@ -29,6 +30,8 @@
false
true
true
+
+
AnyCPU
@@ -59,7 +62,7 @@
true
- true
+ false
LocalIntranet
@@ -67,10 +70,19 @@
Properties\app.manifest
+
+ false
+
..\packages\BouncyCastle.Cryptography.2.3.1\lib\net461\BouncyCastle.Cryptography.dll
+
+ ..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll
+
+
+ ..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll
+
..\packages\Google.Protobuf.3.26.1\lib\net45\Google.Protobuf.dll
@@ -93,14 +105,20 @@
..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll
+
..\packages\System.Configuration.ConfigurationManager.8.0.0\lib\net462\System.Configuration.ConfigurationManager.dll
-
- False
- ..\Dll\System.Data.SQLite.dll
+
+ ..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\lib\net46\System.Data.SQLite.dll
+
+
+ ..\packages\System.Data.SQLite.EF6.1.0.119.0\lib\net46\System.Data.SQLite.EF6.dll
+
+
+ ..\packages\System.Data.SQLite.Linq.1.0.119.0\lib\net46\System.Data.SQLite.Linq.dll
..\packages\System.Diagnostics.DiagnosticSource.8.0.1\lib\net462\System.Diagnostics.DiagnosticSource.dll
@@ -217,6 +235,10 @@
+
+ {89a1edd9-d79e-468d-b6d3-7d07b8843562}
+ HighWayIot.Common
+
{DEABC30C-EC6F-472E-BD67-D65702FDAF74}
HighWayIot.Log4net
@@ -246,6 +268,9 @@
+
+ PreserveNewest
+
PreserveNewest
@@ -254,4 +279,14 @@
+
+
+ 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/RFIDSocket/RFIDSocket.resx b/RFIDSocket/RFIDSocket.resx
index 2883d33..7842a63 100644
--- a/RFIDSocket/RFIDSocket.resx
+++ b/RFIDSocket/RFIDSocket.resx
@@ -123,6 +123,9 @@
159, 17
+
+ True
+
159, 17
@@ -147,7 +150,4 @@
True
-
- True
-
\ No newline at end of file
diff --git a/RFIDSocket/packages.config b/RFIDSocket/packages.config
index f849323..9561461 100644
--- a/RFIDSocket/packages.config
+++ b/RFIDSocket/packages.config
@@ -1,14 +1,20 @@
+
+
+
+
+
+