refeat - 重构完毕

dep
SoulStar 4 months ago
parent 2407ffe9b4
commit a67e72bd1c

@ -25,6 +25,7 @@ namespace HighWayIot.Common
private MsgUtil() { }
public byte[] HexStrTorbytes(string strHex)//e.g. " 01 01" ---> { 0x01, 0x01}
{
strHex = strHex.Replace(" ", "");
@ -84,7 +85,7 @@ namespace HighWayIot.Common
{
for (int i = 0; i < iLen; i++)
{
sb.Append(bytes[i].ToString("X2"));
sb.Append(bytes[i].ToString("X2") + " ");
}
}
return sb.ToString();

@ -10,12 +10,14 @@
<logger name="logerror">
<level value="ALL" />
<appender-ref ref="ErrorAppender" />
<appender-ref ref="ColoredConsoleAppender" />
</logger>
<!--信息日志类-->
<logger name="loginfo">
<level value="ALL" />
<appender-ref ref="InfoAppender" />
<appender-ref ref="ColoredConsoleAppender" />
</logger>
<!--PLC日志类-->
@ -28,6 +30,7 @@
<logger name="rfidlog">
<level value="ALL" />
<appender-ref ref="RfidAppender" />
<appender-ref ref="ColoredConsoleAppender" />
</logger>
<!--RFID日志类-->
@ -48,6 +51,27 @@
<appender-ref ref="SemaphoreAppender" />
</logger>
<!-- 将日志输出到控制台 -->
<appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
<mapping>
<level value="ERROR" />
<foreColor value="Red, HighIntensity" />
</mapping>
<mapping>
<level value="Info" />
<foreColor value="White" />
</mapping>
<mapping>
<level value="Debug" />
<foreColor value="Yellow, HighIntensity" />
</mapping>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
<!--错误日志附加介质-->
<appender name="ErrorAppender" type="log4net.Appender.RollingFileAppender">
<param name="File" value="Log\" />

@ -23,6 +23,9 @@ namespace HighWayIot.Repository.domain
[SugarColumn(ColumnName = "logtime")]
public DateTime LogTime { get; set; }
[SugarColumn(ColumnName = "lineno")]
public string LineNo { get; set; }
}
}

@ -11,8 +11,8 @@ namespace HighWayIot.Repository.domain
[SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
public int ID { get; set; }
[SugarColumn(ColumnName = "deviceno")]
public int DeviceNo { get; set; }
[SugarColumn(ColumnName = "lineno")]
public string LineNo { get; set; }
[SugarColumn(ColumnName = "beattime")]
public DateTime BeatTime { get; set; }

@ -19,6 +19,9 @@ namespace HighWayIot.Repository.domain
[SugarColumn(ColumnName = "logtime")]
public DateTime LogTime { get; set; }
[SugarColumn(ColumnName = "lineno")]
public string LineNo { get; set; }
}
}

@ -11,15 +11,40 @@ namespace HighWayIot.Repository.service
{
/// <summary>
/// 获取RFID信息列表
/// 获取RFID信息列表(指定线体)
/// </summary>
/// <returns></returns>
List<RFIDContent> GetContentInfos( );
List<RFIDContent> GetContentInfos(string lineNo);
/// <summary>
/// 获取RFID信息列表所有的
/// </summary>
/// <returns></returns>
List<RFIDContent> GetContentInfos();
/// <summary>
/// 获取最近200条RFID信息列表指定线体
/// </summary>
/// <param name="lineNo"></param>
/// <returns></returns>
List<RFIDContent> Get200Infos(string lineNo);
/// <summary>
/// 获取最近200条RFID信息列表所有线体
/// </summary>
/// <returns></returns>
List<RFIDContent> Get200Infos();
/// <summary>
/// 新增一条信息
/// </summary>
/// <param name="content"></param>
void AddContentInfo(RFIDContent content);
/// <summary>
/// 清楚一个月之前的数据
/// </summary>
/// <returns></returns>
bool DelBeforeMonthContent();
}
}

@ -27,7 +27,7 @@ namespace HighWayIot.Repository.service
/// </summary>
/// <param name="deviceno"></param>
/// <returns>影响的行数</returns>
int UpdateHeartbeatInfo(int deviceno);
int UpdateHeartbeatInfo(string deviceno);
}
}

@ -11,16 +11,62 @@ namespace HighWayIot.Repository.service.Impl
{
public class BaseContentServiceImpl : IContentService
{
private static readonly Lazy<BaseContentServiceImpl> lazy = new Lazy<BaseContentServiceImpl>(() => new BaseContentServiceImpl());
public static BaseContentServiceImpl Instance => lazy.Value;
private LogHelper log = LogHelper.Instance;
Repository<RFIDContent> _repository => new Repository<RFIDContent>("sqlite");
public List<RFIDContent> GetContentInfos(string lineNo)
{
try
{
List<RFIDContent> deviceInfo = _repository.GetList(x => x.LineNo == lineNo);
return deviceInfo;
}catch (Exception ex)
{
log.Error("RFID内容信息获取异常", ex);
return null;
}
}
public List<RFIDContent> GetContentInfos()
{
try
{
List<RFIDContent> deviceInfo = _repository.GetList();
return deviceInfo;
}catch (Exception ex)
}
catch (Exception ex)
{
log.Error("RFID内容信息获取异常", ex);
return null;
}
}
public List<RFIDContent> Get200Infos(string lineNo)
{
try
{
List<RFIDContent> deviceInfo = _repository.GetList(x => x.LineNo == lineNo).OrderByDescending(x => x.ID).Take(200).ToList();
return deviceInfo;
}
catch (Exception ex)
{
log.Error("RFID内容信息获取异常", ex);
return null;
}
}
public List<RFIDContent> Get200Infos()
{
try
{
List<RFIDContent> deviceInfo = _repository.GetList().OrderByDescending(x => x.ID).Take(200).ToList();
return deviceInfo;
}
catch (Exception ex)
{
log.Error("RFID内容信息获取异常", ex);
return null;
@ -38,5 +84,21 @@ namespace HighWayIot.Repository.service.Impl
log.Error("RFID内容信息插入异常", ex);
}
}
public bool DelBeforeMonthContent()
{
try
{
DateTime time = DateTime.Now - TimeSpan.FromDays(30);
_repository.AsDeleteable().Where(x => x.LogTime <= time).ExecuteCommand();
return true;
}
catch(Exception ex)
{
log.Error("RFID内容信息删除异常", ex);
return false;
}
}
}
}

