-
Notifications
You must be signed in to change notification settings - Fork 0
/
S7Selector.cs
58 lines (52 loc) · 1.72 KB
/
S7Selector.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
namespace TeleScope.Connectors.Plc.Siemens
{
/// <summary>
/// This structure holds information to select a data source on SIEMENS S7 PLCs.
/// </summary>
public struct S7Selector
{
// -- properties
/// <summary>
/// Gets or sets the selected datablock.
/// </summary>
public int Datablock { get; }
/// <summary>
/// Gets or sets the bit offset within the datablock.
/// </summary>
public int BitOffset { get; }
/// <summary>
/// Gets or sets the number or index of a single bit or the number of characters to be read.
/// </summary>
public int Number { get; }
// -- constructurs
/// <summary>
/// Creates an instance of the selector with the given parameters. The property Number will be zero.
/// </summary>
/// <param name="datablock">The datablock to be selected.</param>
/// <param name="bitOffset">The bit offset to be selected.</param>
public S7Selector(int datablock, int bitOffset)
{
Datablock = datablock;
BitOffset = bitOffset;
Number = 0;
}
/// <summary>
/// Creates an instance of the selector with the given parameters.
/// </summary>
/// <param name="datablock">The datablock to be selected.</param>
/// <param name="bitOffset">The bit offset to be selected.</param>
/// <param name="count">The count of a single bit index or the number of characters.</param>
public S7Selector(int datablock, int bitOffset, int count)
{
Datablock = datablock;
BitOffset = bitOffset;
Number = count;
}
// -- methods
/// <summary>
/// Overrides the ToString to present the properties.
/// </summary>
/// <returns>The combined string with property values.</returns>
public override string ToString() => $"DB: {Datablock} Offset: {BitOffset} Count: {Number}";
}
}