hat.drivers.iec60870.encodings.iec104

IEC 60870-5-104 messages

  1"""IEC 60870-5-104 messages"""
  2
  3from hat.drivers.iec60870.encodings.iec104.common import (
  4    AsduTypeError,
  5    TimeSize,
  6    Time,
  7    time_from_datetime,
  8    time_to_datetime,
  9    OriginatorAddress,
 10    AsduAddress,
 11    IoAddress,
 12    AsduType,
 13    CauseType,
 14    OtherCauseType,
 15    Cause,
 16    QualityType,
 17    IndicationQuality,
 18    MeasurementQuality,
 19    CounterQuality,
 20    ProtectionQuality,
 21    Quality,
 22    FreezeCode,
 23    SingleValue,
 24    DoubleValue,
 25    RegulatingValue,
 26    StepPositionValue,
 27    BitstringValue,
 28    NormalizedValue,
 29    ScaledValue,
 30    FloatingValue,
 31    BinaryCounterValue,
 32    ProtectionValue,
 33    ProtectionStartValue,
 34    ProtectionCommandValue,
 35    StatusValue,
 36    IoElement_M_SP_NA,
 37    IoElement_M_DP_NA,
 38    IoElement_M_ST_NA,
 39    IoElement_M_BO_NA,
 40    IoElement_M_ME_NA,
 41    IoElement_M_ME_NB,
 42    IoElement_M_ME_NC,
 43    IoElement_M_IT_NA,
 44    IoElement_M_PS_NA,
 45    IoElement_M_ME_ND,
 46    IoElement_M_SP_TB,
 47    IoElement_M_DP_TB,
 48    IoElement_M_ST_TB,
 49    IoElement_M_BO_TB,
 50    IoElement_M_ME_TD,
 51    IoElement_M_ME_TE,
 52    IoElement_M_ME_TF,
 53    IoElement_M_IT_TB,
 54    IoElement_M_EP_TD,
 55    IoElement_M_EP_TE,
 56    IoElement_M_EP_TF,
 57    IoElement_C_SC_NA,
 58    IoElement_C_DC_NA,
 59    IoElement_C_RC_NA,
 60    IoElement_C_SE_NA,
 61    IoElement_C_SE_NB,
 62    IoElement_C_SE_NC,
 63    IoElement_C_BO_NA,
 64    IoElement_M_EI_NA,
 65    IoElement_C_IC_NA,
 66    IoElement_C_CI_NA,
 67    IoElement_C_RD_NA,
 68    IoElement_C_CS_NA,
 69    IoElement_C_RP_NA,
 70    IoElement_P_ME_NA,
 71    IoElement_P_ME_NB,
 72    IoElement_P_ME_NC,
 73    IoElement_P_AC_NA,
 74    IoElement_F_FR_NA,
 75    IoElement_F_SR_NA,
 76    IoElement_F_SC_NA,
 77    IoElement_F_LS_NA,
 78    IoElement_F_AF_NA,
 79    IoElement_F_SG_NA,
 80    IoElement_F_DR_TA,
 81    IoElement_C_SC_TA,
 82    IoElement_C_DC_TA,
 83    IoElement_C_RC_TA,
 84    IoElement_C_SE_TA,
 85    IoElement_C_SE_TB,
 86    IoElement_C_SE_TC,
 87    IoElement_C_BO_TA,
 88    IoElement_C_TS_TA,
 89    IoElement,
 90    IO,
 91    ASDU)
 92from hat.drivers.iec60870.encodings.iec104.encoder import (
 93    iec101_asdu_types,
 94    Encoder)
 95
 96
 97__all__ = ['AsduTypeError',
 98           'TimeSize',
 99           'Time',
100           'time_from_datetime',
101           'time_to_datetime',
102           'OriginatorAddress',
103           'AsduAddress',
104           'IoAddress',
105           'AsduType',
106           'CauseType',
107           'OtherCauseType',
108           'Cause',
109           'QualityType',
110           'IndicationQuality',
111           'MeasurementQuality',
112           'CounterQuality',
113           'ProtectionQuality',
114           'Quality',
115           'FreezeCode',
116           'SingleValue',
117           'DoubleValue',
118           'RegulatingValue',
119           'StepPositionValue',
120           'BitstringValue',
121           'NormalizedValue',
122           'ScaledValue',
123           'FloatingValue',
124           'BinaryCounterValue',
125           'ProtectionValue',
126           'ProtectionStartValue',
127           'ProtectionCommandValue',
128           'StatusValue',
129           'IoElement_M_SP_NA',
130           'IoElement_M_DP_NA',
131           'IoElement_M_ST_NA',
132           'IoElement_M_BO_NA',
133           'IoElement_M_ME_NA',
134           'IoElement_M_ME_NB',
135           'IoElement_M_ME_NC',
136           'IoElement_M_IT_NA',
137           'IoElement_M_PS_NA',
138           'IoElement_M_ME_ND',
139           'IoElement_M_SP_TB',
140           'IoElement_M_DP_TB',
141           'IoElement_M_ST_TB',
142           'IoElement_M_BO_TB',
143           'IoElement_M_ME_TD',
144           'IoElement_M_ME_TE',
145           'IoElement_M_ME_TF',
146           'IoElement_M_IT_TB',
147           'IoElement_M_EP_TD',
148           'IoElement_M_EP_TE',
149           'IoElement_M_EP_TF',
150           'IoElement_C_SC_NA',
151           'IoElement_C_DC_NA',
152           'IoElement_C_RC_NA',
153           'IoElement_C_SE_NA',
154           'IoElement_C_SE_NB',
155           'IoElement_C_SE_NC',
156           'IoElement_C_BO_NA',
157           'IoElement_M_EI_NA',
158           'IoElement_C_IC_NA',
159           'IoElement_C_CI_NA',
160           'IoElement_C_RD_NA',
161           'IoElement_C_CS_NA',
162           'IoElement_C_RP_NA',
163           'IoElement_P_ME_NA',
164           'IoElement_P_ME_NB',
165           'IoElement_P_ME_NC',
166           'IoElement_P_AC_NA',
167           'IoElement_F_FR_NA',
168           'IoElement_F_SR_NA',
169           'IoElement_F_SC_NA',
170           'IoElement_F_LS_NA',
171           'IoElement_F_AF_NA',
172           'IoElement_F_SG_NA',
173           'IoElement_F_DR_TA',
174           'IoElement_C_SC_TA',
175           'IoElement_C_DC_TA',
176           'IoElement_C_RC_TA',
177           'IoElement_C_SE_TA',
178           'IoElement_C_SE_TB',
179           'IoElement_C_SE_TC',
180           'IoElement_C_BO_TA',
181           'IoElement_C_TS_TA',
182           'IoElement',
183           'IO',
184           'ASDU',
185           'iec101_asdu_types',
186           'Encoder']
class AsduTypeError(builtins.Exception):
8class AsduTypeError(Exception):
9    pass

Common base class for all non-exit exceptions.

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

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

Create Time from datetime.datetime

def time_to_datetime(t: Time) -> datetime.datetime:
 95def time_to_datetime(t: Time
 96                     ) -> datetime.datetime:
 97    """Convert Time to datetime.datetime"""
 98    # TODO document edge cases (local time, os implementation, ...)
 99    # TODO support TimeSize.FOUR