@ -11,6 +11,10 @@ namespace HighWayIot.Repository.service.Impl
{
public class BaseHeartbeatServiceImpl : IHeartbeatService
{
private static readonly Lazy<BaseHeartbeatServiceImpl> lazy = new Lazy<BaseHeartbeatServiceImpl>(() => new BaseHeartbeatServiceImpl());
public static BaseHeartbeatServiceImpl Instance => lazy.Value;
private LogHelper log = LogHelper.Instance;
Repository<RFIDHeartbeat> _repository => new Repository<RFIDHeartbeat>("sqlite");
@ -20,7 +24,8 @@ namespace HighWayIot.Repository.service.Impl
{
List<RFIDHeartbeat> deviceInfo = _repository.GetList();
return deviceInfo;
}catch (Exception ex)
}
catch (Exception ex)
{
log.Error("RFID心跳信息获取异常", ex);
return null;
@ -39,13 +44,13 @@ namespace HighWayIot.Repository.service.Impl
}
}
public int UpdateHeartbeatInfo(int deviceno)
public int UpdateHeartbeatInfo(string deviceno)
{
try
{
return _repository.AsUpdateable().SetColumns(x => x.BeatTime == DateTime.Now).Where(x => x.DeviceNo == deviceno).ExecuteCommand();
return _repository.AsUpdateable().SetColumns(x => x.BeatTime == DateTime.Now).Where(x => x.LineNo == deviceno).ExecuteCommand();
}
catch(Exception ex)
catch (Exception ex)
{
log.Error("RFID心跳信息更新异常", ex);
return -1;

@ -11,6 +11,10 @@ namespace HighWayIot.Repository.service.Impl
{
public class BaseStateServiceImpl : IStateService
{
private static readonly Lazy<BaseStateServiceImpl> lazy = new Lazy<BaseStateServiceImpl>(() => new BaseStateServiceImpl());
public static BaseStateServiceImpl Instance => lazy.Value;
private LogHelper log = LogHelper.Instance;
Repository<RFIDState> _repository => new Repository<RFIDState>("sqlite");

@ -1,4 +1,7 @@
using HighWayIot.TouchSocket.Entity;
using HighWayIot.Repository.domain;
using HighWayIot.Repository.service.Impl;
using HighWayIot.TouchSocket.Entity;
using Org.BouncyCastle.Crypto;
using System;
using System.Collections.Generic;
using System.Linq;
@ -19,7 +22,7 @@ namespace HighWayIot.TouchSocket
private ServerBufferAnalysis serverBufferAnalysis = ServerBufferAnalysis.Instance;
private TcpServer tcpServer = TcpServer.Instance;
public Action<byte[], string> MessegeSend;
/// <summary>
/// 消息分类工厂
@ -38,10 +41,11 @@ namespace HighWayIot.TouchSocket
if (functionCode == 1) //连接注册请求报文
{
RegisterProcess(messagePack, id);
FirstHeartbeat(id);
}
if (functionCode == 600) //读码报文接收
{
ReadCodeReportProcess(messagePack);
ReadCodeReportProcess(messagePack, id);
}
if (functionCode == 610) //状态上报报文
{
@ -54,8 +58,20 @@ namespace HighWayIot.TouchSocket
/// </summary>
private void HeartbeatProcess(BaseMessagePack messagePack, string id)
{
//直接反馈
tcpServer.SendMessage(
//数据库操作
if (BaseHeartbeatServiceImpl.Instance.UpdateHeartbeatInfo(id) == 0)
{
RFIDHeartbeat heartbeat = new RFIDHeartbeat()
{
LineNo = id,
BeatTime = DateTime.Now,
};
BaseHeartbeatServiceImpl.Instance.AddHeartbeatInfo(heartbeat);
}
//反馈
MessegeSend.Invoke(
serverBufferAnalysis.BasePackedServerBufferAnalysis(
HeartbeatResponse(messagePack)
),
@ -68,7 +84,7 @@ namespace HighWayIot.TouchSocket
private void RegisterProcess(BaseMessagePack messagePack, string id)
{
//直接反馈
tcpServer.SendMessage(
MessegeSend.Invoke(
serverBufferAnalysis.BasePackedServerBufferAnalysis(
StandardResponse(messagePack)
),
@ -78,10 +94,33 @@ namespace HighWayIot.TouchSocket
/// <summary>
/// 读码应答报文处理
/// </summary>
private void ReadCodeReportProcess(BaseMessagePack messagePack)
private void ReadCodeReportProcess(BaseMessagePack messagePack, string id)
{
//存数据库,无需反馈
//解析数据内容
RFIDContent rfidContent = new RFIDContent();
int index = 0;
index += 4;
byte[] temp = new byte[2];
Array.Copy(messagePack.DataContent, index, temp, 0, 2);
Array.Reverse(temp);
rfidContent.DeviceNo = BitConverter.ToUInt16(temp, 0);
index += 2;
rfidContent.ReadKind = ASCIIEncoding.UTF8.GetString(messagePack.DataContent, index, 2);
index += 2;
int length = messagePack.DataContent[index];
index++;
rfidContent.Content = ASCIIEncoding.UTF8.GetString(messagePack.DataContent, index, length);
rfidContent.LineNo = id;
rfidContent.LogTime = DateTime.Now;
BaseContentServiceImpl.Instance.AddContentInfo(rfidContent);
}
/// <summary>
@ -90,14 +129,40 @@ namespace HighWayIot.TouchSocket
private void StateReportProcess(BaseMessagePack messagePack, string id)
{
//存数据库,需反馈
byte[] temp = new byte[2];
Array.Copy(messagePack.DataContent, 0, temp, 0, 2);
Array.Reverse(temp);
int deviceno = BitConverter.ToUInt16(temp, 0);
tcpServer.SendMessage(
RFIDState rFIDState = new RFIDState()
{
DeviceNo = deviceno,
DeviceState = messagePack.DataContent[2] == 0 ? true : false,
LogTime = DateTime.Now,
LineNo = id
};
BaseStateServiceImpl.Instance.AddStateInfo(rFIDState);
MessegeSend.Invoke(
serverBufferAnalysis.BasePackedServerBufferAnalysis(
StandardResponse(messagePack)
),
id);
}
/// <summary>
/// 读码请求报文处理
/// </summary>
/// <param name="id"></param>
public void ReadCodeRequestProcess(string id)
{
MessegeSend.Invoke(
serverBufferAnalysis.BasePackedServerBufferAnalysis(
ReadRequest()
),
id);
}
/// <summary>
/// 包封装(心跳响应)
/// </summary>
@ -130,13 +195,31 @@ namespace HighWayIot.TouchSocket
//来时报文功能码
Array.Reverse(messagePack.FunctionCode);
Array.Copy(messagePack.FunctionCode, 0, data, index, 2);
Array.Reverse(messagePack.FunctionCode);
index += 2;
PackedData(ref messagePack, 10, data);
return messagePack;
}
/// <summary>
/// 读码请求报文(主动)
/// </summary>
/// <returns></returns>
public BaseMessagePack ReadRequest()
{
BaseMessagePack messagePack = new BaseMessagePack();
messagePack.SerialCode = BitConverter.GetBytes((uint)0);
messagePack.VersionCode = 0x01;
var datacontent = BitConverter.GetBytes((ushort)481);
Array.Reverse(datacontent);
PackedData(ref messagePack, 500, datacontent);
return messagePack;
}
/// <summary>
/// 封装数据部分(版本号沿用,序列号自动加一)
/// </summary>
@ -149,7 +232,7 @@ namespace HighWayIot.TouchSocket
{
return;
}
messagePack.Length = BitConverter.GetBytes(functionCode);
messagePack.FunctionCode = BitConverter.GetBytes(functionCode);
uint code = BitConverter.ToUInt32(messagePack.SerialCode, 0);
code++;
messagePack.SerialCode = BitConverter.GetBytes(code);
@ -158,5 +241,21 @@ namespace HighWayIot.TouchSocket
messagePack.Length = BitConverter.GetBytes(Convert.ToUInt16(messagePack.DataContent.Length + 13u));
}
/// <summary>
/// 初次心跳发送
/// </summary>
public void FirstHeartbeat(string id)
{
BaseMessagePack messagePack = new BaseMessagePack();
messagePack.FunctionCode = BitConverter.GetBytes((ushort)0);
messagePack.VersionCode = 0x01;
messagePack.SerialCode = BitConverter.GetBytes((uint)0);
//反馈
MessegeSend.Invoke(
serverBufferAnalysis.BasePackedServerBufferAnalysis(
HeartbeatResponse(messagePack)
),
id);
}
}
}

@ -121,6 +121,10 @@ namespace HighWayIot.TouchSocket
index++;
//报文序列号
//序列号加一
//uint serial = BitConverter.ToUInt32(message.SerialCode, 0);
//serial++;
//message.SerialCode = BitConverter.GetBytes(serial);
Array.Reverse(message.SerialCode);
Array.Copy(message.SerialCode, 0, bytes, index, 4);
index += 4;
@ -140,9 +144,11 @@ namespace HighWayIot.TouchSocket
byte[] checkBytes = new byte[bytes.Length - 4];
Array.Copy(bytes, 1, checkBytes, 0, bytes.Length - 4);
bytes[index] = CalculateCheckSum(checkBytes);
index++;
//结束字符1
bytes[index] = 0x0D;
index++;
//结束字符2
bytes[index] = 0x0A;

@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using TouchSocket.Core;
using TouchSocket.Sockets;
@ -21,6 +22,8 @@ namespace HighWayIot.TouchSocket
public static TcpServer Instance => lazy.Value;
private MsgUtil msgUtil = MsgUtil.Instance;
private static LogHelper logHelper = LogHelper.Instance;
private ServerBufferAnalysis _serverBufferAnalysis = ServerBufferAnalysis.Instance;
@ -44,13 +47,20 @@ namespace HighWayIot.TouchSocket
private TcpService service = new TcpService();
public List<string> Ids = new List<string>();
public List<string> Ids
{
get => service.Clients.Select(x => x.Id).ToList();
}
public int ConnectCount = 0;
public int ConnectCount
{
get => service.Clients.Count;
}
public TcpServer()
{
clientsConfigs = _xmlUtil.ClientReader();
_messageFactory.MessegeSend += SendMessage;
}
public bool ServerStart(string host)
@ -69,11 +79,17 @@ namespace HighWayIot.TouchSocket
var now = clientsConfigs.Where(x => x.IP == client.IP && x.Port == client.Port.ToString()).FirstOrDefault();
if (now == null)
{
//如果配置文件端口为0就都能连
if(clientsConfigs.Where(x => x.IP == client.IP).FirstOrDefault().Port == "0")
{
Ids.Add(client.Id);
return EasyTask.CompletedTask;
}
client.Close();
}
else
{
ConnectCount++;
client.ResetIdAsync(now.ID);
Ids.Add(now.ID);
}
return EasyTask.CompletedTask;
@ -86,12 +102,14 @@ namespace HighWayIot.TouchSocket
service.Closed = (client, e) =>
{
logHelper.Info($"客户端{client.IP}:{client.Port}断开连接");
ConnectCount--;
Ids.Remove(client.Id);
return EasyTask.CompletedTask;
};//有客户端断开连接
service.Received = (client, e) =>
{
_messageFactory.Factory(_serverBufferAnalysis.BaseUnpackServerBufferAnalysis(e.ByteBlock.Span.ToArray()), client.Id);
var mes = e.ByteBlock.Span.ToArray();
Console.WriteLine(">>>>>" + msgUtil.bytesToHexStr(mes, mes.Length));
_messageFactory.Factory(_serverBufferAnalysis.BaseUnpackServerBufferAnalysis(mes), client.Id);
return EasyTask.CompletedTask;
};
@ -132,17 +150,16 @@ namespace HighWayIot.TouchSocket
/// </summary>
/// <param name="message"></param>
/// <returns></returns>
public bool SendMessage(byte[] message, string id)
public void SendMessage(byte[] message, string id)
{
try
{
service.SendAsync(id, message).GetAwaiter().GetResult();
return true;
Console.WriteLine("<<<<<" + msgUtil.bytesToHexStr(message, message.Length));
}
catch (Exception ex)
{
logHelper.Error("发送信息失败! 错误代码" + ex.ToString());
return false;
}
}

@ -21,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HighWayIot.Mqtt", "HighWayI
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RFIDSocket", "RFIDSocket\RFIDSocket.csproj", "{B632CAA9-47D5-47DC-A49F-2106166096BA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTest", "UnitTest\UnitTest.csproj", "{26673E87-2292-4993-890A-C1694B55D0E9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -63,6 +65,10 @@ Global
{B632CAA9-47D5-47DC-A49F-2106166096BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B632CAA9-47D5-47DC-A49F-2106166096BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B632CAA9-47D5-47DC-A49F-2106166096BA}.Release|Any CPU.Build.0 = Release|Any CPU
{26673E87-2292-4993-890A-C1694B55D0E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{26673E87-2292-4993-890A-C1694B55D0E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{26673E87-2292-4993-890A-C1694B55D0E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{26673E87-2292-4993-890A-C1694B55D0E9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura />
</Weavers>

@ -1,4 +1,5 @@
using HighWayIot.Repository.domain;
using HighWayIot.Repository.service.Impl;
using System;
using System.Collections.Generic;
using System.Linq;
@ -10,6 +11,15 @@ namespace RFIDSocket
{
public class LogControl
{
public static List<RFIDContent> LogLineSelect(List<RFIDContent> lists, string lineNo)
{
if (string.IsNullOrEmpty(lineNo))
{
return lists;
}
return lists.Where(x => x.LineNo == lineNo).ToList();
}
public static List<RFIDContent> LogContentSelect(List<RFIDContent> lists, string content)
{
return lists.Where(x => x.Content.Contains(content)).ToList();

@ -19,10 +19,20 @@ namespace RFIDSocket
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
logger.Info("初始化启动");
Application.Run(new RFIDSocket());
try
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
logger.Info("初始化启动");
Application.Run(new RFIDSocket());
}
catch (Exception ex)
{
logger.Info("程序异常退出:" + ex.Message);
}
finally
{
}
}
}
}

@ -2,6 +2,12 @@
<RFIDMonitor>
<Server ip="192.168.18.11" port="31108"/>
<Clients>
<Client ip="192.168.18.53" port="6501" ID="1"/>
<Client ip="192.168.18.53" port="6501" ID="111"/>
</Clients>
</RFIDMonitor>
<!--<RFIDMonitor>
<Server ip="127.0.0.1" port="31108"/>
<Clients>
<Client ip="127.0.0.1" port="0" ID="111"/>
</Clients>
</RFIDMonitor>-->

@ -34,21 +34,22 @@
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.EndTime = new System.Windows.Forms.DateTimePicker();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.ReadKind = new System.Windows.Forms.ComboBox();
this.ReadKindSelect = new System.Windows.Forms.Button();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.LineSelectCombobox = new System.Windows.Forms.ComboBox();
this.LineSelectButton = new System.Windows.Forms.Button();
this.Content = new System.Windows.Forms.TextBox();
this.DeviceNo = new System.Windows.Forms.TextBox();
this.ContentSelect = new System.Windows.Forms.Button();
this.ReadKind = new System.Windows.Forms.ComboBox();
this.DeviceNoSelect = new System.Windows.Forms.Button();
this.ReadKindSelect = new System.Windows.Forms.Button();
this.LogContent = new System.Windows.Forms.DataGridView();
this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.LineNo = 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.groupBox4 = new System.Windows.Forms.GroupBox();
this.Content = new System.Windows.Forms.TextBox();
this.ContentSelect = new System.Windows.Forms.Button();
this.SelectAll = new System.Windows.Forms.Button();
this.ExcelOutPut = new System.Windows.Forms.Button();
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
@ -65,12 +66,11 @@
this.TotalReadCount = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.LogContent)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.rFIDContentBindingSource)).BeginInit();
this.groupBox4.SuspendLayout();
this.SuspendLayout();
//
// TimeSelect
@ -115,62 +115,93 @@
//
// groupBox2
//
this.groupBox2.Controls.Add(this.LineSelectCombobox);
this.groupBox2.Controls.Add(this.LineSelectButton);
this.groupBox2.Controls.Add(this.Content);
this.groupBox2.Controls.Add(this.DeviceNo);
this.groupBox2.Controls.Add(this.ContentSelect);
this.groupBox2.Controls.Add(this.ReadKind);
this.groupBox2.Controls.Add(this.DeviceNoSelect);
this.groupBox2.Controls.Add(this.ReadKindSelect);
this.groupBox2.Location = new System.Drawing.Point(12, 149);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(208, 131);
this.groupBox2.Size = new System.Drawing.Size(208, 265);
this.groupBox2.TabIndex = 5;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "读码结果查询";
this.groupBox2.Text = "其他条件查询";
//
// LineSelectCombobox
//
this.LineSelectCombobox.FormattingEnabled = true;
this.LineSelectCombobox.Location = new System.Drawing.Point(8, 35);
this.LineSelectCombobox.Name = "LineSelectCombobox";
this.LineSelectCombobox.Size = new System.Drawing.Size(94, 20);
this.LineSelectCombobox.TabIndex = 3;
this.LineSelectCombobox.Text = " ";
//
// LineSelectButton
//
this.LineSelectButton.Location = new System.Drawing.Point(108, 20);
this.LineSelectButton.Name = "LineSelectButton";
this.LineSelectButton.Size = new System.Drawing.Size(94, 48);
this.LineSelectButton.TabIndex = 2;
this.LineSelectButton.Text = "线选择";
this.LineSelectButton.UseVisualStyleBackColor = true;
this.LineSelectButton.Click += new System.EventHandler(this.button2_Click);
//
// Content
//
this.Content.Location = new System.Drawing.Point(6, 182);
this.Content.Name = "Content";
this.Content.Size = new System.Drawing.Size(196, 21);
this.Content.TabIndex = 1;
//
// DeviceNo
//
this.DeviceNo.Location = new System.Drawing.Point(8, 143);
this.DeviceNo.Name = "DeviceNo";
this.DeviceNo.Size = new System.Drawing.Size(94, 21);
this.DeviceNo.TabIndex = 1;
//
// ContentSelect
//
this.ContentSelect.Location = new System.Drawing.Point(42, 209);
this.ContentSelect.Name = "ContentSelect";
this.ContentSelect.Size = new System.Drawing.Size(122, 48);
this.ContentSelect.TabIndex = 0;
this.ContentSelect.Text = "条码内容查询";
this.ContentSelect.UseVisualStyleBackColor = true;
this.ContentSelect.Click += new System.EventHandler(this.ContentSelect_Click);
//
// ReadKind
//
this.ReadKind.FormattingEnabled = true;
this.ReadKind.Location = new System.Drawing.Point(42, 30);
this.ReadKind.Location = new System.Drawing.Point(8, 89);
this.ReadKind.Name = "ReadKind";
this.ReadKind.Size = new System.Drawing.Size(122, 20);
this.ReadKind.Size = new System.Drawing.Size(94, 20);
this.ReadKind.TabIndex = 1;
this.ReadKind.Text = " ";
//
// ReadKindSelect
//
this.ReadKindSelect.Location = new System.Drawing.Point(42, 65);
this.ReadKindSelect.Name = "ReadKindSelect";
this.ReadKindSelect.Size = new System.Drawing.Size(122, 48);
this.ReadKindSelect.TabIndex = 0;
this.ReadKindSelect.Text = "读码结果查询";
this.ReadKindSelect.UseVisualStyleBackColor = true;
this.ReadKindSelect.Click += new System.EventHandler(this.ReadKindSelect_Click);
//
// groupBox3
//
this.groupBox3.Controls.Add(this.DeviceNo);
this.groupBox3.Controls.Add(this.DeviceNoSelect);
this.groupBox3.Location = new System.Drawing.Point(12, 286);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(208, 131);
this.groupBox3.TabIndex = 6;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "设备编号查询";
//
// DeviceNo
//
this.DeviceNo.Location = new System.Drawing.Point(42, 29);
this.DeviceNo.Name = "DeviceNo";
this.DeviceNo.Size = new System.Drawing.Size(122, 21);
this.DeviceNo.TabIndex = 1;
//
// DeviceNoSelect
//
this.DeviceNoSelect.Location = new System.Drawing.Point(42, 65);
this.DeviceNoSelect.Location = new System.Drawing.Point(108, 128);
this.DeviceNoSelect.Name = "DeviceNoSelect";
this.DeviceNoSelect.Size = new System.Drawing.Size(122, 48);
this.DeviceNoSelect.Size = new System.Drawing.Size(94, 48);
this.DeviceNoSelect.TabIndex = 0;
this.DeviceNoSelect.Text = "设备编号查询";
this.DeviceNoSelect.UseVisualStyleBackColor = true;
this.DeviceNoSelect.Click += new System.EventHandler(this.DeviceNoSelect_Click);
//
// ReadKindSelect
//
this.ReadKindSelect.Location = new System.Drawing.Point(108, 74);
this.ReadKindSelect.Name = "ReadKindSelect";
this.ReadKindSelect.Size = new System.Drawing.Size(94, 48);
this.ReadKindSelect.TabIndex = 0;
this.ReadKindSelect.Text = "读码结果查询";
this.ReadKindSelect.UseVisualStyleBackColor = true;
this.ReadKindSelect.Click += new System.EventHandler(this.ReadKindSelect_Click);
//
// LogContent
//
this.LogContent.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -178,8 +209,10 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.LogContent.AutoGenerateColumns = false;
this.LogContent.ColumnHeadersHeight = 20;
this.LogContent.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
this.LogContent.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.ID,
this.LineNo,
this.deviceNoDataGridViewTextBoxColumn,
this.readKindDataGridViewTextBoxColumn,
this.contentDataGridViewTextBoxColumn,
@ -188,7 +221,9 @@
this.LogContent.Location = new System.Drawing.Point(226, 12);
this.LogContent.Name = "LogContent";
this.LogContent.RowHeadersVisible = false;
this.LogContent.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
this.LogContent.RowTemplate.Height = 18;
this.LogContent.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.LogContent.Size = new System.Drawing.Size(669, 899);
this.LogContent.TabIndex = 7;
//
@ -199,12 +234,19 @@
this.ID.Name = "ID";
this.ID.Width = 40;
//
// LineNo
//
this.LineNo.DataPropertyName = "LineNo";
this.LineNo.HeaderText = "线体号";
this.LineNo.Name = "LineNo";
this.LineNo.Width = 50;
//
// deviceNoDataGridViewTextBoxColumn
//
this.deviceNoDataGridViewTextBoxColumn.DataPropertyName = "DeviceNo";
this.deviceNoDataGridViewTextBoxColumn.HeaderText = "格口";
this.deviceNoDataGridViewTextBoxColumn.Name = "deviceNoDataGridViewTextBoxColumn";
this.deviceNoDataGridViewTextBoxColumn.Width = 40;
this.deviceNoDataGridViewTextBoxColumn.Width = 50;
//
// readKindDataGridViewTextBoxColumn
//
@ -231,38 +273,10 @@
//
this.rFIDContentBindingSource.DataSource = typeof(HighWayIot.Repository.domain.RFIDContent);
//
// groupBox4
//
this.groupBox4.Controls.Add(this.Content);
this.groupBox4.Controls.Add(this.ContentSelect);
this.groupBox4.Location = new System.Drawing.Point(12, 423);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(208, 131);
this.groupBox4.TabIndex = 7;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "条码内容查询";
//
// Content
//
this.Content.Location = new System.Drawing.Point(42, 29);
this.Content.Name = "Content";
this.Content.Size = new System.Drawing.Size(122, 21);
this.Content.TabIndex = 1;
//
// ContentSelect
//
this.ContentSelect.Location = new System.Drawing.Point(42, 65);
this.ContentSelect.Name = "ContentSelect";
this.ContentSelect.Size = new System.Drawing.Size(122, 48);
this.ContentSelect.TabIndex = 0;
this.ContentSelect.Text = "条码内容查询";
this.ContentSelect.UseVisualStyleBackColor = true;
this.ContentSelect.Click += new System.EventHandler(this.ContentSelect_Click);
//
// SelectAll
//
this.SelectAll.Font = new System.Drawing.Font("宋体", 12F);
this.SelectAll.Location = new System.Drawing.Point(12, 560);
this.SelectAll.Location = new System.Drawing.Point(12, 420);
this.SelectAll.Name = "SelectAll";
this.SelectAll.Size = new System.Drawing.Size(208, 48);
this.SelectAll.TabIndex = 2;
@ -408,17 +422,27 @@
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(18, 611);
this.label3.Location = new System.Drawing.Point(12, 471);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(149, 12);
this.label3.TabIndex = 21;
this.label3.Text = "※某条件为空既过滤该条件";
//
// button2
//
this.button2.Location = new System.Drawing.Point(12, 609);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(208, 23);
this.button2.TabIndex = 22;
this.button2.Text = "清除一个月之前的数据";
this.button2.UseVisualStyleBackColor = true;
//
// RFIDLog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(907, 923);
this.Controls.Add(this.button2);
this.Controls.Add(this.label3);
this.Controls.Add(this.TotalReadCount);
this.Controls.Add(this.label4);
@ -434,21 +458,16 @@
this.Controls.Add(this.txtPath);
this.Controls.Add(this.ExcelOutPut);
this.Controls.Add(this.SelectAll);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.LogContent);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Name = "RFIDLog";
this.Text = "日志查询";
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.LogContent)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.rFIDContentBindingSource)).EndInit();
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@ -463,12 +482,10 @@
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.ComboBox ReadKind;
private System.Windows.Forms.Button ReadKindSelect;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.TextBox DeviceNo;
private System.Windows.Forms.Button DeviceNoSelect;
private System.Windows.Forms.DataGridView LogContent;
private System.Windows.Forms.BindingSource rFIDContentBindingSource;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.TextBox Content;
private System.Windows.Forms.Button ContentSelect;
private System.Windows.Forms.Button SelectAll;
@ -484,13 +501,17 @@
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label TotalReadCount;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.ComboBox LineSelectCombobox;
private System.Windows.Forms.Button LineSelectButton;
private System.Windows.Forms.DataGridViewTextBoxColumn ID;
private System.Windows.Forms.DataGridViewTextBoxColumn LineNo;
private System.Windows.Forms.DataGridViewTextBoxColumn deviceNoDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn readKindDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn contentDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn logTimeDataGridViewTextBoxColumn;
private System.Windows.Forms.Label TotalReadCount;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button button2;
}
}

@ -1,4 +1,5 @@
using HighWayIot.Repository.domain;
using HighWayIot.Common;
using HighWayIot.Repository.domain;
using HighWayIot.Repository.service.Impl;
using System;
using System.Collections.Generic;
@ -18,7 +19,8 @@ namespace RFIDSocket
{
List<RFIDContent> rFIDContents = new List<RFIDContent>();
BaseContentServiceImpl sql = new BaseContentServiceImpl();
BaseContentServiceImpl sql = BaseContentServiceImpl.Instance;
XmlUtil _xmlUtil = XmlUtil.Instance;
public RFIDLog()
{
InitializeComponent();
@ -36,36 +38,80 @@ namespace RFIDSocket
ReadKind.DisplayMember = "Key";
ReadKind.ValueMember = "Value";
txtPath.Text = Environment.CurrentDirectory.ToString();
List<string> Ids = new List<string>();
Ids.Add("");
Ids.AddRange(_xmlUtil.ClientReader().Select(x => x.ID).ToList());
LineSelectCombobox.DataSource = null;
LineSelectCombobox.DataSource = Ids;
Init();
}
/// <summary>
/// 初始化
/// </summary>
private void Init()
{
rFIDContents = sql.GetContentInfos();
}
/// <summary>
/// 时间选择
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TimeSelect_Click(object sender, EventArgs e)
{
if (LogContent != null)
{
Init();
var list = LogControl.LogTimeSelect(rFIDContents, StartTime.Value, EndTime.Value);
LogContent.DataSource = null;
LogContent.DataSource = ServerDataAnalysis.ChangeReadResult(list);
LogContent.DataSource = ServerDataAnalysis.Instance.ChangeReadResult(list);
NumCount(list);
}
}
/// <summary>
/// 线体选择查询按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
if (LogContent != null)
{
Init();
var list = LogControl.LogLineSelect(rFIDContents, LineSelectCombobox.Text);
LogContent.DataSource = null;
LogContent.DataSource = ServerDataAnalysis.Instance.ChangeReadResult(list);
}
}
/// <summary>
/// 按读取类型查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ReadKindSelect_Click(object sender, EventArgs e)
{
if (LogContent != null)
{
Init();
var list = LogControl.LogReadKindSelect(rFIDContents, ReadKind.SelectedValue.ToString());
LogContent.DataSource = null;
LogContent.DataSource = ServerDataAnalysis.ChangeReadResult(list);
LogContent.DataSource = ServerDataAnalysis.Instance.ChangeReadResult(list);
NumCount(list);
}
}
/// <summary>
/// 按格口号查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DeviceNoSelect_Click(object sender, EventArgs e)
{
int no;
@ -82,25 +128,36 @@ namespace RFIDSocket
next:
if (LogContent != null)
{
Init();
var list = LogControl.LogDeviceNoSelect(rFIDContents, no);
LogContent.DataSource = null;
LogContent.DataSource = ServerDataAnalysis.ChangeReadResult(list);
LogContent.DataSource = ServerDataAnalysis.Instance.ChangeReadResult(list);
NumCount(list);
}
}
/// <summary>
/// 按内容查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ContentSelect_Click(object sender, EventArgs e)
{
if (LogContent != null)
{
Init();
var list = LogControl.LogContentSelect(rFIDContents, Content.Text);
LogContent.DataSource = null;
LogContent.DataSource = ServerDataAnalysis.ChangeReadResult(list);
LogContent.DataSource = ServerDataAnalysis.Instance.ChangeReadResult(list);
NumCount(list);
}
}
/// <summary>
/// 综合条件查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SelectAll_Click(object sender, EventArgs e)
{
int no;
@ -117,16 +174,21 @@ namespace RFIDSocket
next:
if (LogContent != null)
{
var list = LogControl.LogTimeSelect(
LogControl.LogReadKindSelect(
LogControl.LogDeviceNoSelect(
LogControl.LogContentSelect(rFIDContents,
Content.Text),
no),
ReadKind.SelectedValue.ToString()),
StartTime.Value, EndTime.Value);
Init();
var list =
LogControl.LogLineSelect(
LogControl.LogTimeSelect(
LogControl.LogReadKindSelect(
LogControl.LogDeviceNoSelect(
LogControl.LogContentSelect(rFIDContents,
Content.Text),
no),
ReadKind.SelectedValue.ToString()),
StartTime.Value, EndTime.Value),
LineSelectCombobox.Text);
LogContent.DataSource = null;
LogContent.DataSource = ServerDataAnalysis.ChangeReadResult(list);
LogContent.DataSource = ServerDataAnalysis.Instance.ChangeReadResult(list);
NumCount(list);
}
}
@ -145,8 +207,6 @@ namespace RFIDSocket
percent *= 100f;
ReadSuccessPercent.Text = $"%{percent}";
rFIDContents = sql.GetContentInfos();
}
/// <summary>
@ -272,7 +332,21 @@ namespace RFIDSocket
txtPath.Text = folderBrowserDialog1.SelectedPath;
}
}
/// <summary>
/// 清除一个月之前的数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click_1(object sender, EventArgs e)
{
if(MessageBox.Show("确认要删除之前的数据吗", "确定", MessageBoxButtons.OKCancel) == DialogResult.OK)
{
if (!sql.DelBeforeMonthContent())
{
MessageBox.Show("删除失败");
}
}
}
}
}

