Skip to content

Commit 2b2cb2b

Browse files
committed
Merge remote-tracking branch 'origin/master'
# Conflicts: # lib60870/CS104/Server.cs
2 parents 2020462 + 80584f4 commit 2b2cb2b

File tree

7 files changed

+356
-99
lines changed

7 files changed

+356
-99
lines changed

examples/cs104-redundancy-server/Program.cs

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,11 @@
1-
// /*
2-
// * Copyright 2016, 2017 MZ Automation GmbH
3-
// *
4-
// * This file is part of lib60870.NET
5-
// *
6-
// * lib60870.NET is free software: you can redistribute it and/or modify
7-
// * it under the terms of the GNU General Public License as published by
8-
// * the Free Software Foundation, either version 3 of the License, or
9-
// * (at your option) any later version.
10-
// *
11-
// * lib60870.NET is distributed in the hope that it will be useful,
12-
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
// * GNU General Public License for more details.
15-
// *
16-
// * You should have received a copy of the GNU General Public License
17-
// * along with lib60870.NET. If not, see <http://www.gnu.org/licenses/>.
18-
// *
19-
// * See COPYING file for the complete license text.
20-
// */
21-
//
22-
//
23-
using System;
1+
using System;
2+
using System.Net;
3+
using System.Net.Sockets;
4+
using System.Threading;
245

256
using lib60870;
267
using lib60870.CS101;
278
using lib60870.CS104;
28-
using System.Net;
29-
using System.Threading;
309

