hat.drivers.iec101

IEC 60870-5-101 communication protocol

  1"""IEC 60870-5-101 communication protocol"""
  2
  3from hat.drivers.iec101.common import (AsduTypeError,
  4                                       Address,
  5                                       AddressSize,
  6                                       CauseSize,
  7                                       AsduAddressSize,
  8                                       IoAddressSize,
  9                                       TimeSize,
 10                                       Time,
 11                                       OriginatorAddress,
 12                                       AsduAddress,
 13                                       IoAddress,
 14                                       IndicationQuality,
 15                                       MeasurementQuality,
 16                                       CounterQuality,
 17                                       ProtectionQuality,
 18                                       Quality,
 19                                       FreezeCode,
 20                                       SingleValue,
 21                                       DoubleValue,
 22                                       RegulatingValue,
 23                                       StepPositionValue,
 24                                       BitstringValue,
 25                                       NormalizedValue,
 26                                       ScaledValue,
 27                                       FloatingValue,
 28                                       BinaryCounterValue,
 29                                       ProtectionValue,
 30                                       ProtectionStartValue,
 31                                       ProtectionCommandValue,
 32                                       StatusValue,
 33                                       OtherCause,
 34                                       DataResCause,
 35                                       DataCause,
 36                                       CommandReqCause,
 37                                       CommandResCause,
 38                                       CommandCause,
 39                                       InitializationResCause,
 40                                       InitializationCause,
 41                                       ReadReqCause,
 42                                       ReadResCause,
 43                                       ReadCause,
 44                                       ClockSyncReqCause,
 45                                       ClockSyncResCause,
 46                                       ClockSyncCause,
 47                                       ActivationReqCause,
 48                                       ActivationResCause,
 49                                       ActivationCause,
 50                                       DelayReqCause,
 51                                       DelayResCause,
 52                                       DelayCause,
 53                                       ParameterReqCause,
 54                                       ParameterResCause,
 55                                       ParameterCause,
 56                                       ParameterActivationReqCause,
 57                                       ParameterActivationResCause,
 58                                       ParameterActivationCause,
 59                                       SingleData,
 60                                       DoubleData,
 61                                       StepPositionData,
 62                                       BitstringData,
 63                                       NormalizedData,
 64                                       ScaledData,
 65                                       FloatingData,
 66                                       BinaryCounterData,
 67                                       ProtectionData,
 68                                       ProtectionStartData,
 69                                       ProtectionCommandData,
 70                                       StatusData,
 71                                       Data,
 72                                       SingleCommand,
 73                                       DoubleCommand,
 74                                       RegulatingCommand,
 75                                       NormalizedCommand,
 76                                       ScaledCommand,
 77                                       FloatingCommand,
 78                                       BitstringCommand,
 79                                       Command,
 80                                       NormalizedParameter,
 81                                       ScaledParameter,
 82                                       FloatingParameter,
 83                                       Parameter,
 84                                       DataMsg,
 85                                       CommandMsg,
 86                                       InitializationMsg,
 87                                       InterrogationMsg,
 88                                       CounterInterrogationMsg,
 89                                       ReadMsg,
 90                                       ClockSyncMsg,
 91                                       TestMsg,
 92                                       ResetMsg,
 93                                       DelayMsg,
 94                                       ParameterMsg,
 95                                       ParameterActivationMsg,
 96                                       Msg,
 97                                       time_from_datetime,
 98                                       time_to_datetime)
 99from hat.drivers.iec101.master import MasterConnection
100from hat.drivers.iec101.slave import SlaveConnection
101
102
103__all__ = ['AsduTypeError',
104           'Address',
105           'AddressSize',
106           'CauseSize',
107           'AsduAddressSize',
108           'IoAddressSize',
109           'TimeSize',
110           'Time',
111           'OriginatorAddress',
112           'AsduAddress',
113           'IoAddress',
114           'IndicationQuality',
115           'MeasurementQuality',
116           'CounterQuality',
117           'ProtectionQuality',
118           'Quality',
119           'FreezeCode',
120           'SingleValue',
121           'DoubleValue',
122           'RegulatingValue',
123           'StepPositionValue',
124           'BitstringValue',
125           'NormalizedValue',
126           'ScaledValue',
127           'FloatingValue',
128           'BinaryCounterValue',
129           'ProtectionValue',
130           'ProtectionStartValue',
131           'ProtectionCommandValue',
132           'StatusValue',
133           'OtherCause',
134           'DataResCause',
135           'DataCause',
136           'CommandReqCause',
137           'CommandResCause',
138           'CommandCause',
139           'InitializationResCause',
140           'InitializationCause',
141           'ReadReqCause',
142           'ReadResCause',
143           'ReadCause',
144           'ClockSyncReqCause',
145           'ClockSyncResCause',
146           'ClockSyncCause',
147           'ActivationReqCause',
148           'ActivationResCause',
149           'ActivationCause',
150           'DelayReqCause',
151           'DelayResCause',
152           'DelayCause',
153           'ParameterReqCause',
154           'ParameterResCause',
155           'ParameterCause',
156           'ParameterActivationReqCause',
157           'ParameterActivationResCause',
158           'ParameterActivationCause',
159           'SingleData',
160           'DoubleData',
161           'StepPositionData',
162           'BitstringData',
163           'NormalizedData',
164           'ScaledData',
165           'FloatingData',
166           'BinaryCounterData',
167           'ProtectionData',
168           'ProtectionStartData',
169           'ProtectionCommandData',
170           'StatusData',
171           'Data',
172           'SingleCommand',
173           'DoubleCommand',
174           'RegulatingCommand',
175           'NormalizedCommand',
176           'ScaledCommand',
177           'FloatingCommand',
178           'BitstringCommand',
179           'Command',
180           'NormalizedParameter',
181           'ScaledParameter',
182           'FloatingParameter',
183           'Parameter',
184           'DataMsg',
185           'CommandMsg',
186           'InitializationMsg',
187           'InterrogationMsg',
188           'CounterInterrogationMsg',
189           'ReadMsg',
190           'ClockSyncMsg',
191           'TestMsg',
192           'ResetMsg',
193           'DelayMsg',
194           'ParameterMsg',
195           'ParameterActivationMsg',
196           'Msg',
197           'time_from_datetime',
198           'time_to_datetime',
199           'MasterConnection',
200           'SlaveConnection']
class AsduTypeError(builtins.Exception):
12class AsduTypeError(Exception):
13    pass

Common base class for all non-exit exceptions.

Address = int | None
class AddressSize(enum.Enum):
17class AddressSize(enum.Enum):
18    ZERO = 0
19    ONE = 1
20    TWO = 2

An enumeration.

ZERO = <AddressSize.ZERO: 0>
ONE = <AddressSize.ONE: 1>
TWO = <AddressSize.TWO: 2>
class CauseSize(enum.Enum):
 8class CauseSize(enum.Enum):
 9    ONE = 1
10    TWO = 2

An enumeration.

ONE = <CauseSize.ONE: 1>
TWO = <CauseSize.TWO: 2>
class AsduAddressSize(enum.Enum):
13class AsduAddressSize(enum.Enum):
14    ONE = 1
15    TWO = 2

An enumeration.

ONE = <AsduAddressSize.ONE: 1>
TWO = <AsduAddressSize.TWO: 2>
class IoAddressSize(enum.Enum):
18class IoAddressSize(enum.Enum):
19    ONE = 1
20    TWO = 2
21    THREE = 3

An enumeration.

ONE = <IoAddressSize.ONE: 1>
TWO = <IoAddressSize.TWO: 2>
THREE = <IoAddressSize.THREE: 3>
class TimeSize(enum.Enum):
24class TimeSize(enum.Enum):
25    TWO = 2
26    THREE = 3
27    FOUR = 4
28    SEVEN = 7

An enumeration.

