Skip to content

Commit 2d77dcf

Browse files
committed
Add net stat feature.Release version 2.1.7
1 parent dcbd385 commit 2d77dcf

22 files changed

+363
-42
lines changed

QpTestClient/Controls/ConnectionInfoControl.Designer.cs

Lines changed: 112 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using QpTestClient.Utils;
2+
using Quick.Protocol;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.ComponentModel;
6+
using System.Data;
7+
using System.Drawing;
8+
using System.Linq;
9+
using System.Text;
10+
using System.Threading.Tasks;
11+
using System.Windows.Forms;
12+
13+
namespace QpTestClient.Controls
14+
{
15+
public partial class ConnectionInfoControl : UserControl
16+
{
17+
private ConnectionContext item;
18+
public ConnectionInfoControl(ConnectionContext item)
19+
{
20+
this.item = item;
21+
InitializeComponent();
22+
23+
var ctl = UiUtils.GetPropertyGridControl(item.ConnectionInfo.QpClientOptions);
24+
ctl.Dock = DockStyle.Fill;
25+
tpBasic.Controls.Add(ctl);
26+
}
27+
private string lastNetstatStr = string.Empty;
28+
private void timerNetstat_Tick(object sender, EventArgs e)
29+
{
30+
QpChannel channel = item.QpClient;
31+
if (!item.Connected || channel == null)
32+
{
33+
showNetStat("当前未连接");
34+
return;
35+
}
36+
if (!item.ConnectionInfo.QpClientOptions.EnableNetstat)
37+
{
38+
showNetStat("当前连接没有配置启用网络统计功能");
39+
return;
40+
}
41+
showNetStat(@$"发送的字节数:{channel.BytesSent.ToString("N0")}
42+
接收的字节数:{channel.BytesReceived.ToString("N0")}
43+
每秒发送字节数:{channel.BytesSentPerSec.ToString("N0")}
44+
每秒接收字节数:{channel.BytesSentPerSec.ToString("N0")}");
45+
}
46+
47+
private void showNetStat(string content)
48+
{
49+
//如果内容未改变
50+
if (content != null && content == lastNetstatStr)
51+
return;
52+
txtNetstat.Text = content;
53+
}
54+
}
55+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<root>
2+
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
3+
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
4+
<xsd:element name="root" msdata:IsDataSet="true">
5+
<xsd:complexType>
6+
<xsd:choice maxOccurs="unbounded">
7+
<xsd:element name="metadata">
8+
<xsd:complexType>
9+
<xsd:sequence>
10+
<xsd:element name="value" type="xsd:string" minOccurs="0" />
11+
</xsd:sequence>
12+
<xsd:attribute name="name" use="required" type="xsd:string" />
13+
<xsd:attribute name="type" type="xsd:string" />
14+
<xsd:attribute name="mimetype" type="xsd:string" />
15+
<xsd:attribute ref="xml:space" />
16+
</xsd:complexType>
17+
</xsd:element>
18+
<xsd:element name="assembly">
19+
<xsd:complexType>
20+
<xsd:attribute name="alias" type="xsd:string" />
21+
<xsd:attribute name="name" type="xsd:string" />
22+
</xsd:complexType>
23+
</xsd:element>
24+
<xsd:element name="data">
25+
<xsd:complexType>
26+
<xsd:sequence>
27+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
28+
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
29+
</xsd:sequence>
30+
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
31+
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
32+
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
33+
<xsd:attribute ref="xml:space" />
34+
</xsd:complexType>
35+
</xsd:element>
36+
<xsd:element name="resheader">
37+
<xsd:complexType>
38+
<xsd:sequence>
39+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
40+
</xsd:sequence>
41+
<xsd:attribute name="name" type="xsd:string" use="required" />
42+
</xsd:complexType>
43+
</xsd:element>
44+
</xsd:choice>
45+
</xsd:complexType>
46+
</xsd:element>
47+
</xsd:schema>
48+
<resheader name="resmimetype">
49+
<value>text/microsoft-resx</value>
50+
</resheader>
51+
<resheader name="version">
52+
<value>2.0</value>
53+
</resheader>
54+
<resheader name="reader">
55+
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
56+
</resheader>
57+
<resheader name="writer">
58+
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
59+
</resheader>
60+
<metadata name="timerNetstat.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
61+
<value>17, 17</value>
62+
</metadata>
63+
</root>

QpTestClient/MainForm.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,6 @@ private void showContent(Control item)
104104
}
105105
}
106106

