hat.drivers.iec104

IEC 60870-5-104 communication protocol

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

Common base class for all non-exit exceptions.

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):
125class CommandMsg(typing.NamedTuple):
126    is_test: bool
127    originator_address: OriginatorAddress
128    asdu_address: AsduAddress
129    io_address: IoAddress
130    command: Command
131    is_negative_confirm: bool
132    time: Time | None
133    cause: CommandCause

CommandMsg(is_test, originator_address, asdu_address, io_address, command, is_negative_confirm, time, 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, time: Time | None, cause: CommandReqCause | CommandResCause | int)

Create new instance of CommandMsg(is_test, originator_address, asdu_address, io_address, command, is_negative_confirm, 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

is_negative_confirm: bool

Alias for field number 5

time: Time | None

Alias for field number 6

Alias for field number 7

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):
136class TestMsg(typing.NamedTuple):
137    is_test: bool
138    originator_address: OriginatorAddress
139    asdu_address: AsduAddress
140    counter: int
141    """counter in range [0, 65535]"""
142    time: Time
143    cause: ActivationCause

TestMsg(is_test, originator_address, asdu_address, counter, time, cause)

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

Create new instance of TestMsg(is_test, originator_address, asdu_address, counter, 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

counter: int

counter in range [0, 65535]

time: Time

Alias for field number 4

Alias for field number 5

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 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 Connection(hat.aio.group.Resource):
163class Connection(aio.Resource):
164
165    @property
166    @abc.abstractmethod
167    def conn(self) -> apci.Connection:
168        pass
169
170    @property
171    def async_group(self) -> aio.Group:
172        return self.conn.async_group
173
174    @property
175    def info(self) -> tcp.ConnectionInfo:
176        return self.conn.info
177
178    @property
179    def is_enabled(self) -> bool:
180        return self.conn.is_enabled
181
182    def register_enabled_cb(self,
183                            cb: typing.Callable[[bool], None]
184                            ) -> util.RegisterCallbackHandle:
185        return self.conn.register_enabled_cb(cb)
186
187    @abc.abstractmethod
188    async def send(self, msgs: list[Msg], wait_ack: bool = False):
189        pass
190
191    @abc.abstractmethod
192    async def drain(self, wait_ack: bool = False):
193        pass
194
195    @abc.abstractmethod
196    async def receive(self) -> list[Msg]:
197        pass

Resource with lifetime control based on Group.

conn: Connection
165    @property
166    @abc.abstractmethod
167    def conn(self) -> apci.Connection:
168        pass
async_group: hat.aio.group.Group
170    @property
171    def async_group(self) -> aio.Group:
172        return self.conn.async_group

Group controlling resource's lifetime.

info: hat.drivers.tcp.ConnectionInfo
174    @property
175    def info(self) -> tcp.ConnectionInfo:
176        return self.conn.info
is_enabled: bool
178    @property
179    def is_enabled(self) -> bool:
180        return self.conn.is_enabled
def register_enabled_cb( self, cb: Callable[[bool], NoneType]) -> hat.util.callback.RegisterCallbackHandle:
182    def register_enabled_cb(self,
183                            cb: typing.Callable[[bool], None]
184                            ) -> util.RegisterCallbackHandle:
185        return self.conn.register_enabled_cb(cb)
@abc.abstractmethod
async def send( self, msgs: list[DataMsg | CommandMsg | InitializationMsg | InterrogationMsg | CounterInterrogationMsg | ReadMsg | ClockSyncMsg | TestMsg | ResetMsg | ParameterMsg | ParameterActivationMsg], wait_ack: bool = False):
187    @abc.abstractmethod
188    async def send(self, msgs: list[Msg], wait_ack: bool = False):
189        pass
@abc.abstractmethod
async def drain(self, wait_ack: bool = False):
191    @abc.abstractmethod
192    async def drain(self, wait_ack: bool = False):
193        pass
@abc.abstractmethod
async def receive( self) -> list[DataMsg | CommandMsg | InitializationMsg | InterrogationMsg | CounterInterrogationMsg | ReadMsg | ClockSyncMsg | TestMsg | ResetMsg | ParameterMsg | ParameterActivationMsg]:
195    @abc.abstractmethod
196    async def receive(self) -> list[Msg]:
197        pass
class Function(enum.Enum):
200class Function(enum.Enum):
201    DATA = 'data'
202    COMMAND = 'command'
203    INITIALIZATION = 'initialization'
204    INTERROGATION = 'interrogation'
205    COUNTER_INTERROGATION = 'counter_interrogation'
206    READ = 'read'
207    CLOCK_SYNC = 'clock_sync'
208    TEST = 'test'
209    RESET = 'reset'
210    PARAMETER = 'parameter'
211    PARAMETER_ACTIVATION = 'parameter_activation'

An enumeration.

DATA = <Function.DATA: 'data'>
COMMAND = <Function.COMMAND: 'command'>
INITIALIZATION = <Function.INITIALIZATION: 'initialization'>
INTERROGATION = <Function.INTERROGATION: 'interrogation'>
COUNTER_INTERROGATION = <Function.COUNTER_INTERROGATION: 'counter_interrogation'>
READ = <Function.READ: 'read'>
CLOCK_SYNC = <Function.CLOCK_SYNC: 'clock_sync'>
TEST = <Function.TEST: 'test'>
RESET = <Function.RESET: 'reset'>
PARAMETER = <Function.PARAMETER: 'parameter'>
PARAMETER_ACTIVATION = <Function.PARAMETER_ACTIVATION: 'parameter_activation'>
ConnectionCb = typing.Callable[[Connection], typing.Optional[typing.Awaitable[NoneType]]]
async def connect( addr: hat.drivers.tcp.Address, response_timeout: float = 15, supervisory_timeout: float = 10, test_timeout: float = 20, send_window_size: int = 12, receive_window_size: int = 8, update_key: bytes | bytearray | memoryview | None = None, critical_functions: set[Function] = {<Function.PARAMETER: 'parameter'>, <Function.TEST: 'test'>, <Function.COMMAND: 'command'>, <Function.RESET: 'reset'>, <Function.PARAMETER_ACTIVATION: 'parameter_activation'>}, **kwargs) -> Connection:
17async def connect(addr: tcp.Address,
18                  response_timeout: float = 15,
19                  supervisory_timeout: float = 10,
20                  test_timeout: float = 20,
21                  send_window_size: int = 12,
22                  receive_window_size: int = 8,
23                  update_key: util.Bytes | None = None,
24                  critical_functions: set[common.Function] = secure.default_critical_functions,  # NOQA
25                  **kwargs
26                  ) -> common.Connection:
27    apci_conn = await apci.connect(addr=addr,
28                                   response_timeout=response_timeout,
29                                   supervisory_timeout=supervisory_timeout,
30                                   test_timeout=test_timeout,
31                                   send_window_size=send_window_size,
32                                   receive_window_size=receive_window_size,
33                                   **kwargs)
34
35    if update_key is not None:
36        return secure.SecureConnection(apci_conn, True, update_key,
37                                       critical_functions)
38
39    return regular.RegularConnection(apci_conn)
async def listen( connection_cb: Callable[[Connection], Optional[Awaitable[NoneType]]], addr: hat.drivers.tcp.Address = Address(host='0.0.0.0', port=2404), response_timeout: float = 15, supervisory_timeout: float = 10, test_timeout: float = 20, send_window_size: int = 12, receive_window_size: int = 8, update_key: bytes | bytearray | memoryview | None = None, critical_functions: set[Function] = {<Function.PARAMETER: 'parameter'>, <Function.TEST: 'test'>, <Function.COMMAND: 'command'>, <Function.RESET: 'reset'>, <Function.PARAMETER_ACTIVATION: 'parameter_activation'>}, **kwargs) -> Server:
42async def listen(connection_cb: ConnectionCb,
43                 addr: tcp.Address = tcp.Address('0.0.0.0', 2404),
44                 response_timeout: float = 15,
45                 supervisory_timeout: float = 10,
46                 test_timeout: float = 20,
47                 send_window_size: int = 12,
48                 receive_window_size: int = 8,
49                 update_key: util.Bytes | None = None,
50                 critical_functions: set[common.Function] = secure.default_critical_functions,  # NOQA
51                 **kwargs
52                 ) -> 'Server':
53    server = Server()
54    server._connection_cb = connection_cb
55    server._update_key = update_key
56    server._critical_functions = critical_functions
57    server._srv = await apci.listen(connection_cb=server._on_connection,
58                                    addr=addr,
59                                    response_timeout=response_timeout,
60                                    supervisory_timeout=supervisory_timeout,
61                                    test_timeout=test_timeout,
62                                    send_window_size=send_window_size,
63                                    receive_window_size=receive_window_size,
64                                    **kwargs)
65    return server
class Server(hat.aio.group.Resource):
68class Server(aio.Resource):
69
70    @property
71    def async_group(self):
72        return self._srv.async_group
73
74    async def _on_connection(self, apci_conn):
75        if self._update_key is None:
76            conn = regular.RegularConnection(apci_conn)
77
78        else:
79            conn = secure.SecureConnection(apci_conn, False, self._update_key,
80                                           self._critical_functions)
81
82        try:
83            await aio.call(self._connection_cb, conn)
84
85        except BaseException:
86            await aio.uncancellable(conn.async_close())

Resource with lifetime control based on Group.

async_group
70    @property
71    def async_group(self):
72        return self._srv.async_group

Group controlling resource's lifetime.