From e8dce7cc3df7fb8643bc054006607b3c25463a32 Mon Sep 17 00:00:00 2001 From: wangsr Date: Fri, 5 Jan 2024 16:15:41 +0800 Subject: [PATCH] =?UTF-8?q?add=20-=20=E6=B7=BB=E5=8A=A0=E5=88=86=E9=A1=B5?= =?UTF-8?q?=20=E6=8A=A5=E8=AD=A6=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HighWayIot.Repository/domain/RFIDHeartbeat.cs | 3 + RFIDSocket/DataAnalysis.cs | 45 +- RFIDSocket/RFIDSocket.Designer.cs | 433 ++++++++++-------- RFIDSocket/RFIDSocket.cs | 50 +- RFIDSocket/RFIDSocket.resx | 22 +- 5 files changed, 362 insertions(+), 191 deletions(-) diff --git a/HighWayIot.Repository/domain/RFIDHeartbeat.cs b/HighWayIot.Repository/domain/RFIDHeartbeat.cs index 97854b6..fe28a6f 100644 --- a/HighWayIot.Repository/domain/RFIDHeartbeat.cs +++ b/HighWayIot.Repository/domain/RFIDHeartbeat.cs @@ -17,6 +17,9 @@ namespace HighWayIot.Repository.domain [SugarColumn(ColumnName = "beattime")] public DateTime BeatTime { get; set; } + [SugarColumn(ColumnName = "timespan")] + public string TimeSpan { get; set; } + } } \ No newline at end of file diff --git a/RFIDSocket/DataAnalysis.cs b/RFIDSocket/DataAnalysis.cs index 636fd85..381b31c 100644 --- a/RFIDSocket/DataAnalysis.cs +++ b/RFIDSocket/DataAnalysis.cs @@ -18,16 +18,59 @@ namespace RFIDSocket 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 void GetData() { BaseContentServiceImpl baseContentServiceImpl = new BaseContentServiceImpl(); BaseHeartbeatServiceImpl baseHeartbeatServiceImpl = new BaseHeartbeatServiceImpl(); BaseStateServiceImpl baseStateServiceImpl = new BaseStateServiceImpl(); + rFIDContents = baseContentServiceImpl.GetContentInfos().Reverse().Take(200).ToList(); - rFIDHeartbeats = baseHeartbeatServiceImpl.GetHeartbeatInfos(); + rFIDStates = baseStateServiceImpl.GetStateInfos(); + + var StateGroup = rFIDStates.GroupBy(x => x.DeviceNo); + + AlarmState.Clear(); + + foreach(var a in StateGroup) + { + var b = a.LastOrDefault(); + if (b.DeviceState) + { + AlarmState.Add(b); + } + } + + rFIDHeartbeats = baseHeartbeatServiceImpl.GetHeartbeatInfos(); + + var HeartBeatGroup = rFIDHeartbeats.GroupBy(x => x.DeviceNo); + + HeartbeatsState.Clear(); + + foreach (var a in HeartBeatGroup) + { + var b = a.LastOrDefault(); + if (DateTime.Now - b.BeatTime > TimeSpan.FromSeconds(10)) + { + b.TimeSpan = SecondToTime(Convert.ToInt32((DateTime.Now - b.BeatTime).TotalSeconds)); + HeartbeatsState.Add(b); + } + } + } + + private string SecondToTime(int t) + { + int m = t / 60; + int s = t % 60; + if (m == 0) + { + return "00 分 " + s.ToString("00") + " 秒"; + } + return m.ToString("00") + " 分 " + s.ToString("00") + " 秒"; } } } diff --git a/RFIDSocket/RFIDSocket.Designer.cs b/RFIDSocket/RFIDSocket.Designer.cs index d2c5641..0f2c605 100644 --- a/RFIDSocket/RFIDSocket.Designer.cs +++ b/RFIDSocket/RFIDSocket.Designer.cs @@ -30,7 +30,12 @@ { this.components = new System.ComponentModel.Container(); this.CotentData = new System.Windows.Forms.DataGridView(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.deviceNoDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.readKindDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.contentDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.logTimeDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.rFIDContentBindingSource = new System.Windows.Forms.BindingSource(this.components); this.IPText = new System.Windows.Forms.TextBox(); this.SetAddress = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); @@ -39,139 +44,51 @@ this.label4 = new System.Windows.Forms.Label(); this.MonitorState = new System.Windows.Forms.Label(); this.TableTimer = new System.Windows.Forms.Timer(this.components); - this.rFIDContentBindingSource = new System.Windows.Forms.BindingSource(this.components); - this.deviceNoDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.readKindDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.contentDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.logTimeDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.StateData = new System.Windows.Forms.DataGridView(); 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.rFIDStateBindingSource = new System.Windows.Forms.BindingSource(this.components); - this.rFIDHeartbeatBindingSource = new System.Windows.Forms.BindingSource(this.components); - this.deviceNoDataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.logTimeDataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.deviceNoDataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.beatTimeDataGridViewTextBoxColumn = 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(); + this.PageRange = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.CotentData)).BeginInit(); - this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.rFIDContentBindingSource)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.StateData)).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.rFIDStateBindingSource)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.rFIDHeartbeatBindingSource)).BeginInit(); this.SuspendLayout(); // // CotentData // this.CotentData.AutoGenerateColumns = false; + this.CotentData.ColumnHeadersHeight = 20; this.CotentData.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.deviceNoDataGridViewTextBoxColumn, this.readKindDataGridViewTextBoxColumn, this.contentDataGridViewTextBoxColumn, - this.logTimeDataGridViewTextBoxColumn}); + this.logTimeDataGridViewTextBoxColumn, + this.ID}); this.CotentData.DataSource = this.rFIDContentBindingSource; - this.CotentData.Location = new System.Drawing.Point(12, 129); + this.CotentData.Location = new System.Drawing.Point(9, 103); + this.CotentData.Margin = new System.Windows.Forms.Padding(2); this.CotentData.Name = "CotentData"; this.CotentData.RowHeadersVisible = false; this.CotentData.RowHeadersWidth = 51; - this.CotentData.RowTemplate.Height = 20; + this.CotentData.RowTemplate.Height = 17; this.CotentData.ScrollBars = System.Windows.Forms.ScrollBars.None; - this.CotentData.Size = new System.Drawing.Size(648, 1026); + this.CotentData.Size = new System.Drawing.Size(486, 870); this.CotentData.TabIndex = 0; // - // groupBox1 - // - this.groupBox1.Controls.Add(this.IPText); - this.groupBox1.Controls.Add(this.SetAddress); - this.groupBox1.Controls.Add(this.label1); - this.groupBox1.Controls.Add(this.PortText); - this.groupBox1.Location = new System.Drawing.Point(12, 12); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(408, 111); - this.groupBox1.TabIndex = 1; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "端口设置"; - // - // IPText - // - this.IPText.Location = new System.Drawing.Point(152, 24); - this.IPText.MaxLength = 6; - this.IPText.Name = "IPText"; - this.IPText.Size = new System.Drawing.Size(163, 25); - this.IPText.TabIndex = 7; - this.IPText.Text = "127.0.0.1"; - // - // SetAddress - // - this.SetAddress.Location = new System.Drawing.Point(117, 55); - this.SetAddress.Name = "SetAddress"; - this.SetAddress.Size = new System.Drawing.Size(166, 50); - this.SetAddress.TabIndex = 6; - this.SetAddress.Text = "确认服务端地址"; - this.SetAddress.UseVisualStyleBackColor = true; - this.SetAddress.Click += new System.EventHandler(this.SetPort_Click); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(18, 29); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(128, 15); - this.label1.TabIndex = 1; - this.label1.Text = "服务端IP:端口号"; - // - // PortText - // - this.PortText.Location = new System.Drawing.Point(321, 24); - this.PortText.MaxLength = 6; - this.PortText.Name = "PortText"; - this.PortText.Size = new System.Drawing.Size(62, 25); - this.PortText.TabIndex = 0; - this.PortText.Text = "1234"; - // - // MonitorOnOff - // - this.MonitorOnOff.Location = new System.Drawing.Point(450, 20); - this.MonitorOnOff.Name = "MonitorOnOff"; - this.MonitorOnOff.Size = new System.Drawing.Size(192, 57); - this.MonitorOnOff.TabIndex = 7; - this.MonitorOnOff.Text = "启动监听"; - this.MonitorOnOff.UseVisualStyleBackColor = true; - this.MonitorOnOff.Click += new System.EventHandler(this.MonitorOnOff_Click); - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(493, 100); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(82, 15); - this.label4.TabIndex = 8; - this.label4.Text = "监听状态:"; - // - // MonitorState - // - this.MonitorState.AutoSize = true; - this.MonitorState.BackColor = System.Drawing.Color.Transparent; - this.MonitorState.Location = new System.Drawing.Point(572, 100); - this.MonitorState.Name = "MonitorState"; - this.MonitorState.Size = new System.Drawing.Size(22, 15); - this.MonitorState.TabIndex = 9; - this.MonitorState.Text = "关"; - // - // TableTimer - // - this.TableTimer.Enabled = true; - this.TableTimer.Interval = 1000; - this.TableTimer.Tick += new System.EventHandler(this.TableTimer_Tick); - // - // rFIDContentBindingSource - // - this.rFIDContentBindingSource.DataSource = typeof(HighWayIot.Repository.domain.RFIDContent); - // // deviceNoDataGridViewTextBoxColumn // this.deviceNoDataGridViewTextBoxColumn.DataPropertyName = "DeviceNo"; @@ -204,65 +121,124 @@ this.logTimeDataGridViewTextBoxColumn.Name = "logTimeDataGridViewTextBoxColumn"; this.logTimeDataGridViewTextBoxColumn.Width = 105; // - // StateData + // ID // - this.StateData.AutoGenerateColumns = false; - this.StateData.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { - this.deviceNoDataGridViewTextBoxColumn1, - this.logTimeDataGridViewTextBoxColumn1}); - this.StateData.DataSource = this.rFIDStateBindingSource; - this.StateData.Location = new System.Drawing.Point(6, 24); - this.StateData.Name = "StateData"; - this.StateData.RowHeadersVisible = false; - this.StateData.RowHeadersWidth = 51; - this.StateData.RowTemplate.Height = 20; - this.StateData.ScrollBars = System.Windows.Forms.ScrollBars.None; - this.StateData.Size = new System.Drawing.Size(236, 531); - this.StateData.TabIndex = 10; + this.ID.DataPropertyName = "ID"; + this.ID.HeaderText = "ID"; + this.ID.MinimumWidth = 6; + this.ID.Name = "ID"; + this.ID.Width = 125; + // + // rFIDContentBindingSource + // + this.rFIDContentBindingSource.DataSource = typeof(HighWayIot.Repository.domain.RFIDContent); + // + // IPText + // + this.IPText.Location = new System.Drawing.Point(116, 23); + this.IPText.Margin = new System.Windows.Forms.Padding(2); + this.IPText.MaxLength = 6; + this.IPText.Name = "IPText"; + this.IPText.Size = new System.Drawing.Size(98, 21); + this.IPText.TabIndex = 7; + this.IPText.Text = "127.0.0.1"; + // + // SetAddress + // + this.SetAddress.Location = new System.Drawing.Point(267, 10); + this.SetAddress.Margin = new System.Windows.Forms.Padding(2); + this.SetAddress.Name = "SetAddress"; + this.SetAddress.Size = new System.Drawing.Size(120, 45); + this.SetAddress.TabIndex = 6; + this.SetAddress.Text = "确认服务端地址"; + this.SetAddress.UseVisualStyleBackColor = true; + this.SetAddress.Click += new System.EventHandler(this.SetPort_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(11, 27); + this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(101, 12); + this.label1.TabIndex = 1; + this.label1.Text = "服务端IP:端口号"; + // + // PortText + // + this.PortText.Location = new System.Drawing.Point(218, 23); + this.PortText.Margin = new System.Windows.Forms.Padding(2); + this.PortText.MaxLength = 6; + this.PortText.Name = "PortText"; + this.PortText.Size = new System.Drawing.Size(45, 21); + this.PortText.TabIndex = 0; + this.PortText.Text = "1234"; + // + // MonitorOnOff + // + this.MonitorOnOff.Location = new System.Drawing.Point(421, 11); + this.MonitorOnOff.Margin = new System.Windows.Forms.Padding(2); + this.MonitorOnOff.Name = "MonitorOnOff"; + this.MonitorOnOff.Size = new System.Drawing.Size(110, 45); + this.MonitorOnOff.TabIndex = 7; + this.MonitorOnOff.Text = "启动监听"; + this.MonitorOnOff.UseVisualStyleBackColor = true; + this.MonitorOnOff.Click += new System.EventHandler(this.MonitorOnOff_Click); + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(569, 27); + 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); + this.label4.TabIndex = 8; + this.label4.Text = "监听状态:"; + // + // MonitorState + // + this.MonitorState.AutoSize = true; + this.MonitorState.BackColor = System.Drawing.Color.Transparent; + this.MonitorState.Location = new System.Drawing.Point(638, 27); + 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); + this.MonitorState.TabIndex = 9; + this.MonitorState.Text = "关"; + // + // TableTimer + // + this.TableTimer.Interval = 1000; + this.TableTimer.Tick += new System.EventHandler(this.TableTimer_Tick); // // groupBox2 // this.groupBox2.Controls.Add(this.StateData); - this.groupBox2.Location = new System.Drawing.Point(666, 12); + this.groupBox2.Location = new System.Drawing.Point(499, 59); + this.groupBox2.Margin = new System.Windows.Forms.Padding(2); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(248, 561); + this.groupBox2.Padding = new System.Windows.Forms.Padding(2); + this.groupBox2.Size = new System.Drawing.Size(186, 449); this.groupBox2.TabIndex = 11; this.groupBox2.TabStop = false; - this.groupBox2.Text = "发送设备故障"; + this.groupBox2.Text = "工作状态故障"; // - // groupBox3 + // StateData // - this.groupBox3.Controls.Add(this.HeartbeatData); - this.groupBox3.Location = new System.Drawing.Point(666, 579); - this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(248, 576); - this.groupBox3.TabIndex = 12; - this.groupBox3.TabStop = false; - this.groupBox3.Text = "心跳报文停止10秒以上"; - // - // HeartbeatData - // - this.HeartbeatData.AutoGenerateColumns = false; - this.HeartbeatData.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { - this.deviceNoDataGridViewTextBoxColumn2, - this.beatTimeDataGridViewTextBoxColumn}); - this.HeartbeatData.DataSource = this.rFIDHeartbeatBindingSource; - this.HeartbeatData.Location = new System.Drawing.Point(6, 24); - this.HeartbeatData.Name = "HeartbeatData"; - this.HeartbeatData.RowHeadersVisible = false; - this.HeartbeatData.RowHeadersWidth = 51; - this.HeartbeatData.RowTemplate.Height = 20; - this.HeartbeatData.ScrollBars = System.Windows.Forms.ScrollBars.None; - this.HeartbeatData.Size = new System.Drawing.Size(236, 546); - this.HeartbeatData.TabIndex = 10; - // - // rFIDStateBindingSource - // - this.rFIDStateBindingSource.DataSource = typeof(HighWayIot.Repository.domain.RFIDState); - // - // rFIDHeartbeatBindingSource - // - this.rFIDHeartbeatBindingSource.DataSource = typeof(HighWayIot.Repository.domain.RFIDHeartbeat); + 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.Location = new System.Drawing.Point(4, 19); + 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(177, 425); + this.StateData.TabIndex = 0; // // deviceNoDataGridViewTextBoxColumn1 // @@ -272,13 +248,47 @@ this.deviceNoDataGridViewTextBoxColumn1.Name = "deviceNoDataGridViewTextBoxColumn1"; this.deviceNoDataGridViewTextBoxColumn1.Width = 60; // - // logTimeDataGridViewTextBoxColumn1 + // LogTime // - this.logTimeDataGridViewTextBoxColumn1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.logTimeDataGridViewTextBoxColumn1.DataPropertyName = "LogTime"; - this.logTimeDataGridViewTextBoxColumn1.HeaderText = "故障时间"; - this.logTimeDataGridViewTextBoxColumn1.MinimumWidth = 6; - this.logTimeDataGridViewTextBoxColumn1.Name = "logTimeDataGridViewTextBoxColumn1"; + 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.Controls.Add(this.HeartbeatData); + this.groupBox3.Location = new System.Drawing.Point(499, 512); + 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(186, 461); + this.groupBox3.TabIndex = 12; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "连接故障"; + // + // HeartbeatData + // + 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.Location = new System.Drawing.Point(4, 19); + 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.ScrollBars = System.Windows.Forms.ScrollBars.None; + this.HeartbeatData.Size = new System.Drawing.Size(177, 437); + this.HeartbeatData.TabIndex = 0; // // deviceNoDataGridViewTextBoxColumn2 // @@ -288,38 +298,93 @@ this.deviceNoDataGridViewTextBoxColumn2.Name = "deviceNoDataGridViewTextBoxColumn2"; this.deviceNoDataGridViewTextBoxColumn2.Width = 60; // - // beatTimeDataGridViewTextBoxColumn + // timeSpanDataGridViewTextBoxColumn // - this.beatTimeDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.beatTimeDataGridViewTextBoxColumn.DataPropertyName = "BeatTime"; - this.beatTimeDataGridViewTextBoxColumn.HeaderText = "最后一次心跳时间"; - this.beatTimeDataGridViewTextBoxColumn.MinimumWidth = 6; - this.beatTimeDataGridViewTextBoxColumn.Name = "beatTimeDataGridViewTextBoxColumn"; + 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); + // + // PgUp + // + this.PgUp.Location = new System.Drawing.Point(9, 59); + this.PgUp.Margin = new System.Windows.Forms.Padding(2); + this.PgUp.Name = "PgUp"; + this.PgUp.Size = new System.Drawing.Size(101, 40); + this.PgUp.TabIndex = 8; + this.PgUp.Text = "上一页"; + this.PgUp.UseVisualStyleBackColor = true; + this.PgUp.Click += new System.EventHandler(this.PgUp_Click); + // + // PgDn + // + this.PgDn.Location = new System.Drawing.Point(394, 59); + this.PgDn.Margin = new System.Windows.Forms.Padding(2); + this.PgDn.Name = "PgDn"; + this.PgDn.Size = new System.Drawing.Size(101, 40); + this.PgDn.TabIndex = 13; + this.PgDn.Text = "下一页"; + this.PgDn.UseVisualStyleBackColor = true; + this.PgDn.Click += new System.EventHandler(this.PgDn_Click); + // + // PageRange + // + this.PageRange.AutoSize = true; + this.PageRange.BackColor = System.Drawing.Color.Transparent; + this.PageRange.Font = new System.Drawing.Font("宋体", 12F); + this.PageRange.Location = new System.Drawing.Point(255, 69); + this.PageRange.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.PageRange.Name = "PageRange"; + this.PageRange.Size = new System.Drawing.Size(55, 16); + this.PageRange.TabIndex = 15; + this.PageRange.Text = "1 - 50"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("宋体", 12F); + this.label3.Location = new System.Drawing.Point(186, 69); + this.label3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(87, 16); + this.label3.TabIndex = 14; + this.label3.Text = "显示条数:"; // // RFIDSocket // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(927, 1167); + this.ClientSize = new System.Drawing.Size(695, 983); + this.Controls.Add(this.PageRange); + this.Controls.Add(this.label3); + this.Controls.Add(this.IPText); + this.Controls.Add(this.PgDn); + this.Controls.Add(this.SetAddress); + this.Controls.Add(this.label1); + this.Controls.Add(this.PgUp); + this.Controls.Add(this.PortText); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox2); this.Controls.Add(this.MonitorState); this.Controls.Add(this.label4); this.Controls.Add(this.MonitorOnOff); - this.Controls.Add(this.groupBox1); this.Controls.Add(this.CotentData); + this.Margin = new System.Windows.Forms.Padding(2); this.Name = "RFIDSocket"; - this.Text = "小件日志"; + this.Text = " "; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.RFIDSocket_FormClosing); ((System.ComponentModel.ISupportInitialize)(this.CotentData)).EndInit(); - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.rFIDContentBindingSource)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.StateData)).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.rFIDStateBindingSource)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.rFIDHeartbeatBindingSource)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -329,7 +394,6 @@ #endregion private System.Windows.Forms.DataGridView CotentData; - private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.Button SetAddress; private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox PortText; @@ -343,16 +407,21 @@ private System.Windows.Forms.DataGridViewTextBoxColumn readKindDataGridViewTextBoxColumn; private System.Windows.Forms.DataGridViewTextBoxColumn contentDataGridViewTextBoxColumn; private System.Windows.Forms.DataGridViewTextBoxColumn logTimeDataGridViewTextBoxColumn; - private System.Windows.Forms.DataGridView StateData; 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.BindingSource rFIDHeartbeatBindingSource; + private System.Windows.Forms.DataGridView StateData; private System.Windows.Forms.DataGridViewTextBoxColumn deviceNoDataGridViewTextBoxColumn1; - private System.Windows.Forms.DataGridViewTextBoxColumn logTimeDataGridViewTextBoxColumn1; + private System.Windows.Forms.DataGridViewTextBoxColumn LogTime; private System.Windows.Forms.DataGridViewTextBoxColumn deviceNoDataGridViewTextBoxColumn2; - private System.Windows.Forms.DataGridViewTextBoxColumn beatTimeDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn timeSpanDataGridViewTextBoxColumn; + private System.Windows.Forms.BindingSource rFIDHeartbeatBindingSource; + private System.Windows.Forms.DataGridViewTextBoxColumn ID; + private System.Windows.Forms.Button PgUp; + private System.Windows.Forms.Button PgDn; + private System.Windows.Forms.Label PageRange; + private System.Windows.Forms.Label label3; } } diff --git a/RFIDSocket/RFIDSocket.cs b/RFIDSocket/RFIDSocket.cs index 4df7997..1e4d378 100644 --- a/RFIDSocket/RFIDSocket.cs +++ b/RFIDSocket/RFIDSocket.cs @@ -1,4 +1,5 @@ -using HighWayIot.TouchSocket; +using HighWayIot.Repository.domain; +using HighWayIot.TouchSocket; using System; using System.Collections.Generic; using System.ComponentModel; @@ -23,6 +24,8 @@ namespace RFIDSocket string Port = "1234"; string IP = "127.0.0.1"; + int PageNo = 1; + public RFIDSocket() { InitializeComponent(); @@ -43,7 +46,9 @@ namespace RFIDSocket } Port = PortText.Text; - IP = IPText.Text; + IP = IPText.Text; + + } private void MonitorOnOff_Click(object sender, EventArgs e) @@ -53,6 +58,7 @@ namespace RFIDSocket if (Server.ServerStart(IP, Port)) { MessageBox.Show("监听服务启动成功!"); + TableTimer.Enabled = true; } else { @@ -64,6 +70,7 @@ namespace RFIDSocket if (Server.ServerStop()) { MessageBox.Show("监听服务关闭成功!"); + TableTimer.Enabled = false; } else { @@ -95,8 +102,21 @@ namespace RFIDSocket RFIDData.GetData(); - CotentData.DataSource = RFIDData.rFIDContents; + CotentData.DataSource = null; + StateData.DataSource = null; + HeartbeatData.DataSource = null; + switch (PageNo) + { + case 1: ContentPages(0); PageRange.Text = "0 - 50"; break; + case 2: ContentPages(50); PageRange.Text = "51 - 100"; break; + case 3: ContentPages(100); PageRange.Text = "101 - 150"; break; + case 4: ContentPages(150); PageRange.Text = "151 - 200"; break; + default: ContentPages(0); PageRange.Text = "0 - 50"; break; + } + + StateData.DataSource = RFIDData.AlarmState; + HeartbeatData.DataSource = RFIDData.HeartbeatsState; } private void RFIDSocket_FormClosing(object sender, FormClosingEventArgs e) @@ -116,5 +136,29 @@ namespace RFIDSocket } } + private void ContentPages(int skip) + { + CotentData.DataSource = RFIDData.rFIDContents.Skip(skip).Take(50).ToList(); + } + + private void PgUp_Click(object sender, EventArgs e) + { + if(PageNo == 1) + { + MessageBox.Show("已经是首页!"); + return; + } + PageNo--; + } + + private void PgDn_Click(object sender, EventArgs e) + { + if (PageNo == 4) + { + MessageBox.Show("已经是尾页!"); + return; + } + PageNo++; + } } } diff --git a/RFIDSocket/RFIDSocket.resx b/RFIDSocket/RFIDSocket.resx index eb4f47f..d331993 100644 --- a/RFIDSocket/RFIDSocket.resx +++ b/RFIDSocket/RFIDSocket.resx @@ -117,14 +117,29 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + + + 159, 17 + + + True + 159, 17 17, 17 - - 159, 17 + + True + + + 413, 17 + + + True 413, 17 @@ -132,9 +147,6 @@ 646, 17 - - 413, 17 - 646, 17