Skip to content

Commit cf882cb

Browse files
committed
feat(nuget): 更新nuget包,升级控件组件。将作为hsl的进阶教程。
1 parent 8695435 commit cf882cb

File tree

13 files changed

+106
-82
lines changed

13 files changed

+106
-82
lines changed

Android/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ buildscript {
88
}
99
dependencies {
1010
classpath 'com.android.tools.build:gradle:3.1.3'
11-
1211

1312
// NOTE: Do not place your application dependencies here; they belong
1413
// in the individual module build.gradle files

Client/Client.csproj

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@
3131
<WarningLevel>4</WarningLevel>
3232
</PropertyGroup>
3333
<ItemGroup>
34-
<Reference Include="HslCommunication, Version=5.1.1.0, Culture=neutral, processorArchitecture=MSIL">
35-
<HintPath>..\packages\HslCommunication.5.1.1\lib\net35\HslCommunication.dll</HintPath>
34+
<Reference Include="HslCommunication, Version=6.1.2.0, Culture=neutral, PublicKeyToken=cdb2261fa039ed67, processorArchitecture=MSIL">
35+
<HintPath>..\packages\HslCommunication.6.1.2\lib\net35\HslCommunication.dll</HintPath>
3636
</Reference>
37-
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
38-
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net35\Newtonsoft.Json.dll</HintPath>
37+
<Reference Include="HslControls, Version=2.0.4.0, Culture=neutral, PublicKeyToken=a3ad7c5c937ec0c0, processorArchitecture=MSIL">
38+
<HintPath>..\packages\HslControls.2.0.4\lib\net35\HslControls.dll</HintPath>
39+
</Reference>
40+
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
41+
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net35\Newtonsoft.Json.dll</HintPath>
3942
</Reference>
4043
<Reference Include="System" />
4144
<Reference Include="System.Core" />

Client/FormClient.Designer.cs

Lines changed: 62 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Client/FormClient.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ private void FormClient_Load(object sender, EventArgs e)
2323
{
2424
NetComplexInitialization();
2525

26-
userCurve1.SetLeftCurve( "A", new float[0], Color.LimeGreen ); // 新增一条实时曲线
27-
userCurve1.AddLeftAuxiliary( 100, Color.Tomato ); // 新增一条100度的辅助线
26+
hslCurve1.SetLeftCurve( "温度", new float[0], Color.LimeGreen ); // 新增一条实时曲线
27+
hslCurve1.AddLeftAuxiliary( 100, Color.Tomato ); // 新增一条100度的辅助线
2828

2929
pushClient.CreatePush( PushCallBack ); // 创建数据订阅器
3030
}
@@ -106,19 +106,22 @@ private void ShowReadContent(JObject content)
106106
int product = content["product"].ToObject<int>( ); // 产量数据
107107

108108

109-
label2.Text = temp1.ToString();
109+
hslLedDisplay1.DisplayText = temp1.ToString();
110110

111111
// 如果温度超100℃就把背景改为红色
112-
label2.BackColor = temp1 > 100d ? Color.Tomato : Color.Transparent;
112+
hslLedDisplay1.ForeColor = temp1 > 100d ? Color.Tomato : Color.Lime;
113113
label3.Text = product.ToString();
114114

115115
label5.Text = machineEnable ? "运行中" : "未启动";
116116

117117
// 添加仪表盘显示
118-
userGaugeChart1.Value = Math.Round( temp1, 1 );
118+
hslGauge1.Value = (float)Math.Round( temp1, 1 );
119+
120+
// 添加温度控件显示
121+
hslThermometer1.Value = (float)Math.Round( temp1, 1 );
119122

120123
// 添加实时的数据曲线
121-
userCurve1.AddCurveData( "A", (float)temp1 );
124+
hslCurve1.AddCurveData( "温度", (float)temp1 );
122125
}
123126

124127

@@ -136,7 +139,7 @@ private void ShowHistory( byte[] content )
136139
value[i] = BitConverter.ToSingle( content, i * 4 );
137140
}
138141

139-
userCurve1.AddCurveData( "A", value );
142+
hslCurve1.AddCurveData( "温度", value );
140143

141144
}
142145

Client/packages.config

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="HslCommunication" version="5.1.1" targetFramework="net35" />
4-
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net35" />
3+
<package id="HslCommunication" version="6.1.2" targetFramework="net35" />
4+
<package id="HslControls" version="2.0.4" targetFramework="net35" />
5+
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net35" />
56
</packages>