100    if t.size == TimeSize.TWO:
101        local_now = datetime.datetime.now()
102        local_dt = local_now.replace(
103            second=int(t.milliseconds / 1000),
104            microsecond=(t.milliseconds % 1000) * 1000)
105
106        local_seconds = local_now.second + local_now.microsecond / 1_000_000
107        t_seconds = t.milliseconds / 1_000
108
109        if abs(local_seconds - t_seconds) > 30:
110            if local_seconds < t_seconds:
111                local_dt = local_dt - datetime.timedelta(minutes=1)
112
113            else:
114                local_dt = local_dt + datetime.timedelta(minutes=1)
115
116    elif t.size == TimeSize.THREE:
117        local_now = datetime.datetime.now()
118        local_dt = local_now.replace(
119            minute=t.minutes,
120            second=int(t.milliseconds / 1000),
121            microsecond=(t.milliseconds % 1000) * 1000)
122
123        local_minutes = (local_now.minute +
124                         local_now.second / 60 +
125                         local_now.microsecond / 60_000_000)
126        t_minutes = t.minutes + t.milliseconds / 60_000
127
128        if abs(local_minutes - t_minutes) > 30:
129            if local_minutes < t_minutes:
130                local_dt = local_dt - datetime.timedelta(hours=1)
131
132            else:
133                local_dt = local_dt + datetime.timedelta(hours=1)
134
135    elif t.size == TimeSize.SEVEN:
136        local_dt = datetime.datetime(
137            year=2000 + t.years if t.years < 70 else 1900 + t.years,
138            month=t.months,
139            day=t.day_of_month,
140            hour=t.hours,
141            minute=t.minutes,
142            second=int(t.milliseconds / 1000),
143            microsecond=(t.milliseconds % 1000) * 1000,
144            fold=not t.summer_time)
145
146    else:
147        raise ValueError('unsupported time size')
148
149    return local_dt.astimezone(tz=datetime.timezone.utc)

Convert Time to datetime.datetime

OriginatorAddress = <class 'int'>
AsduAddress = <class 'int'>
IoAddress = <class 'int'>
class AsduType(enum.Enum):
21class AsduType(enum.Enum):
22    M_SP_NA = iec101.AsduType.M_SP_NA.value
23    M_DP_NA = iec101.AsduType.M_DP_NA.value
24    M_ST_NA = iec101.AsduType.M_ST_NA.value
25    M_BO_NA = iec101.AsduType.M_BO_NA.value
26    M_ME_NA = iec101.AsduType.M_ME_NA.value
27    M_ME_NB = iec101.AsduType.M_ME_NB.value
28    M_ME_NC = iec101.AsduType.M_ME_NC.value
29    M_IT_NA = iec101.AsduType.M_IT_NA.value
30    M_PS_NA = iec101.AsduType.M_PS_NA.value
31    M_ME_ND = iec101.AsduType.M_ME_ND.value
32    M_SP_TB = iec101.AsduType.M_SP_TB.value
33    M_DP_TB = iec101.AsduType.M_DP_TB.value
34    M_ST_TB = iec101.AsduType.M_ST_TB.value
35    M_BO_TB = iec101.AsduType.M_BO_TB.value
36    M_ME_TD = iec101.AsduType.M_ME_TD.value
37    M_ME_TE = iec101.AsduType.M_ME_TE.value
38    M_ME_TF = iec101.AsduType.M_ME_TF.value
39    M_IT_TB = iec101.AsduType.M_IT_TB.value
40    M_EP_TD = iec101.AsduType.M_EP_TD.value
41    M_EP_TE = iec101.AsduType.M_EP_TE.value
42    M_EP_TF = iec101.AsduType.M_EP_TF.value
43    C_SC_NA = iec101.AsduType.C_SC_NA.value
44    C_DC_NA = iec101.AsduType.C_DC_NA.value
45    C_RC_NA = iec101.AsduType.C_RC_NA.value
46    C_SE_NA = iec101.AsduType.C_SE_NA.value
47    C_SE_NB = iec101.AsduType.C_SE_NB.value
48    C_SE_NC = iec101.AsduType.C_SE_NC.value
49    C_BO_NA = iec101.AsduType.C_BO_NA.value
50    C_SC_TA = 58
51    C_DC_TA = 59
52    C_RC_TA = 60
53    C_SE_TA = 61
54    C_SE_TB = 62
55    C_SE_TC = 63
56    C_BO_TA = 64
57    M_EI_NA = iec101.AsduType.M_EI_NA.value
58    C_IC_NA = iec101.AsduType.C_IC_NA.value
59    C_CI_NA = iec101.AsduType.C_CI_NA.value
60    C_RD_NA = iec101.AsduType.C_RD_NA.value
61    C_CS_NA = iec101.AsduType.C_CS_NA.value
62    C_RP_NA = iec101.AsduType.C_RP_NA.value
63    C_TS_TA = 107
64    P_ME_NA = iec101.AsduType.P_ME_NA.value
65    P_ME_NB = iec101.AsduType.P_ME_NB.value
66    P_ME_NC = iec101.AsduType.P_ME_NC.value
67    P_AC_NA = iec101.AsduType.P_AC_NA.value
68    F_FR_NA = iec101.AsduType.F_FR_NA.value
69    F_SR_NA = iec101.AsduType.F_SR_NA.value
70    F_SC_NA = iec101.AsduType.F_SC_NA.value
71    F_LS_NA = iec101.AsduType.F_LS_NA.value
72    F_AF_NA = iec101.AsduType.F_AF_NA.value
73    F_SG_NA = iec101.AsduType.F_SG_NA.value
74    F_DR_TA = iec101.AsduType.F_DR_TA.value
M_SP_NA = <AsduType.M_SP_NA: 1>
M_DP_NA = <AsduType.M_DP_NA: 3>
M_ST_NA = <AsduType.M_ST_NA: 5>
M_BO_NA = <AsduType.M_BO_NA: 7>
M_ME_NA = <AsduType.M_ME_NA: 9>
M_ME_NB = <AsduType.M_ME_NB: 11>
M_ME_NC = <AsduType.M_ME_NC: 13>
M_IT_NA = <AsduType.M_IT_NA: 15>
M_PS_NA = <AsduType.M_PS_NA: 20>
M_ME_ND = <AsduType.M_ME_ND: 21>
M_SP_TB = <AsduType.M_SP_TB: 30>
M_DP_TB = <AsduType.M_DP_TB: 31>
M_ST_TB = <AsduType.M_ST_TB: 32>
M_BO_TB = <AsduType.M_BO_TB: 33>
M_ME_TD = <AsduType.M_ME_TD: 34>
M_ME_TE = <AsduType.M_ME_TE: 35>
M_ME_TF = <AsduType.M_ME_TF: 36>
M_IT_TB = <AsduType.M_IT_TB: 37>
M_EP_TD = <AsduType.M_EP_TD: 38>
M_EP_TE = <AsduType.M_EP_TE: 39>
M_EP_TF = <AsduType.M_EP_TF: 40>
C_SC_NA = <AsduType.C_SC_NA: 45>
C_DC_NA = <AsduType.C_DC_NA: 46>
C_RC_NA = <AsduType.C_RC_NA: 47>
C_SE_NA = <AsduType.C_SE_NA: 48>
C_SE_NB = <AsduType.C_SE_NB: 49>
C_SE_NC = <AsduType.C_SE_NC: 50>
C_BO_NA = <AsduType.C_BO_NA: 51>
C_SC_TA = <AsduType.C_SC_TA: 58>
C_DC_TA = <AsduType.C_DC_TA: 59>
C_RC_TA = <AsduType.C_RC_TA: 60>
C_SE_TA = <AsduType.C_SE_TA: 61>
C_SE_TB = <AsduType.C_SE_TB: 62>
C_SE_TC = <AsduType.C_SE_TC: 63>
C_BO_TA = <AsduType.C_BO_TA: 64>
M_EI_NA = <AsduType.M_EI_NA: 70>
C_IC_NA = <AsduType.C_IC_NA: 100>
C_CI_NA = <AsduType.C_CI_NA: 101>
C_RD_NA = <AsduType.C_RD_NA: 102>
C_CS_NA = <AsduType.C_CS_NA: 103>
C_RP_NA = <AsduType.C_RP_NA: 105>
C_TS_TA = <AsduType.C_TS_TA: 107>
P_ME_NA = <AsduType.P_ME_NA: 110>
P_ME_NB = <AsduType.P_ME_NB: 111>
P_ME_NC = <AsduType.P_ME_NC: 112>
P_AC_NA = <AsduType.P_AC_NA: 113>
F_FR_NA = <AsduType.F_FR_NA: 120>
F_SR_NA = <AsduType.F_SR_NA: 121>
F_SC_NA = <AsduType.F_SC_NA: 122>
F_LS_NA = <AsduType.F_LS_NA: 123>
F_AF_NA = <AsduType.F_AF_NA: 124>
F_SG_NA = <AsduType.F_SG_NA: 125>
F_DR_TA = <AsduType.F_DR_TA: 126>
class CauseType(enum.Enum):
 86class CauseType(enum.Enum):
 87    UNDEFINED = 0
 88    PERIODIC = 1
 89    BACKGROUND_SCAN = 2
 90    SPONTANEOUS = 3
 91    INITIALIZED = 4
 92    REQUEST = 5
 93    ACTIVATION = 6
 94    ACTIVATION_CONFIRMATION = 7
 95    DEACTIVATION = 8
 96    DEACTIVATION_CONFIRMATION = 9
 97    ACTIVATION_TERMINATION = 10
 98    REMOTE_COMMAND = 11
 99    LOCAL_COMMAND = 12