TWO = <TimeSize.TWO: 2>
THREE = <TimeSize.THREE: 3>
FOUR = <TimeSize.FOUR: 4>
SEVEN = <TimeSize.SEVEN: 7>
class Time(typing.NamedTuple):
31class Time(typing.NamedTuple):
32    size: TimeSize
33    milliseconds: int
34    """milliseconds in range [0, 59999]"""
35    invalid: bool | None
36    """available for size THREE, FOUR, SEVEN"""
37    minutes: int | None
38    """available for size THREE, FOUR, SEVEN (minutes in range [0, 59])"""
39    summer_time: bool | None
40    """available for size FOUR, SEVEN"""
41    hours: int | None
42    """available for size FOUR, SEVEN (hours in range [0, 23])"""
43    day_of_week: int | None
44    """available for size SEVEN (day_of_week in range [1, 7])"""
45    day_of_month: int | None
46    """available for size SEVEN (day_of_month in range [1, 31])"""
47    months: int | None
48    """available for size SEVEN (months in range [1, 12])"""
49    years: int | None
50    """available for size SEVEN (years in range [0, 99])"""

Time(size, milliseconds, invalid, minutes, summer_time, hours, day_of_week, day_of_month, months, years)

Time( size: TimeSize, milliseconds: int, invalid: bool | None, minutes: int | None, summer_time: bool | None, hours: int | None, day_of_week: int | None, day_of_month: int | None, months: int | None, years: int | None)

Create new instance of Time(size, milliseconds, invalid, minutes, summer_time, hours, day_of_week, day_of_month, months, years)

size: TimeSize

Alias for field number 0

milliseconds: int

milliseconds in range [0, 59999]

invalid: bool | None

available for size THREE, FOUR, SEVEN

minutes: int | None

available for size THREE, FOUR, SEVEN (minutes in range [0, 59])

summer_time: bool | None

available for size FOUR, SEVEN

hours: int | None

available for size FOUR, SEVEN (hours in range [0, 23])

day_of_week: int | None

available for size SEVEN (day_of_week in range [1, 7])

day_of_month: int | None

available for size SEVEN (day_of_month in range [1, 31])

months: int | None

available for size SEVEN (months in range [1, 12])

years: int | None

available for size SEVEN (years in range [0, 99])

OriginatorAddress = <class 'int'>
AsduAddress = <class 'int'>
IoAddress = <class 'int'>
class IndicationQuality(typing.NamedTuple):
147class IndicationQuality(typing.NamedTuple):
148    invalid: bool
149    not_topical: bool
150    substituted: bool
151    blocked: bool

IndicationQuality(invalid, not_topical, substituted, blocked)

IndicationQuality(invalid: bool, not_topical: bool, substituted: bool, blocked: bool)

Create new instance of IndicationQuality(invalid, not_topical, substituted, blocked)

invalid: bool

Alias for field number 0

not_topical: bool

Alias for field number 1

substituted: bool

Alias for field number 2

blocked: bool

Alias for field number 3

class MeasurementQuality(typing.NamedTuple):
154class MeasurementQuality(typing.NamedTuple):
155    invalid: bool
156    not_topical: bool
157    substituted: bool
158    blocked: bool
159    overflow: bool

MeasurementQuality(invalid, not_topical, substituted, blocked, overflow)

MeasurementQuality( invalid: bool, not_topical: bool, substituted: bool, blocked: bool, overflow: bool)

Create new instance of MeasurementQuality(invalid, not_topical, substituted, blocked, overflow)

invalid: bool

Alias for field number 0

not_topical: bool

Alias for field number 1

substituted: bool

Alias for field number 2

blocked: bool

Alias for field number 3

overflow: bool

Alias for field number 4

class CounterQuality(typing.NamedTuple):
162class CounterQuality(typing.NamedTuple):
163    invalid: bool
164    adjusted: bool
165    overflow: bool
166    sequence: int
167    """sequence in range [0, 31]"""

CounterQuality(invalid, adjusted, overflow, sequence)

CounterQuality(invalid: bool, adjusted: bool, overflow: bool, sequence: int)

Create new instance of CounterQuality(invalid, adjusted, overflow, sequence)

invalid: bool

Alias for field number 0

adjusted: bool

Alias for field number 1

overflow: bool

Alias for field number 2

sequence: int

sequence in range [0, 31]

class ProtectionQuality(typing.NamedTuple):
170class ProtectionQuality(typing.NamedTuple):
171    invalid: bool
172    not_topical: bool
173    substituted: bool
174    blocked: bool
175    time_invalid: bool

ProtectionQuality(invalid, not_topical, substituted, blocked, time_invalid)

ProtectionQuality( invalid: bool, not_topical: bool, substituted: bool, blocked: bool, time_invalid: bool)

Create new instance of ProtectionQuality(invalid, not_topical, substituted, blocked, time_invalid)

invalid: bool

Alias for field number 0

not_topical: bool

Alias for field number 1

substituted: bool

Alias for field number 2

blocked: bool

Alias for field number 3

time_invalid: bool

Alias for field number 4

class FreezeCode(enum.Enum):
184class FreezeCode(enum.Enum):
185    READ = 0
186    FREEZE = 1
187    FREEZE_AND_RESET = 2
188    RESET = 3

An enumeration.

READ = <FreezeCode.READ: 0>
FREEZE = <FreezeCode.FREEZE: 1>
FREEZE_AND_RESET = <FreezeCode.FREEZE_AND_RESET: 2>
RESET = <FreezeCode.RESET: 3>
class SingleValue(enum.Enum):
191class SingleValue(enum.Enum):
192    OFF = 0
193    ON = 1

An enumeration.

OFF = <SingleValue.OFF: 0>
ON = <SingleValue.ON: 1>
class DoubleValue(enum.Enum):
196class DoubleValue(enum.Enum):
197    """DoubleDataValue
198
199    `FAULT` stands for value 3, defined in the protocol as *INDETERMINATE*.
200    This is in order to make it more distinguishable from ``INTERMEDIATE``.
201
202    """
203    INTERMEDIATE = 0
204    OFF = 1
205    ON = 2
206    FAULT = 3

DoubleDataValue

FAULT stands for value 3, defined in the protocol as INDETERMINATE. This is in order to make it more distinguishable from INTERMEDIATE.

INTERMEDIATE = <DoubleValue.INTERMEDIATE: 0>
OFF = <DoubleValue.OFF: 1>
ON = <DoubleValue.ON: 2>
FAULT = <DoubleValue.FAULT: 3>
class RegulatingValue(enum.Enum):
209class RegulatingValue(enum.Enum):
210    LOWER = 1
211    HIGHER = 2

An enumeration.

LOWER = <RegulatingValue.LOWER: 1>
HIGHER = <RegulatingValue.HIGHER: 2>
class StepPositionValue(typing.NamedTuple):
214class StepPositionValue(typing.NamedTuple):
215    value: int
216    """value in range [-64, 63]"""
217    transient: bool

StepPositionValue(value, transient)

StepPositionValue(value: int, transient: bool)

Create new instance of StepPositionValue(value, transient)

value: int

value in range [-64, 63]

transient: bool

Alias for field number 1

class BitstringValue(typing.NamedTuple):
220class BitstringValue(typing.NamedTuple):
221    value: util.Bytes
222    """bitstring encoded as 4 bytes"""

BitstringValue(value,)

BitstringValue(value: bytes | bytearray | memoryview)

Create new instance of BitstringValue(value,)

value: bytes | bytearray | memoryview

bitstring encoded as 4 bytes

class NormalizedValue(typing.NamedTuple):
225class NormalizedValue(typing.NamedTuple):
226    value: float
227    """value in range [-1.0, 1.0)"""

NormalizedValue(value,)

NormalizedValue(value: float)

Create new instance of NormalizedValue(value,)

value: float

value in range [-1.0, 1.0)

class ScaledValue(typing.NamedTuple):
230class ScaledValue(typing.NamedTuple):
231    value: int
232    """value in range [-2^15, 2^15-1]"""

ScaledValue(value,)

ScaledValue(value: int)

Create new instance of ScaledValue(value,)

value: int

value in range [-2^15, 2^15-1]

class FloatingValue(typing.NamedTuple):
235class FloatingValue(typing.NamedTuple):
236    value: float

FloatingValue(value,)

FloatingValue(value: float)

Create new instance of FloatingValue(value,)

value: float

Alias for field number 0

class BinaryCounterValue(typing.NamedTuple):
239class BinaryCounterValue(typing.NamedTuple):
240    value: int
241    """value in range [-2^31, 2^31-1]"""

BinaryCounterValue(value,)

BinaryCounterValue(value: int)

Create new instance of BinaryCounterValue(value,)

