diff --git a/HighWayIot.TouchSocket/ClientStringAnalysis.cs b/HighWayIot.TouchSocket/ClientStringAnalysis.cs
new file mode 100644
index 0000000..133f37a
--- /dev/null
+++ b/HighWayIot.TouchSocket/ClientStringAnalysis.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms.VisualStyles;
+
+namespace HighWayIot.TouchSocket
+{
+ ///
+ /// 客户端字符串解析
+ ///
+ public class ClientStringAnalysis
+ {
+ ///
+ /// Getinfo信号解析
+ /// 格式为
+ /// From 001
+ /// qwertyuiopasdfghjklzxcvbnm[]\;',./!@#$%^&*()_+1234567890-=`~
+ ///
+ /// 所有的From信号
+ public static string[] GetInfoAnalyzer(string mes)
+ {
+ if (string.IsNullOrWhiteSpace(mes))
+ {
+ return Array.Empty();
+ }
+
+ // 按行分割输入
+ string[] lines = mes.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
+ List result = new List();
+
+ foreach (string line in lines)
+ {
+ // 检查并提取符合格式的 "From XXX"
+ if (line.StartsWith(" > From "))
+ {
+ string number = line.Substring(8, 3); // 提取后三位数字
+ result.Add(number);
+ }
+ }
+
+ return result.ToArray();
+ }
+ }
+}
diff --git a/HighWayIot.TouchSocket/HighWayIot.TouchSocket.csproj b/HighWayIot.TouchSocket/HighWayIot.TouchSocket.csproj
index 5e946b4..0fffefd 100644
--- a/HighWayIot.TouchSocket/HighWayIot.TouchSocket.csproj
+++ b/HighWayIot.TouchSocket/HighWayIot.TouchSocket.csproj
@@ -102,6 +102,7 @@
+
diff --git a/HighWayIot.TouchSocket/TcpClientServer.cs b/HighWayIot.TouchSocket/TcpClientServer.cs
index d2afb03..a182f87 100644
--- a/HighWayIot.TouchSocket/TcpClientServer.cs
+++ b/HighWayIot.TouchSocket/TcpClientServer.cs
@@ -21,6 +21,16 @@ namespace HighWayIot.TouchSocket
TcpClient tcpClient = new TcpClient();
+ ///
+ /// 字符串数组转换为int数组
+ ///
+ public Action GetBinCode;
+
+ public Action GetString;
+
+ ///
+ /// 客户端状态获取
+ ///
public bool ClientState
{
get => tcpClient.Online;
@@ -32,59 +42,113 @@ namespace HighWayIot.TouchSocket
///
public async Task ClientConnect(string ip, string port)
{
-
-
- tcpClient.Connecting = (client, e) =>
+ try
{
- 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;
- };
+ if (!string.IsNullOrEmpty(tcpClient.IP))
+ {
+ tcpClient.Connect();
+ tcpClient.Logger.Info("客户端成功连接");
+ return true;
+ }
+ 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 = async (client, e) =>
+ {
+ //从服务器收到信息。但是一般byteBlock和requestInfo会根据适配器呈现不同的值。
+ var mes = e.ByteBlock.Span.ToString(Encoding.UTF8);
+ logHelper.Info($"客户端接收到信息:{mes}");
+ if (await MessageAnalyzer(mes))
+ {
+ logHelper.Info("数据解析成功");
+ }
+ else
+ {
+ logHelper.Error("数据解析失败或者getinfo信号发送失败");
+ }
+ };
- //载入配置
- await tcpClient.SetupAsync(new TouchSocketConfig()
- .SetRemoteIPHost($"{ip}:{port}")
- .ConfigureContainer(a =>
- {
- a.AddConsoleLogger();//添加一个日志注入
- }));
+ //载入配置
+ await tcpClient.SetupAsync(new TouchSocketConfig()
+ .SetRemoteIPHost($"{ip}:{port}")
+ .ConfigureContainer(a =>
+ {
+ a.AddConsoleLogger();//添加一个日志注入
+ }));
- await tcpClient.ConnectAsync();//调用连接,当连接不成功时,会抛出异常。
+ tcpClient.Connect();//调用连接,当连接不成功时,会抛出异常。
- Result result = await tcpClient.TryConnectAsync();//或者可以调用TryConnectAsync
- if (result.IsSuccess())
- {
tcpClient.Logger.Info("客户端成功连接");
+
+ return true;
}
- else
+ catch (Exception ex)
{
- tcpClient.Logger.Info("客户端连接失败");
+ tcpClient.Logger.Info("客户端连接失败" + ex);
+ return false;
}
- return result.IsSuccess();
}
- public bool SendMessage(string message)
+ ///
+ /// 接收数据分析
+ ///
+ ///
+ ///
+ public async Task MessageAnalyzer(string mes)
{
try
{
- tcpClient.SendAsync(message);
+ if (mes.Contains("OK"))
+ {
+ await Send("getinfo");
+ }
+ else
+ {
+ //string[] binNoList = ClientStringAnalysis.GetInfoAnalyzer(mes);
+ GetString.Invoke(mes);
+ }
+ return true;
+ }
+ catch (ClientNotConnectedException ex)
+ {
+ logHelper.Error("发送数据发生错误" + ex);
+ return false;
+ }
+ catch (OverlengthException ex)
+ {
+ logHelper.Error("发送数据发生错误" + ex);
+ return false;
+ }
+ catch(Exception ex)
+ {
+ logHelper.Error("数据解析类发生错误" + ex);
+ return false;
+ }
+ }
+
+ ///
+ /// 信息发送
+ ///
+ ///
+ ///
+ public async Task Send(string message)
+ {
+ try
+ {
+ await tcpClient.SendAsync(message);
return true;
}
catch (Exception e)
@@ -94,11 +158,15 @@ namespace HighWayIot.TouchSocket
}
}
- public bool ClientClose()
+ ///
+ /// 客户端关闭
+ ///
+ ///
+ public async Task ClientClose()
{
try
{
- tcpClient.CloseAsync();
+ await tcpClient.CloseAsync();
return true;
}
catch(Exception e)
diff --git a/HighWayIot.TouchSocket/TcpServer.cs b/HighWayIot.TouchSocket/TcpServer.cs
index db24eea..40ac63a 100644
--- a/HighWayIot.TouchSocket/TcpServer.cs
+++ b/HighWayIot.TouchSocket/TcpServer.cs
@@ -147,6 +147,10 @@ namespace HighWayIot.TouchSocket
{
ServerBufferAnalysis.RFIDCodeSocket(bytes);
}
+ else
+ {
+ logHelper.Error("未知数据格式!");
+ }
}
}
diff --git a/RFIDSocket/Configuration.xml b/RFIDSocket/Configuration.xml
index cce621d..98e01e8 100644
--- a/RFIDSocket/Configuration.xml
+++ b/RFIDSocket/Configuration.xml
@@ -3,5 +3,11 @@
192.168.1.100
1500
192.168.0.7:1500
- 354
+ 192.168.0.7:1500
+ 192.168.0.7:1500
+ 192.168.0.7:1500
+ 192.168.0.7:1500
+ 192.168.0.7:1500
+ 192.168.0.7:1500
+ 100
diff --git a/RFIDSocket/MultiFuncLoading.Designer.cs b/RFIDSocket/MultiFuncLoading.Designer.cs
new file mode 100644
index 0000000..c557ee1
--- /dev/null
+++ b/RFIDSocket/MultiFuncLoading.Designer.cs
@@ -0,0 +1,124 @@
+namespace RFIDSocket
+{
+ partial class MultiFuncLoading
+ {
+ ///
+ /// 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.label1 = new System.Windows.Forms.Label();
+ this.lbl_tips = new System.Windows.Forms.Label();
+ this.lbl_tips_son = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.lbl_jd = new System.Windows.Forms.Label();
+ this.lbl_cur = new System.Windows.Forms.TextBox();
+ this.SuspendLayout();
+ //
+ // label1
+ //
+ this.label1.Image = global::RFIDSocket.Properties.Resources.loading3;
+ this.label1.Location = new System.Drawing.Point(3, 10);
+ this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(75, 69);
+ this.label1.TabIndex = 0;
+ //
+ // lbl_tips
+ //
+ this.lbl_tips.AutoSize = true;
+ this.lbl_tips.Location = new System.Drawing.Point(79, 13);
+ this.lbl_tips.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+ this.lbl_tips.Name = "lbl_tips";
+ this.lbl_tips.Size = new System.Drawing.Size(107, 12);
+ this.lbl_tips.TabIndex = 3;
+ this.lbl_tips.Text = "加载中,请稍等...";
+ //
+ // lbl_tips_son
+ //
+ this.lbl_tips_son.AutoSize = true;
+ this.lbl_tips_son.Location = new System.Drawing.Point(79, 38);
+ this.lbl_tips_son.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+ this.lbl_tips_son.Name = "lbl_tips_son";
+ this.lbl_tips_son.Size = new System.Drawing.Size(113, 12);
+ this.lbl_tips_son.TabIndex = 4;
+ this.lbl_tips_son.Text = "Please Waitting...";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(79, 61);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(65, 12);
+ this.label2.TabIndex = 5;
+ this.label2.Text = "执行进度:";
+ //
+ // lbl_jd
+ //
+ this.lbl_jd.AutoSize = true;
+ this.lbl_jd.Location = new System.Drawing.Point(145, 61);
+ this.lbl_jd.Name = "lbl_jd";
+ this.lbl_jd.Size = new System.Drawing.Size(41, 12);
+ this.lbl_jd.TabIndex = 6;
+ this.lbl_jd.Text = "label3";
+ //
+ // lbl_cur
+ //
+ this.lbl_cur.Location = new System.Drawing.Point(12, 88);
+ this.lbl_cur.Multiline = true;
+ this.lbl_cur.Name = "lbl_cur";
+ this.lbl_cur.ScrollBars = System.Windows.Forms.ScrollBars.Both;
+ this.lbl_cur.Size = new System.Drawing.Size(333, 101);
+ this.lbl_cur.TabIndex = 9;
+ //
+ // MultiFuncLoading
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(357, 201);
+ this.Controls.Add(this.lbl_cur);
+ this.Controls.Add(this.lbl_jd);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.lbl_tips_son);
+ this.Controls.Add(this.lbl_tips);
+ this.Controls.Add(this.label1);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+ this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.Name = "MultiFuncLoading";
+ this.Text = "Loading";
+ this.Load += new System.EventHandler(this.Loading_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Label lbl_tips;
+ private System.Windows.Forms.Label lbl_tips_son;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Label lbl_jd;
+ private System.Windows.Forms.TextBox lbl_cur;
+ }
+}
\ No newline at end of file
diff --git a/RFIDSocket/MultiFuncLoading.cs b/RFIDSocket/MultiFuncLoading.cs
new file mode 100644
index 0000000..bdbbea5
--- /dev/null
+++ b/RFIDSocket/MultiFuncLoading.cs
@@ -0,0 +1,65 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace RFIDSocket
+{
+ public partial class MultiFuncLoading : Form
+ {
+ //保存父窗口信息,主要用于居中显示加载窗体
+ private Form partentForm = null;
+ public MultiFuncLoading(Form partentForm)
+ {
+ InitializeComponent();
+ this.partentForm = partentForm;
+ }
+
+ private void Loading_Load(object sender, EventArgs e)
+ {
+ //设置一些Loading窗体信息
+ this.FormBorderStyle = FormBorderStyle.FixedSingle;
+ this.ControlBox = false;
+ this.Text = "有进度,有提示,有取消按钮 Loading...";
+ // 下面的方法用来使得Loading窗体居中父窗体显示
+ int parentForm_Position_x = this.partentForm.Location.X;
+ int parentForm_Position_y = this.partentForm.Location.Y;
+ int parentForm_Width = this.partentForm.Width;
+ int parentForm_Height = this.partentForm.Height;
+
+ int start_x = (int)(parentForm_Position_x + (parentForm_Width - this.Width) / 2);
+ int start_y = (int)(parentForm_Position_y + (parentForm_Height - this.Height) / 2);
+ this.Location = new System.Drawing.Point(start_x, start_y);
+
+ }
+
+ /////
+ ///// 改变Loading的进度
+ /////
+ /////
+ public void SetTxt(string title = "Loading...", string lbl1 = "加载中,请稍等...", string lbl2 = "Please Waitting...")
+ {
+ // 采用Invoke形式进行操作
+ this.Invoke(new MethodInvoker(() =>
+ {
+ this.Text = title;
+ this.lbl_tips.Text = lbl1;
+ this.lbl_tips_son.Text = lbl2;
+ }));
+ }
+ public void SetJD(string JDStr, string curstr)
+ {
+ // 采用Invoke形式进行操作
+ this.Invoke(new MethodInvoker(() =>
+ {
+ this.lbl_jd.Text = JDStr;
+ this.lbl_cur.AppendText(curstr + "\r\n");
+ }));
+ }
+ }
+}
diff --git a/RFIDSocket/MultiFuncLoading.resx b/RFIDSocket/MultiFuncLoading.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/RFIDSocket/MultiFuncLoading.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
\ No newline at end of file
diff --git a/RFIDSocket/Properties/Resources.Designer.cs b/RFIDSocket/Properties/Resources.Designer.cs
index 10c3172..7771f59 100644
--- a/RFIDSocket/Properties/Resources.Designer.cs
+++ b/RFIDSocket/Properties/Resources.Designer.cs
@@ -1,71 +1,73 @@
//------------------------------------------------------------------------------
//
// 此代码由工具生成。
-// 运行时版本: 4.0.30319.42000
+// 运行时版本:4.0.30319.42000
//
-// 对此文件的更改可能导致不正确的行为,如果
-// 重新生成代码,则所做更改将丢失。
+// 对此文件的更改可能会导致不正确的行为,并且如果
+// 重新生成代码,这些更改将会丢失。
//
//------------------------------------------------------------------------------
-namespace RFIDSocket.Properties
-{
-
-
+namespace RFIDSocket.Properties {
+ using System;
+
+
///
- /// 强类型资源类,用于查找本地化字符串等。
+ /// 一个强类型的资源类,用于查找本地化的字符串等。
///
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources
- {
-
+ internal class Resources {
+
private static global::System.Resources.ResourceManager resourceMan;
-
+
private static global::System.Globalization.CultureInfo resourceCulture;
-
+
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources()
- {
+ internal Resources() {
}
-
+
///
- /// 返回此类使用的缓存 ResourceManager 实例。
+ /// 返回此类使用的缓存的 ResourceManager 实例。
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager
- {
- get
- {
- if ((resourceMan == null))
- {
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RFIDSocket.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
-
+
///
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写。
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture
- {
- get
- {
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
return resourceCulture;
}
- set
- {
+ set {
resourceCulture = value;
}
}
+
+ ///
+ /// 查找 System.Drawing.Bitmap 类型的本地化资源。
+ ///
+ internal static System.Drawing.Bitmap loading3 {
+ get {
+ object obj = ResourceManager.GetObject("loading3", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
}
}
diff --git a/RFIDSocket/Properties/Resources.resx b/RFIDSocket/Properties/Resources.resx
index af7dbeb..59ae8d1 100644
--- a/RFIDSocket/Properties/Resources.resx
+++ b/RFIDSocket/Properties/Resources.resx
@@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
- : System.Serialization.Formatters.Binary.BinaryFormatter
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
: and then encoded with base64 encoding.
-->
+
@@ -68,9 +69,10 @@
-
+
+
@@ -85,9 +87,10 @@
-
+
+
@@ -109,9 +112,13 @@
2.0
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ ..\loading3.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
\ No newline at end of file
diff --git a/RFIDSocket/RFIDBinAudlt.Designer.cs b/RFIDSocket/RFIDBinAudlt.Designer.cs
index 07e9ff6..dd8ccd9 100644
--- a/RFIDSocket/RFIDBinAudlt.Designer.cs
+++ b/RFIDSocket/RFIDBinAudlt.Designer.cs
@@ -357,7 +357,7 @@
// label3
//
this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(478, 12);
+ this.label3.Location = new System.Drawing.Point(457, 10);
this.label3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(101, 12);
@@ -417,9 +417,7 @@
this.MaximizeBox = false;
this.Name = "RFIDBinAudlt";
this.Text = "格口盘点";
- this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.RFIDBinAudlt_MouseDown);
- this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.RFIDBinAudlt_MouseMove);
- this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.RFIDBinAudlt_MouseUp);
+ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.RFIDBinAudlt_FormClosing);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.DataGroupBox.ResumeLayout(false);
this.ResumeLayout(false);
diff --git a/RFIDSocket/RFIDBinAudlt.cs b/RFIDSocket/RFIDBinAudlt.cs
index 0023231..4f5a00d 100644
--- a/RFIDSocket/RFIDBinAudlt.cs
+++ b/RFIDSocket/RFIDBinAudlt.cs
@@ -1,11 +1,15 @@
-using HighWayIot.TouchSocket;
+using HighWayIot.Log4net;
+using HighWayIot.TouchSocket;
+using Org.BouncyCastle.Utilities;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
+using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
@@ -15,31 +19,83 @@ namespace RFIDSocket
{
public partial class RFIDBinAudlt : Form
{
- private TcpClientServer TCPClient = TcpClientServer.Instance;
+ private TcpClientServer Client = TcpClientServer.Instance;
+ ///
+ /// 日志实例
+ ///
+ private static LogHelper logHelper = LogHelper.Instance;
+
+ ///
+ /// 前端列表实例
+ ///
private DataTable dt = new DataTable();
+ ///
+ /// xml读写实例
+ ///
+ XmlDocument xd = new XmlDocument();
+
+ ///
+ /// 运行时路径
+ ///
private string Path = System.Environment.CurrentDirectory;
+ ///
+ /// 所有适配器IP
+ ///
private string[] ServiceIPs;
+ ///
+ /// 格口编码集合
+ ///
+ private string[] BinCodes = new string[0];
+
+ ///
+ /// 格口编码返回结果字符串
+ ///
+ private StringBuilder BinCodesString = new StringBuilder();
+
+ ///
+ /// 应有格口数
+ ///
private int ServiceCount = -1;
+ ///
+ /// 正常格口数
+ ///
private int NormalCount = 0;
+ ///
+ /// 异常格口数
+ ///
private int ErrorCount = 0;
+ ///
+ /// 服务端端口
+ ///
string Port = string.Empty;
+ ///
+ /// 服务端地址
+ ///
string IP = string.Empty;
+ ///
+ /// 上次接受数据的时间
+ ///
+ DateTime LastInfoTime = DateTime.Now;
+
public RFIDBinAudlt()
{
InitializeComponent();
Init();
}
- private void Init()
+ ///
+ /// 初始化方法
+ ///
+ private async void Init()
{
GetSetting();
dataGridView.AutoGenerateColumns = false;
@@ -47,6 +103,9 @@ namespace RFIDSocket
{
dt.Columns.Add(column.HeaderText, typeof(string));
}
+
+ //Client.GetBinCode += AddBinCodeString;
+ Client.GetString += ConnectMessageString;
}
///
@@ -54,7 +113,6 @@ namespace RFIDSocket
///
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"
@@ -70,8 +128,10 @@ namespace RFIDSocket
}
XmlNode ServerIp = rootNode.SelectSingleNode("ConnectIp"); // 服务器IP
XmlNode ServerPort = rootNode.SelectSingleNode("ConnectPort"); // 服务器端口
- IP = ServerIp.InnerText;
- Port = ServerPort.InnerText;
+ IP = ServerIp.InnerText.Trim();
+ Port = ServerPort.InnerText.Trim();
+ IPText.Text = IP;
+ PortText.Text = Port;
}
///
@@ -81,16 +141,115 @@ namespace RFIDSocket
///
private void AudltButton_Click(object sender, EventArgs e)
{
+ BinCodes = new string[0];
+ BinCodesString.Clear();
+
+ MultiFuncLoading loadingfrm = new MultiFuncLoading(this);
+ SplashScreenManager loading = new SplashScreenManager(loadingfrm);
+ loading.ShowLoading();
+ loadingfrm.SetTxt("格口盘点中", $"共有{ServiceIPs.Length}个IP需要扫描", "Please Waitting...");
+
+ try
+ {
+ Task.Run(async () =>
+ {
+ int count = 0;
+ foreach (string s in ServiceIPs)
+ {
+ count++;
+ Client.Send($"connect {s}").GetAwaiter().GetResult();
+ loadingfrm.SetJD($"正在盘点{s} {count}/{ServiceIPs.Length}", $"正在盘点{s} {count}/{ServiceIPs.Length}");
+ do
+ {
+ await Task.Delay(500);
+ }
+ while (DateTime.Now - LastInfoTime <= TimeSpan.FromMilliseconds(3000));
+ }
+ }).GetAwaiter().GetResult();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("加载发生错误,请检查连接情况" + ex);
+ return;
+ }
+ finally
+ {
+ loading.CloseWaitForm();
+ }
+ string sss = BinCodesString.ToString();
+
+ logHelper.Info($"此次盘点的字符串为{sss}");
+
+ BinCodes = ClientStringAnalysis.GetInfoAnalyzer(sss);
+
+ int[] intArray = BinCodes
+ .Select(a => int.Parse(a)) // 转换为整型
+ .Distinct() // 去重
+ .OrderBy(x => x) // 排序
+ .ToArray(); // 转换为数组
+
NormalCount = 0;
ErrorCount = 0;
- GridViewRefresh(GenerateRandomBoolArray(ServiceCount));
+
+ GridViewRefresh(ConvertToBoolArray(intArray, ServiceCount));
+
NormalCountLabel.Text = NormalCount.ToString();
ErrorCountLabel.Text = ErrorCount.ToString();
}
+ ///
+ /// 字符串连接委托类
+ ///
+ ///
+ private void ConnectMessageString(string message)
+ {
+ LastInfoTime = DateTime.Now;
+ BinCodesString.Append(message);
+ }
+
+ ///
+ /// 获取BinCode委托方法
+ ///
+ private void AddBinCodeString(string[] binCodes)
+ {
+ ///拼接BinCode
+ Task.Run(() =>
+ {
+ string[] temp = new string[binCodes.Length + BinCodes.Length];
+ Array.Copy(BinCodes, 0, temp, 0, BinCodes.Length);
+ Array.Copy(binCodes, 0, temp, BinCodes.Length, binCodes.Length);
+ BinCodes = temp;
+ });
+ }
+
+ ///
+ /// int数组转化为bool数组
+ ///
+ ///
+ ///
+ ///
+ private bool[] ConvertToBoolArray(int[] intArray, int count)
+ {
+ // 初始化一个长度为count的bool数组,默认为false
+ bool[] result = new bool[count];
+
+ // 遍历intArray,将对应位置的值设置为true
+ foreach (int num in intArray)
+ {
+ if (num >= 1 && num <= count) // 确保num在合法范围内
+ {
+ result[num - 1] = true; // 将下标为num-1的值设置为true
+ }
+ }
+
+ return result;
+ }
+
+
///
/// 表格刷新
///
+ /// bool状态列表
private void GridViewRefresh(bool[] states)
{
if (ServiceCount < 0)
@@ -188,10 +347,13 @@ namespace RFIDSocket
///
private void MonitorOnOff_Click(object sender, EventArgs e)
{
- if (!TCPClient.ClientState)
+ if (!Client.ClientState)
{
- if (TCPClient.ClientConnect(IP, Port).GetAwaiter().GetResult())
+ if (Client.ClientConnect(IP, Port).GetAwaiter().GetResult())
{
+ MonitorOnOff.Text = "断开客户端";
+ MonitorState.Text = "开";
+ MonitorState.BackColor = Color.Green;
MessageBox.Show("服务端连接成功!");
}
else
@@ -199,10 +361,13 @@ namespace RFIDSocket
MessageBox.Show("服务端连接失败!");
}
}
- else if (TCPClient.ClientState)
+ else if (Client.ClientState)
{
- if (TCPClient.ClientClose())
+ if (Client.ClientClose().GetAwaiter().GetResult())
{
+ MonitorOnOff.Text = "连接客户端";
+ MonitorState.Text = "关";
+ MonitorState.BackColor = Color.Transparent;
MessageBox.Show("服务端断开成功!");
}
else
@@ -219,44 +384,40 @@ namespace RFIDSocket
///
private void SetAddress_Click(object sender, EventArgs e)
{
-
- }
-
- #region 鼠标拖拽
-
- private bool isDragging = false; // 用于检测是否正在拖动
-
- private Point lastLocation; // 保存上次鼠标位置
-
- private void RFIDBinAudlt_MouseDown(object sender, MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Left)
+ try
{
- isDragging = true;
- lastLocation = e.Location; // 记录鼠标按下时的位置
+ IP = IPText.Text.Trim();
+ Port = PortText.Text.Trim();
+ //ip保存
+ XmlNode rootNode = xd.SelectSingleNode("BinAudlt");//得到xml文档的根节点
+ XmlNode ServerIp = rootNode.SelectSingleNode("ConnectIp"); // 服务器IP
+ XmlNode ServerPort = rootNode.SelectSingleNode("ConnectPort"); // 服务器端口
+ ServerIp.InnerText = IP;
+ ServerPort.InnerText = Port;
+ xd.Save($"{Path}\\Configuration.xml");
+ MessageBox.Show("保存成功!");
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("服务端地址 XML文件保存失败!");
}
}
///
- /// 全局拖拽
+ /// 关闭窗口事件
///
///
///
- private void RFIDBinAudlt_MouseMove(object sender, MouseEventArgs e)
+ private void RFIDBinAudlt_FormClosing(object sender, FormClosingEventArgs e)
{
- if (isDragging)
+ if (Client.ClientState)
{
- this.Top = this.Top + (e.Y - lastLocation.Y);
- this.Left = this.Left + (e.X - lastLocation.X);
+ if (!Client.ClientClose().GetAwaiter().GetResult())
+ {
+ MessageBox.Show("服务端断开失败!请检查原因后重新关闭或重试");
+ }
}
}
- private void RFIDBinAudlt_MouseUp(object sender, MouseEventArgs e)
- {
- isDragging = false;
- }
-
- #endregion
-
}
}
diff --git a/RFIDSocket/RFIDBinAudlt.resx b/RFIDSocket/RFIDBinAudlt.resx
index 67a9371..6d60700 100644
--- a/RFIDSocket/RFIDBinAudlt.resx
+++ b/RFIDSocket/RFIDBinAudlt.resx
@@ -177,64 +177,4 @@
True
-
- 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 79f7ff5..516524c 100644
--- a/RFIDSocket/RFIDLog.Designer.cs
+++ b/RFIDSocket/RFIDLog.Designer.cs
@@ -56,6 +56,12 @@
this.Label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
+ this.ReadSuccessPercent = new System.Windows.Forms.Label();
+ this.ErrorReadNum = new System.Windows.Forms.Label();
+ this.NormalReadNum = new System.Windows.Forms.Label();
+ this.label9 = new System.Windows.Forms.Label();
+ this.label8 = new System.Windows.Forms.Label();
+ this.label7 = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
@@ -307,11 +313,83 @@
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
+ // ReadSuccessPercent
+ //
+ this.ReadSuccessPercent.AutoSize = true;
+ this.ReadSuccessPercent.Font = new System.Drawing.Font("宋体", 12F);
+ this.ReadSuccessPercent.Location = new System.Drawing.Point(132, 836);
+ this.ReadSuccessPercent.Margin = new System.Windows.Forms.Padding(3, 3, 3, 0);
+ this.ReadSuccessPercent.Name = "ReadSuccessPercent";
+ this.ReadSuccessPercent.Size = new System.Drawing.Size(31, 16);
+ this.ReadSuccessPercent.TabIndex = 18;
+ this.ReadSuccessPercent.Text = "N/A";
+ //
+ // ErrorReadNum
+ //
+ this.ErrorReadNum.AutoSize = true;
+ this.ErrorReadNum.Font = new System.Drawing.Font("宋体", 12F);
+ this.ErrorReadNum.Location = new System.Drawing.Point(132, 802);
+ this.ErrorReadNum.Margin = new System.Windows.Forms.Padding(3, 3, 3, 0);
+ this.ErrorReadNum.Name = "ErrorReadNum";
+ this.ErrorReadNum.Size = new System.Drawing.Size(31, 16);
+ this.ErrorReadNum.TabIndex = 17;
+ this.ErrorReadNum.Text = "N/A";
+ //
+ // NormalReadNum
+ //
+ this.NormalReadNum.AutoSize = true;
+ this.NormalReadNum.Font = new System.Drawing.Font("宋体", 12F);
+ this.NormalReadNum.Location = new System.Drawing.Point(132, 768);
+ this.NormalReadNum.Margin = new System.Windows.Forms.Padding(3, 3, 3, 0);
+ this.NormalReadNum.Name = "NormalReadNum";
+ this.NormalReadNum.Size = new System.Drawing.Size(31, 16);
+ this.NormalReadNum.TabIndex = 16;
+ this.NormalReadNum.Text = "N/A";
+ //
+ // label9
+ //
+ this.label9.AutoSize = true;
+ this.label9.Font = new System.Drawing.Font("宋体", 12F);
+ this.label9.Location = new System.Drawing.Point(11, 768);
+ this.label9.Margin = new System.Windows.Forms.Padding(15, 15, 15, 3);
+ this.label9.Name = "label9";
+ this.label9.Size = new System.Drawing.Size(119, 16);
+ this.label9.TabIndex = 15;
+ this.label9.Text = "正常读码数量:";
+ //
+ // label8
+ //
+ this.label8.AutoSize = true;
+ this.label8.Font = new System.Drawing.Font("宋体", 12F);
+ this.label8.Location = new System.Drawing.Point(11, 802);
+ this.label8.Margin = new System.Windows.Forms.Padding(15, 15, 15, 3);
+ this.label8.Name = "label8";
+ this.label8.Size = new System.Drawing.Size(119, 16);
+ this.label8.TabIndex = 14;
+ this.label8.Text = "异常读码数量:";
+ //
+ // label7
+ //
+ this.label7.AutoSize = true;
+ this.label7.Font = new System.Drawing.Font("宋体", 12F);
+ this.label7.Location = new System.Drawing.Point(11, 836);
+ this.label7.Margin = new System.Windows.Forms.Padding(15, 15, 15, 3);
+ this.label7.Name = "label7";
+ this.label7.Size = new System.Drawing.Size(103, 16);
+ this.label7.TabIndex = 13;
+ this.label7.Text = "读码成功率:";
+ //
// 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.ReadSuccessPercent);
+ this.Controls.Add(this.ErrorReadNum);
+ this.Controls.Add(this.NormalReadNum);
+ this.Controls.Add(this.label9);
+ this.Controls.Add(this.label8);
+ this.Controls.Add(this.label7);
this.Controls.Add(this.button1);
this.Controls.Add(this.label2);
this.Controls.Add(this.Label1);
@@ -367,5 +445,11 @@
private System.Windows.Forms.Label Label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button1;
+ private System.Windows.Forms.Label ReadSuccessPercent;
+ private System.Windows.Forms.Label ErrorReadNum;
+ private System.Windows.Forms.Label NormalReadNum;
+ private System.Windows.Forms.Label label9;
+ private System.Windows.Forms.Label label8;
+ private System.Windows.Forms.Label label7;
}
}
\ No newline at end of file
diff --git a/RFIDSocket/RFIDLog.cs b/RFIDSocket/RFIDLog.cs
index f402940..a997ed4 100644
--- a/RFIDSocket/RFIDLog.cs
+++ b/RFIDSocket/RFIDLog.cs
@@ -47,6 +47,7 @@ namespace RFIDSocket
LogContent.DataSource = null;
LogContent.DataSource = LogControl.LogTimeSelect(rFIDContents, StartTime.Value, EndTime.Value);
}
+ NumCount();
}
private void ReadKindSelect_Click(object sender, EventArgs e)
@@ -56,6 +57,7 @@ namespace RFIDSocket
LogContent.DataSource = null;
LogContent.DataSource = LogControl.LogReadKindSelect(rFIDContents, ReadKind.Text);
}
+ NumCount();
}
private void DeviceNoSelect_Click(object sender, EventArgs e)
@@ -70,6 +72,7 @@ namespace RFIDSocket
LogContent.DataSource = null;
LogContent.DataSource = LogControl.LogDeviceNoSelect(rFIDContents, no);
}
+ NumCount();
}
private void ContentSelect_Click(object sender, EventArgs e)
@@ -79,6 +82,7 @@ namespace RFIDSocket
LogContent.DataSource = null;
LogContent.DataSource = LogControl.LogContentSelect(rFIDContents, Content.Text);
}
+ NumCount();
}
private void SelectAll_Click(object sender, EventArgs e)
@@ -100,6 +104,22 @@ namespace RFIDSocket
ReadKind.Text),
StartTime.Value, EndTime.Value);
}
+ NumCount();
+ }
+
+ private void NumCount()
+ {
+ int normalCount = rFIDContents.Where(x => x.ReadKind == "GR").Count();
+ int errorCount = rFIDContents.Where(x => x.ReadKind == "MR" || x.ReadKind == "NB").Count();
+
+ NormalReadNum.Text = normalCount.ToString();
+ ErrorReadNum.Text = errorCount.ToString();
+
+ //算比例
+ float percent = (float)normalCount / (float)rFIDContents.Count;
+ percent *= 100f;
+
+ ReadSuccessPercent.Text = $"%{percent}";
}
///
diff --git a/RFIDSocket/RFIDSocket.Designer.cs b/RFIDSocket/RFIDSocket.Designer.cs
index c3557f9..56a5c60 100644
--- a/RFIDSocket/RFIDSocket.Designer.cs
+++ b/RFIDSocket/RFIDSocket.Designer.cs
@@ -44,15 +44,7 @@
this.label4 = new System.Windows.Forms.Label();
this.MonitorState = new System.Windows.Forms.Label();
this.TableTimer = new System.Windows.Forms.Timer(this.components);
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.StateData = new System.Windows.Forms.DataGridView();
- this.deviceNoDataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.LogTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.rFIDStateBindingSource = new System.Windows.Forms.BindingSource(this.components);
- this.groupBox3 = new System.Windows.Forms.GroupBox();
- this.HeartbeatData = new System.Windows.Forms.DataGridView();
- this.deviceNoDataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.timeSpanDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.rFIDHeartbeatBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.PgUp = new System.Windows.Forms.Button();
this.PgDn = new System.Windows.Forms.Button();
@@ -61,30 +53,45 @@
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();
this.panel2 = new System.Windows.Forms.Panel();
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.label6 = new System.Windows.Forms.Label();
+ this.groupBox3 = new System.Windows.Forms.GroupBox();
+ this.label10 = new System.Windows.Forms.Label();
+ this.label9 = new System.Windows.Forms.Label();
+ this.label8 = new System.Windows.Forms.Label();
+ this.label7 = new System.Windows.Forms.Label();
+ this.label5 = new System.Windows.Forms.Label();
+ this.label11 = new System.Windows.Forms.Label();
+ this.NormalReadNum = new System.Windows.Forms.Label();
+ this.ErrorReadNum = new System.Windows.Forms.Label();
+ this.ReadSuccessPercent = new System.Windows.Forms.Label();
+ this.ErrorCountDataGridView = new System.Windows.Forms.DataGridView();
+ this.BinNo = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.ErrorCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.CotentData)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.rFIDContentBindingSource)).BeginInit();
- this.groupBox2.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.StateData)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.rFIDStateBindingSource)).BeginInit();
- this.groupBox3.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.HeartbeatData)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.rFIDHeartbeatBindingSource)).BeginInit();
this.ControlGrupbox.SuspendLayout();
this.MainReadGroupBox.SuspendLayout();
this.PageGroupBox.SuspendLayout();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
+ this.groupBox1.SuspendLayout();
+ this.groupBox3.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.ErrorCountDataGridView)).BeginInit();
this.SuspendLayout();
//
// CotentData
//
+ this.CotentData.AllowUserToAddRows = false;
+ this.CotentData.AllowUserToDeleteRows = false;
this.CotentData.AllowUserToResizeRows = false;
this.CotentData.AutoGenerateColumns = false;
this.CotentData.ColumnHeadersHeight = 20;
@@ -99,6 +106,7 @@
this.CotentData.Location = new System.Drawing.Point(3, 17);
this.CotentData.Margin = new System.Windows.Forms.Padding(2);
this.CotentData.Name = "CotentData";
+ this.CotentData.ReadOnly = true;
this.CotentData.RowHeadersVisible = false;
this.CotentData.RowHeadersWidth = 51;
this.CotentData.RowTemplate.Height = 17;
@@ -110,6 +118,7 @@
this.ID.DataPropertyName = "ID";
this.ID.HeaderText = "ID";
this.ID.Name = "ID";
+ this.ID.ReadOnly = true;
this.ID.Width = 40;
//
// deviceNoDataGridViewTextBoxColumn
@@ -118,6 +127,7 @@
this.deviceNoDataGridViewTextBoxColumn.HeaderText = "格口";
this.deviceNoDataGridViewTextBoxColumn.MinimumWidth = 6;
this.deviceNoDataGridViewTextBoxColumn.Name = "deviceNoDataGridViewTextBoxColumn";
+ this.deviceNoDataGridViewTextBoxColumn.ReadOnly = true;
this.deviceNoDataGridViewTextBoxColumn.Width = 40;
//
// readKindDataGridViewTextBoxColumn
@@ -126,6 +136,7 @@
this.readKindDataGridViewTextBoxColumn.HeaderText = "读码结果";
this.readKindDataGridViewTextBoxColumn.MinimumWidth = 6;
this.readKindDataGridViewTextBoxColumn.Name = "readKindDataGridViewTextBoxColumn";
+ this.readKindDataGridViewTextBoxColumn.ReadOnly = true;
this.readKindDataGridViewTextBoxColumn.Width = 60;
//
// contentDataGridViewTextBoxColumn
@@ -135,6 +146,7 @@
this.contentDataGridViewTextBoxColumn.HeaderText = "条码内容";
this.contentDataGridViewTextBoxColumn.MinimumWidth = 6;
this.contentDataGridViewTextBoxColumn.Name = "contentDataGridViewTextBoxColumn";
+ this.contentDataGridViewTextBoxColumn.ReadOnly = true;
//
// logTimeDataGridViewTextBoxColumn
//
@@ -142,6 +154,7 @@
this.logTimeDataGridViewTextBoxColumn.HeaderText = "读取时间";
this.logTimeDataGridViewTextBoxColumn.MinimumWidth = 6;
this.logTimeDataGridViewTextBoxColumn.Name = "logTimeDataGridViewTextBoxColumn";
+ this.logTimeDataGridViewTextBoxColumn.ReadOnly = true;
this.logTimeDataGridViewTextBoxColumn.Width = 105;
//
// rFIDContentBindingSource
@@ -226,109 +239,10 @@
this.TableTimer.Interval = 1000;
this.TableTimer.Tick += new System.EventHandler(this.TableTimer_Tick);
//
- // groupBox2
- //
- this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox2.AutoSize = true;
- this.groupBox2.Controls.Add(this.StateData);
- 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, 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[] {
- this.deviceNoDataGridViewTextBoxColumn1,
- this.LogTime});
- this.StateData.DataSource = this.rFIDStateBindingSource;
- this.StateData.Dock = System.Windows.Forms.DockStyle.Fill;
- this.StateData.Location = new System.Drawing.Point(2, 16);
- this.StateData.Margin = new System.Windows.Forms.Padding(2);
- this.StateData.Name = "StateData";
- this.StateData.RowHeadersVisible = false;
- this.StateData.RowHeadersWidth = 51;
- this.StateData.RowTemplate.Height = 20;
- this.StateData.Size = new System.Drawing.Size(181, 608);
- this.StateData.TabIndex = 0;
- //
- // deviceNoDataGridViewTextBoxColumn1
- //
- this.deviceNoDataGridViewTextBoxColumn1.DataPropertyName = "DeviceNo";
- this.deviceNoDataGridViewTextBoxColumn1.HeaderText = "编号";
- this.deviceNoDataGridViewTextBoxColumn1.MinimumWidth = 6;
- this.deviceNoDataGridViewTextBoxColumn1.Name = "deviceNoDataGridViewTextBoxColumn1";
- this.deviceNoDataGridViewTextBoxColumn1.Width = 60;
- //
- // LogTime
- //
- this.LogTime.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.LogTime.DataPropertyName = "LogTime";
- this.LogTime.HeaderText = "报警时间";
- this.LogTime.MinimumWidth = 6;
- this.LogTime.Name = "LogTime";
- //
// rFIDStateBindingSource
//
this.rFIDStateBindingSource.DataSource = typeof(HighWayIot.Repository.domain.RFIDState);
//
- // groupBox3
- //
- 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(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, 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[] {
- this.deviceNoDataGridViewTextBoxColumn2,
- this.timeSpanDataGridViewTextBoxColumn});
- this.HeartbeatData.DataSource = this.rFIDHeartbeatBindingSource;
- this.HeartbeatData.Dock = System.Windows.Forms.DockStyle.Fill;
- this.HeartbeatData.Location = new System.Drawing.Point(2, 16);
- this.HeartbeatData.Margin = new System.Windows.Forms.Padding(2);
- this.HeartbeatData.Name = "HeartbeatData";
- this.HeartbeatData.RowHeadersVisible = false;
- this.HeartbeatData.RowHeadersWidth = 51;
- this.HeartbeatData.RowTemplate.Height = 20;
- this.HeartbeatData.Size = new System.Drawing.Size(181, 608);
- this.HeartbeatData.TabIndex = 0;
- //
- // deviceNoDataGridViewTextBoxColumn2
- //
- this.deviceNoDataGridViewTextBoxColumn2.DataPropertyName = "DeviceNo";
- this.deviceNoDataGridViewTextBoxColumn2.HeaderText = "编号";
- this.deviceNoDataGridViewTextBoxColumn2.MinimumWidth = 6;
- this.deviceNoDataGridViewTextBoxColumn2.Name = "deviceNoDataGridViewTextBoxColumn2";
- this.deviceNoDataGridViewTextBoxColumn2.Width = 60;
- //
- // timeSpanDataGridViewTextBoxColumn
- //
- this.timeSpanDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.timeSpanDataGridViewTextBoxColumn.DataPropertyName = "TimeSpan";
- this.timeSpanDataGridViewTextBoxColumn.HeaderText = "距上一次心跳时间";
- this.timeSpanDataGridViewTextBoxColumn.MinimumWidth = 6;
- this.timeSpanDataGridViewTextBoxColumn.Name = "timeSpanDataGridViewTextBoxColumn";
- //
// rFIDHeartbeatBindingSource
//
this.rFIDHeartbeatBindingSource.DataSource = typeof(HighWayIot.Repository.domain.RFIDHeartbeat);
@@ -399,7 +313,6 @@
//
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);
@@ -427,17 +340,6 @@
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;
@@ -506,28 +408,203 @@
this.panel2.Size = new System.Drawing.Size(190, 39);
this.panel2.TabIndex = 16;
//
+ // groupBox1
+ //
+ 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.ReadSuccessPercent);
+ this.groupBox1.Controls.Add(this.ErrorReadNum);
+ this.groupBox1.Controls.Add(this.NormalReadNum);
+ this.groupBox1.Controls.Add(this.label11);
+ this.groupBox1.Controls.Add(this.label6);
+ this.groupBox1.Controls.Add(this.groupBox3);
+ this.groupBox1.Controls.Add(this.label10);
+ this.groupBox1.Controls.Add(this.label9);
+ this.groupBox1.Controls.Add(this.label8);
+ this.groupBox1.Controls.Add(this.label7);
+ this.groupBox1.Controls.Add(this.label5);
+ this.groupBox1.Location = new System.Drawing.Point(799, 181);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Size = new System.Drawing.Size(375, 625);
+ this.groupBox1.TabIndex = 19;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "状态面板";
+ //
+ // label6
+ //
+ this.label6.AutoSize = true;
+ this.label6.Font = new System.Drawing.Font("宋体", 12F);
+ this.label6.Location = new System.Drawing.Point(103, 32);
+ this.label6.Margin = new System.Windows.Forms.Padding(3, 3, 3, 0);
+ this.label6.Name = "label6";
+ this.label6.Size = new System.Drawing.Size(39, 16);
+ this.label6.TabIndex = 7;
+ this.label6.Text = "正常";
+ //
+ // groupBox3
+ //
+ this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)));
+ this.groupBox3.Controls.Add(this.ErrorCountDataGridView);
+ this.groupBox3.Font = new System.Drawing.Font("宋体", 9F);
+ this.groupBox3.Location = new System.Drawing.Point(6, 202);
+ this.groupBox3.Margin = new System.Windows.Forms.Padding(3, 15, 3, 3);
+ this.groupBox3.Name = "groupBox3";
+ this.groupBox3.Size = new System.Drawing.Size(363, 423);
+ this.groupBox3.TabIndex = 6;
+ this.groupBox3.TabStop = false;
+ this.groupBox3.Text = "异常统计(最近200条)";
+ //
+ // label10
+ //
+ this.label10.AutoSize = true;
+ this.label10.Font = new System.Drawing.Font("宋体", 12F);
+ this.label10.Location = new System.Drawing.Point(18, 66);
+ this.label10.Margin = new System.Windows.Forms.Padding(15, 15, 15, 3);
+ this.label10.Name = "label10";
+ this.label10.Size = new System.Drawing.Size(87, 16);
+ this.label10.TabIndex = 5;
+ this.label10.Text = "连接状态:";
+ //
+ // label9
+ //
+ this.label9.AutoSize = true;
+ this.label9.Font = new System.Drawing.Font("宋体", 12F);
+ this.label9.Location = new System.Drawing.Point(18, 100);
+ this.label9.Margin = new System.Windows.Forms.Padding(15, 15, 15, 3);
+ this.label9.Name = "label9";
+ this.label9.Size = new System.Drawing.Size(119, 16);
+ this.label9.TabIndex = 4;
+ this.label9.Text = "正常读码数量:";
+ //
+ // label8
+ //
+ this.label8.AutoSize = true;
+ this.label8.Font = new System.Drawing.Font("宋体", 12F);
+ this.label8.Location = new System.Drawing.Point(18, 134);
+ this.label8.Margin = new System.Windows.Forms.Padding(15, 15, 15, 3);
+ this.label8.Name = "label8";
+ this.label8.Size = new System.Drawing.Size(119, 16);
+ this.label8.TabIndex = 3;
+ this.label8.Text = "异常读码数量:";
+ //
+ // label7
+ //
+ this.label7.AutoSize = true;
+ this.label7.Font = new System.Drawing.Font("宋体", 12F);
+ this.label7.Location = new System.Drawing.Point(18, 168);
+ this.label7.Margin = new System.Windows.Forms.Padding(15, 15, 15, 3);
+ this.label7.Name = "label7";
+ this.label7.Size = new System.Drawing.Size(103, 16);
+ this.label7.TabIndex = 2;
+ this.label7.Text = "读码成功率:";
+ //
+ // label5
+ //
+ this.label5.AutoSize = true;
+ this.label5.Font = new System.Drawing.Font("宋体", 12F);
+ this.label5.Location = new System.Drawing.Point(18, 32);
+ this.label5.Margin = new System.Windows.Forms.Padding(15, 15, 15, 3);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(87, 16);
+ this.label5.TabIndex = 0;
+ this.label5.Text = "工作状态:";
+ //
+ // label11
+ //
+ this.label11.AutoSize = true;
+ this.label11.Font = new System.Drawing.Font("宋体", 12F);
+ this.label11.Location = new System.Drawing.Point(103, 66);
+ this.label11.Margin = new System.Windows.Forms.Padding(3, 3, 3, 0);
+ this.label11.Name = "label11";
+ this.label11.Size = new System.Drawing.Size(39, 16);
+ this.label11.TabIndex = 8;
+ this.label11.Text = "正常";
+ //
+ // NormalReadNum
+ //
+ this.NormalReadNum.AutoSize = true;
+ this.NormalReadNum.Font = new System.Drawing.Font("宋体", 12F);
+ this.NormalReadNum.Location = new System.Drawing.Point(139, 100);
+ this.NormalReadNum.Margin = new System.Windows.Forms.Padding(3, 3, 3, 0);
+ this.NormalReadNum.Name = "NormalReadNum";
+ this.NormalReadNum.Size = new System.Drawing.Size(31, 16);
+ this.NormalReadNum.TabIndex = 9;
+ this.NormalReadNum.Text = "N/A";
+ //
+ // ErrorReadNum
+ //
+ this.ErrorReadNum.AutoSize = true;
+ this.ErrorReadNum.Font = new System.Drawing.Font("宋体", 12F);
+ this.ErrorReadNum.Location = new System.Drawing.Point(139, 134);
+ this.ErrorReadNum.Margin = new System.Windows.Forms.Padding(3, 3, 3, 0);
+ this.ErrorReadNum.Name = "ErrorReadNum";
+ this.ErrorReadNum.Size = new System.Drawing.Size(31, 16);
+ this.ErrorReadNum.TabIndex = 10;
+ this.ErrorReadNum.Text = "N/A";
+ //
+ // ReadSuccessPercent
+ //
+ this.ReadSuccessPercent.AutoSize = true;
+ this.ReadSuccessPercent.Font = new System.Drawing.Font("宋体", 12F);
+ this.ReadSuccessPercent.Location = new System.Drawing.Point(125, 168);
+ this.ReadSuccessPercent.Margin = new System.Windows.Forms.Padding(3, 3, 3, 0);
+ this.ReadSuccessPercent.Name = "ReadSuccessPercent";
+ this.ReadSuccessPercent.Size = new System.Drawing.Size(31, 16);
+ this.ReadSuccessPercent.TabIndex = 11;
+ this.ReadSuccessPercent.Text = "N/A";
+ //
+ // ErrorCountDataGridView
+ //
+ this.ErrorCountDataGridView.AllowUserToAddRows = false;
+ this.ErrorCountDataGridView.AllowUserToDeleteRows = false;
+ this.ErrorCountDataGridView.AllowUserToResizeRows = false;
+ this.ErrorCountDataGridView.ColumnHeadersHeight = 20;
+ this.ErrorCountDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.BinNo,
+ this.ErrorCount});
+ this.ErrorCountDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.ErrorCountDataGridView.Location = new System.Drawing.Point(3, 17);
+ this.ErrorCountDataGridView.Name = "ErrorCountDataGridView";
+ this.ErrorCountDataGridView.ReadOnly = true;
+ this.ErrorCountDataGridView.RowHeadersVisible = false;
+ this.ErrorCountDataGridView.RowTemplate.Height = 17;
+ this.ErrorCountDataGridView.Size = new System.Drawing.Size(357, 403);
+ this.ErrorCountDataGridView.TabIndex = 0;
+ //
+ // BinNo
+ //
+ this.BinNo.DataPropertyName = "BinNo";
+ this.BinNo.HeaderText = "格口号";
+ this.BinNo.Name = "BinNo";
+ this.BinNo.ReadOnly = true;
+ //
+ // ErrorCount
+ //
+ this.ErrorCount.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.ErrorCount.DataPropertyName = "ErrorCount";
+ this.ErrorCount.HeaderText = "异常读码次数";
+ this.ErrorCount.Name = "ErrorCount";
+ this.ErrorCount.ReadOnly = true;
+ //
// RFIDSocket
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoScroll = true;
this.ClientSize = new System.Drawing.Size(1186, 817);
+ this.Controls.Add(this.groupBox1);
this.Controls.Add(this.PageGroupBox);
this.Controls.Add(this.MainReadGroupBox);
this.Controls.Add(this.ControlGrupbox);
- this.Controls.Add(this.groupBox3);
- this.Controls.Add(this.groupBox2);
this.Margin = new System.Windows.Forms.Padding(2);
this.Name = "RFIDSocket";
this.Text = "小件监控";
+ this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.RFIDSocket_FormClosing);
((System.ComponentModel.ISupportInitialize)(this.CotentData)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.rFIDContentBindingSource)).EndInit();
- this.groupBox2.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.StateData)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.rFIDStateBindingSource)).EndInit();
- this.groupBox3.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.HeartbeatData)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.rFIDHeartbeatBindingSource)).EndInit();
this.ControlGrupbox.ResumeLayout(false);
this.ControlGrupbox.PerformLayout();
@@ -536,6 +613,10 @@
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
+ this.groupBox1.ResumeLayout(false);
+ this.groupBox1.PerformLayout();
+ this.groupBox3.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.ErrorCountDataGridView)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -553,15 +634,7 @@
private System.Windows.Forms.Timer TableTimer;
private System.Windows.Forms.TextBox IPText;
private System.Windows.Forms.BindingSource rFIDContentBindingSource;
- private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.BindingSource rFIDStateBindingSource;
- private System.Windows.Forms.GroupBox groupBox3;
- private System.Windows.Forms.DataGridView HeartbeatData;
- private System.Windows.Forms.DataGridView StateData;
- private System.Windows.Forms.DataGridViewTextBoxColumn deviceNoDataGridViewTextBoxColumn1;
- private System.Windows.Forms.DataGridViewTextBoxColumn LogTime;
- private System.Windows.Forms.DataGridViewTextBoxColumn deviceNoDataGridViewTextBoxColumn2;
- private System.Windows.Forms.DataGridViewTextBoxColumn timeSpanDataGridViewTextBoxColumn;
private System.Windows.Forms.BindingSource rFIDHeartbeatBindingSource;
private System.Windows.Forms.Button PgUp;
private System.Windows.Forms.Button PgDn;
@@ -575,13 +648,27 @@
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;
+ private System.Windows.Forms.GroupBox groupBox1;
+ private System.Windows.Forms.Label label10;
+ private System.Windows.Forms.Label label9;
+ private System.Windows.Forms.Label label8;
+ private System.Windows.Forms.Label label7;
+ private System.Windows.Forms.Label label5;
+ private System.Windows.Forms.GroupBox groupBox3;
+ private System.Windows.Forms.Label label6;
+ private System.Windows.Forms.Label label11;
+ private System.Windows.Forms.Label ReadSuccessPercent;
+ private System.Windows.Forms.Label ErrorReadNum;
+ private System.Windows.Forms.Label NormalReadNum;
+ private System.Windows.Forms.DataGridView ErrorCountDataGridView;
+ private System.Windows.Forms.DataGridViewTextBoxColumn BinNo;
+ private System.Windows.Forms.DataGridViewTextBoxColumn ErrorCount;
}
}
diff --git a/RFIDSocket/RFIDSocket.cs b/RFIDSocket/RFIDSocket.cs
index b99109d..ac4fac7 100644
--- a/RFIDSocket/RFIDSocket.cs
+++ b/RFIDSocket/RFIDSocket.cs
@@ -34,8 +34,12 @@ namespace RFIDSocket
InitAction();
}
+ ///
+ /// 初始化
+ ///
private void InitAction()
{
+ ErrorCountDataGridView.AutoGenerateColumns = false;
if (Server.State != ServerState.Running)
{
MonitorState.Text = "关";
@@ -54,6 +58,11 @@ namespace RFIDSocket
IP = IPText.Text;
}
+ ///
+ /// 监视启停按钮
+ ///
+ ///
+ ///
private void MonitorOnOff_Click(object sender, EventArgs e)
{
if (Server.State != ServerState.Running)
@@ -82,6 +91,11 @@ namespace RFIDSocket
}
}
+ ///
+ /// 服务端IP端口设置
+ ///
+ ///
+ ///
private void SetPort_Click(object sender, EventArgs e)
{
Config.AppSettings.Settings["IpSetting"].Value = IPText.Text;
@@ -92,6 +106,11 @@ namespace RFIDSocket
MessageBox.Show("服务端IP端口号设置成功");
}
+ ///
+ /// Timer刷新
+ ///
+ ///
+ ///
private void TableTimer_Tick(object sender, EventArgs e)
{
if (Server.State != ServerState.Running)
@@ -111,16 +130,52 @@ namespace RFIDSocket
ConnectCountLabel.Text = Server.ConnectCount.ToString();
- CotentData.DataSource = null;
- StateData.DataSource = null;
- HeartbeatData.DataSource = null;
+ int normalCount = RFIDData.rFIDContents.Where(x => x.ReadKind == "GR").Count();
+ int errorCount = RFIDData.rFIDContents.Where(x => x.ReadKind == "MR" || x.ReadKind == "NB").Count();
+
+ NormalReadNum.Text = normalCount.ToString();
+ ErrorReadNum.Text = errorCount.ToString();
+
+ //算比例
+ float percent = (float)normalCount / (float)RFIDData.rFIDContents.Count;
+ percent *= 100f;
+
+ ReadSuccessPercent.Text = $"%{percent}";
+
+ //展示格口号
+ string text = string.Empty;
+ List list = new List(); // 错误的设备编号
+ foreach (var entity in RFIDData.rFIDContents)
+ {
+ if (entity.ReadKind == "MR" || entity.ReadKind == "NB")
+ {
+ list.Add(entity.DeviceNo);
+ }
+ }
+ var deviceNoGroup = list.GroupBy(x => x);
+ DataTable dataTable = new DataTable();
+ {
+ dataTable.Columns.Add("BinNo");
+ dataTable.Columns.Add("ErrorCount");
+ };
+ foreach (var data in deviceNoGroup)
+ {
+ int deviceNo = data.LastOrDefault();
+ int deviceErrorCount = data.Count();
+ dataTable.Rows.Add(deviceNo.ToString(), deviceErrorCount.ToString());
+ }
+
+ ErrorCountDataGridView.DataSource = null;
+ ErrorCountDataGridView.DataSource = dataTable;
ContentPages();
-
- StateData.DataSource = RFIDData.AlarmState;
- HeartbeatData.DataSource = RFIDData.HeartbeatsState;
}
+ ///
+ /// 窗口关闭
+ ///
+ ///
+ ///
private void RFIDSocket_FormClosing(object sender, FormClosingEventArgs e)
{
if (Server.State == ServerState.Running)
@@ -138,23 +193,37 @@ namespace RFIDSocket
}
}
+ ///
+ /// 刷新页面
+ ///
private void ContentPages()
{
+ CotentData.DataSource = null;
CotentData.DataSource = RFIDData.rFIDContents.Skip((PageNo - 1) * 50).Take(50).ToList();
PageRange.Text = $"{((PageNo - 1) * 50) + 1} - {PageNo * 50}";
}
+ ///
+ /// 下一页
+ ///
+ ///
+ ///
private void PgUp_Click(object sender, EventArgs e)
{
- if(PageNo == 1)
+ if (PageNo == 1)
{
- MessageBox.Show("已经是首页!");
+ MessageBox.Show("已经是首页!");
return;
}
PageNo--;
ContentPages();
}
+ ///
+ /// 上一页
+ ///
+ ///
+ ///
private void PgDn_Click(object sender, EventArgs e)
{
if (PageNo == 4)
@@ -166,6 +235,11 @@ namespace RFIDSocket
ContentPages();
}
+ ///
+ /// 日志界面
+ ///
+ ///
+ ///
private void LogStart_Click(object sender, EventArgs e)
{
RFIDLog rFIDLog = new RFIDLog();
@@ -179,16 +253,21 @@ namespace RFIDSocket
///
private void ClearError_Click(object sender, EventArgs e)
{
- if (RFIDData.ClearAllError())
- {
- MessageBox.Show("设备异常清除成功");
- }
- else
- {
- MessageBox.Show("设备异常清除失败");
- }
+ //if (RFIDData.ClearAllError())
+ //{
+ // MessageBox.Show("设备异常清除成功");
+ //}
+ //else
+ //{
+ // MessageBox.Show("设备异常清除失败");
+ //}
}
+ ///
+ /// 格口盘点界面
+ ///
+ ///
+ ///
private void BinAudlt_Click(object sender, EventArgs e)
{
RFIDBinAudlt form = new RFIDBinAudlt();
diff --git a/RFIDSocket/RFIDSocket.csproj b/RFIDSocket/RFIDSocket.csproj
index 6e53afa..131bad9 100644
--- a/RFIDSocket/RFIDSocket.csproj
+++ b/RFIDSocket/RFIDSocket.csproj
@@ -144,6 +144,12 @@
+
+ Form
+
+
+ MultiFuncLoading.cs
+
Form
@@ -166,6 +172,10 @@
+
+
+ MultiFuncLoading.cs
+
RFIDBinAudlt.cs
@@ -177,6 +187,7 @@
True
Resources.resx
+ True
RFIDLog.cs
@@ -236,6 +247,9 @@
+ PreserveNewest
+
+
Always
diff --git a/RFIDSocket/RFIDSocket.resx b/RFIDSocket/RFIDSocket.resx
index d27b888..7842a63 100644
--- a/RFIDSocket/RFIDSocket.resx
+++ b/RFIDSocket/RFIDSocket.resx
@@ -132,13 +132,22 @@
17, 17
-
- True
-
413, 17
646, 17
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
\ No newline at end of file
diff --git a/RFIDSocket/ServerDataAnalysis.cs b/RFIDSocket/ServerDataAnalysis.cs
index e30e6a6..ee85b7c 100644
--- a/RFIDSocket/ServerDataAnalysis.cs
+++ b/RFIDSocket/ServerDataAnalysis.cs
@@ -24,13 +24,13 @@ namespace RFIDSocket
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 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 IHeartbeatService HeartbeatService = new BaseHeartbeatServiceImpl();
+ //public IStateService StateService = new BaseStateServiceImpl();
///
/// 获取数据解析
@@ -40,46 +40,46 @@ namespace RFIDSocket
rFIDContents = ContentService.GetContentInfos().Reverse().Take(200).ToList();
- rFIDStates = StateService.GetStateInfos();
+ //rFIDStates = StateService.GetStateInfos();
- var StateGroup = rFIDStates.GroupBy(x => x.DeviceNo);
+ //var StateGroup = rFIDStates.GroupBy(x => x.DeviceNo);
- AlarmState.Clear();
+ //AlarmState.Clear();
- foreach(var a in StateGroup)
- {
- var b = a.LastOrDefault();
- if (b.DeviceState)
- {
- AlarmState.Add(b);
- }
- }
+ //foreach(var a in StateGroup)
+ //{
+ // var b = a.LastOrDefault();
+ // if (b.DeviceState)
+ // {
+ // AlarmState.Add(b);
+ // }
+ //}
- rFIDHeartbeats = HeartbeatService.GetHeartbeatInfos();
+ //rFIDHeartbeats = HeartbeatService.GetHeartbeatInfos();
- var HeartBeatGroup = rFIDHeartbeats.GroupBy(x => x.DeviceNo);
+ //var HeartBeatGroup = rFIDHeartbeats.GroupBy(x => x.DeviceNo);
- HeartbeatsState.Clear();
+ //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);
- }
- }
+ //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);
+ // }
+ //}
}
- ///
- /// 清除报警
- ///
- ///
- public bool ClearAllError()
- {
- return StateService.SetAllNoError();
- }
+ /////
+ ///// 清除报警
+ /////
+ /////
+ //public bool ClearAllError()
+ //{
+ // return StateService.SetAllNoError();
+ //}
///
/// 秒转时间
diff --git a/RFIDSocket/SplashScreenManager.cs b/RFIDSocket/SplashScreenManager.cs
new file mode 100644
index 0000000..dbc7731
--- /dev/null
+++ b/RFIDSocket/SplashScreenManager.cs
@@ -0,0 +1,90 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace RFIDSocket
+{
+ ///
+ /// 另起一个线程跑Loading SplashScreen窗口,由主进程执行耗时操作
+ ///
+ public class SplashScreenManager
+ {
+ //自定义传入窗口,异步显示
+ private Form LoadingForm;
+
+ ///
+ /// 初始化SplashScreenManager,需要传入一个Form窗体对象
+ ///
+ /// The Parent Form of LoadingForm
+ /// LoadingForm To Show
+ public SplashScreenManager(Form LoadingForm)
+ {
+ this.LoadingForm = LoadingForm;
+ }
+
+ private void ShowWaitForm()
+ {
+ LoadingForm.BringToFront();//放在前端显示
+ LoadingForm.Activate(); //当前窗体是LoadingForm
+ LoadingForm.ShowDialog();
+ }
+
+ ///
+ /// 显示加载窗体
+ ///
+ public void ShowLoading()
+ {
+ MethodInvoker invoker = new MethodInvoker(ShowWaitForm);
+ invoker.BeginInvoke(null, null);
+ /*Console.WriteLine("等待Loading窗体实例化"); */
+ while (!LoadingForm.IsHandleCreated) { }
+ // 把显示窗体放到最前面
+ LoadingForm.Invoke(new MethodInvoker(() =>
+ {
+ LoadingForm.BringToFront();//放在前端显示
+ LoadingForm.Activate(); //当前窗体是LoadingForm
+ }));
+
+ }
+
+ ///
+ /// 关闭loading窗体
+ ///
+ public void CloseWaitForm()
+ {
+ int err_count = 0;
+ try
+ {
+ LoadingForm.Invoke(new MethodInvoker(() =>
+ {
+ LoadingForm.Close();
+ }));
+ }
+ catch (Exception)
+ {
+ //防止未初始化,重复去close,直到OK
+ bool isOK = false;
+ err_count++;
+ while (!isOK && err_count < 20)
+ {
+ try
+ {
+ isOK = true;
+ LoadingForm.Invoke(new MethodInvoker(() =>
+ {
+ LoadingForm.Close();
+ }));
+ }
+ catch (Exception) { isOK = false; err_count++; }
+ }
+ }
+ finally
+ {
+
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/RFIDSocket/loading3.gif b/RFIDSocket/loading3.gif
new file mode 100644
index 0000000..95b02aa
Binary files /dev/null and b/RFIDSocket/loading3.gif differ