100    FILE_TRANSFER = 13
101    INTERROGATED_STATION = 20
102    INTERROGATED_GROUP01 = 21
103    INTERROGATED_GROUP02 = 22
104    INTERROGATED_GROUP03 = 23
105    INTERROGATED_GROUP04 = 24
106    INTERROGATED_GROUP05 = 25
107    INTERROGATED_GROUP06 = 26
108    INTERROGATED_GROUP07 = 27
109    INTERROGATED_GROUP08 = 28
110    INTERROGATED_GROUP09 = 29
111    INTERROGATED_GROUP10 = 30
112    INTERROGATED_GROUP11 = 31
113    INTERROGATED_GROUP12 = 32
114    INTERROGATED_GROUP13 = 33
115    INTERROGATED_GROUP14 = 34
116    INTERROGATED_GROUP15 = 35
117    INTERROGATED_GROUP16 = 36
118    INTERROGATED_COUNTER = 37
119    INTERROGATED_COUNTER01 = 38
120    INTERROGATED_COUNTER02 = 39
121    INTERROGATED_COUNTER03 = 40
122    INTERROGATED_COUNTER04 = 41
123    UNKNOWN_TYPE = 44
124    UNKNOWN_CAUSE = 45
125    UNKNOWN_ASDU_ADDRESS = 46
126    UNKNOWN_IO_ADDRESS = 47
UNDEFINED = <CauseType.UNDEFINED: 0>
PERIODIC = <CauseType.PERIODIC: 1>
BACKGROUND_SCAN = <CauseType.BACKGROUND_SCAN: 2>
SPONTANEOUS = <CauseType.SPONTANEOUS: 3>
INITIALIZED = <CauseType.INITIALIZED: 4>
REQUEST = <CauseType.REQUEST: 5>
ACTIVATION = <CauseType.ACTIVATION: 6>
ACTIVATION_CONFIRMATION = <CauseType.ACTIVATION_CONFIRMATION: 7>
DEACTIVATION = <CauseType.DEACTIVATION: 8>
DEACTIVATION_CONFIRMATION = <CauseType.DEACTIVATION_CONFIRMATION: 9>
ACTIVATION_TERMINATION = <CauseType.ACTIVATION_TERMINATION: 10>
REMOTE_COMMAND = <CauseType.REMOTE_COMMAND: 11>
LOCAL_COMMAND = <CauseType.LOCAL_COMMAND: 12>
FILE_TRANSFER = <CauseType.FILE_TRANSFER: 13>
INTERROGATED_STATION = <CauseType.INTERROGATED_STATION: 20>
INTERROGATED_GROUP01 = <CauseType.INTERROGATED_GROUP01: 21>
INTERROGATED_GROUP02 = <CauseType.INTERROGATED_GROUP02: 22>
INTERROGATED_GROUP03 = <CauseType.INTERROGATED_GROUP03: 23>
INTERROGATED_GROUP04 = <CauseType.INTERROGATED_GROUP04: 24>
INTERROGATED_GROUP05 = <CauseType.INTERROGATED_GROUP05: 25>
INTERROGATED_GROUP06 = <CauseType.INTERROGATED_GROUP06: 26>
INTERROGATED_GROUP07 = <CauseType.INTERROGATED_GROUP07: 27>
INTERROGATED_GROUP08 = <CauseType.INTERROGATED_GROUP08: 28>
INTERROGATED_GROUP09 = <CauseType.INTERROGATED_GROUP09: 29>
INTERROGATED_GROUP10 = <CauseType.INTERROGATED_GROUP10: 30>
INTERROGATED_GROUP11 = <CauseType.INTERROGATED_GROUP11: 31>
INTERROGATED_GROUP12 = <CauseType.INTERROGATED_GROUP12: 32>
INTERROGATED_GROUP13 = <CauseType.INTERROGATED_GROUP13: 33>
INTERROGATED_GROUP14 = <CauseType.INTERROGATED_GROUP14: 34>
INTERROGATED_GROUP15 = <CauseType.INTERROGATED_GROUP15: 35>
INTERROGATED_GROUP16 = <CauseType.INTERROGATED_GROUP16: 36>
INTERROGATED_COUNTER = <CauseType.INTERROGATED_COUNTER: 37>
INTERROGATED_COUNTER01 = <CauseType.INTERROGATED_COUNTER01: 38>
INTERROGATED_COUNTER02 = <CauseType.INTERROGATED_COUNTER02: 39>
INTERROGATED_COUNTER03 = <CauseType.INTERROGATED_COUNTER03: 40>
INTERROGATED_COUNTER04 = <CauseType.INTERROGATED_COUNTER04: 41>
UNKNOWN_TYPE = <CauseType.UNKNOWN_TYPE: 44>
UNKNOWN_CAUSE = <CauseType.UNKNOWN_CAUSE: 45>
UNKNOWN_ASDU_ADDRESS = <CauseType.UNKNOWN_ASDU_ADDRESS: 46>
UNKNOWN_IO_ADDRESS = <CauseType.UNKNOWN_IO_ADDRESS: 47>
OtherCauseType = <class 'int'>
class Cause(typing.NamedTuple):
129class Cause(typing.NamedTuple):
130    type: CauseType | OtherCauseType
131    is_negative_confirm: bool
132    is_test: bool
133    originator_address: OriginatorAddress