value: int

value in range [-2^31, 2^31-1]

class ProtectionValue(enum.Enum):
244class ProtectionValue(enum.Enum):
245    OFF = 1
246    ON = 2

An enumeration.

OFF = <ProtectionValue.OFF: 1>
ON = <ProtectionValue.ON: 2>
class ProtectionStartValue(typing.NamedTuple):
249class ProtectionStartValue(typing.NamedTuple):
250    general: bool
251    l1: bool
252    l2: bool
253    l3: bool
254    ie: bool
255    reverse: bool

ProtectionStartValue(general, l1, l2, l3, ie, reverse)

ProtectionStartValue(general: bool, l1: bool, l2: bool, l3: bool, ie: bool, reverse: bool)

Create new instance of ProtectionStartValue(general, l1, l2, l3, ie, reverse)

general: bool

Alias for field number 0

l1: bool

Alias for field number 1

l2: bool

Alias for field number 2

l3: bool

Alias for field number 3

ie: bool

Alias for field number 4

reverse: bool

Alias for field number 5

class ProtectionCommandValue(typing.NamedTuple):
258class ProtectionCommandValue(typing.NamedTuple):
259    general: bool
260    l1: bool
261    l2: bool
262    l3: bool

ProtectionCommandValue(general, l1, l2, l3)

ProtectionCommandValue(general: bool, l1: bool, l2: bool, l3: bool)

Create new instance of ProtectionCommandValue(general, l1, l2, l3)

general: bool

Alias for field number 0

l1: bool

Alias for field number 1

l2: bool

Alias for field number 2

l3: bool

Alias for field number 3

class StatusValue(typing.NamedTuple):
265class StatusValue(typing.NamedTuple):
266    value: list[bool]
267    """value length is 16"""
268    change: list[bool]
269    """change length is 16"""

StatusValue(value, change)

StatusValue(value: list[bool], change: list[bool])

Create new instance of StatusValue(value, change)

value: list[bool]

value length is 16

change: list[bool]

change length is 16

OtherCause = <class 'int'>
class DataResCause(enum.Enum):
50class DataResCause(enum.Enum):
51    PERIODIC = iec101.CauseType.PERIODIC.value
52    BACKGROUND_SCAN = iec101.CauseType.BACKGROUND_SCAN.value
53    SPONTANEOUS = iec101.CauseType.SPONTANEOUS.value
54    REQUEST = iec101.CauseType.REQUEST.value
55    REMOTE_COMMAND = iec101.CauseType.REMOTE_COMMAND.value
56    LOCAL_COMMAND = iec101.CauseType.LOCAL_COMMAND.value
57    INTERROGATED_STATION = iec101.CauseType.INTERROGATED_STATION.value
58    INTERROGATED_GROUP01 = iec101.CauseType.INTERROGATED_GROUP01.value
59    INTERROGATED_GROUP02 = iec101.CauseType.INTERROGATED_GROUP02.value
60    INTERROGATED_GROUP03 = iec101.CauseType.INTERROGATED_GROUP03.value
61    INTERROGATED_GROUP04 = iec101.CauseType.INTERROGATED_GROUP04.value
62    INTERROGATED_GROUP05 = iec101.CauseType.INTERROGATED_GROUP05.value
63    INTERROGATED_GROUP06 = iec101.CauseType.INTERROGATED_GROUP06.value
64    INTERROGATED_GROUP07 = iec101.CauseType.INTERROGATED_GROUP07.value
65    INTERROGATED_GROUP08 = iec101.CauseType.INTERROGATED_GROUP08.value
66    INTERROGATED_GROUP09 = iec101.CauseType.INTERROGATED_GROUP09.value
67    INTERROGATED_GROUP10 = iec101.CauseType.INTERROGATED_GROUP10.value
68    INTERROGATED_GROUP11 = iec101.CauseType.INTERROGATED_GROUP11.value
69    INTERROGATED_GROUP12 = iec101.CauseType.INTERROGATED_GROUP12.value
70    INTERROGATED_GROUP13 = iec101.CauseType.INTERROGATED_GROUP13.value
71    INTERROGATED_GROUP14 = iec101.CauseType.INTERROGATED_GROUP14.value
72    INTERROGATED_GROUP15 = iec101.CauseType.INTERROGATED_GROUP15.value
73    INTERROGATED_GROUP16 = iec101.CauseType.INTERROGATED_GROUP16.value
74    INTERROGATED_COUNTER = iec101.CauseType.INTERROGATED_COUNTER.value
75    INTERROGATED_COUNTER01 = iec101.CauseType.INTERROGATED_COUNTER01.value
76    INTERROGATED_COUNTER02 = iec101.CauseType.INTERROGATED_COUNTER02.value
77    INTERROGATED_COUNTER03 = iec101.CauseType.INTERROGATED_COUNTER03.value
78    INTERROGATED_COUNTER04 = iec101.CauseType.INTERROGATED_COUNTER04.value

An enumeration.

PERIODIC = <DataResCause.PERIODIC: 1>
BACKGROUND_SCAN = <DataResCause.BACKGROUND_SCAN: 2>
SPONTANEOUS = <DataResCause.SPONTANEOUS: 3>
REQUEST = <DataResCause.REQUEST: 5>
REMOTE_COMMAND = <DataResCause.REMOTE_COMMAND: 11>
LOCAL_COMMAND = <DataResCause.LOCAL_COMMAND: 12>
INTERROGATED_STATION = <DataResCause.INTERROGATED_STATION: 20>
INTERROGATED_GROUP01 = <DataResCause.INTERROGATED_GROUP01: 21>
INTERROGATED_GROUP02 = <DataResCause.INTERROGATED_GROUP02: 22>
INTERROGATED_GROUP03 = <DataResCause.INTERROGATED_GROUP03: 23>
INTERROGATED_GROUP04 = <DataResCause.INTERROGATED_GROUP04: 24>
INTERROGATED_GROUP05 = <DataResCause.INTERROGATED_GROUP05: 25>
INTERROGATED_GROUP06 = <DataResCause.INTERROGATED_GROUP06: 26>
INTERROGATED_GROUP07 = <DataResCause.INTERROGATED_GROUP07: 27>
INTERROGATED_GROUP08 = <DataResCause.INTERROGATED_GROUP08: 28>
INTERROGATED_GROUP09 = <DataResCause.INTERROGATED_GROUP09: 29>
INTERROGATED_GROUP10 = <DataResCause.INTERROGATED_GROUP10: 30>
INTERROGATED_GROUP11 = <DataResCause.INTERROGATED_GROUP11: 31>
INTERROGATED_GROUP12 = <DataResCause.INTERROGATED_GROUP12: 32>
INTERROGATED_GROUP13 = <DataResCause.INTERROGATED_GROUP13: 33>
INTERROGATED_GROUP14 = <DataResCause.INTERROGATED_GROUP14: 34>
INTERROGATED_GROUP15 = <DataResCause.INTERROGATED_GROUP15: 35>
INTERROGATED_GROUP16 = <DataResCause.INTERROGATED_GROUP16: 36>
INTERROGATED_COUNTER = <DataResCause.INTERROGATED_COUNTER: 37>
INTERROGATED_COUNTER01 = <DataResCause.INTERROGATED_COUNTER01: 38>
INTERROGATED_COUNTER02 = <DataResCause.INTERROGATED_COUNTER02: 39>
INTERROGATED_COUNTER03 = <DataResCause.INTERROGATED_COUNTER03: 40>
INTERROGATED_COUNTER04 = <DataResCause.INTERROGATED_COUNTER04: 41>
DataCause = DataResCause | int
class CommandReqCause(enum.Enum):
84class CommandReqCause(enum.Enum):
85    ACTIVATION = iec101.CauseType.ACTIVATION.value
86    DEACTIVATION = iec101.CauseType.DEACTIVATION.value

An enumeration.