PlcReadTest/FormServer.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ private void NetPushServerInitialization( )
257257
private void SiemensTcpNetInitialization( )
258258
{
259259
siemensTcpNet = new SiemensS7Net( SiemensPLCS.S1200 ); // 实例化西门子的对象
260-
siemensTcpNet.IpAddress = "192.168.1.195"; // 设置IP地址
261-
siemensTcpNet.LogNet = LogNet; // 设置统一的日志记录器
262-
siemensTcpNet.ConnectTimeOut = 1000; // 超时时间为1秒
260+
siemensTcpNet.IpAddress = "192.168.8.12"; // 设置IP地址
261+
siemensTcpNet.LogNet = LogNet; // 设置统一的日志记录器
262+
siemensTcpNet.ConnectTimeOut = 1000; // 超时时间为1秒
263263

264264
// 启动后台读取的线程
265265
threadReadPlc = new Thread( new System.Threading.ThreadStart( ThreadBackgroundReadPlc ) );
@@ -284,6 +284,7 @@ private void ThreadBackgroundReadPlc( )
284284
*
285285
**************************************************************************************************/
286286

287+
double temperature = 100f;
287288

288289
while (true)
289290
{
@@ -299,14 +300,17 @@ private void ThreadBackgroundReadPlc( )
299300

300301
if (isReadRandom)
301302
{
303+
temperature = Math.Round( temperature + random.Next( 100 ) / 10f - 5f, 1 );
304+
if (temperature < 0 || temperature > 200) temperature = 100;
305+
302306
// 当没有测试的设备的时候,此处就演示读取随机数的情况
303307
read = HslCommunication.OperateResult.CreateSuccessResult( new JObject( )
304308
{
305-
{"temp",new JValue(random.Next(2000)/10d) },
309+
{"temp",new JValue(temperature) },
306310
{"enable",new JValue(random.Next(100)>10) },
307311
{"product",new JValue(random.Next(10000)) }
308312
} );
309-
}
313+
}
310314
else
311315
{
312316
HslCommunication.OperateResult<byte[]> tmp = siemensTcpNet.Read( "M100", 7 );
@@ -484,6 +488,7 @@ private void LogNet_BeforeSaveToFile( object sender, HslEventArgs e )
484488
}
485489

486490
textBox1.AppendText( GetStringFromLogMessage( e ) + Environment.NewLine );
491+
e.HslMessage.Cancel = true; // 取消保存
487492
}
488493

489494
private string GetStringFromLogMessage( HslEventArgs e )

PlcReadTest/PlcReadTest.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
<WarningLevel>4</WarningLevel>
3232
</PropertyGroup>
3333
<ItemGroup>
34-
<Reference Include="HslCommunication, Version=5.1.1.0, Culture=neutral, processorArchitecture=MSIL">
35-
<HintPath>..\packages\HslCommunication.5.1.1\lib\net35\HslCommunication.dll</HintPath>
34+
<Reference Include="HslCommunication, Version=6.1.2.0, Culture=neutral, PublicKeyToken=cdb2261fa039ed67, processorArchitecture=MSIL">
35+
<HintPath>..\packages\HslCommunication.6.1.2\lib\net35\HslCommunication.dll</HintPath>
3636
</Reference>
37-
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
38-
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net35\Newtonsoft.Json.dll</HintPath>
37+
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
38+
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net35\Newtonsoft.Json.dll</HintPath>
3939
</Reference>
4040
<Reference Include="System" />
4141
<Reference Include="System.Core" />

PlcReadTest/packages.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="HslCommunication" version="5.1.1" targetFramework="net35" />
4-
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net35" />
3+
<package id="HslCommunication" version="6.1.2" targetFramework="net35" />
4+
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net35" />
55
</packages>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# RemoteMonitor
22
本项目是一个利用HslCommunication组件读取PLC的示例项目,演示了后台从PLC循环读取到前台显示,并推送给在线客户端,客户端同步显示并画实时曲线图。
33

4-
[![NetFramework](https://img.shields.io/badge/Language-C%23%207.0-orange.svg)](https://blogs.msdn.microsoft.com/dotnet/2016/08/24/whats-new-in-csharp-7-0/) [![Visual Studio](https://img.shields.io/badge/Visual%20Studio-2017-red.svg)](https://www.visualstudio.com/zh-hans/) ![License status](https://img.shields.io/badge/License-MIT-yellow.svg)
4+
[![NetFramework](https://img.shields.io/badge/Language-C%23%207.0-orange.svg)](https://blogs.msdn.microsoft.com/dotnet/2016/08/24/whats-new-in-csharp-7-0/) [![Visual Studio](https://img.shields.io/badge/Visual%20Studio-2019-red.svg)](https://www.visualstudio.com/zh-hans/) ![License status](https://img.shields.io/badge/License-MIT-yellow.svg)
55

66
![Android Studio](https://img.shields.io/badge/Android%20Studio-3.1-red.svg)
77

WebApplication1/Web.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
</dependentAssembly>
3030
<dependentAssembly>
3131
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
32-
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
32+
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
3333
</dependentAssembly>
3434
<dependentAssembly>
3535
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />

0 commit comments

Comments
 (0)