Cause(type, is_negative_confirm, is_test, originator_address)

Cause( type: CauseType | int, is_negative_confirm: bool, is_test: bool, originator_address: int)

Create new instance of Cause(type, is_negative_confirm, is_test, originator_address)

type: CauseType | int

Alias for field number 0

is_negative_confirm: bool

Alias for field number 1

is_test: bool

Alias for field number 2

originator_address: int

Alias for field number 3

class QualityType(enum.Enum):
136class QualityType(enum.Enum):
137    INDICATION = 0
138    MEASUREMENT = 1
139    COUNTER = 2
140    PROTECTION = 3
INDICATION = <QualityType.INDICATION: 0>
MEASUREMENT = <QualityType.MEASUREMENT: 1>
COUNTER = <QualityType.COUNTER: 2>
PROTECTION = <QualityType.PROTECTION: 3>
class IndicationQuality(typing.NamedTuple):
143class IndicationQuality(typing.NamedTuple):
144    invalid: bool
145    not_topical: bool
146    substituted: bool
147    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):
150class MeasurementQuality(typing.NamedTuple):
151    invalid: bool
152    not_topical: bool
153    substituted: bool
154    blocked: bool
155    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):
158class CounterQuality(typing.NamedTuple):
159    invalid: bool
160    adjusted: bool
161    overflow: bool
162    sequence: int
163    """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):
166class ProtectionQuality(typing.NamedTuple):
167    invalid: bool
168    not_topical: bool
169    substituted: bool
170    blocked: bool
171    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):
180class FreezeCode(enum.Enum):
181    READ = 0
182    FREEZE = 1
183    FREEZE_AND_RESET = 2
184    RESET = 3
READ = <FreezeCode.READ: 0>
FREEZE = <FreezeCode.FREEZE: 1>
FREEZE_AND_RESET = <FreezeCode.FREEZE_AND_RESET: 2>
RESET = <FreezeCode.RESET: 3>
class SingleValue(enum.Enum):
187class SingleValue(enum.Enum):
188    OFF = 0
189    ON = 1
OFF = <SingleValue.OFF: 0>
ON = <SingleValue.ON: 1>
class DoubleValue(enum.Enum):
192class DoubleValue(enum.Enum):
193    """DoubleDataValue
194
195    `FAULT` stands for value 3, defined in the protocol as *INDETERMINATE*.
196    This is in order to make it more distinguishable from ``INTERMEDIATE``.
197
198    """
199    INTERMEDIATE = 0
200    OFF = 1
201    ON = 2
202    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):
205class RegulatingValue(enum.Enum):
206    LOWER = 1
207    HIGHER = 2
LOWER = <RegulatingValue.LOWER: 1>
HIGHER = <RegulatingValue.HIGHER: 2>
class StepPositionValue(typing.NamedTuple):
210class StepPositionValue(typing.NamedTuple):
211    value: int
212    """value in range [-64, 63]"""
213    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):
216class BitstringValue(typing.NamedTuple):
217    value: util.Bytes
218    """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):
221class NormalizedValue(typing.NamedTuple):
222    value: float
223    """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):
226class ScaledValue(typing.NamedTuple):
227    value: int
228    """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):
231class FloatingValue(typing.NamedTuple):
232    value: float

FloatingValue(value,)

FloatingValue(value: float)

Create new instance of FloatingValue(value,)

value: float

Alias for field number 0

class BinaryCounterValue(typing.NamedTuple):
235class BinaryCounterValue(typing.NamedTuple):
236    value: int
237    """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):
240class ProtectionValue(enum.Enum):
241    OFF = 1
242    ON = 2
OFF = <ProtectionValue.OFF: 1>
ON = <ProtectionValue.ON: 2>
class ProtectionStartValue(typing.NamedTuple):
245class ProtectionStartValue(typing.NamedTuple):
246    general: bool
247    l1: bool
248    l2: bool
249    l3: bool
250    ie: bool
251    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):
254class ProtectionCommandValue(typing.NamedTuple):
255    general: bool
256    l1: bool
257    l2: bool
258    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):
261class StatusValue(typing.NamedTuple):
262    value: list[bool]
263    """value length is 16"""
264    change: list[bool]
265    """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

class IoElement_M_SP_NA(typing.NamedTuple):
268class IoElement_M_SP_NA(typing.NamedTuple):
269    value: SingleValue
270    quality: IndicationQuality

IoElement_M_SP_NA(value, quality)

IoElement_M_SP_NA( value: SingleValue, quality: IndicationQuality)

Create new instance of IoElement_M_SP_NA(value, quality)

value: SingleValue

Alias for field number 0

Alias for field number 1

class IoElement_M_DP_NA(typing.NamedTuple):
278class IoElement_M_DP_NA(typing.NamedTuple):
279    value: DoubleValue
280    quality: IndicationQuality

IoElement_M_DP_NA(value, quality)

IoElement_M_DP_NA( value: DoubleValue, quality: IndicationQuality)

Create new instance of IoElement_M_DP_NA(value, quality)

value: DoubleValue

Alias for field number 0

Alias for field number 1

class IoElement_M_ST_NA(typing.NamedTuple):
288class IoElement_M_ST_NA(typing.NamedTuple):
289    value: StepPositionValue
290    quality: MeasurementQuality

IoElement_M_ST_NA(value, quality)

IoElement_M_ST_NA( value: StepPositionValue, quality: MeasurementQuality)

Create new instance of IoElement_M_ST_NA(value, quality)

Alias for field number 0

Alias for field number 1

class IoElement_M_BO_NA(typing.NamedTuple):
298class IoElement_M_BO_NA(typing.NamedTuple):
299    value: BitstringValue
300    quality: MeasurementQuality

IoElement_M_BO_NA(value, quality)

IoElement_M_BO_NA( value: BitstringValue, quality: MeasurementQuality)

Create new instance of IoElement_M_BO_NA(value, quality)

Alias for field number 0

Alias for field number 1

class IoElement_M_ME_NA(typing.NamedTuple):
308class IoElement_M_ME_NA(typing.NamedTuple):
309    value: NormalizedValue
310    quality: MeasurementQuality

IoElement_M_ME_NA(value, quality)

IoElement_M_ME_NA( value: NormalizedValue, quality: MeasurementQuality)

Create new instance of IoElement_M_ME_NA(value, quality)