ACTIVATION = <CommandReqCause.ACTIVATION: 6>
DEACTIVATION = <CommandReqCause.DEACTIVATION: 8>
class CommandResCause(enum.Enum):
89class CommandResCause(enum.Enum):
90    ACTIVATION_CONFIRMATION = iec101.CauseType.ACTIVATION_CONFIRMATION.value
91    DEACTIVATION_CONFIRMATION = iec101.CauseType.DEACTIVATION_CONFIRMATION.value  # NOQA
92    ACTIVATION_TERMINATION = iec101.CauseType.ACTIVATION_TERMINATION.value
93    UNKNOWN_TYPE = iec101.CauseType.UNKNOWN_TYPE.value
94    UNKNOWN_CAUSE = iec101.CauseType.UNKNOWN_CAUSE.value
95    UNKNOWN_ASDU_ADDRESS = iec101.CauseType.UNKNOWN_ASDU_ADDRESS.value
96    UNKNOWN_IO_ADDRESS = iec101.CauseType.UNKNOWN_IO_ADDRESS.value

An enumeration.

ACTIVATION_CONFIRMATION = <CommandResCause.ACTIVATION_CONFIRMATION: 7>
DEACTIVATION_CONFIRMATION = <CommandResCause.DEACTIVATION_CONFIRMATION: 9>
ACTIVATION_TERMINATION = <CommandResCause.ACTIVATION_TERMINATION: 10>
UNKNOWN_TYPE = <CommandResCause.UNKNOWN_TYPE: 44>
UNKNOWN_CAUSE = <CommandResCause.UNKNOWN_CAUSE: 45>
UNKNOWN_ASDU_ADDRESS = <CommandResCause.UNKNOWN_ASDU_ADDRESS: 46>
UNKNOWN_IO_ADDRESS = <CommandResCause.UNKNOWN_IO_ADDRESS: 47>
CommandCause = CommandReqCause | CommandResCause | int
class InitializationResCause(enum.Enum):
102class InitializationResCause(enum.Enum):
103    LOCAL_POWER = 0
104    LOCAL_RESET = 1
105    REMOTE_RESET = 2

An enumeration.

InitializationCause = InitializationResCause | int
class ReadReqCause(enum.Enum):
111class ReadReqCause(enum.Enum):
112    REQUEST = iec101.CauseType.REQUEST.value

An enumeration.

REQUEST = <ReadReqCause.REQUEST: 5>
class ReadResCause(enum.Enum):
115class ReadResCause(enum.Enum):
116    UNKNOWN_TYPE = iec101.CauseType.UNKNOWN_TYPE.value
117    UNKNOWN_CAUSE = iec101.CauseType.UNKNOWN_CAUSE.value
118    UNKNOWN_ASDU_ADDRESS = iec101.CauseType.UNKNOWN_ASDU_ADDRESS.value
119    UNKNOWN_IO_ADDRESS = iec101.CauseType.UNKNOWN_IO_ADDRESS.value

An enumeration.

UNKNOWN_TYPE = <ReadResCause.UNKNOWN_TYPE: 44>
UNKNOWN_CAUSE = <ReadResCause.UNKNOWN_CAUSE: 45>
UNKNOWN_ASDU_ADDRESS = <ReadResCause.UNKNOWN_ASDU_ADDRESS: 46>
UNKNOWN_IO_ADDRESS = <ReadResCause.UNKNOWN_IO_ADDRESS: 47>
ReadCause = ReadReqCause | ReadResCause | int
class ClockSyncReqCause(enum.Enum):
125class ClockSyncReqCause(enum.Enum):
126    ACTIVATION = iec101.CauseType.ACTIVATION.value

An enumeration.

ACTIVATION = <ClockSyncReqCause.ACTIVATION: 6>
class ClockSyncResCause(enum.Enum):
129class ClockSyncResCause(enum.Enum):
130    SPONTANEOUS = iec101.CauseType.SPONTANEOUS.value
131    ACTIVATION_CONFIRMATION = iec101.CauseType.ACTIVATION_CONFIRMATION.value
132    UNKNOWN_TYPE = iec101.CauseType.UNKNOWN_TYPE.value
133    UNKNOWN_CAUSE = iec101.CauseType.UNKNOWN_CAUSE.value
134    UNKNOWN_ASDU_ADDRESS = iec101.CauseType.UNKNOWN_ASDU_ADDRESS.value
135    UNKNOWN_IO_ADDRESS = iec101.CauseType.UNKNOWN_IO_ADDRESS.value

An enumeration.

SPONTANEOUS = <ClockSyncResCause.SPONTANEOUS: 3>
ACTIVATION_CONFIRMATION = <ClockSyncResCause.ACTIVATION_CONFIRMATION: 7>
UNKNOWN_TYPE = <ClockSyncResCause.UNKNOWN_TYPE: 44>
UNKNOWN_CAUSE = <ClockSyncResCause.UNKNOWN_CAUSE: 45>
UNKNOWN_ASDU_ADDRESS = <ClockSyncResCause.UNKNOWN_ASDU_ADDRESS: 46>
UNKNOWN_IO_ADDRESS = <ClockSyncResCause.UNKNOWN_IO_ADDRESS: 47>
ClockSyncCause = ClockSyncReqCause | ClockSyncResCause | int
class ActivationReqCause(enum.Enum):
143class ActivationReqCause(enum.Enum):
144    ACTIVATION = iec101.CauseType.ACTIVATION.value

An enumeration.

ACTIVATION = <ActivationReqCause.ACTIVATION: 6>
class ActivationResCause(enum.Enum):
147class ActivationResCause(enum.Enum):
148    ACTIVATION_CONFIRMATION = iec101.CauseType.ACTIVATION_CONFIRMATION.value
149    UNKNOWN_TYPE = iec101.CauseType.UNKNOWN_TYPE.value
150    UNKNOWN_CAUSE = iec101.CauseType.UNKNOWN_CAUSE.value
151    UNKNOWN_ASDU_ADDRESS = iec101.CauseType.UNKNOWN_ASDU_ADDRESS.value
152    UNKNOWN_IO_ADDRESS = iec101.CauseType.UNKNOWN_IO_ADDRESS.value

An enumeration.

ACTIVATION_CONFIRMATION = <ActivationResCause.ACTIVATION_CONFIRMATION: 7>
UNKNOWN_TYPE = <ActivationResCause.UNKNOWN_TYPE: 44>
UNKNOWN_CAUSE = <ActivationResCause.UNKNOWN_CAUSE: 45>
UNKNOWN_ASDU_ADDRESS = <ActivationResCause.UNKNOWN_ASDU_ADDRESS: 46>
UNKNOWN_IO_ADDRESS = <ActivationResCause.UNKNOWN_IO_ADDRESS: 47>
ActivationCause = ActivationReqCause | ActivationResCause | int
class DelayReqCause(enum.Enum):
160class DelayReqCause(enum.Enum):
161    SPONTANEOUS = iec101.CauseType.SPONTANEOUS.value
162    ACTIVATION = iec101.CauseType.ACTIVATION.value

An enumeration.

SPONTANEOUS = <DelayReqCause.SPONTANEOUS: 3>
ACTIVATION = <DelayReqCause.ACTIVATION: 6>
class DelayResCause(enum.Enum):
165class DelayResCause(enum.Enum):
166    ACTIVATION_CONFIRMATION = iec101.CauseType.ACTIVATION_CONFIRMATION.value
167    UNKNOWN_TYPE = iec101.CauseType.UNKNOWN_TYPE.value
168    UNKNOWN_CAUSE = iec101.CauseType.UNKNOWN_CAUSE.value
169    UNKNOWN_ASDU_ADDRESS = iec101.CauseType.UNKNOWN_ASDU_ADDRESS.value
170    UNKNOWN_IO_ADDRESS = iec101.CauseType.UNKNOWN_IO_ADDRESS.value

An enumeration.

ACTIVATION_CONFIRMATION = <DelayResCause.ACTIVATION_CONFIRMATION: 7>
UNKNOWN_TYPE = <DelayResCause.UNKNOWN_TYPE: 44>
UNKNOWN_CAUSE = <DelayResCause.UNKNOWN_CAUSE: 45>
UNKNOWN_ASDU_ADDRESS = <DelayResCause.UNKNOWN_ASDU_ADDRESS: 46>
UNKNOWN_IO_ADDRESS = <DelayResCause.UNKNOWN_IO_ADDRESS: 47>
DelayCause = DelayReqCause | DelayResCause | int
class ParameterReqCause(enum.Enum):
176class ParameterReqCause(enum.Enum):
177    SPONTANEOUS = iec101.CauseType.SPONTANEOUS.value
178    ACTIVATION = iec101.CauseType.ACTIVATION.value