@ -120,10 +120,7 @@
<metadata name="ID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="rFIDContentBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="ID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="LineNo.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="rFIDContentBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">

@ -30,11 +30,6 @@
{
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.MonitorOnOff = new System.Windows.Forms.Button();
this.label4 = new System.Windows.Forms.Label();
@ -49,7 +44,7 @@
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.LineSelectCombobox = 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();
@ -58,6 +53,8 @@
this.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label12 = new System.Windows.Forms.Label();
this.LineListBox = new System.Windows.Forms.ListBox();
this.ReadSuccessPercent = new System.Windows.Forms.Label();
this.ErrorReadNum = new System.Windows.Forms.Label();
this.NormalReadNum = new System.Windows.Forms.Label();
@ -72,6 +69,12 @@
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.LineNo = 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();
@ -93,8 +96,10 @@
this.CotentData.AllowUserToResizeRows = false;
this.CotentData.AutoGenerateColumns = false;
this.CotentData.ColumnHeadersHeight = 20;
this.CotentData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
this.CotentData.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.ID,
this.LineNo,
this.deviceNoDataGridViewTextBoxColumn,
this.readKindDataGridViewTextBoxColumn,
this.contentDataGridViewTextBoxColumn,
@ -107,54 +112,12 @@
this.CotentData.ReadOnly = true;
this.CotentData.RowHeadersVisible = false;
this.CotentData.RowHeadersWidth = 51;
this.CotentData.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
this.CotentData.RowTemplate.Height = 17;
this.CotentData.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.False;
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);
@ -235,7 +198,7 @@
this.PageRange.AutoSize = true;
this.PageRange.BackColor = System.Drawing.Color.Transparent;
this.PageRange.Font = new System.Drawing.Font("宋体", 12F);
this.PageRange.Location = new System.Drawing.Point(114, 11);
this.PageRange.Location = new System.Drawing.Point(96, 11);
this.PageRange.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.PageRange.Name = "PageRange";
this.PageRange.Size = new System.Drawing.Size(55, 16);
@ -270,7 +233,7 @@
//
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.LineSelectCombobox);
this.ControlGrupbox.Controls.Add(this.BinAudlt);
this.ControlGrupbox.Controls.Add(this.label2);
this.ControlGrupbox.Controls.Add(this.ConnectCountLabel);
@ -296,14 +259,14 @@
this.label1.TabIndex = 27;
this.label1.Text = "线体选择:";
//
// comboBox1
// LineSelectCombobox
//
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;
this.LineSelectCombobox.Font = new System.Drawing.Font("宋体", 12F);
this.LineSelectCombobox.FormattingEnabled = true;
this.LineSelectCombobox.Location = new System.Drawing.Point(110, 107);
this.LineSelectCombobox.Name = "LineSelectCombobox";
this.LineSelectCombobox.Size = new System.Drawing.Size(146, 24);
this.LineSelectCombobox.TabIndex = 26;
//
// BinAudlt
//
@ -386,6 +349,8 @@
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.label12);
this.groupBox1.Controls.Add(this.LineListBox);
this.groupBox1.Controls.Add(this.ReadSuccessPercent);
this.groupBox1.Controls.Add(this.ErrorReadNum);
this.groupBox1.Controls.Add(this.NormalReadNum);
@ -404,6 +369,24 @@
this.groupBox1.TabStop = false;
this.groupBox1.Text = "状态面板";
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(243, 17);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(101, 12);
this.label12.TabIndex = 13;
this.label12.Text = "已连接上的线名称";
//
// LineListBox
//
this.LineListBox.FormattingEnabled = true;
this.LineListBox.ItemHeight = 12;
this.LineListBox.Location = new System.Drawing.Point(245, 32);
this.LineListBox.Name = "LineListBox";
this.LineListBox.Size = new System.Drawing.Size(121, 172);
this.LineListBox.TabIndex = 12;
//
// ReadSuccessPercent
//
this.ReadSuccessPercent.AutoSize = true;
@ -479,6 +462,7 @@
this.ErrorCountDataGridView.AllowUserToDeleteRows = false;
this.ErrorCountDataGridView.AllowUserToResizeRows = false;
this.ErrorCountDataGridView.ColumnHeadersHeight = 20;
this.ErrorCountDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
this.ErrorCountDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.BinNo,
this.ErrorCount});
@ -487,7 +471,9 @@
this.ErrorCountDataGridView.Name = "ErrorCountDataGridView";
this.ErrorCountDataGridView.ReadOnly = true;
this.ErrorCountDataGridView.RowHeadersVisible = false;
this.ErrorCountDataGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
this.ErrorCountDataGridView.RowTemplate.Height = 17;
this.ErrorCountDataGridView.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.ErrorCountDataGridView.Size = new System.Drawing.Size(357, 370);
this.ErrorCountDataGridView.TabIndex = 0;
//
@ -561,6 +547,58 @@
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;
//
// LineNo
//
this.LineNo.DataPropertyName = "LineNo";
this.LineNo.HeaderText = "线号";
this.LineNo.Name = "LineNo";
this.LineNo.ReadOnly = true;
this.LineNo.Width = 50;
//
// deviceNoDataGridViewTextBoxColumn
//
this.deviceNoDataGridViewTextBoxColumn.DataPropertyName = "DeviceNo";
this.deviceNoDataGridViewTextBoxColumn.HeaderText = "格口";
this.deviceNoDataGridViewTextBoxColumn.MinimumWidth = 6;
this.deviceNoDataGridViewTextBoxColumn.Name = "deviceNoDataGridViewTextBoxColumn";
this.deviceNoDataGridViewTextBoxColumn.ReadOnly = true;
this.deviceNoDataGridViewTextBoxColumn.Width = 50;
//
// 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);
@ -634,13 +672,17 @@
private System.Windows.Forms.DataGridView ErrorCountDataGridView;
private System.Windows.Forms.DataGridViewTextBoxColumn BinNo;
private System.Windows.Forms.DataGridViewTextBoxColumn ErrorCount;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox LineSelectCombobox;
//private System.Windows.Forms.Button TestButton;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.ListBox LineListBox;
private System.Windows.Forms.DataGridViewTextBoxColumn ID;
private System.Windows.Forms.DataGridViewTextBoxColumn LineNo;
private System.Windows.Forms.DataGridViewTextBoxColumn deviceNoDataGridViewTextBoxColumn;
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;
}
}