Alias for field number 0

Alias for field number 1

class IoElement_M_ME_NB(typing.NamedTuple):
318class IoElement_M_ME_NB(typing.NamedTuple):
319    value: ScaledValue
320    quality: MeasurementQuality

IoElement_M_ME_NB(value, quality)

IoElement_M_ME_NB( value: ScaledValue, quality: MeasurementQuality)

Create new instance of IoElement_M_ME_NB(value, quality)

value: ScaledValue

Alias for field number 0

Alias for field number 1

class IoElement_M_ME_NC(typing.NamedTuple):
328class IoElement_M_ME_NC(typing.NamedTuple):
329    value: FloatingValue
330    quality: MeasurementQuality

IoElement_M_ME_NC(value, quality)

IoElement_M_ME_NC( value: FloatingValue, quality: MeasurementQuality)

Create new instance of IoElement_M_ME_NC(value, quality)

value: FloatingValue

Alias for field number 0

Alias for field number 1

class IoElement_M_IT_NA(typing.NamedTuple):
338class IoElement_M_IT_NA(typing.NamedTuple):
339    value: BinaryCounterValue
340    quality: CounterQuality

IoElement_M_IT_NA(value, quality)

IoElement_M_IT_NA( value: BinaryCounterValue, quality: CounterQuality)

Create new instance of IoElement_M_IT_NA(value, quality)

Alias for field number 0

quality: CounterQuality

Alias for field number 1

class IoElement_M_PS_NA(typing.NamedTuple):
369class IoElement_M_PS_NA(typing.NamedTuple):
370    value: StatusValue
371    quality: MeasurementQuality

IoElement_M_PS_NA(value, quality)

IoElement_M_PS_NA( value: StatusValue, quality: MeasurementQuality)

Create new instance of IoElement_M_PS_NA(value, quality)

value: StatusValue

Alias for field number 0

Alias for field number 1

class IoElement_M_ME_ND(typing.NamedTuple):
374class IoElement_M_ME_ND(typing.NamedTuple):
375    value: NormalizedValue

IoElement_M_ME_ND(value,)

IoElement_M_ME_ND(value: NormalizedValue)

Create new instance of IoElement_M_ME_ND(value,)

Alias for field number 0

class IoElement_M_SP_TB(typing.NamedTuple):
378class IoElement_M_SP_TB(typing.NamedTuple):
379    value: SingleValue
380    quality: IndicationQuality

IoElement_M_SP_TB(value, quality)

IoElement_M_SP_TB( value: SingleValue, quality: IndicationQuality)

Create new instance of IoElement_M_SP_TB(value, quality)

value: SingleValue

Alias for field number 0

Alias for field number 1

class IoElement_M_DP_TB(typing.NamedTuple):
383class IoElement_M_DP_TB(typing.NamedTuple):
384    value: DoubleValue
385    quality: IndicationQuality

IoElement_M_DP_TB(value, quality)

IoElement_M_DP_TB( value: DoubleValue, quality: IndicationQuality)

Create new instance of IoElement_M_DP_TB(value, quality)

value: DoubleValue

Alias for field number 0

Alias for field number 1

class IoElement_M_ST_TB(typing.NamedTuple):
388class IoElement_M_ST_TB(typing.NamedTuple):
389    value: StepPositionValue
390    quality: MeasurementQuality

IoElement_M_ST_TB(value, quality)

IoElement_M_ST_TB( value: StepPositionValue, quality: MeasurementQuality)

Create new instance of IoElement_M_ST_TB(value, quality)

Alias for field number 0

Alias for field number 1

class IoElement_M_BO_TB(typing.NamedTuple):
393class IoElement_M_BO_TB(typing.NamedTuple):
394    value: BitstringValue
395    quality: MeasurementQuality

IoElement_M_BO_TB(value, quality)

IoElement_M_BO_TB( value: BitstringValue, quality: MeasurementQuality)

Create new instance of IoElement_M_BO_TB(value, quality)

Alias for field number 0

Alias for field number 1

class IoElement_M_ME_TD(typing.NamedTuple):
398class IoElement_M_ME_TD(typing.NamedTuple):
399    value: NormalizedValue
400    quality: MeasurementQuality

IoElement_M_ME_TD(value, quality)

IoElement_M_ME_TD( value: NormalizedValue, quality: MeasurementQuality)

Create new instance of IoElement_M_ME_TD(value, quality)

Alias for field number 0

Alias for field number 1

class IoElement_M_ME_TE(typing.NamedTuple):
403class IoElement_M_ME_TE(typing.NamedTuple):
404    value: ScaledValue
405    quality: MeasurementQuality

IoElement_M_ME_TE(value, quality)

IoElement_M_ME_TE( value: ScaledValue, quality: MeasurementQuality)

Create new instance of IoElement_M_ME_TE(value, quality)

value: ScaledValue

Alias for field number 0

Alias for field number 1

class IoElement_M_ME_TF(typing.NamedTuple):
408class IoElement_M_ME_TF(typing.NamedTuple):
409    value: FloatingValue
410    quality: MeasurementQuality

IoElement_M_ME_TF(value, quality)

IoElement_M_ME_TF( value: FloatingValue, quality: MeasurementQuality)

Create new instance of IoElement_M_ME_TF(value, quality)

value: FloatingValue

Alias for field number 0

Alias for field number 1

class IoElement_M_IT_TB(typing.NamedTuple):
413class IoElement_M_IT_TB(typing.NamedTuple):
414    value: BinaryCounterValue
415    quality: CounterQuality

IoElement_M_IT_TB(value, quality)

IoElement_M_IT_TB( value: BinaryCounterValue, quality: CounterQuality)

Create new instance of IoElement_M_IT_TB(value, quality)

Alias for field number 0

quality: CounterQuality

Alias for field number 1

class IoElement_M_EP_TD(typing.NamedTuple):
418class IoElement_M_EP_TD(typing.NamedTuple):
419    value: ProtectionValue
420    quality: ProtectionQuality
421    elapsed_time: int
422    """elapsed_time in range [0, 65535]"""

IoElement_M_EP_TD(value, quality, elapsed_time)

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

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

Alias for field number 0

Alias for field number 1

elapsed_time: int

elapsed_time in range [0, 65535]

class IoElement_M_EP_TE(typing.NamedTuple):
425class IoElement_M_EP_TE(typing.NamedTuple):
426    value: ProtectionStartValue
427    quality: ProtectionQuality
428    duration_time: int
429    """duration_time in range [0, 65535]"""

IoElement_M_EP_TE(value, quality, duration_time)

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

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

Alias for field number 0

Alias for field number 1

duration_time: int

duration_time in range [0, 65535]

class IoElement_M_EP_TF(typing.NamedTuple):
432class IoElement_M_EP_TF(typing.NamedTuple):
433    value: ProtectionCommandValue
434    quality: ProtectionQuality
435    operating_time: int
436    """operating_time in range [0, 65535]"""

IoElement_M_EP_TF(value, quality, operating_time)

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

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

Alias for field number 0

Alias for field number 1

operating_time: int

operating_time in range [0, 65535]