An enumeration.

SPONTANEOUS = <ParameterReqCause.SPONTANEOUS: 3>
ACTIVATION = <ParameterReqCause.ACTIVATION: 6>
class ParameterResCause(enum.Enum):
181class ParameterResCause(enum.Enum):
182    ACTIVATION_CONFIRMATION = iec101.CauseType.ACTIVATION_CONFIRMATION.value
183    INTERROGATED_STATION = iec101.CauseType.INTERROGATED_STATION.value
184    INTERROGATED_GROUP01 = iec101.CauseType.INTERROGATED_GROUP01.value
185    INTERROGATED_GROUP02 = iec101.CauseType.INTERROGATED_GROUP02.value
186    INTERROGATED_GROUP03 = iec101.CauseType.INTERROGATED_GROUP03.value
187    INTERROGATED_GROUP04 = iec101.CauseType.INTERROGATED_GROUP04.value
188    INTERROGATED_GROUP05 = iec101.CauseType.INTERROGATED_GROUP05.value
189    INTERROGATED_GROUP06 = iec101.CauseType.INTERROGATED_GROUP06.value
190    INTERROGATED_GROUP07 = iec101.CauseType.INTERROGATED_GROUP07.value
191    INTERROGATED_GROUP08 = iec101.CauseType.INTERROGATED_GROUP08.value
192    INTERROGATED_GROUP09 = iec101.CauseType.INTERROGATED_GROUP09.value
193    INTERROGATED_GROUP10 = iec101.CauseType.INTERROGATED_GROUP10.value
194    INTERROGATED_GROUP11 = iec101.CauseType.INTERROGATED_GROUP11.value
195    INTERROGATED_GROUP12 = iec101.CauseType.INTERROGATED_GROUP12.value
196    INTERROGATED_GROUP13 = iec101.CauseType.INTERROGATED_GROUP13.value
197    INTERROGATED_GROUP14 = iec101.CauseType.INTERROGATED_GROUP14.value
198    INTERROGATED_GROUP15 = iec101.CauseType.INTERROGATED_GROUP15.value
199    INTERROGATED_GROUP16 = iec101.CauseType.INTERROGATED_GROUP16.value
200    UNKNOWN_TYPE = iec101.CauseType.UNKNOWN_TYPE.value
201    UNKNOWN_CAUSE = iec101.CauseType.UNKNOWN_CAUSE.value
202    UNKNOWN_ASDU_ADDRESS = iec101.CauseType.UNKNOWN_ASDU_ADDRESS.value
203    UNKNOWN_IO_ADDRESS = iec101.CauseType.UNKNOWN_IO_ADDRESS.value

An enumeration.

ACTIVATION_CONFIRMATION = <ParameterResCause.ACTIVATION_CONFIRMATION: 7>
INTERROGATED_STATION = <ParameterResCause.INTERROGATED_STATION: 20>
INTERROGATED_GROUP01 = <ParameterResCause.INTERROGATED_GROUP01: 21>
INTERROGATED_GROUP02 = <ParameterResCause.INTERROGATED_GROUP02: 22>
INTERROGATED_GROUP03 = <ParameterResCause.INTERROGATED_GROUP03: 23>
INTERROGATED_GROUP04 = <ParameterResCause.INTERROGATED_GROUP04: 24>
INTERROGATED_GROUP05 = <ParameterResCause.INTERROGATED_GROUP05: 25>
INTERROGATED_GROUP06 = <ParameterResCause.INTERROGATED_GROUP06: 26>
INTERROGATED_GROUP07 = <ParameterResCause.INTERROGATED_GROUP07: 27>
INTERROGATED_GROUP08 = <ParameterResCause.INTERROGATED_GROUP08: 28>
INTERROGATED_GROUP09 = <ParameterResCause.INTERROGATED_GROUP09: 29>
INTERROGATED_GROUP10 = <ParameterResCause.INTERROGATED_GROUP10: 30>
INTERROGATED_GROUP11 = <ParameterResCause.INTERROGATED_GROUP11: 31>
INTERROGATED_GROUP12 = <ParameterResCause.INTERROGATED_GROUP12: 32>
INTERROGATED_GROUP13 = <ParameterResCause.INTERROGATED_GROUP13: 33>
INTERROGATED_GROUP14 = <ParameterResCause.INTERROGATED_GROUP14: 34>
INTERROGATED_GROUP15 = <ParameterResCause.INTERROGATED_GROUP15: 35>
INTERROGATED_GROUP16 = <ParameterResCause.INTERROGATED_GROUP16: 36>
UNKNOWN_TYPE = <ParameterResCause.UNKNOWN_TYPE: 44>
UNKNOWN_CAUSE = <ParameterResCause.UNKNOWN_CAUSE: 45>
UNKNOWN_ASDU_ADDRESS = <ParameterResCause.UNKNOWN_ASDU_ADDRESS: 46>
UNKNOWN_IO_ADDRESS = <ParameterResCause.UNKNOWN_IO_ADDRESS: 47>
ParameterCause = ParameterReqCause | ParameterResCause | int
class ParameterActivationReqCause(enum.Enum):
211class ParameterActivationReqCause(enum.Enum):
212    ACTIVATION = iec101.CauseType.ACTIVATION.value
213    DEACTIVATION = iec101.CauseType.DEACTIVATION.value

An enumeration.

class ParameterActivationResCause(enum.Enum):
216class ParameterActivationResCause(enum.Enum):
217    ACTIVATION_CONFIRMATION = iec101.CauseType.ACTIVATION_CONFIRMATION.value
218    DEACTIVATION_CONFIRMATION = iec101.CauseType.DEACTIVATION_CONFIRMATION.value  # NOQA
219    UNKNOWN_TYPE = iec101.CauseType.UNKNOWN_TYPE.value
220    UNKNOWN_CAUSE = iec101.CauseType.UNKNOWN_CAUSE.value
221    UNKNOWN_ASDU_ADDRESS = iec101.CauseType.UNKNOWN_ASDU_ADDRESS.value
222    UNKNOWN_IO_ADDRESS = iec101.CauseType.UNKNOWN_IO_ADDRESS.value

An enumeration.

ParameterActivationCause = ParameterActivationReqCause | ParameterActivationResCause | int
class SingleData(typing.NamedTuple):
230class SingleData(typing.NamedTuple):
231    value: SingleValue
232    quality: IndicationQuality

SingleData(value, quality)

SingleData( value: SingleValue, quality: IndicationQuality)

Create new instance of SingleData(value, quality)

value: SingleValue

Alias for field number 0

Alias for field number 1

class DoubleData(typing.NamedTuple):
235class DoubleData(typing.NamedTuple):
236    value: DoubleValue
237    quality: IndicationQuality

DoubleData(value, quality)

DoubleData( value: DoubleValue, quality: IndicationQuality)

Create new instance of DoubleData(value, quality)

value: DoubleValue

Alias for field number 0

Alias for field number 1

class StepPositionData(typing.NamedTuple):
240class StepPositionData(typing.NamedTuple):
241    value: StepPositionValue
242    quality: MeasurementQuality

StepPositionData(value, quality)

StepPositionData( value: StepPositionValue, quality: MeasurementQuality)

Create new instance of StepPositionData(value, quality)

Alias for field number 0

Alias for field number 1

class BitstringData(typing.NamedTuple):
245class BitstringData(typing.NamedTuple):
246    value: BitstringValue
247    quality: MeasurementQuality

BitstringData(value, quality)

BitstringData( value: BitstringValue, quality: MeasurementQuality)

Create new instance of BitstringData(value, quality)

Alias for field number 0

Alias for field number 1

class NormalizedData(typing.NamedTuple):
250class NormalizedData(typing.NamedTuple):
251    value: NormalizedValue
252    quality: MeasurementQuality | None

NormalizedData(value, quality)

NormalizedData( value: NormalizedValue, quality: MeasurementQuality | None)

Create new instance of NormalizedData(value, quality)

Alias for field number 0

quality: MeasurementQuality | None

Alias for field number 1

class ScaledData(typing.NamedTuple):
255class ScaledData(typing.NamedTuple):
256    value: ScaledValue
257    quality: MeasurementQuality