@ -48,6 +48,13 @@ namespace RFIDSocket
MonitorState.Text = "开";
MonitorState.BackColor = Color.LightGreen;
}
List<string> Ids = new List<string>();
Ids.Add("");
Ids.AddRange(_xmlUtil.ClientReader().Select(x => x.ID).ToList());
LineSelectCombobox.DataSource = null;
LineSelectCombobox.DataSource = Ids;
}
/// <summary>
@ -103,10 +110,11 @@ namespace RFIDSocket
MonitorState.BackColor = Color.LightGreen;
}
RFIDData.GetData();
RFIDData.GetData(LineSelectCombobox.Text);
ConnectCountLabel.Text = Server.ConnectCount.ToString();
// 数量
int normalCount = RFIDData.rFIDContents.Where(x => x.ReadKind == "GR").Count();
int errorCount = RFIDData.rFIDContents.Where(x => x.ReadKind == "MR" || x.ReadKind == "NB").Count();
@ -142,6 +150,9 @@ namespace RFIDSocket
dataTable.Rows.Add(deviceNo.ToString(), deviceErrorCount.ToString());
}
LineListBox.Items.Clear();
LineListBox.Items.AddRange(TcpServer.Instance.Ids.ToArray());
ErrorCountDataGridView.DataSource = null;
ErrorCountDataGridView.DataSource = dataTable;
@ -177,7 +188,7 @@ namespace RFIDSocket
{
var list = RFIDData.rFIDContents.Skip((PageNo - 1) * 50).Take(50).ToList();
CotentData.DataSource = null;
CotentData.DataSource = ServerDataAnalysis.ChangeReadResult(list);
CotentData.DataSource = ServerDataAnalysis.Instance.ChangeReadResult(list);
PageRange.Text = $"{((PageNo - 1) * 50) + 1} - {PageNo * 50}";
}
@ -251,5 +262,17 @@ namespace RFIDSocket
RFIDBinAudlt form = new RFIDBinAudlt();
form.Show();
}
/// <summary>
/// 测试按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TestButton_Click(object sender, EventArgs e)
{
MessageFactory.Instance.ReadCodeRequestProcess(LineSelectCombobox.Text);
}
}
}

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Costura.Fody.6.0.0\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.6.0.0\build\Costura.Fody.props')" />
<Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.props" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
@ -14,6 +15,8 @@
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<IsWebBootstrapper>false</IsWebBootstrapper>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<PublishUrl>D:\Temp\publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
@ -25,13 +28,11 @@
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<AutorunEnabled>true</AutorunEnabled>
<ApplicationRevision>5</ApplicationRevision>
<ApplicationRevision>6</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -77,6 +78,9 @@
<Reference Include="BouncyCastle.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=072edcf4a5328938, processorArchitecture=MSIL">
<HintPath>..\packages\BouncyCastle.Cryptography.2.3.1\lib\net461\BouncyCastle.Cryptography.dll</HintPath>
</Reference>
<Reference Include="Costura, Version=6.0.0.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
<HintPath>..\packages\Costura.Fody.6.0.0\lib\netstandard2.0\Costura.dll</HintPath>
</Reference>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll</HintPath>
</Reference>
@ -286,7 +290,12 @@
<Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.props'))" />
<Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.targets'))" />
<Error Condition="!Exists('..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets'))" />
<Error Condition="!Exists('..\packages\Fody.6.8.2\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.6.8.2\build\Fody.targets'))" />
<Error Condition="!Exists('..\packages\Costura.Fody.6.0.0\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.6.0.0\build\Costura.Fody.props'))" />
<Error Condition="!Exists('..\packages\Costura.Fody.6.0.0\build\Costura.Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.6.0.0\build\Costura.Fody.targets'))" />
</Target>
<Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.targets" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" />
<Import Project="..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets" Condition="Exists('..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" />
<Import Project="..\packages\Fody.6.8.2\build\Fody.targets" Condition="Exists('..\packages\Fody.6.8.2\build\Fody.targets')" />
<Import Project="..\packages\Costura.Fody.6.0.0\build\Costura.Fody.targets" Condition="Exists('..\packages\Costura.Fody.6.0.0\build\Costura.Fody.targets')" />
</Project>

