diff --git a/HighWayIot.Repository/service/IStateService.cs b/HighWayIot.Repository/service/IStateService.cs
index 1b1c6e1..11baf0c 100644
--- a/HighWayIot.Repository/service/IStateService.cs
+++ b/HighWayIot.Repository/service/IStateService.cs
@@ -21,5 +21,10 @@ namespace HighWayIot.Repository.service
///
///
void AddStateInfo(RFIDState state);
+
+ ///
+ /// 清除所有报警
+ ///
+ bool SetAllNoError();
}
}
diff --git a/HighWayIot.Repository/service/Impl/BaseStateServiceImpl.cs b/HighWayIot.Repository/service/Impl/BaseStateServiceImpl.cs
index bac6a5c..fba531a 100644
--- a/HighWayIot.Repository/service/Impl/BaseStateServiceImpl.cs
+++ b/HighWayIot.Repository/service/Impl/BaseStateServiceImpl.cs
@@ -38,5 +38,18 @@ namespace HighWayIot.Repository.service.Impl
log.Error("RFID状态信息插入异常", ex);
}
}
+
+ public bool SetAllNoError()
+ {
+ try
+ {
+ return _repository.UpdateSetColumnsTrue(x => new RFIDState() { DeviceState = false}, x => x.DeviceState == true);
+ }
+ catch(Exception ex)
+ {
+ log.Error("RFID状态清除故障异常", ex);
+ return false;
+ }
+ }
}
}
diff --git a/HighWayIot.TouchSocket/HighWayIot.TouchSocket.csproj b/HighWayIot.TouchSocket/HighWayIot.TouchSocket.csproj
index 84f8437..7cd9982 100644
--- a/HighWayIot.TouchSocket/HighWayIot.TouchSocket.csproj
+++ b/HighWayIot.TouchSocket/HighWayIot.TouchSocket.csproj
@@ -103,6 +103,7 @@
+
diff --git a/HighWayIot.TouchSocket/BufferAnalysis.cs b/HighWayIot.TouchSocket/ServerBufferAnalysis.cs
similarity index 99%
rename from HighWayIot.TouchSocket/BufferAnalysis.cs
rename to HighWayIot.TouchSocket/ServerBufferAnalysis.cs
index 8e607e2..eb3af6b 100644
--- a/HighWayIot.TouchSocket/BufferAnalysis.cs
+++ b/HighWayIot.TouchSocket/ServerBufferAnalysis.cs
@@ -9,7 +9,7 @@ using System.Threading.Tasks;
namespace HighWayIot.TouchSocket
{
- public class BufferAnalysis
+ public class ServerBufferAnalysis
{
private static LogHelper logHelper = LogHelper.Instance;
diff --git a/HighWayIot.TouchSocket/TcpClientServer.cs b/HighWayIot.TouchSocket/TcpClientServer.cs
new file mode 100644
index 0000000..b69e3f6
--- /dev/null
+++ b/HighWayIot.TouchSocket/TcpClientServer.cs
@@ -0,0 +1,76 @@
+using HighWayIot.Log4net;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TouchSocket.Core;
+using TouchSocket.Sockets;
+
+namespace HighWayIot.TouchSocket
+{
+ public class TcpClientServer
+ {
+ private static readonly Lazy lazy = new Lazy(() => new TcpClientServer());
+
+ public static TcpClientServer Instance => lazy.Value;
+
+ private static LogHelper logHelper = LogHelper.Instance;
+
+ TcpClient tcpClient = new TcpClient();
+
+
+
+ ///
+ /// 客户端连接
+ ///
+ ///
+ public async Task ClientConnect(string ip, string port)
+ {
+
+
+ tcpClient.Connecting = (client, e) =>
+ {
+ return EasyTask.CompletedTask;
+ };//即将连接到服务器,此时已经创建socket,但是还未建立tcp
+ tcpClient.Connected = (client, e) =>
+ {
+ return EasyTask.CompletedTask;
+ };//成功连接到服务器
+ tcpClient.Closing = (client, e) =>
+ {
+ return EasyTask.CompletedTask;
+ };//即将从服务器断开连接。此处仅主动断开才有效。
+ tcpClient.Closed = (client, e) =>
+ {
+ return EasyTask.CompletedTask;
+ };//从服务器断开连接,当连接不成功时不会触发。
+ tcpClient.Received = (client, e) =>
+ {
+ //从服务器收到信息。但是一般byteBlock和requestInfo会根据适配器呈现不同的值。
+ var mes = e.ByteBlock.Span.ToString(Encoding.UTF8);
+ tcpClient.Logger.Info($"客户端接收到信息:{mes}");
+ return EasyTask.CompletedTask;
+ };
+
+ //载入配置
+ await tcpClient.SetupAsync(new TouchSocketConfig()
+ .SetRemoteIPHost($"{ip}:{port}")
+ .ConfigureContainer(a =>
+ {
+ a.AddConsoleLogger();//添加一个日志注入
+ }));
+
+ await tcpClient.ConnectAsync();//调用连接,当连接不成功时,会抛出异常。
+
+ Result result = await tcpClient.TryConnectAsync();//或者可以调用TryConnectAsync
+ if (result.IsSuccess())
+ {
+
+ }
+
+ tcpClient.Logger.Info("客户端成功连接");
+ return result.IsSuccess();
+ }
+ }
+}
diff --git a/HighWayIot.TouchSocket/TcpServer.cs b/HighWayIot.TouchSocket/TcpServer.cs
index cd4df21..500b202 100644
--- a/HighWayIot.TouchSocket/TcpServer.cs
+++ b/HighWayIot.TouchSocket/TcpServer.cs
@@ -1,4 +1,5 @@
using HighWayIot.Log4net;
+using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -23,10 +24,18 @@ namespace HighWayIot.TouchSocket
private set => State = value;
}
+ public bool ServerState
+ {
+ get => !(service == null);
+ }
+
TcpService service = new TcpService();
+ public int ConnectCount = 0;
+
public bool ServerStart(string ip, string port)
{
+ service = new TcpService();
try
{
service.Connecting = (client, e) =>
@@ -37,6 +46,7 @@ namespace HighWayIot.TouchSocket
service.Connected = (client, e) =>
{
logHelper.Info($"客户端{client.IP}:{client.Port}成功连接");
+ ConnectCount++;
return EasyTask.CompletedTask;
};//有客户端成功连接
service.Closing = (client, e) =>
@@ -47,6 +57,7 @@ namespace HighWayIot.TouchSocket
service.Closed = (client, e) =>
{
logHelper.Info($"客户端{client.IP}:{client.Port}断开连接");
+ ConnectCount--;
return EasyTask.CompletedTask;
};//有客户端断开连接
service.Received = (client, e) =>
diff --git a/RFIDSocket/Configuration.xml b/RFIDSocket/Configuration.xml
new file mode 100644
index 0000000..43c05d9
--- /dev/null
+++ b/RFIDSocket/Configuration.xml
@@ -0,0 +1,9 @@
+
+
+ 192.168.0.101
+ 192.168.0.102
+ 192.168.0.103
+ 192.168.0.104
+ 192.168.0.105
+ 354
+
diff --git a/RFIDSocket/RFIDBinAudlt.Designer.cs b/RFIDSocket/RFIDBinAudlt.Designer.cs
new file mode 100644
index 0000000..70fb875
--- /dev/null
+++ b/RFIDSocket/RFIDBinAudlt.Designer.cs
@@ -0,0 +1,347 @@
+namespace RFIDSocket
+{
+ partial class RFIDBinAudlt
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.AudltButton = new System.Windows.Forms.Button();
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Column8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Column9 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Column10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Column11 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Column12 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Column13 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Column14 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Column15 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Column16 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Column17 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Column18 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Column19 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Column20 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.DataGroupBox = new System.Windows.Forms.GroupBox();
+ this.label1 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.NormalCountLabel = new System.Windows.Forms.Label();
+ this.ErrorCountLabel = new System.Windows.Forms.Label();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.DataGroupBox.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // AudltButton
+ //
+ this.AudltButton.Location = new System.Drawing.Point(12, 12);
+ this.AudltButton.Name = "AudltButton";
+ this.AudltButton.Size = new System.Drawing.Size(114, 40);
+ this.AudltButton.TabIndex = 2;
+ this.AudltButton.Text = "盘点";
+ this.AudltButton.UseVisualStyleBackColor = true;
+ this.AudltButton.Click += new System.EventHandler(this.AudltButton_Click);
+ //
+ // dataGridView
+ //
+ this.dataGridView.AllowUserToDeleteRows = false;
+ this.dataGridView.AllowUserToResizeColumns = false;
+ this.dataGridView.AllowUserToResizeRows = false;
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.ColumnHeadersVisible = false;
+ this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.Column1,
+ this.Column2,
+ this.Column3,
+ this.Column4,
+ this.Column5,
+ this.Column6,
+ this.Column7,
+ this.Column8,
+ this.Column9,
+ this.Column10,
+ this.Column11,
+ this.Column12,
+ this.Column13,
+ this.Column14,
+ this.Column15,
+ this.Column16,
+ this.Column17,
+ this.Column18,
+ this.Column19,
+ this.Column20});
+ this.dataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.dataGridView.Location = new System.Drawing.Point(3, 17);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersVisible = false;
+ this.dataGridView.RowTemplate.Height = 23;
+ this.dataGridView.Size = new System.Drawing.Size(681, 884);
+ this.dataGridView.TabIndex = 3;
+ //
+ // Column1
+ //
+ this.Column1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Column1.DataPropertyName = "Column1";
+ this.Column1.HeaderText = "Column1";
+ this.Column1.Name = "Column1";
+ //
+ // Column2
+ //
+ this.Column2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Column2.DataPropertyName = "Column2";
+ this.Column2.HeaderText = "Column2";
+ this.Column2.Name = "Column2";
+ //
+ // Column3
+ //
+ this.Column3.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Column3.DataPropertyName = "Column3";
+ this.Column3.HeaderText = "Column3";
+ this.Column3.Name = "Column3";
+ //
+ // Column4
+ //
+ this.Column4.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Column4.DataPropertyName = "Column4";
+ this.Column4.HeaderText = "Column4";
+ this.Column4.Name = "Column4";
+ //
+ // Column5
+ //
+ this.Column5.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Column5.DataPropertyName = "Column5";
+ this.Column5.HeaderText = "Column5";
+ this.Column5.Name = "Column5";
+ //
+ // Column6
+ //
+ this.Column6.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Column6.DataPropertyName = "Column6";
+ this.Column6.HeaderText = "Column6";
+ this.Column6.Name = "Column6";
+ //
+ // Column7
+ //
+ this.Column7.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Column7.DataPropertyName = "Column7";
+ this.Column7.HeaderText = "Column7";
+ this.Column7.Name = "Column7";
+ //
+ // Column8
+ //
+ this.Column8.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Column8.DataPropertyName = "Column8";
+ this.Column8.HeaderText = "Column8";
+ this.Column8.Name = "Column8";
+ //
+ // Column9
+ //
+ this.Column9.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Column9.DataPropertyName = "Column9";
+ this.Column9.HeaderText = "Column9";
+ this.Column9.Name = "Column9";
+ //
+ // Column10
+ //
+ this.Column10.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Column10.DataPropertyName = "Column10";
+ this.Column10.HeaderText = "Column10";
+ this.Column10.Name = "Column10";
+ //
+ // Column11
+ //
+ this.Column11.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Column11.DataPropertyName = "Column11";
+ this.Column11.HeaderText = "Column11";
+ this.Column11.Name = "Column11";
+ //
+ // Column12
+ //
+ this.Column12.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Column12.DataPropertyName = "Column12";
+ this.Column12.HeaderText = "Column12";
+ this.Column12.Name = "Column12";
+ //
+ // Column13
+ //
+ this.Column13.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Column13.DataPropertyName = "Column13";
+ this.Column13.HeaderText = "Column13";
+ this.Column13.Name = "Column13";
+ //
+ // Column14
+ //
+ this.Column14.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Column14.DataPropertyName = "Column14";
+ this.Column14.HeaderText = "Column14";
+ this.Column14.Name = "Column14";
+ //
+ // Column15
+ //
+ this.Column15.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Column15.DataPropertyName = "Column15";
+ this.Column15.HeaderText = "Column15";
+ this.Column15.Name = "Column15";
+ //
+ // Column16
+ //
+ this.Column16.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Column16.DataPropertyName = "Column16";
+ this.Column16.HeaderText = "Column16";
+ this.Column16.Name = "Column16";
+ //
+ // Column17
+ //
+ this.Column17.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Column17.DataPropertyName = "Column17";
+ this.Column17.HeaderText = "Column17";
+ this.Column17.Name = "Column17";
+ //
+ // Column18
+ //
+ this.Column18.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Column18.DataPropertyName = "Column18";
+ this.Column18.HeaderText = "Column18";
+ this.Column18.Name = "Column18";
+ //
+ // Column19
+ //
+ this.Column19.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Column19.DataPropertyName = "Column19";
+ this.Column19.HeaderText = "Column19";
+ this.Column19.Name = "Column19";
+ //
+ // Column20
+ //
+ this.Column20.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Column20.DataPropertyName = "Column20";
+ this.Column20.HeaderText = "Column20";
+ this.Column20.Name = "Column20";
+ //
+ // DataGroupBox
+ //
+ this.DataGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.DataGroupBox.AutoSize = true;
+ this.DataGroupBox.Controls.Add(this.dataGridView);
+ this.DataGroupBox.Location = new System.Drawing.Point(12, 58);
+ this.DataGroupBox.Name = "DataGroupBox";
+ this.DataGroupBox.Size = new System.Drawing.Size(687, 904);
+ this.DataGroupBox.TabIndex = 4;
+ this.DataGroupBox.TabStop = false;
+ this.DataGroupBox.Text = "详情显示";
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(141, 12);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(89, 12);
+ this.label1.TabIndex = 5;
+ this.label1.Text = "正常格口数量:";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(141, 40);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(89, 12);
+ this.label2.TabIndex = 6;
+ this.label2.Text = "异常格口数量:";
+ //
+ // NormalCountLabel
+ //
+ this.NormalCountLabel.AutoSize = true;
+ this.NormalCountLabel.Location = new System.Drawing.Point(236, 12);
+ this.NormalCountLabel.Name = "NormalCountLabel";
+ this.NormalCountLabel.Size = new System.Drawing.Size(23, 12);
+ this.NormalCountLabel.TabIndex = 7;
+ this.NormalCountLabel.Text = "N/A";
+ //
+ // ErrorCountLabel
+ //
+ this.ErrorCountLabel.AutoSize = true;
+ this.ErrorCountLabel.Location = new System.Drawing.Point(236, 40);
+ this.ErrorCountLabel.Name = "ErrorCountLabel";
+ this.ErrorCountLabel.Size = new System.Drawing.Size(23, 12);
+ this.ErrorCountLabel.TabIndex = 8;
+ this.ErrorCountLabel.Text = "N/A";
+ //
+ // RFIDBinAudlt
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(711, 974);
+ this.Controls.Add(this.ErrorCountLabel);
+ this.Controls.Add(this.NormalCountLabel);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.DataGroupBox);
+ this.Controls.Add(this.AudltButton);
+ this.Name = "RFIDBinAudlt";
+ this.Text = "格口盘点";
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.DataGroupBox.ResumeLayout(false);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+ private System.Windows.Forms.Button AudltButton;
+ private System.Windows.Forms.DataGridView dataGridView;
+ private System.Windows.Forms.GroupBox DataGroupBox;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Label NormalCountLabel;
+ private System.Windows.Forms.Label ErrorCountLabel;
+ private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
+ private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
+ private System.Windows.Forms.DataGridViewTextBoxColumn Column3;
+ private System.Windows.Forms.DataGridViewTextBoxColumn Column4;
+ private System.Windows.Forms.DataGridViewTextBoxColumn Column5;
+ private System.Windows.Forms.DataGridViewTextBoxColumn Column6;
+ private System.Windows.Forms.DataGridViewTextBoxColumn Column7;
+ private System.Windows.Forms.DataGridViewTextBoxColumn Column8;
+ private System.Windows.Forms.DataGridViewTextBoxColumn Column9;
+ private System.Windows.Forms.DataGridViewTextBoxColumn Column10;
+ private System.Windows.Forms.DataGridViewTextBoxColumn Column11;
+ private System.Windows.Forms.DataGridViewTextBoxColumn Column12;
+ private System.Windows.Forms.DataGridViewTextBoxColumn Column13;
+ private System.Windows.Forms.DataGridViewTextBoxColumn Column14;
+ private System.Windows.Forms.DataGridViewTextBoxColumn Column15;
+ private System.Windows.Forms.DataGridViewTextBoxColumn Column16;
+ private System.Windows.Forms.DataGridViewTextBoxColumn Column17;
+ private System.Windows.Forms.DataGridViewTextBoxColumn Column18;
+ private System.Windows.Forms.DataGridViewTextBoxColumn Column19;
+ private System.Windows.Forms.DataGridViewTextBoxColumn Column20;
+ }
+}
\ No newline at end of file
diff --git a/RFIDSocket/RFIDBinAudlt.cs b/RFIDSocket/RFIDBinAudlt.cs
new file mode 100644
index 0000000..ffcea00
--- /dev/null
+++ b/RFIDSocket/RFIDBinAudlt.cs
@@ -0,0 +1,180 @@
+using HighWayIot.TouchSocket;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using System.Xml;
+
+namespace RFIDSocket
+{
+ public partial class RFIDBinAudlt : Form
+ {
+ TcpClientServer TCPClient = TcpClientServer.Instance;
+
+ DataTable dt = new DataTable();
+
+ string Path = System.Environment.CurrentDirectory;
+
+ string[] ServiceIPs;
+
+ int ServiceCount = -1;
+
+ int NormalCount = 0;
+
+ int ErrorCount = 0;
+
+ public RFIDBinAudlt()
+ {
+ InitializeComponent();
+ Init();
+ }
+
+ private void Init()
+ {
+ GetSetting();
+ dataGridView.AutoGenerateColumns = false;
+ foreach (DataGridViewColumn column in dataGridView.Columns)
+ {
+ dt.Columns.Add(column.HeaderText, typeof(string));
+ }
+ }
+
+ ///
+ /// 读取XML配置文件中的IP
+ ///
+ private void GetSetting()
+ {
+ XmlDocument xd = new XmlDocument();
+ xd.Load($"{Path}\\Configuration.xml");//加载xml文档
+ XmlNode rootNode = xd.SelectSingleNode("BinAudlt");//得到xml文档的根节点
+ XmlNodeList nodes = rootNode.SelectNodes("ServiceIpConfig");//获取根节点的子节点"ServiceIpConfig"
+ ServiceIPs = new string[nodes.Count];
+ for (int i = 0; i < nodes.Count; i++)
+ {
+ ServiceIPs[i] = nodes[i].InnerText;
+ }
+ XmlNode count = rootNode.SelectSingleNode("ServiceIpCount");
+ if (!int.TryParse(count.InnerText, out ServiceCount))
+ {
+ MessageBox.Show("XML配置文件中ServiceIpConfig的值有问题,请重新配置!");
+ }
+ }
+
+ ///
+ /// 开始盘点
+ ///
+ ///
+ ///
+ private void AudltButton_Click(object sender, EventArgs e)
+ {
+ //bool res = TCPClient.ClientConnect("127.0.0.1", "7789").GetAwaiter().GetResult();
+ //if (res)
+ //{
+ // MessageBox.Show("我操牛逼");
+ //}
+ NormalCount = 0;
+ ErrorCount = 0;
+ GridViewRefresh(GenerateRandomBoolArray(ServiceCount));
+ NormalCountLabel.Text = NormalCount.ToString();
+ ErrorCountLabel.Text = ErrorCount.ToString();
+ }
+
+ ///
+ /// 表格刷新
+ ///
+ private void GridViewRefresh(bool[] states)
+ {
+ if (ServiceCount < 0)
+ {
+ return;
+ }
+ //统计多少行
+ int lineCount = ServiceCount / 20;
+ //最后一行多少个数据
+ int lastCount = ServiceCount % 20;
+ if (lastCount > 0)
+ {
+ //最后不完整行
+ lineCount++;
+ }
+ //格口个数
+ int totalCount = 0;
+ dt.Rows.Clear();
+ //添加格口编号 添加状态
+ for (int i = 0; i < lineCount; i++)
+ {
+ //新建dt行
+ DataRow numdr = dt.NewRow();
+ DataRow statedr = dt.NewRow();
+ for (int j = 0; j < 20; j++)
+ {
+ if (totalCount >= ServiceCount)
+ {
+ break;
+ }
+ statedr[j] = states[totalCount] ? "正常" : "异常";
+ //计数
+ if (states[totalCount])
+ {
+ NormalCount++;
+ }
+ else if (!states[totalCount])
+ {
+ ErrorCount++;
+ }
+ numdr[j] = (++totalCount).ToString();
+ }
+ dt.Rows.Add(numdr);
+ dt.Rows.Add(statedr);
+ }
+
+ //添加DT表
+ dataGridView.DataSource = null;
+ dataGridView.DataSource = dt;
+
+ //设置背景颜色
+ for (int i = 0; i < lineCount * 2; i++)
+ {
+ if (i % 2 == 0)
+ {
+ continue;
+ }
+ for (int j = 0; j < 20; j++)
+ {
+ if (int.TryParse(dataGridView.Rows[i - 1].Cells[j].Value.ToString(), out int head))
+ {
+ DataGridViewCell cell = dataGridView.Rows[i].Cells[j];
+ cell.Style.BackColor = states[head - 1] ? Color.Green : Color.Red;
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+ }
+
+ ///
+ /// 随机布尔数组生成
+ ///
+ ///
+ ///
+ public bool[] GenerateRandomBoolArray(int length)
+ {
+ bool[] boolArray = new bool[length];
+ Random random = new Random();
+
+ for (int i = 0; i < length; i++)
+ {
+ boolArray[i] = random.Next(2) == 1;
+ }
+
+ return boolArray;
+ }
+ }
+}
diff --git a/RFIDSocket/RFIDBinAudlt.resx b/RFIDSocket/RFIDBinAudlt.resx
new file mode 100644
index 0000000..6d60700
--- /dev/null
+++ b/RFIDSocket/RFIDBinAudlt.resx
@@ -0,0 +1,180 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
\ No newline at end of file
diff --git a/RFIDSocket/RFIDLog.Designer.cs b/RFIDSocket/RFIDLog.Designer.cs
index c9794f1..79f7ff5 100644
--- a/RFIDSocket/RFIDLog.Designer.cs
+++ b/RFIDSocket/RFIDLog.Designer.cs
@@ -40,6 +40,7 @@
this.DeviceNo = new System.Windows.Forms.TextBox();
this.DeviceNoSelect = new System.Windows.Forms.Button();
this.LogContent = 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();
@@ -49,6 +50,12 @@
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();
+ this.txtPath = new System.Windows.Forms.TextBox();
+ this.Label1 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.button1 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
@@ -163,6 +170,7 @@
this.LogContent.AutoGenerateColumns = false;
this.LogContent.ColumnHeadersHeight = 20;
this.LogContent.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.ID,
this.deviceNoDataGridViewTextBoxColumn,
this.readKindDataGridViewTextBoxColumn,
this.contentDataGridViewTextBoxColumn,
@@ -172,13 +180,20 @@
this.LogContent.Name = "LogContent";
this.LogContent.RowHeadersVisible = false;
this.LogContent.RowTemplate.Height = 18;
- this.LogContent.Size = new System.Drawing.Size(500, 899);
+ this.LogContent.Size = new System.Drawing.Size(669, 899);
this.LogContent.TabIndex = 7;
//
+ // ID
+ //
+ this.ID.DataPropertyName = "ID";
+ this.ID.HeaderText = "ID";
+ this.ID.Name = "ID";
+ this.ID.Width = 40;
+ //
// deviceNoDataGridViewTextBoxColumn
//
this.deviceNoDataGridViewTextBoxColumn.DataPropertyName = "DeviceNo";
- this.deviceNoDataGridViewTextBoxColumn.HeaderText = "编号";
+ this.deviceNoDataGridViewTextBoxColumn.HeaderText = "格口";
this.deviceNoDataGridViewTextBoxColumn.Name = "deviceNoDataGridViewTextBoxColumn";
this.deviceNoDataGridViewTextBoxColumn.Width = 40;
//
@@ -245,11 +260,63 @@
this.SelectAll.UseVisualStyleBackColor = true;
this.SelectAll.Click += new System.EventHandler(this.SelectAll_Click);
//
+ // ExcelOutPut
+ //
+ this.ExcelOutPut.Location = new System.Drawing.Point(14, 672);
+ this.ExcelOutPut.Name = "ExcelOutPut";
+ this.ExcelOutPut.Size = new System.Drawing.Size(203, 36);
+ this.ExcelOutPut.TabIndex = 8;
+ this.ExcelOutPut.Text = "查询内容导出Excel";
+ this.ExcelOutPut.UseVisualStyleBackColor = true;
+ this.ExcelOutPut.Click += new System.EventHandler(this.ExcelOutPut_Click);
+ //
+ // txtPath
+ //
+ this.txtPath.Location = new System.Drawing.Point(14, 645);
+ this.txtPath.Name = "txtPath";
+ this.txtPath.Size = new System.Drawing.Size(203, 21);
+ this.txtPath.TabIndex = 9;
+ //
+ // Label1
+ //
+ this.Label1.AutoSize = true;
+ this.Label1.Location = new System.Drawing.Point(18, 611);
+ this.Label1.Name = "Label1";
+ this.Label1.Size = new System.Drawing.Size(197, 12);
+ this.Label1.TabIndex = 10;
+ this.Label1.Text = "——————文件导出——————";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.BackColor = System.Drawing.Color.Silver;
+ this.label2.Location = new System.Drawing.Point(12, 630);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(53, 12);
+ this.label2.TabIndex = 11;
+ this.label2.Text = "地址选择";
+ this.label2.Click += new System.EventHandler(this.label2_Click);
+ //
+ // button1
+ //
+ this.button1.Location = new System.Drawing.Point(14, 714);
+ this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(203, 36);
+ this.button1.TabIndex = 12;
+ this.button1.Text = "全部内容导出Excel";
+ this.button1.UseVisualStyleBackColor = true;
+ this.button1.Click += new System.EventHandler(this.button1_Click);
+ //
// RFIDLog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(738, 923);
+ this.ClientSize = new System.Drawing.Size(907, 923);
+ this.Controls.Add(this.button1);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.Label1);
+ 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);
@@ -267,6 +334,7 @@
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.ResumeLayout(false);
+ this.PerformLayout();
}
@@ -284,13 +352,20 @@
private System.Windows.Forms.Button DeviceNoSelect;
private System.Windows.Forms.DataGridView LogContent;
private System.Windows.Forms.BindingSource rFIDContentBindingSource;
- 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.GroupBox groupBox4;
private System.Windows.Forms.TextBox Content;
private System.Windows.Forms.Button ContentSelect;
private System.Windows.Forms.Button SelectAll;
+ private System.Windows.Forms.DataGridViewTextBoxColumn ID;
+ 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.Button ExcelOutPut;
+ private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
+ private System.Windows.Forms.TextBox txtPath;
+ private System.Windows.Forms.Label Label1;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Button button1;
}
}
\ No newline at end of file
diff --git a/RFIDSocket/RFIDLog.cs b/RFIDSocket/RFIDLog.cs
index 9cc2db2..f402940 100644
--- a/RFIDSocket/RFIDLog.cs
+++ b/RFIDSocket/RFIDLog.cs
@@ -5,9 +5,11 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
+using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Web;
using System.Windows.Forms;
namespace RFIDSocket
@@ -29,6 +31,7 @@ namespace RFIDSocket
"MR"
};
ReadKind.DataSource = list;
+ txtPath.Text = Environment.CurrentDirectory.ToString();
Init();
}
@@ -98,6 +101,130 @@ namespace RFIDSocket
StartTime.Value, EndTime.Value);
}
}
+
+ ///
+ /// 查询内容导出Excel
+ ///
+ ///
+ ///
+ private void ExcelOutPut_Click(object sender, EventArgs e)
+ {
+ DataTable dt = new DataTable();
+
+ // 列强制转换
+ for (int count = 0; count < LogContent.Columns.Count; count++)
+ {
+ DataColumn dc = new DataColumn(LogContent.Columns[count].HeaderText.ToString());
+ dt.Columns.Add(dc);
+ }
+
+ // 循环行
+ for (int count = 0; count < LogContent.Rows.Count; count++)
+ {
+ DataRow dr = dt.NewRow();
+ for (int countsub = 0; countsub < LogContent.Columns.Count; countsub++)
+ {
+ dr[countsub] = $"{Convert.ToString(LogContent.Rows[count].Cells[countsub].Value)} ";
+ }
+ dt.Rows.Add(dr);
+ }
+ ExportExcel(dt);
+ }
+
+ ///
+ /// 全部内容导出Excel
+ ///
+ ///
+ ///
+ private void button1_Click(object sender, EventArgs e)
+ {
+ DataTable dt = new DataTable();
+ var data = sql.GetContentInfos();
+ dt.Columns.Add("ID", typeof(string));
+ dt.Columns.Add("格口编号", typeof(string));
+ dt.Columns.Add("状态码", typeof(string));
+ dt.Columns.Add("读取内容", typeof(string));
+ dt.Columns.Add("读取时间", typeof(string));
+
+ foreach(var d in data)
+ {
+ dt.Rows.Add(d.ID.ToString(), d.DeviceNo.ToString(), d.ReadKind, $"{d.Content} ", d.LogTime.ToString());
+ }
+ ExportExcel(dt);
+ }
+
+ public void ExportExcel(DataTable dt)
+ {
+ //设置导出文件路径
+ string path = txtPath.Text;
+
+ //设置新建文件路径及名称
+ string savePath = $"{path}{DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")}.xls";
+
+ //创建文件
+ FileStream file = new FileStream(savePath, FileMode.CreateNew, FileAccess.Write);
+
+ //以指定的字符编码向指定的流写入字符
+ StreamWriter sw = new StreamWriter(file, Encoding.GetEncoding("GB2312"));
+
+ StringBuilder strbu = new StringBuilder();
+ try
+ {
+ //写入标题
+ for (int i = 0; i < dt.Columns.Count; i++)
+ {
+ strbu.Append(dt.Columns[i].ColumnName.ToString() + "\t");
+ }
+ //加入换行字符串
+ strbu.Append(Environment.NewLine);
+
+ //写入内容
+ for (int i = 0; i < dt.Rows.Count; i++)
+ {
+ for (int j = 0; j < dt.Columns.Count; j++)
+ {
+ strbu.Append(dt.Rows[i][j].ToString() + "\t");
+ }
+ strbu.Append(Environment.NewLine);
+ }
+
+ sw.Write(strbu.ToString());
+ sw.Flush();
+ file.Flush();
+
+ sw.Close();
+ sw.Dispose();
+
+ file.Close();
+ file.Dispose();
+ }
+ catch(Exception ex)
+ {
+ MessageBox.Show($"导出文件发生错误{ex.Message}");
+ sw.Close();
+ sw.Dispose();
+
+ file.Close();
+ file.Dispose();
+ }
+ }
+
+ ///
+ /// 文件路径选择
+ ///
+ ///
+ ///
+ private void label2_Click(object sender, EventArgs e)
+ {
+ folderBrowserDialog1.Description = "请选择文件夹";
+ folderBrowserDialog1.RootFolder = Environment.SpecialFolder.MyComputer;
+ folderBrowserDialog1.ShowNewFolderButton = true;
+ if (txtPath.Text.Length > 0) folderBrowserDialog1.SelectedPath = txtPath.Text;
+ if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
+ {
+ txtPath.Text = folderBrowserDialog1.SelectedPath;
+ }
+ }
}
diff --git a/RFIDSocket/RFIDLog.resx b/RFIDSocket/RFIDLog.resx
index ca21880..77d971d 100644
--- a/RFIDSocket/RFIDLog.resx
+++ b/RFIDSocket/RFIDLog.resx
@@ -117,7 +117,13 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ True
+
17, 17
+
+ 225, 17
+
\ No newline at end of file
diff --git a/RFIDSocket/RFIDSocket.Designer.cs b/RFIDSocket/RFIDSocket.Designer.cs
index 315b4e4..c3557f9 100644
--- a/RFIDSocket/RFIDSocket.Designer.cs
+++ b/RFIDSocket/RFIDSocket.Designer.cs
@@ -30,6 +30,7 @@
{
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();
@@ -59,6 +60,10 @@
this.label3 = new System.Windows.Forms.Label();
this.LogStart = new System.Windows.Forms.Button();
this.ControlGrupbox = new System.Windows.Forms.GroupBox();
+ this.BinAudlt = new System.Windows.Forms.Button();
+ this.ClearError = new System.Windows.Forms.Button();
+ this.label2 = new System.Windows.Forms.Label();
+ this.ConnectCountLabel = new System.Windows.Forms.Label();
this.MainReadGroupBox = new System.Windows.Forms.GroupBox();
this.PageGroupBox = new System.Windows.Forms.GroupBox();
this.panel1 = new System.Windows.Forms.Panel();
@@ -80,9 +85,11 @@
//
// CotentData
//
+ this.CotentData.AllowUserToResizeRows = false;
this.CotentData.AutoGenerateColumns = false;
this.CotentData.ColumnHeadersHeight = 20;
this.CotentData.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.ID,
this.deviceNoDataGridViewTextBoxColumn,
this.readKindDataGridViewTextBoxColumn,
this.contentDataGridViewTextBoxColumn,
@@ -95,13 +102,20 @@
this.CotentData.RowHeadersVisible = false;
this.CotentData.RowHeadersWidth = 51;
this.CotentData.RowTemplate.Height = 17;
- this.CotentData.Size = new System.Drawing.Size(734, 703);
+ this.CotentData.Size = new System.Drawing.Size(775, 703);
this.CotentData.TabIndex = 0;
//
+ // ID
+ //
+ this.ID.DataPropertyName = "ID";
+ this.ID.HeaderText = "ID";
+ this.ID.Name = "ID";
+ this.ID.Width = 40;
+ //
// deviceNoDataGridViewTextBoxColumn
//
this.deviceNoDataGridViewTextBoxColumn.DataPropertyName = "DeviceNo";
- this.deviceNoDataGridViewTextBoxColumn.HeaderText = "编号";
+ this.deviceNoDataGridViewTextBoxColumn.HeaderText = "格口";
this.deviceNoDataGridViewTextBoxColumn.MinimumWidth = 6;
this.deviceNoDataGridViewTextBoxColumn.Name = "deviceNoDataGridViewTextBoxColumn";
this.deviceNoDataGridViewTextBoxColumn.Width = 40;
@@ -177,10 +191,10 @@
//
// MonitorOnOff
//
- this.MonitorOnOff.Location = new System.Drawing.Point(5, 71);
+ this.MonitorOnOff.Location = new System.Drawing.Point(5, 64);
this.MonitorOnOff.Margin = new System.Windows.Forms.Padding(2);
this.MonitorOnOff.Name = "MonitorOnOff";
- this.MonitorOnOff.Size = new System.Drawing.Size(110, 45);
+ this.MonitorOnOff.Size = new System.Drawing.Size(159, 45);
this.MonitorOnOff.TabIndex = 7;
this.MonitorOnOff.Text = "启动监听";
this.MonitorOnOff.UseVisualStyleBackColor = true;
@@ -189,7 +203,7 @@
// label4
//
this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(119, 87);
+ this.label4.Location = new System.Drawing.Point(13, 118);
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);
@@ -200,7 +214,7 @@
//
this.MonitorState.AutoSize = true;
this.MonitorState.BackColor = System.Drawing.Color.Transparent;
- this.MonitorState.Location = new System.Drawing.Point(188, 87);
+ this.MonitorState.Location = new System.Drawing.Point(82, 118);
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,17 +232,18 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox2.AutoSize = true;
this.groupBox2.Controls.Add(this.StateData);
- this.groupBox2.Location = new System.Drawing.Point(758, 138);
+ this.groupBox2.Location = new System.Drawing.Point(799, 180);
this.groupBox2.Margin = new System.Windows.Forms.Padding(2);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Padding = new System.Windows.Forms.Padding(2);
- this.groupBox2.Size = new System.Drawing.Size(185, 668);
+ this.groupBox2.Size = new System.Drawing.Size(185, 626);
this.groupBox2.TabIndex = 11;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "工作状态故障";
//
// StateData
//
+ this.StateData.AllowUserToResizeRows = false;
this.StateData.AutoGenerateColumns = false;
this.StateData.ColumnHeadersHeight = 20;
this.StateData.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
@@ -242,7 +257,7 @@
this.StateData.RowHeadersVisible = false;
this.StateData.RowHeadersWidth = 51;
this.StateData.RowTemplate.Height = 20;
- this.StateData.Size = new System.Drawing.Size(181, 650);
+ this.StateData.Size = new System.Drawing.Size(181, 608);
this.StateData.TabIndex = 0;
//
// deviceNoDataGridViewTextBoxColumn1
@@ -270,17 +285,18 @@
this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox3.Controls.Add(this.HeartbeatData);
- this.groupBox3.Location = new System.Drawing.Point(948, 138);
+ this.groupBox3.Location = new System.Drawing.Point(989, 180);
this.groupBox3.Margin = new System.Windows.Forms.Padding(2);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Padding = new System.Windows.Forms.Padding(2);
- this.groupBox3.Size = new System.Drawing.Size(185, 668);
+ this.groupBox3.Size = new System.Drawing.Size(185, 626);
this.groupBox3.TabIndex = 12;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "连接故障";
//
// HeartbeatData
//
+ this.HeartbeatData.AllowUserToResizeRows = false;
this.HeartbeatData.AutoGenerateColumns = false;
this.HeartbeatData.ColumnHeadersHeight = 20;
this.HeartbeatData.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
@@ -294,7 +310,7 @@
this.HeartbeatData.RowHeadersVisible = false;
this.HeartbeatData.RowHeadersWidth = 51;
this.HeartbeatData.RowTemplate.Height = 20;
- this.HeartbeatData.Size = new System.Drawing.Size(181, 650);
+ this.HeartbeatData.Size = new System.Drawing.Size(181, 608);
this.HeartbeatData.TabIndex = 0;
//
// deviceNoDataGridViewTextBoxColumn2
@@ -332,7 +348,7 @@
// PgDn
//
this.PgDn.Dock = System.Windows.Forms.DockStyle.Right;
- this.PgDn.Location = new System.Drawing.Point(641, 17);
+ this.PgDn.Location = new System.Drawing.Point(682, 17);
this.PgDn.Margin = new System.Windows.Forms.Padding(2);
this.PgDn.Name = "PgDn";
this.PgDn.Size = new System.Drawing.Size(96, 45);
@@ -370,10 +386,10 @@
//
// LogStart
//
- this.LogStart.Location = new System.Drawing.Point(285, 71);
+ this.LogStart.Location = new System.Drawing.Point(268, 64);
this.LogStart.Margin = new System.Windows.Forms.Padding(2);
this.LogStart.Name = "LogStart";
- this.LogStart.Size = new System.Drawing.Size(85, 45);
+ this.LogStart.Size = new System.Drawing.Size(105, 45);
this.LogStart.TabIndex = 16;
this.LogStart.Text = "日志查询";
this.LogStart.UseVisualStyleBackColor = true;
@@ -382,6 +398,10 @@
// ControlGrupbox
//
this.ControlGrupbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.ControlGrupbox.Controls.Add(this.BinAudlt);
+ this.ControlGrupbox.Controls.Add(this.ClearError);
+ this.ControlGrupbox.Controls.Add(this.label2);
+ this.ControlGrupbox.Controls.Add(this.ConnectCountLabel);
this.ControlGrupbox.Controls.Add(this.LogStart);
this.ControlGrupbox.Controls.Add(this.MonitorOnOff);
this.ControlGrupbox.Controls.Add(this.label4);
@@ -390,13 +410,55 @@
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(758, 12);
+ this.ControlGrupbox.Location = new System.Drawing.Point(799, 12);
this.ControlGrupbox.Name = "ControlGrupbox";
- this.ControlGrupbox.Size = new System.Drawing.Size(375, 121);
+ this.ControlGrupbox.Size = new System.Drawing.Size(375, 163);
this.ControlGrupbox.TabIndex = 17;
this.ControlGrupbox.TabStop = false;
this.ControlGrupbox.Text = "控制面板";
//
+ // BinAudlt
+ //
+ this.BinAudlt.Location = new System.Drawing.Point(218, 114);
+ this.BinAudlt.Name = "BinAudlt";
+ this.BinAudlt.Size = new System.Drawing.Size(151, 43);
+ this.BinAudlt.TabIndex = 25;
+ this.BinAudlt.Text = "格口盘点";
+ this.BinAudlt.UseVisualStyleBackColor = true;
+ this.BinAudlt.Click += new System.EventHandler(this.BinAudlt_Click);
+ //
+ // ClearError
+ //
+ this.ClearError.Location = new System.Drawing.Point(168, 64);
+ this.ClearError.Margin = new System.Windows.Forms.Padding(2);
+ this.ClearError.Name = "ClearError";
+ this.ClearError.Size = new System.Drawing.Size(96, 45);
+ this.ClearError.TabIndex = 24;
+ this.ClearError.Text = "清除报警";
+ this.ClearError.UseVisualStyleBackColor = true;
+ this.ClearError.Click += new System.EventHandler(this.ClearError_Click);
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(13, 140);
+ 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);
+ this.label2.TabIndex = 17;
+ this.label2.Text = "连接数量:";
+ //
+ // ConnectCountLabel
+ //
+ this.ConnectCountLabel.AutoSize = true;
+ this.ConnectCountLabel.BackColor = System.Drawing.Color.Transparent;
+ this.ConnectCountLabel.Location = new System.Drawing.Point(82, 140);
+ 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);
+ this.ConnectCountLabel.TabIndex = 18;
+ this.ConnectCountLabel.Text = "0";
+ //
// MainReadGroupBox
//
this.MainReadGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@@ -406,7 +468,7 @@
this.MainReadGroupBox.Controls.Add(this.CotentData);
this.MainReadGroupBox.Location = new System.Drawing.Point(12, 83);
this.MainReadGroupBox.Name = "MainReadGroupBox";
- this.MainReadGroupBox.Size = new System.Drawing.Size(740, 723);
+ this.MainReadGroupBox.Size = new System.Drawing.Size(781, 723);
this.MainReadGroupBox.TabIndex = 18;
this.MainReadGroupBox.TabStop = false;
this.MainReadGroupBox.Text = "数据监控";
@@ -420,7 +482,7 @@
this.PageGroupBox.Controls.Add(this.PgUp);
this.PageGroupBox.Location = new System.Drawing.Point(12, 12);
this.PageGroupBox.Name = "PageGroupBox";
- this.PageGroupBox.Size = new System.Drawing.Size(740, 65);
+ this.PageGroupBox.Size = new System.Drawing.Size(781, 65);
this.PageGroupBox.TabIndex = 0;
this.PageGroupBox.TabStop = false;
this.PageGroupBox.Text = "页码控制";
@@ -431,7 +493,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(543, 45);
+ this.panel1.Size = new System.Drawing.Size(584, 45);
this.panel1.TabIndex = 16;
//
// panel2
@@ -439,7 +501,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(176, 3);
+ this.panel2.Location = new System.Drawing.Point(197, 3);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(190, 39);
this.panel2.TabIndex = 16;
@@ -449,7 +511,7 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoScroll = true;
- this.ClientSize = new System.Drawing.Size(1145, 817);
+ this.ClientSize = new System.Drawing.Size(1186, 817);
this.Controls.Add(this.PageGroupBox);
this.Controls.Add(this.MainReadGroupBox);
this.Controls.Add(this.ControlGrupbox);
@@ -506,15 +568,20 @@
private System.Windows.Forms.Label PageRange;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button LogStart;
- 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.GroupBox ControlGrupbox;
private System.Windows.Forms.GroupBox MainReadGroupBox;
private System.Windows.Forms.GroupBox PageGroupBox;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Label ConnectCountLabel;
+ private System.Windows.Forms.Button ClearError;
+ private System.Windows.Forms.DataGridViewTextBoxColumn ID;
+ 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.Button BinAudlt;
}
}
diff --git a/RFIDSocket/RFIDSocket.cs b/RFIDSocket/RFIDSocket.cs
index 5dcd7e0..b99109d 100644
--- a/RFIDSocket/RFIDSocket.cs
+++ b/RFIDSocket/RFIDSocket.cs
@@ -19,7 +19,7 @@ namespace RFIDSocket
{
private static TcpServer Server = TcpServer.Instance;
- private static DataAnalysis RFIDData = DataAnalysis.Instance;
+ private static ServerDataAnalysis RFIDData = ServerDataAnalysis.Instance;
Configuration Config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
@@ -60,7 +60,7 @@ namespace RFIDSocket
{
if (Server.ServerStart(IP, Port))
{
- MessageBox.Show("监听服务启动成功!");
+ MessageBox.Show("监听服务启动成功!如更改ip端口号请重新启动监听");
TableTimer.Enabled = true;
}
else
@@ -70,7 +70,7 @@ namespace RFIDSocket
}
else if (Server.State == ServerState.Running)
{
- if (Server.ServerStop() || Server.ServerDispose())
+ if (Server.ServerStop())
{
MessageBox.Show("监听服务关闭成功!");
TableTimer.Enabled = false;
@@ -89,7 +89,7 @@ namespace RFIDSocket
Config.Save();
Port = PortText.Text;
IP = IPText.Text;
- MessageBox.Show("设置成功");
+ MessageBox.Show("服务端IP端口号设置成功");
}
private void TableTimer_Tick(object sender, EventArgs e)
@@ -109,6 +109,8 @@ namespace RFIDSocket
RFIDData.GetData();
+ ConnectCountLabel.Text = Server.ConnectCount.ToString();
+
CotentData.DataSource = null;
StateData.DataSource = null;
HeartbeatData.DataSource = null;
@@ -170,5 +172,27 @@ namespace RFIDSocket
rFIDLog.Show();
}
+ ///
+ /// 清除所有报警
+ ///
+ ///
+ ///
+ private void ClearError_Click(object sender, EventArgs e)
+ {
+ if (RFIDData.ClearAllError())
+ {
+ MessageBox.Show("设备异常清除成功");
+ }
+ else
+ {
+ MessageBox.Show("设备异常清除失败");
+ }
+ }
+
+ private void BinAudlt_Click(object sender, EventArgs e)
+ {
+ RFIDBinAudlt form = new RFIDBinAudlt();
+ form.Show();
+ }
}
}
diff --git a/RFIDSocket/RFIDSocket.csproj b/RFIDSocket/RFIDSocket.csproj
index 389f55d..0245957 100644
--- a/RFIDSocket/RFIDSocket.csproj
+++ b/RFIDSocket/RFIDSocket.csproj
@@ -123,6 +123,7 @@
..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll
+
@@ -144,6 +145,12 @@
+
+ Form
+
+
+ RFIDBinAudlt.cs
+
Form
@@ -159,6 +166,9 @@
+
+ RFIDBinAudlt.cs
+
ResXFileCodeGenerator
Resources.Designer.cs
@@ -224,5 +234,10 @@
false
+
+
+ Always
+
+
\ No newline at end of file
diff --git a/RFIDSocket/RFIDSocket.resx b/RFIDSocket/RFIDSocket.resx
index 743e470..d27b888 100644
--- a/RFIDSocket/RFIDSocket.resx
+++ b/RFIDSocket/RFIDSocket.resx
@@ -117,6 +117,15 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ True
+
+
+ 159, 17
+
+
+ True
+
159, 17
diff --git a/RFIDSocket/DataAnalysis.cs b/RFIDSocket/ServerDataAnalysis.cs
similarity index 58%
rename from RFIDSocket/DataAnalysis.cs
rename to RFIDSocket/ServerDataAnalysis.cs
index 381b31c..e30e6a6 100644
--- a/RFIDSocket/DataAnalysis.cs
+++ b/RFIDSocket/ServerDataAnalysis.cs
@@ -1,36 +1,46 @@
using HighWayIot.Repository.domain;
+using HighWayIot.Repository.service;
using HighWayIot.Repository.service.Impl;
using HighWayIot.TouchSocket;
using System;
using System.Collections.Generic;
+using System.Data;
+using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Web;
namespace RFIDSocket
{
- public class DataAnalysis
+ ///
+ /// 数据解析类
+ ///
+ public class ServerDataAnalysis
{
- private static readonly Lazy lazy = new Lazy(() => new DataAnalysis());
+ private static readonly Lazy lazy = new Lazy(() => new ServerDataAnalysis());
- public static DataAnalysis Instance => lazy.Value;
+ public static ServerDataAnalysis Instance => lazy.Value;
public List rFIDContents = new List();
public List rFIDHeartbeats = new List();
public List HeartbeatsState = new List();
public List rFIDStates = new List();
public List AlarmState = new List();
+ public IContentService ContentService = new BaseContentServiceImpl();
+ public IHeartbeatService HeartbeatService = new BaseHeartbeatServiceImpl();
+ public IStateService StateService = new BaseStateServiceImpl();
+ ///
+ /// 获取数据解析
+ ///
public void GetData()
{
- BaseContentServiceImpl baseContentServiceImpl = new BaseContentServiceImpl();
- BaseHeartbeatServiceImpl baseHeartbeatServiceImpl = new BaseHeartbeatServiceImpl();
- BaseStateServiceImpl baseStateServiceImpl = new BaseStateServiceImpl();
- rFIDContents = baseContentServiceImpl.GetContentInfos().Reverse().Take(200).ToList();
+ rFIDContents = ContentService.GetContentInfos().Reverse().Take(200).ToList();
- rFIDStates = baseStateServiceImpl.GetStateInfos();
+ rFIDStates = StateService.GetStateInfos();
var StateGroup = rFIDStates.GroupBy(x => x.DeviceNo);
@@ -45,7 +55,7 @@ namespace RFIDSocket
}
}
- rFIDHeartbeats = baseHeartbeatServiceImpl.GetHeartbeatInfos();
+ rFIDHeartbeats = HeartbeatService.GetHeartbeatInfos();
var HeartBeatGroup = rFIDHeartbeats.GroupBy(x => x.DeviceNo);
@@ -62,6 +72,20 @@ namespace RFIDSocket
}
}
+ ///
+ /// 清除报警
+ ///
+ ///
+ public bool ClearAllError()
+ {
+ return StateService.SetAllNoError();
+ }
+
+ ///
+ /// 秒转时间
+ ///
+ ///
+ ///
private string SecondToTime(int t)
{
int m = t / 60;
@@ -72,5 +96,7 @@ namespace RFIDSocket
}
return m.ToString("00") + " 分 " + s.ToString("00") + " 秒";
}
+
+
}
}