ScaledData(value, quality)

ScaledData( value: ScaledValue, quality: MeasurementQuality)

Create new instance of ScaledData(value, quality)

value: ScaledValue

Alias for field number 0

Alias for field number 1

class FloatingData(typing.NamedTuple):
260class FloatingData(typing.NamedTuple):
261    value: FloatingValue
262    quality: MeasurementQuality

FloatingData(value, quality)

FloatingData( value: FloatingValue, quality: MeasurementQuality)

Create new instance of FloatingData(value, quality)

value: FloatingValue

Alias for field number 0

Alias for field number 1

class BinaryCounterData(typing.NamedTuple):
265class BinaryCounterData(typing.NamedTuple):
266    value: BinaryCounterValue
267    quality: CounterQuality

BinaryCounterData(value, quality)

BinaryCounterData( value: BinaryCounterValue, quality: CounterQuality)

Create new instance of BinaryCounterData(value, quality)

Alias for field number 0

quality: CounterQuality

Alias for field number 1

class ProtectionData(typing.NamedTuple):
270class ProtectionData(typing.NamedTuple):
271    value: ProtectionValue
272    quality: ProtectionQuality
273    elapsed_time: int
274    """elapsed_time in range [0, 65535]"""

ProtectionData(value, quality, elapsed_time)

ProtectionData( value: ProtectionValue, quality: ProtectionQuality, elapsed_time: int)

Create new instance of ProtectionData(value, quality, elapsed_time)

Alias for field number 0

Alias for field number 1

elapsed_time: int

elapsed_time in range [0, 65535]

class ProtectionStartData(typing.NamedTuple):
277class ProtectionStartData(typing.NamedTuple):
278    value: ProtectionStartValue
279    quality: ProtectionQuality
280    duration_time: int
281    """duration_time in range [0, 65535]"""

ProtectionStartData(value, quality, duration_time)

ProtectionStartData( value: ProtectionStartValue, quality: ProtectionQuality, duration_time: int)

Create new instance of ProtectionStartData(value, quality, duration_time)

Alias for field number 0

Alias for field number 1

duration_time: int

duration_time in range [0, 65535]

class ProtectionCommandData(typing.NamedTuple):
284class ProtectionCommandData(typing.NamedTuple):
285    value: ProtectionCommandValue
286    quality: ProtectionQuality
287    operating_time: int
288    """operating_time in range [0, 65535]"""

ProtectionCommandData(value, quality, operating_time)

ProtectionCommandData( value: ProtectionCommandValue, quality: ProtectionQuality, operating_time: int)

Create new instance of ProtectionCommandData(value, quality, operating_time)

Alias for field number 0

Alias for field number 1

operating_time: int

operating_time in range [0, 65535]

class StatusData(typing.NamedTuple):
291class StatusData(typing.NamedTuple):
292    value: StatusValue
293    quality: MeasurementQuality

StatusData(value, quality)

StatusData( value: StatusValue, quality: MeasurementQuality)

Create new instance of StatusData(value, quality)

value: StatusValue

Alias for field number 0

Alias for field number 1

class SingleCommand(typing.NamedTuple):
310class SingleCommand(typing.NamedTuple):
311    value: SingleValue
312    select: bool
313    qualifier: int
314    """qualifier in range [0, 31]"""

SingleCommand(value, select, qualifier)

SingleCommand( value: SingleValue, select: bool, qualifier: int)

Create new instance of SingleCommand(value, select, qualifier)

value: SingleValue

Alias for field number 0

select: bool

Alias for field number 1

qualifier: int

qualifier in range [0, 31]

class DoubleCommand(typing.NamedTuple):
317class DoubleCommand(typing.NamedTuple):
318    value: DoubleValue
319    select: bool
320    qualifier: int
321    """qualifier in range [0, 31]"""

DoubleCommand(value, select, qualifier)

DoubleCommand( value: DoubleValue, select: bool, qualifier: int)

Create new instance of DoubleCommand(value, select, qualifier)

value: DoubleValue

Alias for field number 0

select: bool

Alias for field number 1

qualifier: int

qualifier in range [0, 31]

class RegulatingCommand(typing.NamedTuple):
324class RegulatingCommand(typing.NamedTuple):
325    value: RegulatingValue
326    select: bool
327    qualifier: int
328    """qualifier in range [0, 31]"""

RegulatingCommand(value, select, qualifier)

RegulatingCommand( value: RegulatingValue, select: bool, qualifier: int)

Create new instance of RegulatingCommand(value, select, qualifier)

Alias for field number 0

select: bool

Alias for field number 1

qualifier: int

qualifier in range [0, 31]

class NormalizedCommand(typing.NamedTuple):
331class NormalizedCommand(typing.NamedTuple):
332    value: NormalizedValue
333    select: bool

NormalizedCommand(value, select)

NormalizedCommand( value: NormalizedValue, select: bool)

Create new instance of NormalizedCommand(value, select)

Alias for field number 0

select: bool

Alias for field number 1

class ScaledCommand(typing.NamedTuple):
336class ScaledCommand(typing.NamedTuple):
337    value: ScaledValue
338    select: bool

ScaledCommand(value, select)

ScaledCommand( value: ScaledValue, select: bool)

Create new instance of ScaledCommand(value, select)

value: ScaledValue

Alias for field number 0

select: bool

Alias for field number 1

class FloatingCommand(typing.NamedTuple):
341class FloatingCommand(typing.NamedTuple):
342    value: FloatingValue
343    select: bool

FloatingCommand(value, select)

FloatingCommand( value: FloatingValue, select: bool)

Create new instance of FloatingCommand(value, select)

value: FloatingValue

Alias for field number 0

select: bool

Alias for field number 1

class BitstringCommand(typing.NamedTuple):
346class BitstringCommand(typing.NamedTuple):
347    value: BitstringValue

BitstringCommand(value,)

BitstringCommand(value: BitstringValue)

Create new instance of BitstringCommand(value,)

Alias for field number 0

class NormalizedParameter(typing.NamedTuple):
359class NormalizedParameter(typing.NamedTuple):
360    value: NormalizedValue
361    qualifier: int
362    """qualifier in range [0, 255]"""

NormalizedParameter(value, qualifier)

NormalizedParameter( value: NormalizedValue, qualifier: int)

Create new instance of NormalizedParameter(value, qualifier)

Alias for field number 0

qualifier: int

qualifier in range [0, 255]

class ScaledParameter(typing.NamedTuple):
365class ScaledParameter(typing.NamedTuple):
366    value: ScaledValue
367    qualifier: int
368    """qualifier in range [0, 255]"""

ScaledParameter(value, qualifier)

ScaledParameter( value: ScaledValue, qualifier: int)

Create new instance of ScaledParameter(value, qualifier)

value: ScaledValue

Alias for field number 0

qualifier: int

qualifier in range [0, 255]

class FloatingParameter(typing.NamedTuple):
371class FloatingParameter(typing.NamedTuple):
372    value: FloatingValue
373    qualifier: int
374    """qualifier in range [0, 255]"""

FloatingParameter(value, qualifier)

FloatingParameter( value: FloatingValue, qualifier: int)

Create new instance of FloatingParameter(value, qualifier)

value: FloatingValue

Alias for field number 0

qualifier: int

qualifier in range [0, 255]

class DataMsg(typing.NamedTuple):
382class DataMsg(typing.NamedTuple):
383    is_test: bool
384    originator_address: OriginatorAddress
385    asdu_address: AsduAddress
386    io_address: IoAddress
387    data: Data
388    time: Time | None
389    cause: DataCause

DataMsg(is_test, originator_address, asdu_address, io_address, data, time, cause)

DataMsg( is_test: bool, originator_address: int, asdu_address: int, io_address: int, data: SingleData | DoubleData | StepPositionData | BitstringData | NormalizedData | ScaledData | FloatingData | BinaryCounterData | ProtectionData | ProtectionStartData | ProtectionCommandData | StatusData, time: Time | None, cause: DataResCause | int)

Create new instance of DataMsg(is_test, originator_address, asdu_address, io_address, data, time, cause)

is_test: bool

Alias for field number 0

originator_address: int

Alias for field number 1

asdu_address: int

Alias for field number 2

io_address: int

Alias for field number 3

time: Time | None