class IoElement_C_SC_NA(typing.NamedTuple):
439class IoElement_C_SC_NA(typing.NamedTuple):
440    value: SingleValue
441    select: bool
442    qualifier: int
443    """qualifier in range [0, 31]"""

IoElement_C_SC_NA(value, select, qualifier)

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

Create new instance of IoElement_C_SC_NA(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 IoElement_C_DC_NA(typing.NamedTuple):
446class IoElement_C_DC_NA(typing.NamedTuple):
447    value: DoubleValue
448    select: bool
449    qualifier: int
450    """qualifier in range [0, 31]"""

IoElement_C_DC_NA(value, select, qualifier)

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

Create new instance of IoElement_C_DC_NA(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 IoElement_C_RC_NA(typing.NamedTuple):
453class IoElement_C_RC_NA(typing.NamedTuple):
454    value: RegulatingValue
455    select: bool
456    qualifier: int
457    """qualifier in range [0, 31]"""

IoElement_C_RC_NA(value, select, qualifier)

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

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

Alias for field number 0

select: bool

Alias for field number 1

qualifier: int

qualifier in range [0, 31]

class IoElement_C_SE_NA(typing.NamedTuple):
460class IoElement_C_SE_NA(typing.NamedTuple):
461    value: NormalizedValue
462    select: bool

IoElement_C_SE_NA(value, select)

IoElement_C_SE_NA( value: NormalizedValue, select: bool)

Create new instance of IoElement_C_SE_NA(value, select)

Alias for field number 0

select: bool

Alias for field number 1

class IoElement_C_SE_NB(typing.NamedTuple):
465class IoElement_C_SE_NB(typing.NamedTuple):
466    value: ScaledValue
467    select: bool

IoElement_C_SE_NB(value, select)

IoElement_C_SE_NB( value: ScaledValue, select: bool)

Create new instance of IoElement_C_SE_NB(value, select)

value: ScaledValue

Alias for field number 0

select: bool

Alias for field number 1

class IoElement_C_SE_NC(typing.NamedTuple):
470class IoElement_C_SE_NC(typing.NamedTuple):
471    value: FloatingValue
472    select: bool

IoElement_C_SE_NC(value, select)

IoElement_C_SE_NC( value: FloatingValue, select: bool)

Create new instance of IoElement_C_SE_NC(value, select)

value: FloatingValue

Alias for field number 0

select: bool

Alias for field number 1

class IoElement_C_BO_NA(typing.NamedTuple):
475class IoElement_C_BO_NA(typing.NamedTuple):
476    value: BitstringValue

IoElement_C_BO_NA(value,)

IoElement_C_BO_NA(value: BitstringValue)

Create new instance of IoElement_C_BO_NA(value,)

Alias for field number 0

class IoElement_M_EI_NA(typing.NamedTuple):
479class IoElement_M_EI_NA(typing.NamedTuple):
480    param_change: bool
481    cause: int
482    """cause in range [0, 127]"""

IoElement_M_EI_NA(param_change, cause)

IoElement_M_EI_NA(param_change: bool, cause: int)

Create new instance of IoElement_M_EI_NA(param_change, cause)

param_change: bool

Alias for field number 0

cause: int

cause in range [0, 127]

class IoElement_C_IC_NA(typing.NamedTuple):
485class IoElement_C_IC_NA(typing.NamedTuple):
486    qualifier: int
487    """qualifier in range [0, 255]"""

IoElement_C_IC_NA(qualifier,)

IoElement_C_IC_NA(qualifier: int)

Create new instance of IoElement_C_IC_NA(qualifier,)

qualifier: int

qualifier in range [0, 255]

class IoElement_C_CI_NA(typing.NamedTuple):
490class IoElement_C_CI_NA(typing.NamedTuple):
491    request: int
492    """request in range [0, 63]"""
493    freeze: FreezeCode

IoElement_C_CI_NA(request, freeze)

IoElement_C_CI_NA( request: int, freeze: FreezeCode)

Create new instance of IoElement_C_CI_NA(request, freeze)

request: int

request in range [0, 63]

freeze: FreezeCode

Alias for field number 1

class IoElement_C_RD_NA(typing.NamedTuple):
496class IoElement_C_RD_NA(typing.NamedTuple):
497    pass

IoElement_C_RD_NA()

IoElement_C_RD_NA()

Create new instance of IoElement_C_RD_NA()

class IoElement_C_CS_NA(typing.NamedTuple):
500class IoElement_C_CS_NA(typing.NamedTuple):
501    time: Time
502    """time size is SEVEN"""

IoElement_C_CS_NA(time,)

IoElement_C_CS_NA(time: Time)

Create new instance of IoElement_C_CS_NA(time,)

time: Time

time size is SEVEN

class IoElement_C_RP_NA(typing.NamedTuple):
509class IoElement_C_RP_NA(typing.NamedTuple):
510    qualifier: int
511    """qualifier in range [0, 255]"""

IoElement_C_RP_NA(qualifier,)

IoElement_C_RP_NA(qualifier: int)

Create new instance of IoElement_C_RP_NA(qualifier,)

qualifier: int

qualifier in range [0, 255]

class IoElement_P_ME_NA(typing.NamedTuple):
519class IoElement_P_ME_NA(typing.NamedTuple):
520    value: NormalizedValue
521    qualifier: int
522    """qualifier in range [0, 255]"""

IoElement_P_ME_NA(value, qualifier)

IoElement_P_ME_NA( value: NormalizedValue, qualifier: int)

Create new instance of IoElement_P_ME_NA(value, qualifier)

Alias for field number 0

qualifier: int

qualifier in range [0, 255]

class IoElement_P_ME_NB(typing.NamedTuple):
525class IoElement_P_ME_NB(typing.NamedTuple):
526    value: ScaledValue
527    qualifier: int
528    """qualifier in range [0, 255]"""

IoElement_P_ME_NB(value, qualifier)

IoElement_P_ME_NB( value: ScaledValue, qualifier: int)

Create new instance of IoElement_P_ME_NB(value, qualifier)

value: ScaledValue

Alias for field number 0

qualifier: int

qualifier in range [0, 255]

class IoElement_P_ME_NC(typing.NamedTuple):
531class IoElement_P_ME_NC(typing.NamedTuple):
532    value: FloatingValue
533    qualifier: int
534    """qualifier in range [0, 255]"""

IoElement_P_ME_NC(value, qualifier)

IoElement_P_ME_NC( value: FloatingValue, qualifier: int)

Create new instance of IoElement_P_ME_NC(value, qualifier)

value: FloatingValue

Alias for field number 0

qualifier: int

qualifier in range [0, 255]

class IoElement_P_AC_NA(typing.NamedTuple):
537class IoElement_P_AC_NA(typing.NamedTuple):
538    qualifier: int
539    """qualifier in range [0, 255]"""

IoElement_P_AC_NA(qualifier,)

IoElement_P_AC_NA(qualifier: int)

Create new instance of IoElement_P_AC_NA(qualifier,)

qualifier: int

qualifier in range [0, 255]

class IoElement_F_FR_NA(typing.NamedTuple):
542class IoElement_F_FR_NA(typing.NamedTuple):
543    file_name: int
544    """file_name in range [0, 65535]"""
545    file_length: int
546    """file_length in range [0, 16777215]"""
547    ready: bool

IoElement_F_FR_NA(file_name, file_length, ready)

IoElement_F_FR_NA(file_name: int, file_length: int, ready: bool)

Create new instance of IoElement_F_FR_NA(file_name, file_length, ready)

file_name: int

file_name in range [0, 65535]

file_length: int

file_length in range [0, 16777215]

ready: bool

Alias for field number 2

class IoElement_F_SR_NA(typing.NamedTuple):
550class IoElement_F_SR_NA(typing.NamedTuple):
551    file_name: int
552    """file_name in range [0, 65535]"""
553    section_name: int
554    """section_name in range [0, 255]"""
555    section_length: int
556    """section_length in range [0, 16777215]"""
557    ready: bool

IoElement_F_SR_NA(file_name, section_name, section_length, ready)

IoElement_F_SR_NA(file_name: int, section_name: int, section_length: int, ready: bool)

Create new instance of IoElement_F_SR_NA(file_name, section_name, section_length, ready)

file_name: int

file_name in range [0, 65535]

section_name: int

section_name in range [0, 255]

section_length: int

section_length in range [0, 16777215]

ready: bool

Alias for field number 3

class IoElement_F_SC_NA(typing.NamedTuple):
560class IoElement_F_SC_NA(typing.NamedTuple):
561    file_name: int
562    """file_name in range [0, 65535]"""
563    section_name: int
564    """section_name in range [0, 255]"""
565    qualifier: int
566    """qualifier in range [0, 255]"""

IoElement_F_SC_NA(file_name, section_name, qualifier)

IoElement_F_SC_NA(file_name: int, section_name: int, qualifier: int)

Create new instance of IoElement_F_SC_NA(file_name, section_name, qualifier)

file_name: int

file_name in range [0, 65535]

section_name: int

section_name in range [0, 255]

qualifier: int

qualifier in range [0, 255]

class IoElement_F_LS_NA(typing.NamedTuple):
569class IoElement_F_LS_NA(typing.NamedTuple):
570    file_name: int
571    """file_name in range [0, 65535]"""
572    section_name: int
573    """section_name in range [0, 255]"""
574    last_qualifier: int
575    """last_qualifier in range [0, 255]"""
576    checksum: int
577    """checksum in range [0, 255]"""

IoElement_F_LS_NA(file_name, section_name, last_qualifier, checksum)

IoElement_F_LS_NA( file_name: int, section_name: int, last_qualifier: int, checksum: int)

Create new instance of IoElement_F_LS_NA(file_name, section_name, last_qualifier, checksum)

file_name: int

file_name in range [0, 65535]

section_name: int

section_name in range [0, 255]

last_qualifier: int

last_qualifier in range [0, 255]

checksum: int

checksum in range [0, 255]

class IoElement_F_AF_NA(typing.NamedTuple):
580class IoElement_F_AF_NA(typing.NamedTuple):
581    file_name: int
582    """file_name in range [0, 65535]"""
583    section_name: int
584    """section_name in range [0, 255]"""
585    qualifier: int
586    """qualifier in range [0, 255]"""

IoElement_F_AF_NA(file_name, section_name, qualifier)

IoElement_F_AF_NA(file_name: int, section_name: int, qualifier: int)

Create new instance of IoElement_F_AF_NA(file_name, section_name, qualifier)

file_name: int

file_name in range [0, 65535]

section_name: int

section_name in range [0, 255]

qualifier: int

qualifier in range [0, 255]

class IoElement_F_SG_NA(typing.NamedTuple):
589class IoElement_F_SG_NA(typing.NamedTuple):
590    file_name: int
591    """file_name in range [0, 65535]"""
592    section_name: int
593    """section_name in range [0, 255]"""
594    segment: util.Bytes

IoElement_F_SG_NA(file_name, section_name, segment)

IoElement_F_SG_NA( file_name: int, section_name: int, segment: bytes | bytearray | memoryview)

Create new instance of IoElement_F_SG_NA(file_name, section_name, segment)

file_name: int

file_name in range [0, 65535]

section_name: int

section_name in range [0, 255]

segment: bytes | bytearray | memoryview

Alias for field number 2

class IoElement_F_DR_TA(typing.NamedTuple):
597class IoElement_F_DR_TA(typing.NamedTuple):
598    file_name: int
599    """file_name in range [0, 65535]"""
600    file_length: int
601    """file_length in range [0, 16777215]"""
602    more_follows: bool
603    is_directory: bool
604    transfer_active: bool
605    creation_time: Time

IoElement_F_DR_TA(file_name, file_length, more_follows, is_directory, transfer_active, creation_time)

IoElement_F_DR_TA( file_name: int, file_length: int, more_follows: bool, is_directory: bool, transfer_active: bool, creation_time: Time)

Create new instance of IoElement_F_DR_TA(file_name, file_length, more_follows, is_directory, transfer_active, creation_time)

file_name: int

file_name in range [0, 65535]

file_length: int

file_length in range [0, 16777215]

more_follows: bool

Alias for field number 2

is_directory: bool

Alias for field number 3

transfer_active: bool

Alias for field number 4

creation_time: Time

Alias for field number 5

class IoElement_C_SC_TA(typing.NamedTuple):
151class IoElement_C_SC_TA(typing.NamedTuple):
152    value: SingleValue
153    select: bool
154    qualifier: int
155    """qualifier in range [0, 31]"""

IoElement_C_SC_TA(value, select, qualifier)

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

Create new instance of IoElement_C_SC_TA(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 IoElement_C_DC_TA(typing.NamedTuple):
158class IoElement_C_DC_TA(typing.NamedTuple):
159    value: DoubleValue
160    select: bool
161    qualifier: int
162    """qualifier in range [0, 31]"""

IoElement_C_DC_TA(value, select, qualifier)

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

Create new instance of IoElement_C_DC_TA(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 IoElement_C_RC_TA(typing.NamedTuple):
165class IoElement_C_RC_TA(typing.NamedTuple):
166    value: RegulatingValue
167    select: bool
168    qualifier: int
169    """qualifier in range [0, 31]"""

IoElement_C_RC_TA(value, select, qualifier)

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

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

Alias for field number 0

select: bool

Alias for field number 1

qualifier: int

qualifier in range [0, 31]

class IoElement_C_SE_TA(typing.NamedTuple):
172class IoElement_C_SE_TA(typing.NamedTuple):
173    value: NormalizedValue
174    select: bool

IoElement_C_SE_TA(value, select)

IoElement_C_SE_TA( value: NormalizedValue, select: bool)

Create new instance of IoElement_C_SE_TA(value, select)

Alias for field number 0

select: bool

Alias for field number 1

class IoElement_C_SE_TB(typing.NamedTuple):
177class IoElement_C_SE_TB(typing.NamedTuple):
178    value: ScaledValue
179    select: bool

IoElement_C_SE_TB(value, select)

IoElement_C_SE_TB( value: ScaledValue, select: bool)

Create new instance of IoElement_C_SE_TB(value, select)

value: ScaledValue

Alias for field number 0

select: bool

Alias for field number 1

class IoElement_C_SE_TC(typing.NamedTuple):
182class IoElement_C_SE_TC(typing.NamedTuple):
183    value: FloatingValue
184    select: bool

IoElement_C_SE_TC(value, select)

IoElement_C_SE_TC( value: FloatingValue, select: bool)

Create new instance of IoElement_C_SE_TC(value, select)

value: FloatingValue

Alias for field number 0

select: bool

Alias for field number 1

class IoElement_C_BO_TA(typing.NamedTuple):
187class IoElement_C_BO_TA(typing.NamedTuple):
188    value: BitstringValue

IoElement_C_BO_TA(value,)

IoElement_C_BO_TA(value: BitstringValue)

Create new instance of IoElement_C_BO_TA(value,)

Alias for field number 0

class IoElement_C_TS_TA(typing.NamedTuple):
191class IoElement_C_TS_TA(typing.NamedTuple):
192    counter: int
193    """counter in range [0, 65535]"""

IoElement_C_TS_TA(counter,)

IoElement_C_TS_TA(counter: int)

Create new instance of IoElement_C_TS_TA(counter,)

counter: int

counter in range [0, 65535]

class IO(typing.NamedTuple):
251class IO(typing.NamedTuple):
252    address: IoAddress
253    elements: list[IoElement]
254    time: Time | None

IO(address, elements, time)

address: int

Alias for field number 0

time: Time | None

Alias for field number 2

class ASDU(typing.NamedTuple):
257class ASDU(typing.NamedTuple):
258    type: AsduType
259    cause: Cause
260    address: AsduAddress
261    ios: list[IO]

ASDU(type, cause, address, ios)

ASDU( type: AsduType, cause: Cause, address: int, ios: list[IO])

Create new instance of ASDU(type, cause, address, ios)

type: AsduType

Alias for field number 0

cause: Cause

Alias for field number 1

address: int

Alias for field number 2

ios: list[IO]

Alias for field number 3

iec101_asdu_types = {1, 3, 5, 7, 9, 11, 13, 15, 20, 21, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 45, 46, 47, 48, 49, 50, 51, 70, 100, 101, 102, 103, 105, 110, 111, 112, 113, 120, 121, 122, 123, 124, 125, 126}
class Encoder:
 56class Encoder:
 57
 58    def __init__(self, max_asdu_size: int = 249):
 59        self._max_asdu_size = max_asdu_size
 60        self._encoder = encoder.Encoder(
 61            cause_size=common.CauseSize.TWO,
 62            asdu_address_size=common.AsduAddressSize.TWO,
 63            io_address_size=common.IoAddressSize.THREE,
 64            asdu_type_time_sizes=_asdu_type_time_sizes,
 65            inverted_sequence_bit=False,
 66            decode_io_element_cb=_decode_io_element,
 67            encode_io_element_cb=_encode_io_element)
 68
 69    @property
 70    def max_asdu_size(self) -> int:
 71        return self._max_asdu_size
 72
 73    @property
 74    def cause_size(self) -> common.CauseSize:
 75        return self._encoder.cause_size
 76
 77    @property
 78    def asdu_address_size(self) -> common.AsduAddressSize:
 79        return self._encoder.asdu_address_size
 80
 81    @property
 82    def io_address_size(self) -> common.IoAddressSize:
 83        return self._encoder.io_address_size
 84
 85    def decode_asdu(self,
 86                    asdu_bytes: util.Bytes
 87                    ) -> tuple[common.ASDU, util.Bytes]:
 88        asdu, rest = self._encoder.decode_asdu(asdu_bytes)
 89
 90        asdu_type = _decode_asdu_type(asdu.type)
 91
 92        cause = iec101.decode_cause(asdu.cause, common.CauseSize.TWO)
 93        address = asdu.address
 94        ios = [common.IO(address=io.address,
 95                         elements=io.elements,
 96                         time=io.time)
 97               for io in asdu.ios]
 98
 99        asdu = common.ASDU(type=asdu_type,
100                           cause=cause,
101                           address=address,
102                           ios=ios)
103        return asdu, rest
104
105    def encode_asdu(self, asdu: common.ASDU) -> util.Bytes:
106        asdu_type = asdu.type.value
107        cause = iec101.encode_cause(asdu.cause, common.CauseSize.TWO)
108        address = asdu.address
109        ios = [encoder.common.IO(address=io.address,
110                                 elements=io.elements,
111                                 time=io.time)
112               for io in asdu.ios]
113
114        asdu = encoder.common.ASDU(type=asdu_type,
115                                   cause=cause,
116                                   address=address,
117                                   ios=ios)
118
119        return self._encoder.encode_asdu(asdu)
Encoder(max_asdu_size: int = 249)
58    def __init__(self, max_asdu_size: int = 249):
59        self._max_asdu_size = max_asdu_size
60        self._encoder = encoder.Encoder(
61            cause_size=common.CauseSize.TWO,
62            asdu_address_size=common.AsduAddressSize.TWO,
63            io_address_size=common.IoAddressSize.THREE,
64            asdu_type_time_sizes=_asdu_type_time_sizes,
65            inverted_sequence_bit=False,
66            decode_io_element_cb=_decode_io_element,
67            encode_io_element_cb=_encode_io_element)
max_asdu_size: int
69    @property
70    def max_asdu_size(self) -> int:
71        return self._max_asdu_size
73    @property
74    def cause_size(self) -> common.CauseSize:
75        return self._encoder.cause_size
77    @property
78    def asdu_address_size(self) -> common.AsduAddressSize:
79        return self._encoder.asdu_address_size
81    @property
82    def io_address_size(self) -> common.IoAddressSize:
83        return self._encoder.io_address_size
def decode_asdu( self, asdu_bytes: bytes | bytearray | memoryview) -> tuple[ASDU, bytes | bytearray | memoryview]:
 85    def decode_asdu(self,
 86                    asdu_bytes: util.Bytes
 87                    ) -> tuple[common.ASDU, util.Bytes]:
 88        asdu, rest = self._encoder.decode_asdu(asdu_bytes)
 89
 90        asdu_type = _decode_asdu_type(asdu.type)
 91
 92        cause = iec101.decode_cause(asdu.cause, common.CauseSize.TWO)
 93        address = asdu.address
 94        ios = [common.IO(address=io.address,
 95                         elements=io.elements,
 96                         time=io.time)
 97               for io in asdu.ios]
 98
 99        asdu = common.ASDU(type=asdu_type,
100                           cause=cause,
101                           address=address,
102                           ios=ios)
103        return asdu, rest
def encode_asdu( self, asdu: ASDU) -> bytes | bytearray | memoryview:
105    def encode_asdu(self, asdu: common.ASDU) -> util.Bytes:
106        asdu_type = asdu.type.value
107        cause = iec101.encode_cause(asdu.cause, common.CauseSize.TWO)
108        address = asdu.address
109        ios = [encoder.common.IO(address=io.address,
110                                 elements=io.elements,
111                                 time=io.time)
112               for io in asdu.ios]
113
114        asdu = encoder.common.ASDU(type=asdu_type,
115                                   cause=cause,
116                                   address=address,
117                                   ios=ios)
118
119        return self._encoder.encode_asdu(asdu)