3110
namespace cs104_redundancy_server
3211
{

lib60870.NET.sln

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.28307.757
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.9.34714.143
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lib60870", "lib60870\lib60870.csproj", "{F604286A-1AFC-4355-8C2C-A998CFCEE979}"
77
EndProject
@@ -43,6 +43,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cs104-redundancy-server", "
4343
EndProject
4444
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cs104-client-file-upload", "examples\cs104-client-file-upload\cs104-client-file-upload.csproj", "{8DAC3BE2-E1C9-4E12-BF11-70FFBAE4C888}"
4545
EndProject
46+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cs104-server4", "examples\cs104-server4\cs104-server4.csproj", "{7A8DD7FA-3248-4DA4-8A6E-3BF673D2C6FE}"
47+
EndProject
48+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cs104-server5", "examples\cs104-server5\cs104-server5.csproj", "{E510D4EA-5C1A-4343-8BA7-4E4C941B2CB8}"
49+
EndProject
4650
Global
4751
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4852
Debug|Any CPU = Debug|Any CPU
@@ -173,6 +177,22 @@ Global
173177
{8DAC3BE2-E1C9-4E12-BF11-70FFBAE4C888}.Release|Any CPU.ActiveCfg = Release|x86
174178
{8DAC3BE2-E1C9-4E12-BF11-70FFBAE4C888}.Release|x86.ActiveCfg = Release|x86
175179
{8DAC3BE2-E1C9-4E12-BF11-70FFBAE4C888}.Release|x86.Build.0 = Release|x86
180+
{7A8DD7FA-3248-4DA4-8A6E-3BF673D2C6FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
181+
{7A8DD7FA-3248-4DA4-8A6E-3BF673D2C6FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
182+
{7A8DD7FA-3248-4DA4-8A6E-3BF673D2C6FE}.Debug|x86.ActiveCfg = Debug|Any CPU
183+
{7A8DD7FA-3248-4DA4-8A6E-3BF673D2C6FE}.Debug|x86.Build.0 = Debug|Any CPU
184+
{7A8DD7FA-3248-4DA4-8A6E-3BF673D2C6FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
185+
{7A8DD7FA-3248-4DA4-8A6E-3BF673D2C6FE}.Release|Any CPU.Build.0 = Release|Any CPU
186+
{7A8DD7FA-3248-4DA4-8A6E-3BF673D2C6FE}.Release|x86.ActiveCfg = Release|Any CPU
187+
{7A8DD7FA-3248-4DA4-8A6E-3BF673D2C6FE}.Release|x86.Build.0 = Release|Any CPU
188+
{E510D4EA-5C1A-4343-8BA7-4E4C941B2CB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
189+
{E510D4EA-5C1A-4343-8BA7-4E4C941B2CB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
190+
{E510D4EA-5C1A-4343-8BA7-4E4C941B2CB8}.Debug|x86.ActiveCfg = Debug|Any CPU
191+
{E510D4EA-5C1A-4343-8BA7-4E4C941B2CB8}.Debug|x86.Build.0 = Debug|Any CPU
192+
{E510D4EA-5C1A-4343-8BA7-4E4C941B2CB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
193+
{E510D4EA-5C1A-4343-8BA7-4E4C941B2CB8}.Release|Any CPU.Build.0 = Release|Any CPU
194+
{E510D4EA-5C1A-4343-8BA7-4E4C941B2CB8}.Release|x86.ActiveCfg = Release|Any CPU
195+
{E510D4EA-5C1A-4343-8BA7-4E4C941B2CB8}.Release|x86.Build.0 = Release|Any CPU
176196
EndGlobalSection
177197
GlobalSection(SolutionProperties) = preSolution
178198
HideSolutionNode = FALSE

lib60870/CS101/ASDU.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,10 @@ internal void Encode(Frame frame, ApplicationLayerParameters parameters)
227227
frame.AppendBytes(payload);
228228
else
229229
{
230-
231230
bool isFirst = true;
232231

233232
foreach (InformationObject io in informationObjects)
234233
{
235-
236234
if (isFirst)
237235
{
238236
io.Encode(frame, parameters, false);
@@ -245,7 +243,6 @@ internal void Encode(Frame frame, ApplicationLayerParameters parameters)
245243
else
246244
io.Encode(frame, parameters, false);
247245
}
248-
249246
}
250247
}
251248
}

lib60870/CS104/ClientConnection.cs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,6 @@ private void sendNextAvailableASDU()
512512
{
513513
oldestSentASDU = 0;
514514
newestSentASDU = 0;
515-
516515
}
517516
else
518517
{
@@ -1011,36 +1010,33 @@ private bool HandleMessage(byte[] buffer, int msgSize)
10111010
return false;
10121011
}
10131012
}
1014-
10151013
// Check for TESTFR_ACT message
10161014
else if ((buffer[2] & 0x43) == 0x43)
10171015
{
1018-
10191016
DebugLog("Send TESTFR_CON");
10201017

10211018
socketStream.Write(TESTFR_CON_MSG, 0, TESTFR_CON_MSG.Length);
10221019
}
1023-
10241020
// Check for STARTDT_ACT message
10251021
else if ((buffer[2] & 0x07) == 0x07)
10261022
{
1027-
10281023
DebugLog("Send STARTDT_CON");
10291024

1025+
socketStream.Write(STARTDT_CON_MSG, 0, TESTFR_CON_MSG.Length);
1026+
10301027
if (this.isActive == false)
10311028
{
10321029
this.isActive = true;
10331030

10341031
this.server.Activated(this);
10351032
}
1036-
1037-
socketStream.Write(STARTDT_CON_MSG, 0, TESTFR_CON_MSG.Length);
1033+
else {
1034+
DebugLog("STARTDT-ACT received while connection is already active");
1035+
}
10381036
}
1039-
10401037
// Check for STOPDT_ACT message
10411038
else if ((buffer[2] & 0x13) == 0x13)
10421039
{
1043-
10441040
DebugLog("Send STOPDT_CON");
10451041

10461042
if (this.isActive == true)
@@ -1052,7 +1048,6 @@ private bool HandleMessage(byte[] buffer, int msgSize)
10521048

10531049
socketStream.Write(STOPDT_CON_MSG, 0, TESTFR_CON_MSG.Length);
10541050
}
1055-
10561051
// Check for TESTFR_CON message
10571052
else if ((buffer[2] & 0x83) == 0x83)
10581053
{
@@ -1062,7 +1057,6 @@ private bool HandleMessage(byte[] buffer, int msgSize)
10621057

10631058
ResetT3Timeout(currentTime);
10641059
}
1065-
10661060
// S-message
10671061
else if (buffer[2] == 0x01)
10681062
{
@@ -1080,7 +1074,6 @@ private bool HandleMessage(byte[] buffer, int msgSize)
10801074

10811075
if (CheckSequenceNumber(seqNo) == false)
10821076
return false;
1083-
10841077
}
10851078
else
10861079
{
@@ -1129,7 +1122,6 @@ private bool handleTimeouts()
11291122

11301123
if (unconfirmedReceivedIMessages > 0)
11311124
{
1132-
11331125
if ((currentTime - lastConfirmationTime) >= (UInt64)(apciParameters.T2 * 1000))
11341126
{
11351127

@@ -1147,7 +1139,6 @@ private bool handleTimeouts()
11471139
{
11481140
if (((long)currentTime - sentASDUs[oldestSentASDU].sentTime) >= (apciParameters.T1 * 1000))
11491141
{
1150-
11511142
PrintSendBuffer();
11521143
DebugLog("I message timeout for " + oldestSentASDU + " seqNo: " + sentASDUs[oldestSentASDU].seqNo);
11531144
return false;
@@ -1162,7 +1153,6 @@ private bool AreByteArraysEqual(byte[] array1, byte[] array2)
11621153
{
11631154
if (array1.Length == array2.Length)
11641155
{
1165-
11661156
for (int i = 0; i < array1.Length; i++)
11671157
{
11681158
if (array1[i] != array2[i])
@@ -1284,15 +1274,13 @@ private void HandleConnection()
12841274

12851275
while (running)
12861276
{
1287-
12881277
try
12891278
{
12901279
// Receive the response from the remote device.
12911280
int bytesRec = receiveMessage(bytes);
12921281

12931282
if (bytesRec > 0)
12941283
{
1295-
12961284
DebugLog("RCVD: " + BitConverter.ToString(bytes, 0, bytesRec));
12971285

12981286
if (HandleMessage(bytes, bytesRec) == false)

lib60870/CS104/Connection.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,15 +1660,12 @@ public X509Certificate LocalCertificateSelectionCallback(object sender, string t
16601660

16611661
private void HandleConnection()
16621662
{
1663-
16641663
byte[] bytes = new byte[300];
16651664

16661665
try
16671666
{
1668-
16691667
try
16701668
{
1671-
16721669
connecting = true;
16731670

16741671
try

0 commit comments

Comments
 (0)