Alias for field number 5

cause: DataResCause | int

Alias for field number 6

class CommandMsg(typing.NamedTuple):
392class CommandMsg(typing.NamedTuple):
393    is_test: bool
394    originator_address: OriginatorAddress
395    asdu_address: AsduAddress
396    io_address: IoAddress
397    command: Command
398    is_negative_confirm: bool
399    cause: CommandCause

CommandMsg(is_test, originator_address, asdu_address, io_address, command, is_negative_confirm, cause)

CommandMsg( is_test: bool, originator_address: int, asdu_address: int, io_address: int, command: SingleCommand | DoubleCommand | RegulatingCommand | NormalizedCommand | ScaledCommand | FloatingCommand | BitstringCommand, is_negative_confirm: bool, cause: CommandReqCause | CommandResCause | int)

Create new instance of CommandMsg(is_test, originator_address, asdu_address, io_address, command, is_negative_confirm, cause)

is_test: bool

Alias for field number 0

originator_address: int

Alias for field number 1

asdu_address: int

Alias for field number 2

io_address: int

Alias for field number 3

is_negative_confirm: bool

Alias for field number 5

Alias for field number 6

class InitializationMsg(typing.NamedTuple):
402class InitializationMsg(typing.NamedTuple):
403    is_test: bool
404    originator_address: OriginatorAddress
405    asdu_address: AsduAddress
406    param_change: bool
407    cause: InitializationCause

InitializationMsg(is_test, originator_address, asdu_address, param_change, cause)

InitializationMsg( is_test: bool, originator_address: int, asdu_address: int, param_change: bool, cause: InitializationResCause | int)

Create new instance of InitializationMsg(is_test, originator_address, asdu_address, param_change, cause)

is_test: bool

Alias for field number 0

originator_address: int

Alias for field number 1

asdu_address: int

Alias for field number 2

param_change: bool

Alias for field number 3

cause: InitializationResCause | int

Alias for field number 4

class InterrogationMsg(typing.NamedTuple):
410class InterrogationMsg(typing.NamedTuple):
411    is_test: bool
412    originator_address: OriginatorAddress
413    asdu_address: AsduAddress
414    request: int
415    """request in range [0, 255]"""
416    is_negative_confirm: bool
417    cause: CommandCause

InterrogationMsg(is_test, originator_address, asdu_address, request, is_negative_confirm, cause)

InterrogationMsg( is_test: bool, originator_address: int, asdu_address: int, request: int, is_negative_confirm: bool, cause: CommandReqCause | CommandResCause | int)

Create new instance of InterrogationMsg(is_test, originator_address, asdu_address, request, is_negative_confirm, cause)

is_test: bool

Alias for field number 0

originator_address: int

Alias for field number 1

asdu_address: int

Alias for field number 2

request: int

request in range [0, 255]

is_negative_confirm: bool

Alias for field number 4

Alias for field number 5

class CounterInterrogationMsg(typing.NamedTuple):
420class CounterInterrogationMsg(typing.NamedTuple):
421    is_test: bool
422    originator_address: OriginatorAddress
423    asdu_address: AsduAddress
424    request: int
425    """request in range [0, 63]"""
426    freeze: FreezeCode
427    is_negative_confirm: bool
428    cause: CommandCause

CounterInterrogationMsg(is_test, originator_address, asdu_address, request, freeze, is_negative_confirm, cause)

CounterInterrogationMsg( is_test: bool, originator_address: int, asdu_address: int, request: int, freeze: FreezeCode, is_negative_confirm: bool, cause: CommandReqCause | CommandResCause | int)

Create new instance of CounterInterrogationMsg(is_test, originator_address, asdu_address, request, freeze, is_negative_confirm, cause)

is_test: bool

Alias for field number 0

originator_address: int

Alias for field number 1

asdu_address: int

Alias for field number 2

request: int

request in range [0, 63]

freeze: FreezeCode

Alias for field number 4

is_negative_confirm: bool

Alias for field number 5

Alias for field number 6

class ReadMsg(typing.NamedTuple):
431class ReadMsg(typing.NamedTuple):
432    is_test: bool
433    originator_address: OriginatorAddress
434    asdu_address: AsduAddress
435    io_address: IoAddress
436    cause: ReadCause

ReadMsg(is_test, originator_address, asdu_address, io_address, cause)

ReadMsg( is_test: bool, originator_address: int, asdu_address: int, io_address: int, cause: ReadReqCause | ReadResCause | int)

Create new instance of ReadMsg(is_test, originator_address, asdu_address, io_address, cause)

is_test: bool

Alias for field number 0

originator_address: int

Alias for field number 1

asdu_address: int

Alias for field number 2

io_address: int

Alias for field number 3

cause: ReadReqCause | ReadResCause | int

Alias for field number 4

class ClockSyncMsg(typing.NamedTuple):
439class ClockSyncMsg(typing.NamedTuple):
440    is_test: bool
441    originator_address: OriginatorAddress
442    asdu_address: AsduAddress
443    time: Time
444    is_negative_confirm: bool
445    cause: ClockSyncCause

ClockSyncMsg(is_test, originator_address, asdu_address, time, is_negative_confirm, cause)

ClockSyncMsg( is_test: bool, originator_address: int, asdu_address: int, time: Time, is_negative_confirm: bool, cause: ClockSyncReqCause | ClockSyncResCause | int)

Create new instance of ClockSyncMsg(is_test, originator_address, asdu_address, time, is_negative_confirm, cause)

is_test: bool

Alias for field number 0

originator_address: int

Alias for field number 1

asdu_address: int

Alias for field number 2

time: Time

Alias for field number 3

is_negative_confirm: bool

Alias for field number 4

Alias for field number 5

class TestMsg(typing.NamedTuple):
448class TestMsg(typing.NamedTuple):
449    is_test: bool
450    originator_address: OriginatorAddress
451    asdu_address: AsduAddress
452    cause: ActivationCause

TestMsg(is_test, originator_address, asdu_address, cause)

TestMsg( is_test: bool, originator_address: int, asdu_address: int, cause: ActivationReqCause | ActivationResCause | int)

Create new instance of TestMsg(is_test, originator_address, asdu_address, cause)

is_test: bool

Alias for field number 0

originator_address: int

Alias for field number 1

asdu_address: int

Alias for field number 2

Alias for field number 3

class ResetMsg(typing.NamedTuple):
455class ResetMsg(typing.NamedTuple):
456    is_test: bool
457    originator_address: OriginatorAddress
458    asdu_address: AsduAddress
459    qualifier: int
460    """qualifier in range [0, 255]"""
461    cause: ActivationCause

ResetMsg(is_test, originator_address, asdu_address, qualifier, cause)

ResetMsg( is_test: bool, originator_address: int, asdu_address: int, qualifier: int, cause: ActivationReqCause | ActivationResCause | int)

Create new instance of ResetMsg(is_test, originator_address, asdu_address, qualifier, cause)

is_test: bool

Alias for field number 0

originator_address: int

Alias for field number 1

asdu_address: int

Alias for field number 2

qualifier: int

qualifier in range [0, 255]

Alias for field number 4

class DelayMsg(typing.NamedTuple):
464class DelayMsg(typing.NamedTuple):
465    is_test: bool
466    originator_address: OriginatorAddress
467    asdu_address: AsduAddress
468    time: int
469    """time in range [0, 65535]"""
470    cause: DelayCause

DelayMsg(is_test, originator_address, asdu_address, time, cause)

DelayMsg( is_test: bool, originator_address: int, asdu_address: int, time: int, cause: DelayReqCause | DelayResCause | int)

Create new instance of DelayMsg(is_test, originator_address, asdu_address, time, cause)

is_test: bool

Alias for field number 0

originator_address: int

Alias for field number 1

asdu_address: int

Alias for field number 2

time: int

time in range [0, 65535]

cause: DelayReqCause | DelayResCause | int

Alias for field number 4

class ParameterMsg(typing.NamedTuple):
473class ParameterMsg(typing.NamedTuple):
474    is_test: bool
475    originator_address: OriginatorAddress
476    asdu_address: AsduAddress
477    io_address: IoAddress
478    parameter: Parameter
479    cause: ParameterCause

ParameterMsg(is_test, originator_address, asdu_address, io_address, parameter, cause)

