Skip to content

Commit 97dcfe1

Browse files
authored
Merge branch 'thomas-v2:master' into master
2 parents ebfcde8 + 51f1fd9 commit 97dcfe1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+11907
-383
lines changed

src/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*.suo
55
*.user
66
.vs/
7+
.editorconfig
78

89
# Build results
910
[Dd]ebug/

src/DriverTest/Program.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Collections.Generic;
66
using S7CommPlusDriver;
7+
78
using S7CommPlusDriver.ClientApi;
89

910

@@ -13,23 +14,23 @@ class Program
1314
{
1415
static void Main(string[] args)
1516
{
16-
string HostIp;
17+
string HostIp = "192.168.1.30";
18+
string Password = "";
1719
int res;
1820
List<ItemAddress> readlist = new List<ItemAddress>();
1921
Console.WriteLine("Main - START");
20-
// Als Parameter lässt sich die IP-Adresse übergeben, sonst Default-Wert von unten
21-
if (args.Length == 1)
22-
{
22+
// Als Parameter lässt sich die IP-Adresse übergeben, sonst Default-Wert von oben
23+
if (args.Length >= 1) {
2324
HostIp = args[0];
2425
}
25-
else
26-
{
27-
HostIp = "192.168.1.30";
26+
// Als Parameter lässt sich das Passwort übergeben, sonst Default-Wert von oben (kein Passwort)
27+
if (args.Length >= 2) {
28+
Password = args[1];
2829
}
2930
Console.WriteLine("Main - Versuche Verbindungsaufbau zu: " + HostIp);
3031

3132
S7CommPlusConnection conn = new S7CommPlusConnection();
32-
res = conn.Connect(HostIp);
33+
res = conn.Connect(HostIp, Password);
3334
if (res == 0)
3435
{
3536
Console.WriteLine("Main - Connect fertig");
@@ -51,7 +52,7 @@ static void Main(string[] args)
5152

5253
foreach (var v in vars)
5354
{
54-
taglist.Add(tags.TagFactory(v.Name, new ItemAddress(v.AccessSequence), v.Softdatatype));
55+
taglist.Add(PlcTags.TagFactory(v.Name, new ItemAddress(v.AccessSequence), v.Softdatatype));
5556
}
5657
foreach (var t in taglist)
5758
{

src/S7CommPlusDriver.sln

Lines changed: 71 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,71 @@
1-
2-
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.33328.57
5-
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "S7CommPlusDriver", "S7CommPlusDriver\S7CommPlusDriver.csproj", "{781951D8-80DE-4E2F-92CA-A5FEF0059415}"
7-
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DriverTest", "DriverTest\DriverTest.csproj", "{94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}"
9-
EndProject
10-
Global
11-
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12-
Debug|x64 = Debug|x64
13-
Debug|x86 = Debug|x86
14-
Release|x64 = Release|x64
15-
Release|x86 = Release|x86
16-
EndGlobalSection
17-
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18-
{781951D8-80DE-4E2F-92CA-A5FEF0059415}.Debug|x64.ActiveCfg = Debug|x64
19-
{781951D8-80DE-4E2F-92CA-A5FEF0059415}.Debug|x64.Build.0 = Debug|x64
20-
{781951D8-80DE-4E2F-92CA-A5FEF0059415}.Debug|x86.ActiveCfg = Debug|x86
21-
{781951D8-80DE-4E2F-92CA-A5FEF0059415}.Debug|x86.Build.0 = Debug|x86
22-
{781951D8-80DE-4E2F-92CA-A5FEF0059415}.Release|x64.ActiveCfg = Release|x64
23-
{781951D8-80DE-4E2F-92CA-A5FEF0059415}.Release|x64.Build.0 = Release|x64
24-
{781951D8-80DE-4E2F-92CA-A5FEF0059415}.Release|x86.ActiveCfg = Release|x86
25-
{781951D8-80DE-4E2F-92CA-A5FEF0059415}.Release|x86.Build.0 = Release|x86
26-
{94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Debug|x64.ActiveCfg = Debug|x64
27-
{94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Debug|x64.Build.0 = Debug|x64
28-
{94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Debug|x86.ActiveCfg = Debug|x86
29-
{94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Debug|x86.Build.0 = Debug|x86
30-
{94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Release|x64.ActiveCfg = Release|Any CPU
31-
{94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Release|x64.Build.0 = Release|Any CPU
32-
{94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Release|x86.ActiveCfg = Release|Any CPU
33-
{94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Release|x86.Build.0 = Release|Any CPU
34-
EndGlobalSection
35-
GlobalSection(SolutionProperties) = preSolution
36-
HideSolutionNode = FALSE
37-
EndGlobalSection
38-
GlobalSection(ExtensibilityGlobals) = postSolution
39-
SolutionGuid = {641BA78D-D608-4377-9F99-E4C1029EFA0B}
40-
EndGlobalSection
41-
EndGlobal
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.33328.57
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "S7CommPlusDriver", "S7CommPlusDriver\S7CommPlusDriver.csproj", "{781951D8-80DE-4E2F-92CA-A5FEF0059415}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DriverTest", "DriverTest\DriverTest.csproj", "{94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "S7CommPlusGUIBrowser", "S7CommPlusGUIBrowser\S7CommPlusGUIBrowser.csproj", "{BEB37276-B3B3-4DEE-A1EA-D95EB774223B}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Zlib.net", "Zlib.net\Zlib.net.csproj", "{0C89B7A2-A218-49E4-B545-5B044A45F977}"
13+
EndProject
14+
Global
15+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
16+
Debug|Any CPU = Debug|Any CPU
17+
Debug|x64 = Debug|x64
18+
Debug|x86 = Debug|x86
19+
Release|Any CPU = Release|Any CPU
20+
Release|x64 = Release|x64
21+
Release|x86 = Release|x86
22+
EndGlobalSection
23+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
24+
{781951D8-80DE-4E2F-92CA-A5FEF0059415}.Debug|Any CPU.ActiveCfg = Debug|x86
25+
{781951D8-80DE-4E2F-92CA-A5FEF0059415}.Debug|x64.ActiveCfg = Debug|x64
26+
{781951D8-80DE-4E2F-92CA-A5FEF0059415}.Debug|x64.Build.0 = Debug|x64
27+
{781951D8-80DE-4E2F-92CA-A5FEF0059415}.Debug|x86.ActiveCfg = Debug|x86
28+
{781951D8-80DE-4E2F-92CA-A5FEF0059415}.Debug|x86.Build.0 = Debug|x86
29+
{781951D8-80DE-4E2F-92CA-A5FEF0059415}.Release|Any CPU.ActiveCfg = Release|x86
30+
{781951D8-80DE-4E2F-92CA-A5FEF0059415}.Release|x64.ActiveCfg = Release|x64
31+
{781951D8-80DE-4E2F-92CA-A5FEF0059415}.Release|x64.Build.0 = Release|x64
32+
{781951D8-80DE-4E2F-92CA-A5FEF0059415}.Release|x86.ActiveCfg = Release|x86
33+
{781951D8-80DE-4E2F-92CA-A5FEF0059415}.Release|x86.Build.0 = Release|x86
34+
{94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Debug|Any CPU.ActiveCfg = Debug|x86
35+
{94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Debug|x64.ActiveCfg = Debug|x64
36+
{94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Debug|x64.Build.0 = Debug|x64
37+
{94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Debug|x86.ActiveCfg = Debug|x86
38+
{94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Debug|x86.Build.0 = Debug|x86
39+
{94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Release|Any CPU.ActiveCfg = Release|x86
40+
{94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Release|x64.ActiveCfg = Release|x64
41+
{94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Release|x64.Build.0 = Release|x64
42+
{94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Release|x86.ActiveCfg = Release|x86
43+
{94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Release|x86.Build.0 = Release|x86
44+
{BEB37276-B3B3-4DEE-A1EA-D95EB774223B}.Debug|Any CPU.ActiveCfg = Debug|x86
45+
{BEB37276-B3B3-4DEE-A1EA-D95EB774223B}.Debug|x64.ActiveCfg = Debug|x64
46+
{BEB37276-B3B3-4DEE-A1EA-D95EB774223B}.Debug|x64.Build.0 = Debug|x64
47+
{BEB37276-B3B3-4DEE-A1EA-D95EB774223B}.Debug|x86.ActiveCfg = Debug|x86
48+
{BEB37276-B3B3-4DEE-A1EA-D95EB774223B}.Debug|x86.Build.0 = Debug|x86
49+
{BEB37276-B3B3-4DEE-A1EA-D95EB774223B}.Release|Any CPU.ActiveCfg = Release|x86
50+
{BEB37276-B3B3-4DEE-A1EA-D95EB774223B}.Release|x64.ActiveCfg = Release|x64
51+
{BEB37276-B3B3-4DEE-A1EA-D95EB774223B}.Release|x64.Build.0 = Release|x64
52+
{BEB37276-B3B3-4DEE-A1EA-D95EB774223B}.Release|x86.ActiveCfg = Release|x86
53+
{BEB37276-B3B3-4DEE-A1EA-D95EB774223B}.Release|x86.Build.0 = Release|x86
54+
{0C89B7A2-A218-49E4-B545-5B044A45F977}.Debug|Any CPU.ActiveCfg = Debug|x86
55+
{0C89B7A2-A218-49E4-B545-5B044A45F977}.Debug|x64.ActiveCfg = Debug|x64
56+
{0C89B7A2-A218-49E4-B545-5B044A45F977}.Debug|x64.Build.0 = Debug|x64
57+
{0C89B7A2-A218-49E4-B545-5B044A45F977}.Debug|x86.ActiveCfg = Debug|x86
58+
{0C89B7A2-A218-49E4-B545-5B044A45F977}.Debug|x86.Build.0 = Debug|x86
59+
{0C89B7A2-A218-49E4-B545-5B044A45F977}.Release|Any CPU.ActiveCfg = Release|x86
60+
{0C89B7A2-A218-49E4-B545-5B044A45F977}.Release|x64.ActiveCfg = Release|x64
61+
{0C89B7A2-A218-49E4-B545-5B044A45F977}.Release|x64.Build.0 = Release|x64
62+
{0C89B7A2-A218-49E4-B545-5B044A45F977}.Release|x86.ActiveCfg = Release|x86
63+
{0C89B7A2-A218-49E4-B545-5B044A45F977}.Release|x86.Build.0 = Release|x86
64+
EndGlobalSection
65+
GlobalSection(SolutionProperties) = preSolution
66+
HideSolutionNode = FALSE
67+
EndGlobalSection
68+
GlobalSection(ExtensibilityGlobals) = postSolution
69+
SolutionGuid = {641BA78D-D608-4377-9F99-E4C1029EFA0B}
70+
EndGlobalSection
71+
EndGlobal
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#region License
2+
/******************************************************************************
3+
* S7CommPlusDriver
4+
*
5+
* Copyright (C) 2023 Thomas Wiens, [email protected]
6+
*
7+
* This file is part of S7CommPlusDriver.
8+
*
9+
* S7CommPlusDriver is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Lesser General Public License as
11+
* published by the Free Software Foundation, either version 3 of the
12+
* License, or (at your option) any later version.
13+
/****************************************************************************/
14+
#endregion
15+
16+
using System;
17+
using System.Collections.Generic;
18+
19+
namespace S7CommPlusDriver.Alarming
20+
{
21+
public class AlarmsAlarmTexts
22+
{
23+
public int LanguageId;
24+
public string Infotext = String.Empty;
25+
public string AlarmText = String.Empty;
26+
public string AdditionalText1 = String.Empty;
27+
public string AdditionalText2 = String.Empty;
28+
public string AdditionalText3 = String.Empty;
29+
public string AdditionalText4 = String.Empty;
30+
public string AdditionalText5 = String.Empty;
31+
public string AdditionalText6 = String.Empty;
32+
public string AdditionalText7 = String.Empty;
33+
public string AdditionalText8 = String.Empty;
34+
public string AdditionalText9 = String.Empty;
35+
36+
// These two values we get in addition when browsing for the alarmtexts
37+
// Don't know if they are useful for something.
38+
public ushort UnknownValue1;
39+
public ushort UnknownValue2;
40+
41+
public static AlarmsAlarmTexts FromNotificationBlob(ValueBlobSparseArray blob, int languageId)
42+
{
43+
var at = new AlarmsAlarmTexts();
44+
string s;
45+
int lcid;
46+
int textid;
47+
at.LanguageId = languageId;
48+
foreach (var v in blob.Value)
49+
{
50+
s = Utils.GetUtfString(v.Value.value, 0, (uint)v.Value.value.Length);
51+
// Values in older CPUs, from: 0xa09c8001..0xa09c800b (2694610945..2694610955)
52+
// Current CPUs use: 0x04070001..0x0407000b ( 67567617.. 67567627)
53+
// Where the left word is the language ID, 0x0407 = 1031, and the right word is the text id.
54+
// The blob may contain several languages. If you need them all, you need to call this multiple times.
55+
lcid = (int)(v.Key >> 16);
56+
textid = (int)(v.Key & 0xffff);
57+
if (lcid == languageId)
58+
{
59+
switch (textid)
60+
{
61+
case 1:
62+
at.Infotext = s;
63+
break;
64+
case 2:
65+
at.AlarmText = s;
66+
break;
67+
case 3:
68+
at.AdditionalText1 = s;
69+
break;
70+
case 4:
71+
at.AdditionalText2 = s;
72+
break;
73+
case 5:
74+
at.AdditionalText3 = s;
75+
break;
76+
case 6:
77+
at.AdditionalText4 = s;
78+
break;
79+
case 7:
80+
at.AdditionalText5 = s;
81+
break;
82+
case 8:
83+
at.AdditionalText6 = s;
84+
break;
85+
case 9:
86+
at.AdditionalText7 = s;
87+
break;
88+
case 10:
89+
at.AdditionalText8 = s;
90+
break;
91+
case 11:
92+
at.AdditionalText9 = s;
93+
break;
94+
}
95+
}
96+
}
97+
return at;
98+
}
99+
100+
public override string ToString()
101+
{
102+
string s = "<AlarmsAlarmTexts LanguageId=\"" + LanguageId.ToString() + "\">" + Environment.NewLine;
103+
s += "<Infotext>" + Infotext.ToString() + "</Infotext>" + Environment.NewLine;
104+
s += "<AlarmText>" + AlarmText.ToString() + "</AlarmText>" + Environment.NewLine;
105+
s += "<AdditionalText1>" + AdditionalText1.ToString() + "</AdditionalText1>" + Environment.NewLine;
106+
s += "<AdditionalText2>" + AdditionalText2.ToString() + "</AdditionalText2>" + Environment.NewLine;
107+
s += "<AdditionalText3>" + AdditionalText3.ToString() + "</AdditionalText3>" + Environment.NewLine;
108+
s += "<AdditionalText4>" + AdditionalText4.ToString() + "</AdditionalText4>" + Environment.NewLine;
109+
s += "<AdditionalText5>" + AdditionalText5.ToString() + "</AdditionalText5>" + Environment.NewLine;
110+
s += "<AdditionalText6>" + AdditionalText6.ToString() + "</AdditionalText6>" + Environment.NewLine;
111+
s += "<AdditionalText7>" + AdditionalText7.ToString() + "</AdditionalText7>" + Environment.NewLine;
112+
s += "<AdditionalText8>" + AdditionalText8.ToString() + "</AdditionalText8>" + Environment.NewLine;
113+
s += "<AdditionalText9>" + AdditionalText9.ToString() + "</AdditionalText9>" + Environment.NewLine;
114+
s += "</AlarmsAlarmTexts>" + Environment.NewLine;
115+
return s;
116+
}
117+
}
118+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#region License
2+
/******************************************************************************
3+
* S7CommPlusDriver
4+
*
5+
* Copyright (C) 2023 Thomas Wiens, [email protected]
6+
*
7+
* This file is part of S7CommPlusDriver.
8+
*
9+
* S7CommPlusDriver is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Lesser General Public License as
11+
* published by the Free Software Foundation, either version 3 of the
12+
* License, or (at your option) any later version.
13+
/****************************************************************************/
14+
#endregion
15+
16+
using System;
17+
18+
namespace S7CommPlusDriver.Alarming
19+
{
20+
public class AlarmsAsCgs
21+
{
22+
public enum SubtypeIds
23+
{
24+
Coming = Ids.DAI_Coming,
25+
Going = Ids.DAI_Going
26+
}
27+
public uint SubtypeId; // This is not part of the class, but is neccessary to store the information: 2673 = DAI.Coming, 2677 = DAI.Going
28+
29+
public byte AllStatesInfo;
30+
public DateTime Timestamp;
31+
public AlarmsAssociatedValues AssociatedValues;
32+
public DateTime AckTimestamp;
33+
34+
public override string ToString()
35+
{
36+
string s = "<AlarmsAsCgs>" + Environment.NewLine;
37+
s += "<SubtypeId>" + SubtypeId.ToString() + "</SubtypeId>" + Environment.NewLine;
38+
s += "<SubtypeIdName>" + ((SubtypeIds)SubtypeId).ToString() + "</SubtypeIdName>" + Environment.NewLine;
39+
s += "<AllStatesInfo>" + AllStatesInfo.ToString() + "</AllStatesInfo>" + Environment.NewLine;
40+
s += "<AssociatedValues>" + Environment.NewLine + AssociatedValues.ToString() + "</AssociatedValues>" + Environment.NewLine;
41+
s += "<Timestamp>" + Timestamp.ToString() + "</Timestamp>" + Environment.NewLine;
42+
s += "<AckTimestamp>" + AckTimestamp.ToString() + "</AckTimestamp>" + Environment.NewLine;
43+
s += "</AlarmsAsCgs>" + Environment.NewLine;
44+
return s;
45+
}
46+
47+
public static AlarmsAsCgs FromValueStruct(ValueStruct str)
48+
{
49+
var asCgs = new AlarmsAsCgs();
50+
asCgs.AllStatesInfo = ((ValueUSInt)str.GetStructElement(Ids.AS_CGS_AllStatesInfo)).GetValue();
51+
asCgs.Timestamp = Utils.DtFromValueTimestamp(((ValueTimestamp)str.GetStructElement(Ids.AS_CGS_Timestamp)).GetValue());
52+
asCgs.AssociatedValues = AlarmsAssociatedValues.FromValueBlob(((ValueBlobArray)str.GetStructElement(Ids.AS_CGS_AssociatedValues)));
53+
asCgs.AckTimestamp = Utils.DtFromValueTimestamp(((ValueTimestamp)str.GetStructElement(Ids.AS_CGS_AckTimestamp)).GetValue());
54+
return asCgs;
55+
}
56+
}
57+
}

0 commit comments

Comments
 (0)