DLMS-SPODES 0.87.12__py3-none-any.whl → 0.87.15__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- DLMS_SPODES/Values/EN/__init__.py +1 -1
- DLMS_SPODES/Values/EN/actors.py +8 -8
- DLMS_SPODES/Values/EN/relation_to_obis_names.py +387 -387
- DLMS_SPODES/Values/RU/__init__.py +1 -1
- DLMS_SPODES/Values/RU/actors.py +8 -8
- DLMS_SPODES/Values/RU/relation_to_obis_names.py +396 -396
- DLMS_SPODES/__init__.py +6 -6
- DLMS_SPODES/configEN.ini +126 -126
- DLMS_SPODES/config_parser.py +53 -53
- DLMS_SPODES/cosem_interface_classes/__class_init__.py +3 -3
- DLMS_SPODES/cosem_interface_classes/__init__.py +1 -1
- DLMS_SPODES/cosem_interface_classes/a_parameter.py +20 -20
- DLMS_SPODES/cosem_interface_classes/activity_calendar.py +254 -254
- DLMS_SPODES/cosem_interface_classes/arbitrator.py +105 -105
- DLMS_SPODES/cosem_interface_classes/association_ln/abstract.py +34 -34
- DLMS_SPODES/cosem_interface_classes/association_ln/authentication_mechanism_name.py +25 -25
- DLMS_SPODES/cosem_interface_classes/association_ln/mechanism_id.py +25 -25
- DLMS_SPODES/cosem_interface_classes/association_ln/method.py +5 -5
- DLMS_SPODES/cosem_interface_classes/association_ln/ver0.py +485 -485
- DLMS_SPODES/cosem_interface_classes/association_ln/ver1.py +133 -133
- DLMS_SPODES/cosem_interface_classes/association_ln/ver2.py +36 -36
- DLMS_SPODES/cosem_interface_classes/association_ln/ver3.py +4 -4
- DLMS_SPODES/cosem_interface_classes/association_sn/ver0.py +12 -12
- DLMS_SPODES/cosem_interface_classes/attr_indexes.py +12 -12
- DLMS_SPODES/cosem_interface_classes/clock.py +131 -131
- DLMS_SPODES/cosem_interface_classes/collection.py +2122 -2122
- DLMS_SPODES/cosem_interface_classes/cosem_interface_class.py +583 -583
- DLMS_SPODES/cosem_interface_classes/data.py +21 -21
- DLMS_SPODES/cosem_interface_classes/demand_register/ver0.py +59 -59
- DLMS_SPODES/cosem_interface_classes/disconnect_control.py +74 -74
- DLMS_SPODES/cosem_interface_classes/extended_register.py +27 -27
- DLMS_SPODES/cosem_interface_classes/gprs_modem_setup.py +43 -43
- DLMS_SPODES/cosem_interface_classes/gsm_diagnostic/ver0.py +103 -103
- DLMS_SPODES/cosem_interface_classes/gsm_diagnostic/ver1.py +40 -40
- DLMS_SPODES/cosem_interface_classes/gsm_diagnostic/ver2.py +9 -9
- DLMS_SPODES/cosem_interface_classes/iec_hdlc_setup/ver0.py +11 -11
- DLMS_SPODES/cosem_interface_classes/iec_hdlc_setup/ver1.py +53 -53
- DLMS_SPODES/cosem_interface_classes/iec_local_port_setup.py +11 -11
- DLMS_SPODES/cosem_interface_classes/image_transfer/image_transfer_status.py +15 -15
- DLMS_SPODES/cosem_interface_classes/image_transfer/ver0.py +126 -126
- DLMS_SPODES/cosem_interface_classes/implementations/__init__.py +3 -3
- DLMS_SPODES/cosem_interface_classes/implementations/arbitrator.py +19 -19
- DLMS_SPODES/cosem_interface_classes/implementations/data.py +487 -487
- DLMS_SPODES/cosem_interface_classes/implementations/profile_generic.py +83 -83
- DLMS_SPODES/cosem_interface_classes/ipv4_setup.py +72 -72
- DLMS_SPODES/cosem_interface_classes/limiter.py +111 -111
- DLMS_SPODES/cosem_interface_classes/ln_pattern.py +333 -333
- DLMS_SPODES/cosem_interface_classes/modem_configuration/ver0.py +65 -65
- DLMS_SPODES/cosem_interface_classes/modem_configuration/ver1.py +39 -39
- DLMS_SPODES/cosem_interface_classes/ntp_setup/ver0.py +67 -67
- DLMS_SPODES/cosem_interface_classes/obis.py +23 -23
- DLMS_SPODES/cosem_interface_classes/overview.py +197 -197
- DLMS_SPODES/cosem_interface_classes/parameter.py +547 -547
- DLMS_SPODES/cosem_interface_classes/parameters.py +172 -172
- DLMS_SPODES/cosem_interface_classes/profile_generic/ver0.py +122 -122
- DLMS_SPODES/cosem_interface_classes/profile_generic/ver1.py +277 -277
- DLMS_SPODES/cosem_interface_classes/push_setup/ver0.py +12 -12
- DLMS_SPODES/cosem_interface_classes/push_setup/ver1.py +10 -10
- DLMS_SPODES/cosem_interface_classes/push_setup/ver2.py +166 -166
- DLMS_SPODES/cosem_interface_classes/register.py +45 -45
- DLMS_SPODES/cosem_interface_classes/register_activation/ver0.py +80 -80
- DLMS_SPODES/cosem_interface_classes/register_monitor.py +46 -46
- DLMS_SPODES/cosem_interface_classes/reports.py +70 -70
- DLMS_SPODES/cosem_interface_classes/schedule.py +176 -176
- DLMS_SPODES/cosem_interface_classes/script_table.py +87 -87
- DLMS_SPODES/cosem_interface_classes/security_setup/ver0.py +68 -68
- DLMS_SPODES/cosem_interface_classes/security_setup/ver1.py +158 -158
- DLMS_SPODES/cosem_interface_classes/single_action_schedule.py +50 -50
- DLMS_SPODES/cosem_interface_classes/special_days_table.py +84 -84
- DLMS_SPODES/cosem_interface_classes/tcp_udp_setup.py +42 -42
- DLMS_SPODES/cosem_pdu.py +93 -93
- DLMS_SPODES/enums.py +625 -625
- DLMS_SPODES/exceptions.py +106 -106
- DLMS_SPODES/firmwares.py +99 -99
- DLMS_SPODES/hdlc/frame.py +875 -875
- DLMS_SPODES/hdlc/sub_layer.py +54 -54
- DLMS_SPODES/literals.py +17 -17
- DLMS_SPODES/obis/__init__.py +1 -1
- DLMS_SPODES/obis/media_id.py +931 -931
- DLMS_SPODES/pardata.py +22 -22
- DLMS_SPODES/pdu_enums.py +98 -98
- DLMS_SPODES/relation_to_OBIS.py +465 -463
- DLMS_SPODES/settings.py +551 -551
- DLMS_SPODES/types/choices.py +142 -142
- DLMS_SPODES/types/common_data_types.py +2401 -2399
- DLMS_SPODES/types/cosem_service_types.py +109 -109
- DLMS_SPODES/types/implementations/arrays.py +25 -25
- DLMS_SPODES/types/implementations/bitstrings.py +97 -97
- DLMS_SPODES/types/implementations/double_long_usingneds.py +35 -35
- DLMS_SPODES/types/implementations/enums.py +57 -57
- DLMS_SPODES/types/implementations/integers.py +11 -11
- DLMS_SPODES/types/implementations/long_unsigneds.py +127 -127
- DLMS_SPODES/types/implementations/octet_string.py +11 -11
- DLMS_SPODES/types/implementations/structs.py +64 -64
- DLMS_SPODES/types/useful_types.py +677 -677
- {dlms_spodes-0.87.12.dist-info → dlms_spodes-0.87.15.dist-info}/METADATA +30 -30
- dlms_spodes-0.87.15.dist-info/RECORD +117 -0
- {dlms_spodes-0.87.12.dist-info → dlms_spodes-0.87.15.dist-info}/WHEEL +1 -1
- dlms_spodes-0.87.12.dist-info/RECORD +0 -117
- {dlms_spodes-0.87.12.dist-info → dlms_spodes-0.87.15.dist-info}/top_level.txt +0 -0
DLMS_SPODES/types/choices.py
CHANGED
|
@@ -1,142 +1,142 @@
|
|
|
1
|
-
from abc import ABC
|
|
2
|
-
from itertools import chain
|
|
3
|
-
from typing import TypeAlias, Self
|
|
4
|
-
from ..types import cdt, ut, cst
|
|
5
|
-
from ..types.implementations import structs
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class CommonDataTypeChoiceBase(ut.CHOICE, ABC):
|
|
9
|
-
""" For some attributes of some COSEM interface objects, the data type may be chosen at COSEM object instantiation, in the implementation phase
|
|
10
|
-
of the COSEM server. The Server always shall send back the data type and the value of each attribute, so that together with the logical name, an
|
|
11
|
-
unambiguous interpretation is ensured. The list of possible data types is defined in the “Attribute description” section of a COSEM interface
|
|
12
|
-
class specification. DLMS UA 1000-1 Ed. 13. The tag of a type defined using the CHOICE keyword takes the value of the tag of the type from which
|
|
13
|
-
the chosen data value is taken. ITU-T Rec. X.680 | ISO/IEC 8824-1 """
|
|
14
|
-
TYPE = cdt.CommonDataType
|
|
15
|
-
|
|
16
|
-
def __init_subclass__(cls, **kwargs):
|
|
17
|
-
cls.ELEMENTS = dict()
|
|
18
|
-
for t in kwargs["types"]:
|
|
19
|
-
if isinstance(t, dict): # extended choice
|
|
20
|
-
cls.ELEMENTS[int.from_bytes(tuple(t.values())[0].TAG, "big")] = {k: ut.SequenceElement(str(v.TAG), v) for k, v in t.items()}
|
|
21
|
-
elif issubclass(t, cdt.CommonDataType):
|
|
22
|
-
cls.ELEMENTS[int.from_bytes(t.TAG, "big")] = ut.SequenceElement(str(t.TAG), t)
|
|
23
|
-
else:
|
|
24
|
-
raise TypeError(F"got {t.__class__} expected cdt or dict")
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class SimpleDataTypeChoice(CommonDataTypeChoiceBase, types=cdt.SimpleDataTypes):
|
|
28
|
-
"""All Simple Data Types"""
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
class ComplexDataTypeChoice(CommonDataTypeChoiceBase, types=cdt.ComplexDataTypes):
|
|
32
|
-
"""All Complex Data Types"""
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
class AccessSelectorsChoice(CommonDataTypeChoiceBase, types=(cdt.NullData, cdt.Array)):
|
|
36
|
-
"""All Complex Data Types"""
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
class CommonDataTypeChoice(CommonDataTypeChoiceBase, types=chain(cdt.SimpleDataTypes, cdt.ComplexDataTypes)):
|
|
40
|
-
"""Types of Data.value"""
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
class ExtendedRegisterChoice(CommonDataTypeChoiceBase,
|
|
44
|
-
types=(cdt.NullData, cdt.BitString, cdt.DoubleLongUnsigned, cdt.OctetString, cdt.VisibleString, cdt.Utf8String, cdt.Unsigned, cdt.LongUnsigned,
|
|
45
|
-
cdt.Long64Unsigned)):
|
|
46
|
-
"""Types of ExtendedRegister.value"""
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
class RegisterChoice(CommonDataTypeChoiceBase,
|
|
50
|
-
types=(cdt.NullData, cdt.BitString, cdt.DoubleLongUnsigned, cdt.OctetString, cdt.VisibleString, cdt.Utf8String, cdt.Unsigned, cdt.LongUnsigned,
|
|
51
|
-
cdt.Long64Unsigned, cdt.DoubleLong, cdt.Integer, cdt.Long, cdt.Long64, cdt.Enum, cdt.Float32, cdt.Float64)):
|
|
52
|
-
"""Types of ExtendedRegister.value"""
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
class AnyDateTimeChoice(CommonDataTypeChoiceBase, types=(cdt.DateTime, cdt.Date, cdt.Time, {12: cst.OctetStringDateTime, 5: cst.OctetStringDate, 4: cst.OctetStringTime})):
|
|
56
|
-
"""Date of the event may contain the date only, the time only or both, encoded as specified in 4.1.6.1."""
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
simple_dt = SimpleDataTypeChoice()
|
|
60
|
-
complex_dt = ComplexDataTypeChoice()
|
|
61
|
-
common_dt = CommonDataTypeChoice()
|
|
62
|
-
extended_register = ExtendedRegisterChoice()
|
|
63
|
-
register = RegisterChoice()
|
|
64
|
-
access_selectors: cdt.NullData | cdt.Array = AccessSelectorsChoice()
|
|
65
|
-
any_date_time = AnyDateTimeChoice()
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
ExtendedRegisterValues: TypeAlias = cdt.NullData | cdt.BitString | cdt.DoubleLongUnsigned | cdt.OctetString | cdt.VisibleString | cdt.Utf8String | cdt.Unsigned \
|
|
69
|
-
| cdt.LongUnsigned | cdt.Long64Unsigned
|
|
70
|
-
RegisterValues: TypeAlias = ExtendedRegisterValues | cdt.DoubleLong | cdt.Integer | cdt.Long | cdt.Long64 | cdt.Enum | cdt.Float32 | cdt.Float64
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
class RestrictionValue(ut.CHOICE):
|
|
74
|
-
TYPE = (cdt.Structure, cdt.NullData)
|
|
75
|
-
ELEMENTS = {0: ut.SequenceElement("no restriction apply", cdt.NullData),
|
|
76
|
-
1: ut.SequenceElement("restriction by date", structs.RestrictionByDate),
|
|
77
|
-
2: ut.SequenceElement("restriction by entry", structs.RestrictionByEntry)}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
restriction_value = RestrictionValue()
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
class IdentifiedKeyInfoOptions(cdt.Enum, elements=(0, 1)):
|
|
84
|
-
""""""
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
class KEKId(cdt.Enum, elements=(0,)):
|
|
88
|
-
""""""
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
class WrappedKeyInfoOptions(cdt.Structure):
|
|
92
|
-
kek_id: KEKId
|
|
93
|
-
key_ciphered_data: cdt.OctetString
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
class AgreedKeyInfoOptions(cdt.Structure):
|
|
97
|
-
kek_id: cdt.OctetString
|
|
98
|
-
key_ciphered_data: cdt.OctetString
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
class KeyInfoOptions(ut.CHOICE):
|
|
102
|
-
TYPE = (cdt.Enum, cdt.Structure)
|
|
103
|
-
ELEMENTS = {0: ut.SequenceElement("identified_key", IdentifiedKeyInfoOptions),
|
|
104
|
-
1: ut.SequenceElement("wrapped_key", WrappedKeyInfoOptions),
|
|
105
|
-
2: ut.SequenceElement("agreed_key", AgreedKeyInfoOptions)}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
key_info_options = KeyInfoOptions()
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
class StructureMixin:
|
|
112
|
-
"""use for cdt.Structure[Enum, CommonDataType]"""
|
|
113
|
-
ELEMENTS: tuple[cdt.StructElement, cdt.StructElement]
|
|
114
|
-
values: list[cdt.Enum, cdt.CommonDataType]
|
|
115
|
-
__len__: int
|
|
116
|
-
|
|
117
|
-
def __init__(self, value: bytes | tuple | list | None | bytearray | Self = None):
|
|
118
|
-
def raise_error(set_value):
|
|
119
|
-
raise RuntimeError(F"not can't be set {set_value} to {self}, available only set complex struct value")
|
|
120
|
-
super(StructureMixin, self).__init__(value)
|
|
121
|
-
self.values[0].register_cb_preset(raise_error)
|
|
122
|
-
|
|
123
|
-
def from_sequence(self, sequence: tuple):
|
|
124
|
-
if len(sequence) != len(self):
|
|
125
|
-
raise ValueError(F'Struct {self.__class__.__name__} got length:{len(sequence)}, expected length:{len(self)}')
|
|
126
|
-
self.values.append(self.ELEMENTS[0].TYPE(sequence[0]))
|
|
127
|
-
self.values.append(self.ELEMENTS[1].TYPE(int(self.values[0])))
|
|
128
|
-
self.values[1].set(sequence[1])
|
|
129
|
-
|
|
130
|
-
def from_content(self, value: bytes):
|
|
131
|
-
el_value, pdu = cdt.get_instance_and_pdu(self.ELEMENTS[0].TYPE, value)
|
|
132
|
-
self.values.append(el_value)
|
|
133
|
-
el_value, pdu = cdt.get_instance_and_pdu(self.ELEMENTS[1].TYPE.ELEMENTS[int(self.values[0])].TYPE, pdu)
|
|
134
|
-
self.values.append(el_value)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
class DeviceIDobject(CommonDataTypeChoiceBase,
|
|
138
|
-
types=(cdt.DoubleLongUnsigned, cdt.OctetString, cdt.VisibleString, cdt.Utf8String, cdt.Unsigned, cdt.LongUnsigned)):
|
|
139
|
-
"""DLMS UA 1000-1 Ed. 14 6.2.42 Device ID objects """
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
device_id_object = DeviceIDobject()
|
|
1
|
+
from abc import ABC
|
|
2
|
+
from itertools import chain
|
|
3
|
+
from typing import TypeAlias, Self
|
|
4
|
+
from ..types import cdt, ut, cst
|
|
5
|
+
from ..types.implementations import structs
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class CommonDataTypeChoiceBase(ut.CHOICE, ABC):
|
|
9
|
+
""" For some attributes of some COSEM interface objects, the data type may be chosen at COSEM object instantiation, in the implementation phase
|
|
10
|
+
of the COSEM server. The Server always shall send back the data type and the value of each attribute, so that together with the logical name, an
|
|
11
|
+
unambiguous interpretation is ensured. The list of possible data types is defined in the “Attribute description” section of a COSEM interface
|
|
12
|
+
class specification. DLMS UA 1000-1 Ed. 13. The tag of a type defined using the CHOICE keyword takes the value of the tag of the type from which
|
|
13
|
+
the chosen data value is taken. ITU-T Rec. X.680 | ISO/IEC 8824-1 """
|
|
14
|
+
TYPE = cdt.CommonDataType
|
|
15
|
+
|
|
16
|
+
def __init_subclass__(cls, **kwargs):
|
|
17
|
+
cls.ELEMENTS = dict()
|
|
18
|
+
for t in kwargs["types"]:
|
|
19
|
+
if isinstance(t, dict): # extended choice
|
|
20
|
+
cls.ELEMENTS[int.from_bytes(tuple(t.values())[0].TAG, "big")] = {k: ut.SequenceElement(str(v.TAG), v) for k, v in t.items()}
|
|
21
|
+
elif issubclass(t, cdt.CommonDataType):
|
|
22
|
+
cls.ELEMENTS[int.from_bytes(t.TAG, "big")] = ut.SequenceElement(str(t.TAG), t)
|
|
23
|
+
else:
|
|
24
|
+
raise TypeError(F"got {t.__class__} expected cdt or dict")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class SimpleDataTypeChoice(CommonDataTypeChoiceBase, types=cdt.SimpleDataTypes):
|
|
28
|
+
"""All Simple Data Types"""
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class ComplexDataTypeChoice(CommonDataTypeChoiceBase, types=cdt.ComplexDataTypes):
|
|
32
|
+
"""All Complex Data Types"""
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class AccessSelectorsChoice(CommonDataTypeChoiceBase, types=(cdt.NullData, cdt.Array)):
|
|
36
|
+
"""All Complex Data Types"""
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class CommonDataTypeChoice(CommonDataTypeChoiceBase, types=chain(cdt.SimpleDataTypes, cdt.ComplexDataTypes)):
|
|
40
|
+
"""Types of Data.value"""
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class ExtendedRegisterChoice(CommonDataTypeChoiceBase,
|
|
44
|
+
types=(cdt.NullData, cdt.BitString, cdt.DoubleLongUnsigned, cdt.OctetString, cdt.VisibleString, cdt.Utf8String, cdt.Unsigned, cdt.LongUnsigned,
|
|
45
|
+
cdt.Long64Unsigned)):
|
|
46
|
+
"""Types of ExtendedRegister.value"""
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class RegisterChoice(CommonDataTypeChoiceBase,
|
|
50
|
+
types=(cdt.NullData, cdt.BitString, cdt.DoubleLongUnsigned, cdt.OctetString, cdt.VisibleString, cdt.Utf8String, cdt.Unsigned, cdt.LongUnsigned,
|
|
51
|
+
cdt.Long64Unsigned, cdt.DoubleLong, cdt.Integer, cdt.Long, cdt.Long64, cdt.Enum, cdt.Float32, cdt.Float64)):
|
|
52
|
+
"""Types of ExtendedRegister.value"""
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class AnyDateTimeChoice(CommonDataTypeChoiceBase, types=(cdt.DateTime, cdt.Date, cdt.Time, {12: cst.OctetStringDateTime, 5: cst.OctetStringDate, 4: cst.OctetStringTime})):
|
|
56
|
+
"""Date of the event may contain the date only, the time only or both, encoded as specified in 4.1.6.1."""
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
simple_dt = SimpleDataTypeChoice()
|
|
60
|
+
complex_dt = ComplexDataTypeChoice()
|
|
61
|
+
common_dt = CommonDataTypeChoice()
|
|
62
|
+
extended_register = ExtendedRegisterChoice()
|
|
63
|
+
register = RegisterChoice()
|
|
64
|
+
access_selectors: cdt.NullData | cdt.Array = AccessSelectorsChoice()
|
|
65
|
+
any_date_time = AnyDateTimeChoice()
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
ExtendedRegisterValues: TypeAlias = cdt.NullData | cdt.BitString | cdt.DoubleLongUnsigned | cdt.OctetString | cdt.VisibleString | cdt.Utf8String | cdt.Unsigned \
|
|
69
|
+
| cdt.LongUnsigned | cdt.Long64Unsigned
|
|
70
|
+
RegisterValues: TypeAlias = ExtendedRegisterValues | cdt.DoubleLong | cdt.Integer | cdt.Long | cdt.Long64 | cdt.Enum | cdt.Float32 | cdt.Float64
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class RestrictionValue(ut.CHOICE):
|
|
74
|
+
TYPE = (cdt.Structure, cdt.NullData)
|
|
75
|
+
ELEMENTS = {0: ut.SequenceElement("no restriction apply", cdt.NullData),
|
|
76
|
+
1: ut.SequenceElement("restriction by date", structs.RestrictionByDate),
|
|
77
|
+
2: ut.SequenceElement("restriction by entry", structs.RestrictionByEntry)}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
restriction_value = RestrictionValue()
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class IdentifiedKeyInfoOptions(cdt.Enum, elements=(0, 1)):
|
|
84
|
+
""""""
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class KEKId(cdt.Enum, elements=(0,)):
|
|
88
|
+
""""""
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class WrappedKeyInfoOptions(cdt.Structure):
|
|
92
|
+
kek_id: KEKId
|
|
93
|
+
key_ciphered_data: cdt.OctetString
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class AgreedKeyInfoOptions(cdt.Structure):
|
|
97
|
+
kek_id: cdt.OctetString
|
|
98
|
+
key_ciphered_data: cdt.OctetString
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class KeyInfoOptions(ut.CHOICE):
|
|
102
|
+
TYPE = (cdt.Enum, cdt.Structure)
|
|
103
|
+
ELEMENTS = {0: ut.SequenceElement("identified_key", IdentifiedKeyInfoOptions),
|
|
104
|
+
1: ut.SequenceElement("wrapped_key", WrappedKeyInfoOptions),
|
|
105
|
+
2: ut.SequenceElement("agreed_key", AgreedKeyInfoOptions)}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
key_info_options = KeyInfoOptions()
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class StructureMixin:
|
|
112
|
+
"""use for cdt.Structure[Enum, CommonDataType]"""
|
|
113
|
+
ELEMENTS: tuple[cdt.StructElement, cdt.StructElement]
|
|
114
|
+
values: list[cdt.Enum, cdt.CommonDataType]
|
|
115
|
+
__len__: int
|
|
116
|
+
|
|
117
|
+
def __init__(self, value: bytes | tuple | list | None | bytearray | Self = None):
|
|
118
|
+
def raise_error(set_value):
|
|
119
|
+
raise RuntimeError(F"not can't be set {set_value} to {self}, available only set complex struct value")
|
|
120
|
+
super(StructureMixin, self).__init__(value)
|
|
121
|
+
self.values[0].register_cb_preset(raise_error)
|
|
122
|
+
|
|
123
|
+
def from_sequence(self, sequence: tuple):
|
|
124
|
+
if len(sequence) != len(self):
|
|
125
|
+
raise ValueError(F'Struct {self.__class__.__name__} got length:{len(sequence)}, expected length:{len(self)}')
|
|
126
|
+
self.values.append(self.ELEMENTS[0].TYPE(sequence[0]))
|
|
127
|
+
self.values.append(self.ELEMENTS[1].TYPE(int(self.values[0])))
|
|
128
|
+
self.values[1].set(sequence[1])
|
|
129
|
+
|
|
130
|
+
def from_content(self, value: bytes):
|
|
131
|
+
el_value, pdu = cdt.get_instance_and_pdu(self.ELEMENTS[0].TYPE, value)
|
|
132
|
+
self.values.append(el_value)
|
|
133
|
+
el_value, pdu = cdt.get_instance_and_pdu(self.ELEMENTS[1].TYPE.ELEMENTS[int(self.values[0])].TYPE, pdu)
|
|
134
|
+
self.values.append(el_value)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
class DeviceIDobject(CommonDataTypeChoiceBase,
|
|
138
|
+
types=(cdt.DoubleLongUnsigned, cdt.OctetString, cdt.VisibleString, cdt.Utf8String, cdt.Unsigned, cdt.LongUnsigned)):
|
|
139
|
+
"""DLMS UA 1000-1 Ed. 14 6.2.42 Device ID objects """
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
device_id_object = DeviceIDobject()
|