ParameterMsg( is_test: bool, originator_address: int, asdu_address: int, io_address: int, parameter: NormalizedParameter | ScaledParameter | FloatingParameter, cause: ParameterReqCause | ParameterResCause | int)

Create new instance of ParameterMsg(is_test, originator_address, asdu_address, io_address, parameter, cause)

is_test: bool

Alias for field number 0

originator_address: int

Alias for field number 1

asdu_address: int

Alias for field number 2

io_address: int

Alias for field number 3

Alias for field number 4

Alias for field number 5

class ParameterActivationMsg(typing.NamedTuple):
482class ParameterActivationMsg(typing.NamedTuple):
483    is_test: bool
484    originator_address: OriginatorAddress
485    asdu_address: AsduAddress
486    io_address: IoAddress
487    qualifier: int
488    """qualifier in range [0, 255]"""
489    cause: ParameterActivationCause

ParameterActivationMsg(is_test, originator_address, asdu_address, io_address, qualifier, cause)

ParameterActivationMsg( is_test: bool, originator_address: int, asdu_address: int, io_address: int, qualifier: int, cause: ParameterActivationReqCause | ParameterActivationResCause | int)

Create new instance of ParameterActivationMsg(is_test, originator_address, asdu_address, io_address, qualifier, cause)

is_test: bool

Alias for field number 0

originator_address: int

Alias for field number 1

asdu_address: int

Alias for field number 2

io_address: int

Alias for field number 3

qualifier: int

qualifier in range [0, 255]

Alias for field number 5

def time_from_datetime( dt: datetime.datetime, invalid: bool = False) -> Time:
66def time_from_datetime(dt: datetime.datetime,
67                       invalid: bool = False
68                       ) -> Time:
69    """Create Time from datetime.datetime"""
70    # TODO document edge cases (local time, os implementation, ...)
71    #  rounding microseconds to the nearest millisecond
72    dt_rounded = (
73        dt.replace(microsecond=0) +
74        datetime.timedelta(milliseconds=round(dt.microsecond / 1000)))
75    local_time = time.localtime(dt_rounded.timestamp())
76
77    return Time(
78        size=TimeSize.SEVEN,
79        milliseconds=(local_time.tm_sec * 1000 +
80                      dt_rounded.microsecond // 1000),
81        invalid=invalid,
82        minutes=local_time.tm_min,
83        summer_time=bool(local_time.tm_isdst),
84        hours=local_time.tm_hour,
85        day_of_week=local_time.tm_wday + 1,
86        day_of_month=local_time.tm_mday,
87        months=local_time.tm_mon,
88        years=local_time.tm_year % 100)

Create Time from datetime.datetime

def time_to_datetime(t: Time) -> datetime.datetime:
 91def time_to_datetime(t: Time
 92                     ) -> datetime.datetime:
 93    """Convert Time to datetime.datetime"""
 94    # TODO document edge cases (local time, os implementation, ...)
 95    # TODO maybe allow diferent time size (use now for time)
 96    if t.size != TimeSize.SEVEN:
 97        raise ValueError('unsupported time size')
 98
 99    local_dt = datetime.datetime(
100        year=2000 + t.years if t.years < 70 else 1900 + t.years,
101        month=t.months,
102        day=t.day_of_month,
103        hour=t.hours,
104        minute=t.minutes,
105        second=int(t.milliseconds / 1000),
106        microsecond=(t.milliseconds % 1000) * 1000,
107        fold=not t.summer_time)
108
109    return local_dt.astimezone(tz=datetime.timezone.utc)

Convert Time to datetime.datetime

class MasterConnection(hat.aio.group.Resource):
 9class MasterConnection(aio.Resource):
10
11    def __init__(self,
12                 conn: unbalanced.MasterConnection,
13                 cause_size: common.CauseSize,
14                 asdu_address_size: common.AsduAddressSize,
15                 io_address_size: common.IoAddressSize):
16        self._conn = conn
17        self._encoder = encoder.Encoder(cause_size=cause_size,
18                                        asdu_address_size=asdu_address_size,
19                                        io_address_size=io_address_size)
20
21    @property
22    def async_group(self):
23        return self._conn.async_group
24
25    @property
26    def address(self) -> common.Address:
27        return self._conn.address
28
29    async def send(self, msgs: list[common.Msg]):
30        for data in self._encoder.encode(msgs):
31            await self._conn.send(data)
32
33    async def receive(self) -> list[common.Msg]:
34        data = await self._conn.receive()
35        return list(self._encoder.decode(data))

Resource with lifetime control based on Group.

MasterConnection( conn: MasterConnection, cause_size: CauseSize, asdu_address_size: AsduAddressSize, io_address_size: IoAddressSize)
11    def __init__(self,
12                 conn: unbalanced.MasterConnection,
13                 cause_size: common.CauseSize,
14                 asdu_address_size: common.AsduAddressSize,
15                 io_address_size: common.IoAddressSize):
16        self._conn = conn
17        self._encoder = encoder.Encoder(cause_size=cause_size,
18                                        asdu_address_size=asdu_address_size,
19                                        io_address_size=io_address_size)
async_group
21    @property
22    def async_group(self):
23        return self._conn.async_group

Group controlling resource's lifetime.

address: int | None
25    @property
26    def address(self) -> common.Address:
27        return self._conn.address
29    async def send(self, msgs: list[common.Msg]):
30        for data in self._encoder.encode(msgs):
31            await self._conn.send(data)
33    async def receive(self) -> list[common.Msg]:
34        data = await self._conn.receive()
35        return list(self._encoder.decode(data))
class SlaveConnection(hat.aio.group.Resource):
11class SlaveConnection(aio.Resource):
12
13    def __init__(self,
14                 conn: unbalanced.SlaveConnection,
15                 cause_size: common.CauseSize,
16                 asdu_address_size: common.AsduAddressSize,
17                 io_address_size: common.IoAddressSize):
18        self._conn = conn
19        self._encoder = encoder.Encoder(cause_size=cause_size,
20                                        asdu_address_size=asdu_address_size,
21                                        io_address_size=io_address_size)
22
23    @property
24    def async_group(self):
25        return self._conn.async_group
26
27    @property
28    def address(self) -> common.Address:
29        return self._conn.address
30
31    def send(self,
32             msgs: list[common.Msg],
33             sent_cb: aio.AsyncCallable[[], None] | None = None):
34        data = collections.deque(self._encoder.encode(msgs))
35        while data:
36            i = data.popleft()
37            self._conn.send(i, sent_cb=None if data else sent_cb)
38
39    async def receive(self) -> list[common.Msg]:
40        data = await self._conn.receive()
41        return list(self._encoder.decode(data))

Resource with lifetime control based on Group.

SlaveConnection( conn: SlaveConnection, cause_size: CauseSize, asdu_address_size: AsduAddressSize, io_address_size: IoAddressSize)
13    def __init__(self,
14                 conn: unbalanced.SlaveConnection,
15                 cause_size: common.CauseSize,
16                 asdu_address_size: common.AsduAddressSize,
17                 io_address_size: common.IoAddressSize):
18        self._conn = conn
19        self._encoder = encoder.Encoder(cause_size=cause_size,
20                                        asdu_address_size=asdu_address_size,
21                                        io_address_size=io_address_size)
async_group
23    @property
24    def async_group(self):
25        return self._conn.async_group

Group controlling resource's lifetime.

address: int | None
27    @property
28    def address(self) -> common.Address:
29        return self._conn.address
def send( self, msgs: list[DataMsg | CommandMsg | InitializationMsg | InterrogationMsg | CounterInterrogationMsg | ReadMsg | ClockSyncMsg | TestMsg | ResetMsg | DelayMsg | ParameterMsg | ParameterActivationMsg], sent_cb: Optional[Callable[[], Optional[Awaitable[NoneType]]]] = None):
31    def send(self,
32             msgs: list[common.Msg],
33             sent_cb: aio.AsyncCallable[[], None] | None = None):
34        data = collections.deque(self._encoder.encode(msgs))
35        while data:
36            i = data.popleft()
37            self._conn.send(i, sent_cb=None if data else sent_cb)
39    async def receive(self) -> list[common.Msg]:
40        data = await self._conn.receive()
41        return list(self._encoder.decode(data))