107-
private Control getPropertyGridControl(object obj)
108-
{
109-
TypeDescriptor.AddAttributes(obj, new Attribute[] { new ReadOnlyAttribute(true) });
110-
111-
var control = new PropertyGrid();
112-
control.SelectedObject = obj;
113-
control.ToolbarVisible = false;
114-
control.PropertySort = PropertySort.NoSort;
115-
return control;
116-
}
117-
118107
private void tvQpInstructions_AfterSelect(object sender, TreeViewEventArgs e)
119108
{
120109
var node = e.Node;
@@ -128,11 +117,11 @@ private void tvQpInstructions_AfterSelect(object sender, TreeViewEventArgs e)
128117
else if (nodeObj is ConnectionContext)
129118
{
130119
var connectionContext = (ConnectionContext)nodeObj;
131-
showContent(getPropertyGridControl(connectionContext.ConnectionInfo.QpClientOptions));
120+
showContent(new Controls.ConnectionInfoControl(connectionContext));
132121
}
133122
else if (nodeObj is QpInstruction)
134123
{
135-
showContent(getPropertyGridControl(nodeObj));
124+
showContent(UiUtils.GetPropertyGridControl(nodeObj));
136125
}
137126
else if (nodeObj is QpNoticeInfo)
138127
{

QpTestClient/QpTestClient.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Product>[QuickProtocol]测试客户端</Product>
99
<AssemblyTitle>[QuickProtocol]测试客户端</AssemblyTitle>
1010
<Authors>aaasoft</Authors>
11-
<Version>2.1.6</Version>
11+
<Version>2.1.7</Version>
1212
<ApplicationIcon>logo.ico</ApplicationIcon>
1313
<Description>用于测试连接到[QuickProtocol]服务端的客户端。
1414
项目地址:https://github.com/QuickProtocol

QpTestClient/Utils/UiUtils.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows.Forms;
8+
9+
namespace QpTestClient.Utils
10+
{
11+
public class UiUtils
12+
{
13+
public static Control GetPropertyGridControl(object obj)
14+
{
15+
TypeDescriptor.AddAttributes(obj, new Attribute[] { new ReadOnlyAttribute(true) });
16+
17+
var control = new PropertyGrid();
18+
control.SelectedObject = obj;
19+
control.ToolbarVisible = false;
20+
control.PropertySort = PropertySort.NoSort;
21+
return control;
22+
}
23+
}
24+
}

Quick.Protocol.AllClients/Quick.Protocol.AllClients.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<Copyright />
88
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
99
<Authors>scbeta</Authors>
10-
<Version>2.1.6</Version>
10+
<Version>2.1.7</Version>
1111
<Company />
1212
<Description>Incluse all QpClient implements.
1313
Common use:

Quick.Protocol.Pipeline/QpPipelineClientOptions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ public override void Check()
2424
throw new ArgumentNullException(nameof(PipeName));
2525
}
2626

27-
public override string GetConnectionInfo() => $"{ServerName}\\{PipeName}";
28-
2927
public override Type GetQpClientType() => typeof(QpPipelineClient);
3028

3129
protected override void LoadFromUri(Uri uri)

Quick.Protocol.Pipeline/Quick.Protocol.Pipeline.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
66
<PackageProjectUrl>https://github.com/QuickProtocol</PackageProjectUrl>
77
<RepositoryUrl>https://github.com/QuickProtocol/QuickProtocol_CSharp</RepositoryUrl>
8-
<Version>2.1.6</Version>
8+
<Version>2.1.7</Version>
99
<Authors>scbeta</Authors>
1010
<Company />
1111
<Product>Quick.Protocol</Product>

Quick.Protocol.SerialPort/QpSerialPortClientOptions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ public override void Check()
4747
throw new ArgumentNullException(nameof(PortName));
4848
}
4949

50-
public override string GetConnectionInfo() => PortName;
51-
5250
public override Type GetQpClientType() => typeof(QpSerialPortClient);
5351

5452
protected override void LoadFromUri(Uri uri)

0 commit comments

Comments
 (0)