@ -120,10 +120,7 @@
<metadata name="ID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="rFIDContentBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>159, 17</value>
</metadata>
<metadata name="ID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="LineNo.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="rFIDContentBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">

@ -24,63 +24,22 @@ namespace RFIDSocket
public static ServerDataAnalysis Instance => lazy.Value;
public List<RFIDContent> rFIDContents = new List<RFIDContent>();
//public List<RFIDHeartbeat> rFIDHeartbeats = new List<RFIDHeartbeat>();
//public List<RFIDHeartbeat> HeartbeatsState = new List<RFIDHeartbeat>();
//public List<RFIDState> rFIDStates = new List<RFIDState>();
//public List<RFIDState> AlarmState = new List<RFIDState>();
public IContentService ContentService = new BaseContentServiceImpl();
//public IHeartbeatService HeartbeatService = new BaseHeartbeatServiceImpl();
//public IStateService StateService = new BaseStateServiceImpl();
/// <summary>
/// 获取数据解析
/// </summary>
public void GetData()
public void GetData(string lineNo)
{
rFIDContents = ContentService.GetContentInfos().Reverse<RFIDContent>().Take(200).ToList();
//rFIDStates = StateService.GetStateInfos();
//var StateGroup = rFIDStates.GroupBy(x => x.DeviceNo);
//AlarmState.Clear();
//foreach(var a in StateGroup)
//{
// var b = a.LastOrDefault();
// if (b.DeviceState)
// {
// AlarmState.Add(b);
// }
//}
//rFIDHeartbeats = HeartbeatService.GetHeartbeatInfos();
//var HeartBeatGroup = rFIDHeartbeats.GroupBy(x => x.DeviceNo);
//HeartbeatsState.Clear();
//foreach (var a in HeartBeatGroup)
//{
// var b = a.LastOrDefault();
// if (DateTime.Now - b.BeatTime > TimeSpan.FromSeconds(10))
// {
// b.TimeSpan = SecondToTime(Convert.ToInt32((DateTime.Now - b.BeatTime).TotalSeconds));
// HeartbeatsState.Add(b);
// }
//}
if(string.IsNullOrEmpty(lineNo))
{
rFIDContents = BaseContentServiceImpl.Instance.Get200Infos().ToList();
}
else
{
rFIDContents = BaseContentServiceImpl.Instance.Get200Infos(lineNo).ToList();
}
}
///// <summary>
///// 清除报警
///// </summary>
///// <returns></returns>
//public bool ClearAllError()
//{
// return StateService.SetAllNoError();
//}
/// <summary>
/// 秒转时间
/// </summary>
@ -97,7 +56,7 @@ namespace RFIDSocket
return m.ToString("00") + " 分 " + s.ToString("00") + " 秒";
}
public static List<RFIDContent> ChangeReadResult(List<RFIDContent> list)
public List<RFIDContent> ChangeReadResult(List<RFIDContent> list)
{
foreach (var item in list)
{

@ -1,7 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BouncyCastle.Cryptography" version="2.3.1" targetFramework="net48" />
<package id="Costura.Fody" version="6.0.0" targetFramework="net48" developmentDependency="true" />
<package id="EntityFramework" version="6.4.4" targetFramework="net48" />
<package id="Fody" version="6.8.2" targetFramework="net48" developmentDependency="true" />
<package id="Google.Protobuf" version="3.26.1" targetFramework="net48" />
<package id="K4os.Compression.LZ4" version="1.3.8" targetFramework="net48" />
<package id="K4os.Compression.LZ4.Streams" version="1.3.8" targetFramework="net48" />

@ -0,0 +1,20 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("UnitTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UnitTest")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("26673e87-2292-4993-890a-c1694b55d0e9")]
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.props')" />
<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>{26673E87-2292-4993-890A-C1694B55D0E9}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>UnitTest</RootNamespace>
<AssemblyName>UnitTest</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</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>
</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>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.2.2.10\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.2.2.10\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="UnitTest1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HighWayIot.Common\HighWayIot.Common.csproj">
<Project>{89A1EDD9-D79E-468D-B6D3-7D07B8843562}</Project>
<Name>HighWayIot.Common</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets'))" />
</Target>
<Import Project="..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets')" />
</Project>

@ -0,0 +1,47 @@
using HighWayIot.Common;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.IO;
namespace UnitTest
{
[TestClass]
public class UnitTest1
{
MsgUtil msgUtil = MsgUtil.Instance;
[TestMethod]
public void TestMethod1()
{
var bytes = msgUtil.HexStrTorbytes("00 0A 00 13 01 00 00 02 10 00 00 01 99 6F 39 E9 27 00 00 02 0F 00 01");
var res = CalculateCheckSum(bytes);
Assert.AreEqual(0x69, res);
}
public void CauCheck()
{
var bytes = msgUtil.HexStrTorbytes("00 0A 00 13 01 00 00 02 10 00 00 01 99 6F 39 E9 27 00 00 02 0F 00 01");
byte[] sum = new byte[1];
sum[0] = CalculateCheckSum(bytes);
var res = msgUtil.bytesToHexStr(sum, sum.Length);
Console.WriteLine(res);
}
/// <summary>
/// 和校验
/// </summary>
/// <param name="bytes"></param>
/// <param name="length"></param>
/// <returns></returns>
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;
}
}
}

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MSTest.TestAdapter" version="2.2.10" targetFramework="net48" />
<package id="MSTest.TestFramework" version="2.2.10" targetFramework="net48" />
</packages>
Loading…
Cancel
Save