odxtools 9.6.1__py3-none-any.whl → 9.7.0__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.
- odxtools/addressing.py +8 -0
- odxtools/basecomparam.py +2 -15
- odxtools/basicstructure.py +4 -3
- odxtools/codec.py +1 -184
- odxtools/commrelation.py +1 -8
- odxtools/commrelationvaluetype.py +9 -0
- odxtools/compositecodec.py +191 -0
- odxtools/compumethods/compucategory.py +13 -0
- odxtools/compumethods/compucodecompumethod.py +2 -1
- odxtools/compumethods/compumethod.py +1 -12
- odxtools/compumethods/intervaltype.py +8 -0
- odxtools/compumethods/limit.py +1 -7
- odxtools/compumethods/linearcompumethod.py +2 -1
- odxtools/compumethods/ratfunccompumethod.py +2 -1
- odxtools/compumethods/scalelinearcompumethod.py +3 -2
- odxtools/compumethods/scaleratfunccompumethod.py +2 -1
- odxtools/compumethods/tabintpcompumethod.py +4 -2
- odxtools/compumethods/texttablecompumethod.py +2 -1
- odxtools/description.py +1 -17
- odxtools/diagclasstype.py +11 -0
- odxtools/diagcomm.py +2 -25
- odxtools/diagservice.py +3 -79
- odxtools/dtcconnector.py +45 -0
- odxtools/dtcdop.py +2 -47
- odxtools/dyndefinedspec.py +3 -155
- odxtools/dyniddefmodeinfo.py +161 -0
- odxtools/envdataconnector.py +49 -0
- odxtools/externalaccessmethod.py +23 -0
- odxtools/externaldoc.py +23 -0
- odxtools/linkeddtcdop.py +62 -0
- odxtools/minmaxlengthtype.py +1 -7
- odxtools/parameterinfo.py +1 -1
- odxtools/parameters/rowfragment.py +7 -0
- odxtools/parameters/tableentryparameter.py +1 -6
- odxtools/physicaltype.py +1 -8
- odxtools/posresponsesuppressible.py +73 -0
- odxtools/radix.py +9 -0
- odxtools/relateddiagcommref.py +23 -0
- odxtools/request.py +5 -3
- odxtools/response.py +5 -3
- odxtools/scaleconstr.py +1 -8
- odxtools/standardizationlevel.py +9 -0
- odxtools/standardlengthtype.py +2 -11
- odxtools/statetransition.py +1 -14
- odxtools/subcomponent.py +8 -241
- odxtools/subcomponentparamconnector.py +103 -0
- odxtools/subcomponentpattern.py +42 -0
- odxtools/table.py +3 -41
- odxtools/tablediagcommconnector.py +47 -0
- odxtools/tablerowconnector.py +46 -0
- odxtools/templates/macros/printService.xml.jinja2 +2 -1
- odxtools/termination.py +8 -0
- odxtools/transmode.py +9 -0
- odxtools/unitgroup.py +1 -6
- odxtools/unitgroupcategory.py +7 -0
- odxtools/usage.py +9 -0
- odxtools/utils.py +29 -0
- odxtools/validtype.py +9 -0
- odxtools/version.py +2 -2
- {odxtools-9.6.1.dist-info → odxtools-9.7.0.dist-info}/METADATA +1 -1
- {odxtools-9.6.1.dist-info → odxtools-9.7.0.dist-info}/RECORD +65 -39
- {odxtools-9.6.1.dist-info → odxtools-9.7.0.dist-info}/WHEEL +0 -0
- {odxtools-9.6.1.dist-info → odxtools-9.7.0.dist-info}/entry_points.txt +0 -0
- {odxtools-9.6.1.dist-info → odxtools-9.7.0.dist-info}/licenses/LICENSE +0 -0
- {odxtools-9.6.1.dist-info → odxtools-9.7.0.dist-info}/top_level.txt +0 -0
odxtools/addressing.py
ADDED
odxtools/basecomparam.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from enum import Enum
|
4
3
|
from typing import Any, Dict, List, Optional, cast
|
5
4
|
from xml.etree import ElementTree
|
6
5
|
|
@@ -8,23 +7,11 @@ from .element import IdentifiableElement
|
|
8
7
|
from .exceptions import odxraise, odxrequire
|
9
8
|
from .odxlink import OdxDocFragment, OdxLinkDatabase, OdxLinkId
|
10
9
|
from .snrefcontext import SnRefContext
|
10
|
+
from .standardizationlevel import StandardizationLevel
|
11
|
+
from .usage import Usage
|
11
12
|
from .utils import dataclass_fields_asdict
|
12
13
|
|
13
14
|
|
14
|
-
class StandardizationLevel(Enum):
|
15
|
-
STANDARD = "STANDARD"
|
16
|
-
OEM_SPECIFIC = "OEM-SPECIFIC"
|
17
|
-
OPTIONAL = "OPTIONAL"
|
18
|
-
OEM_OPTIONAL = "OEM-OPTIONAL"
|
19
|
-
|
20
|
-
|
21
|
-
class Usage(Enum):
|
22
|
-
ECU_SOFTWARE = "ECU-SOFTWARE"
|
23
|
-
ECU_COMM = "ECU-COMM"
|
24
|
-
APPLICATION = "APPLICATION"
|
25
|
-
TESTER = "TESTER"
|
26
|
-
|
27
|
-
|
28
15
|
@dataclass
|
29
16
|
class BaseComparam(IdentifiableElement):
|
30
17
|
param_class: str
|
odxtools/basicstructure.py
CHANGED
@@ -5,10 +5,11 @@ from xml.etree import ElementTree
|
|
5
5
|
|
6
6
|
from typing_extensions import override
|
7
7
|
|
8
|
-
from .codec import (composite_codec_decode_from_pdu, composite_codec_encode_into_pdu,
|
9
|
-
composite_codec_get_free_parameters, composite_codec_get_required_parameters,
|
10
|
-
composite_codec_get_static_bit_length)
|
11
8
|
from .complexdop import ComplexDop
|
9
|
+
from .compositecodec import (composite_codec_decode_from_pdu, composite_codec_encode_into_pdu,
|
10
|
+
composite_codec_get_free_parameters,
|
11
|
+
composite_codec_get_required_parameters,
|
12
|
+
composite_codec_get_static_bit_length)
|
12
13
|
from .decodestate import DecodeState
|
13
14
|
from .encodestate import EncodeState
|
14
15
|
from .exceptions import DecodeError, odxraise
|
odxtools/codec.py
CHANGED
@@ -1,15 +1,10 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
import typing
|
3
|
-
from typing import
|
3
|
+
from typing import Optional, runtime_checkable
|
4
4
|
|
5
5
|
from .decodestate import DecodeState
|
6
6
|
from .encodestate import EncodeState
|
7
|
-
from .exceptions import EncodeError, odxraise
|
8
7
|
from .odxtypes import ParameterValue
|
9
|
-
from .parameters.codedconstparameter import CodedConstParameter
|
10
|
-
from .parameters.matchingrequestparameter import MatchingRequestParameter
|
11
|
-
from .parameters.parameter import Parameter
|
12
|
-
from .parameters.physicalconstantparameter import PhysicalConstantParameter
|
13
8
|
|
14
9
|
|
15
10
|
@runtime_checkable
|
@@ -31,181 +26,3 @@ class Codec(typing.Protocol):
|
|
31
26
|
|
32
27
|
def get_static_bit_length(self) -> Optional[int]:
|
33
28
|
...
|
34
|
-
|
35
|
-
|
36
|
-
@runtime_checkable
|
37
|
-
class CompositeCodec(Codec, typing.Protocol):
|
38
|
-
"""Any object which can be en- or decoded to be transferred over
|
39
|
-
the wire which is composed of multiple parameter implements this
|
40
|
-
API.
|
41
|
-
|
42
|
-
"""
|
43
|
-
|
44
|
-
@property
|
45
|
-
def parameters(self) -> List[Parameter]:
|
46
|
-
return []
|
47
|
-
|
48
|
-
@property
|
49
|
-
def required_parameters(self) -> List[Parameter]:
|
50
|
-
return []
|
51
|
-
|
52
|
-
@property
|
53
|
-
def free_parameters(self) -> List[Parameter]:
|
54
|
-
return []
|
55
|
-
|
56
|
-
|
57
|
-
# some helper functions useful for composite codec objects
|
58
|
-
def composite_codec_get_static_bit_length(codec: CompositeCodec) -> Optional[int]:
|
59
|
-
"""Compute the length of a composite codec object in bits
|
60
|
-
|
61
|
-
This is basically the sum of the lengths of all parameters. If the
|
62
|
-
length of any parameter can only determined at runtime, `None` is
|
63
|
-
returned.
|
64
|
-
"""
|
65
|
-
|
66
|
-
cursor = 0
|
67
|
-
byte_length = 0
|
68
|
-
for param in codec.parameters:
|
69
|
-
param_bit_length = param.get_static_bit_length()
|
70
|
-
if param_bit_length is None:
|
71
|
-
# We were not able to calculate a static bit length
|
72
|
-
return None
|
73
|
-
elif param.byte_position is not None:
|
74
|
-
cursor = param.byte_position
|
75
|
-
|
76
|
-
cursor += ((param.bit_position or 0) + param_bit_length + 7) // 8
|
77
|
-
byte_length = max(byte_length, cursor)
|
78
|
-
|
79
|
-
return byte_length * 8
|
80
|
-
|
81
|
-
|
82
|
-
def composite_codec_get_required_parameters(codec: CompositeCodec) -> List[Parameter]:
|
83
|
-
"""Return the list of parameters which are required to be
|
84
|
-
specified for encoding the composite codec object
|
85
|
-
|
86
|
-
I.e., all free parameters that do not exhibit a default value.
|
87
|
-
"""
|
88
|
-
return [p for p in codec.parameters if p.is_required]
|
89
|
-
|
90
|
-
|
91
|
-
def composite_codec_get_free_parameters(codec: CompositeCodec) -> List[Parameter]:
|
92
|
-
"""Return the list of parameters which can be freely specified by
|
93
|
-
the user when encoding the composite codec object
|
94
|
-
|
95
|
-
This means all required parameters plus parameters that can be
|
96
|
-
omitted because they specify a default.
|
97
|
-
"""
|
98
|
-
return [p for p in codec.parameters if p.is_settable]
|
99
|
-
|
100
|
-
|
101
|
-
def composite_codec_get_coded_const_prefix(codec: CompositeCodec,
|
102
|
-
request_prefix: bytes = b'') -> bytes:
|
103
|
-
encode_state = EncodeState(coded_message=bytearray(), triggering_request=request_prefix)
|
104
|
-
|
105
|
-
for param in codec.parameters:
|
106
|
-
if (isinstance(param, MatchingRequestParameter) and param.request_byte_position < len(request_prefix)) or \
|
107
|
-
isinstance(param, (CodedConstParameter, PhysicalConstantParameter)):
|
108
|
-
param.encode_into_pdu(physical_value=None, encode_state=encode_state)
|
109
|
-
else:
|
110
|
-
break
|
111
|
-
|
112
|
-
return encode_state.coded_message
|
113
|
-
|
114
|
-
|
115
|
-
def composite_codec_encode_into_pdu(codec: CompositeCodec, physical_value: Optional[ParameterValue],
|
116
|
-
encode_state: EncodeState) -> None:
|
117
|
-
from .parameters.lengthkeyparameter import LengthKeyParameter
|
118
|
-
from .parameters.tablekeyparameter import TableKeyParameter
|
119
|
-
|
120
|
-
if not isinstance(physical_value, dict):
|
121
|
-
odxraise(
|
122
|
-
f"Expected a dictionary for the values of {codec.short_name}, "
|
123
|
-
f"got {type(physical_value).__name__}", EncodeError)
|
124
|
-
elif encode_state.cursor_bit_position != 0:
|
125
|
-
odxraise(
|
126
|
-
f"Compositional codec objecs must be byte aligned, but "
|
127
|
-
f"{codec.short_name} requested to be at bit position "
|
128
|
-
f"{encode_state.cursor_bit_position}", EncodeError)
|
129
|
-
encode_state.bit_position = 0
|
130
|
-
|
131
|
-
orig_origin = encode_state.origin_byte_position
|
132
|
-
encode_state.origin_byte_position = encode_state.cursor_byte_position
|
133
|
-
|
134
|
-
orig_is_end_of_pdu = encode_state.is_end_of_pdu
|
135
|
-
encode_state.is_end_of_pdu = False
|
136
|
-
|
137
|
-
# ensure that no values for unknown parameters are specified.
|
138
|
-
if not encode_state.allow_unknown_parameters:
|
139
|
-
param_names = {param.short_name for param in codec.parameters}
|
140
|
-
for param_value_name in physical_value:
|
141
|
-
if param_value_name not in param_names:
|
142
|
-
odxraise(f"Value for unknown parameter '{param_value_name}' specified "
|
143
|
-
f"for composite codec object {codec.short_name}")
|
144
|
-
|
145
|
-
for param in codec.parameters:
|
146
|
-
if id(param) == id(codec.parameters[-1]):
|
147
|
-
# The last parameter of the composite codec object is at
|
148
|
-
# the end of the PDU if the codec object itself is at the
|
149
|
-
# end of the PDU.
|
150
|
-
#
|
151
|
-
# TODO: This assumes that the last parameter specified in
|
152
|
-
# the ODX is located last in the PDU...
|
153
|
-
encode_state.is_end_of_pdu = orig_is_end_of_pdu
|
154
|
-
|
155
|
-
if isinstance(param, (LengthKeyParameter, TableKeyParameter)):
|
156
|
-
# At this point, we encode a placeholder value for length-
|
157
|
-
# and table keys, since these can be specified
|
158
|
-
# implicitly (i.e., by means of parameters that use
|
159
|
-
# these keys). To avoid getting an "overlapping
|
160
|
-
# parameter" warning, we must encode a value of zero
|
161
|
-
# into the PDU here and add the real value of the
|
162
|
-
# parameter in a post-processing step.
|
163
|
-
param.encode_placeholder_into_pdu(
|
164
|
-
physical_value=physical_value.get(param.short_name), encode_state=encode_state)
|
165
|
-
|
166
|
-
continue
|
167
|
-
|
168
|
-
if param.is_required and param.short_name not in physical_value:
|
169
|
-
odxraise(f"No value for required parameter {param.short_name} specified", EncodeError)
|
170
|
-
|
171
|
-
param_phys_value = physical_value.get(param.short_name)
|
172
|
-
param.encode_into_pdu(physical_value=param_phys_value, encode_state=encode_state)
|
173
|
-
|
174
|
-
encode_state.journal.append((param, param_phys_value))
|
175
|
-
|
176
|
-
encode_state.is_end_of_pdu = False
|
177
|
-
|
178
|
-
# encode the length- and table keys. This cannot be done above
|
179
|
-
# because we allow these to be defined implicitly (i.e. they
|
180
|
-
# are defined by their respective users)
|
181
|
-
for param in codec.parameters:
|
182
|
-
if not isinstance(param, (LengthKeyParameter, TableKeyParameter)):
|
183
|
-
# the current parameter is neither a length- nor a table key
|
184
|
-
continue
|
185
|
-
|
186
|
-
# Encode the value of the key parameter into the message
|
187
|
-
param.encode_value_into_pdu(encode_state=encode_state)
|
188
|
-
|
189
|
-
encode_state.origin_byte_position = orig_origin
|
190
|
-
|
191
|
-
|
192
|
-
def composite_codec_decode_from_pdu(codec: CompositeCodec,
|
193
|
-
decode_state: DecodeState) -> ParameterValue:
|
194
|
-
# move the origin since positions specified by sub-parameters of
|
195
|
-
# composite codec objects are relative to the beginning of the
|
196
|
-
# object.
|
197
|
-
orig_origin = decode_state.origin_byte_position
|
198
|
-
decode_state.origin_byte_position = decode_state.cursor_byte_position
|
199
|
-
|
200
|
-
result = {}
|
201
|
-
for param in codec.parameters:
|
202
|
-
value = param.decode_from_pdu(decode_state)
|
203
|
-
|
204
|
-
decode_state.journal.append((param, value))
|
205
|
-
result[param.short_name] = value
|
206
|
-
|
207
|
-
# decoding of the composite codec object finished. go back the
|
208
|
-
# original origin.
|
209
|
-
decode_state.origin_byte_position = orig_origin
|
210
|
-
|
211
|
-
return result
|
odxtools/commrelation.py
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
import warnings
|
3
3
|
from dataclasses import dataclass
|
4
|
-
from enum import Enum
|
5
4
|
from typing import Any, Dict, List, Optional
|
6
5
|
from xml.etree import ElementTree
|
7
6
|
|
7
|
+
from .commrelationvaluetype import CommRelationValueType
|
8
8
|
from .description import Description
|
9
9
|
from .diagcomm import DiagComm
|
10
10
|
from .diagservice import DiagService
|
@@ -14,13 +14,6 @@ from .parameters.parameter import Parameter
|
|
14
14
|
from .snrefcontext import SnRefContext
|
15
15
|
|
16
16
|
|
17
|
-
class CommRelationValueType(Enum):
|
18
|
-
CURRENT = "CURRENT"
|
19
|
-
STORED = "STORED"
|
20
|
-
STATIC = "STATIC"
|
21
|
-
SUBSTITUTED = "SUBSTITUTED"
|
22
|
-
|
23
|
-
|
24
17
|
@dataclass
|
25
18
|
class CommRelation:
|
26
19
|
description: Optional[Description]
|
@@ -0,0 +1,191 @@
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
2
|
+
import typing
|
3
|
+
from typing import List, Optional, runtime_checkable
|
4
|
+
|
5
|
+
from .codec import Codec
|
6
|
+
from .decodestate import DecodeState
|
7
|
+
from .encodestate import EncodeState
|
8
|
+
from .exceptions import EncodeError, odxraise
|
9
|
+
from .odxtypes import ParameterValue
|
10
|
+
from .parameters.codedconstparameter import CodedConstParameter
|
11
|
+
from .parameters.matchingrequestparameter import MatchingRequestParameter
|
12
|
+
from .parameters.parameter import Parameter
|
13
|
+
from .parameters.physicalconstantparameter import PhysicalConstantParameter
|
14
|
+
|
15
|
+
|
16
|
+
@runtime_checkable
|
17
|
+
class CompositeCodec(Codec, typing.Protocol):
|
18
|
+
"""Any object which can be en- or decoded to be transferred over
|
19
|
+
the wire which is composed of multiple parameter implements this
|
20
|
+
API.
|
21
|
+
|
22
|
+
"""
|
23
|
+
|
24
|
+
@property
|
25
|
+
def parameters(self) -> List[Parameter]:
|
26
|
+
return []
|
27
|
+
|
28
|
+
@property
|
29
|
+
def required_parameters(self) -> List[Parameter]:
|
30
|
+
return []
|
31
|
+
|
32
|
+
@property
|
33
|
+
def free_parameters(self) -> List[Parameter]:
|
34
|
+
return []
|
35
|
+
|
36
|
+
|
37
|
+
# some helper functions useful for composite codec objects
|
38
|
+
def composite_codec_get_static_bit_length(codec: CompositeCodec) -> Optional[int]:
|
39
|
+
"""Compute the length of a composite codec object in bits
|
40
|
+
|
41
|
+
This is basically the sum of the lengths of all parameters. If the
|
42
|
+
length of any parameter can only determined at runtime, `None` is
|
43
|
+
returned.
|
44
|
+
"""
|
45
|
+
|
46
|
+
cursor = 0
|
47
|
+
byte_length = 0
|
48
|
+
for param in codec.parameters:
|
49
|
+
param_bit_length = param.get_static_bit_length()
|
50
|
+
if param_bit_length is None:
|
51
|
+
# We were not able to calculate a static bit length
|
52
|
+
return None
|
53
|
+
elif param.byte_position is not None:
|
54
|
+
cursor = param.byte_position
|
55
|
+
|
56
|
+
cursor += ((param.bit_position or 0) + param_bit_length + 7) // 8
|
57
|
+
byte_length = max(byte_length, cursor)
|
58
|
+
|
59
|
+
return byte_length * 8
|
60
|
+
|
61
|
+
|
62
|
+
def composite_codec_get_required_parameters(codec: CompositeCodec) -> List[Parameter]:
|
63
|
+
"""Return the list of parameters which are required to be
|
64
|
+
specified for encoding the composite codec object
|
65
|
+
|
66
|
+
I.e., all free parameters that do not exhibit a default value.
|
67
|
+
"""
|
68
|
+
return [p for p in codec.parameters if p.is_required]
|
69
|
+
|
70
|
+
|
71
|
+
def composite_codec_get_free_parameters(codec: CompositeCodec) -> List[Parameter]:
|
72
|
+
"""Return the list of parameters which can be freely specified by
|
73
|
+
the user when encoding the composite codec object
|
74
|
+
|
75
|
+
This means all required parameters plus parameters that can be
|
76
|
+
omitted because they specify a default.
|
77
|
+
"""
|
78
|
+
return [p for p in codec.parameters if p.is_settable]
|
79
|
+
|
80
|
+
|
81
|
+
def composite_codec_get_coded_const_prefix(codec: CompositeCodec,
|
82
|
+
request_prefix: bytes = b'') -> bytes:
|
83
|
+
encode_state = EncodeState(coded_message=bytearray(), triggering_request=request_prefix)
|
84
|
+
|
85
|
+
for param in codec.parameters:
|
86
|
+
if (isinstance(param, MatchingRequestParameter) and param.request_byte_position < len(request_prefix)) or \
|
87
|
+
isinstance(param, (CodedConstParameter, PhysicalConstantParameter)):
|
88
|
+
param.encode_into_pdu(physical_value=None, encode_state=encode_state)
|
89
|
+
else:
|
90
|
+
break
|
91
|
+
|
92
|
+
return encode_state.coded_message
|
93
|
+
|
94
|
+
|
95
|
+
def composite_codec_encode_into_pdu(codec: CompositeCodec, physical_value: Optional[ParameterValue],
|
96
|
+
encode_state: EncodeState) -> None:
|
97
|
+
from .parameters.lengthkeyparameter import LengthKeyParameter
|
98
|
+
from .parameters.tablekeyparameter import TableKeyParameter
|
99
|
+
|
100
|
+
if not isinstance(physical_value, dict):
|
101
|
+
odxraise(
|
102
|
+
f"Expected a dictionary for the values of {codec.short_name}, "
|
103
|
+
f"got {type(physical_value).__name__}", EncodeError)
|
104
|
+
elif encode_state.cursor_bit_position != 0:
|
105
|
+
odxraise(
|
106
|
+
f"Compositional codec objecs must be byte aligned, but "
|
107
|
+
f"{codec.short_name} requested to be at bit position "
|
108
|
+
f"{encode_state.cursor_bit_position}", EncodeError)
|
109
|
+
encode_state.bit_position = 0
|
110
|
+
|
111
|
+
orig_origin = encode_state.origin_byte_position
|
112
|
+
encode_state.origin_byte_position = encode_state.cursor_byte_position
|
113
|
+
|
114
|
+
orig_is_end_of_pdu = encode_state.is_end_of_pdu
|
115
|
+
encode_state.is_end_of_pdu = False
|
116
|
+
|
117
|
+
# ensure that no values for unknown parameters are specified.
|
118
|
+
if not encode_state.allow_unknown_parameters:
|
119
|
+
param_names = {param.short_name for param in codec.parameters}
|
120
|
+
for param_value_name in physical_value:
|
121
|
+
if param_value_name not in param_names:
|
122
|
+
odxraise(f"Value for unknown parameter '{param_value_name}' specified "
|
123
|
+
f"for composite codec object {codec.short_name}")
|
124
|
+
|
125
|
+
for param in codec.parameters:
|
126
|
+
if id(param) == id(codec.parameters[-1]):
|
127
|
+
# The last parameter of the composite codec object is at
|
128
|
+
# the end of the PDU if the codec object itself is at the
|
129
|
+
# end of the PDU.
|
130
|
+
#
|
131
|
+
# TODO: This assumes that the last parameter specified in
|
132
|
+
# the ODX is located last in the PDU...
|
133
|
+
encode_state.is_end_of_pdu = orig_is_end_of_pdu
|
134
|
+
|
135
|
+
if isinstance(param, (LengthKeyParameter, TableKeyParameter)):
|
136
|
+
# At this point, we encode a placeholder value for length-
|
137
|
+
# and table keys, since these can be specified
|
138
|
+
# implicitly (i.e., by means of parameters that use
|
139
|
+
# these keys). To avoid getting an "overlapping
|
140
|
+
# parameter" warning, we must encode a value of zero
|
141
|
+
# into the PDU here and add the real value of the
|
142
|
+
# parameter in a post-processing step.
|
143
|
+
param.encode_placeholder_into_pdu(
|
144
|
+
physical_value=physical_value.get(param.short_name), encode_state=encode_state)
|
145
|
+
|
146
|
+
continue
|
147
|
+
|
148
|
+
if param.is_required and param.short_name not in physical_value:
|
149
|
+
odxraise(f"No value for required parameter {param.short_name} specified", EncodeError)
|
150
|
+
|
151
|
+
param_phys_value = physical_value.get(param.short_name)
|
152
|
+
param.encode_into_pdu(physical_value=param_phys_value, encode_state=encode_state)
|
153
|
+
|
154
|
+
encode_state.journal.append((param, param_phys_value))
|
155
|
+
|
156
|
+
encode_state.is_end_of_pdu = False
|
157
|
+
|
158
|
+
# encode the length- and table keys. This cannot be done above
|
159
|
+
# because we allow these to be defined implicitly (i.e. they
|
160
|
+
# are defined by their respective users)
|
161
|
+
for param in codec.parameters:
|
162
|
+
if not isinstance(param, (LengthKeyParameter, TableKeyParameter)):
|
163
|
+
# the current parameter is neither a length- nor a table key
|
164
|
+
continue
|
165
|
+
|
166
|
+
# Encode the value of the key parameter into the message
|
167
|
+
param.encode_value_into_pdu(encode_state=encode_state)
|
168
|
+
|
169
|
+
encode_state.origin_byte_position = orig_origin
|
170
|
+
|
171
|
+
|
172
|
+
def composite_codec_decode_from_pdu(codec: CompositeCodec,
|
173
|
+
decode_state: DecodeState) -> ParameterValue:
|
174
|
+
# move the origin since positions specified by sub-parameters of
|
175
|
+
# composite codec objects are relative to the beginning of the
|
176
|
+
# object.
|
177
|
+
orig_origin = decode_state.origin_byte_position
|
178
|
+
decode_state.origin_byte_position = decode_state.cursor_byte_position
|
179
|
+
|
180
|
+
result = {}
|
181
|
+
for param in codec.parameters:
|
182
|
+
value = param.decode_from_pdu(decode_state)
|
183
|
+
|
184
|
+
decode_state.journal.append((param, value))
|
185
|
+
result[param.short_name] = value
|
186
|
+
|
187
|
+
# decoding of the composite codec object finished. go back the
|
188
|
+
# original origin.
|
189
|
+
decode_state.origin_byte_position = orig_origin
|
190
|
+
|
191
|
+
return result
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
2
|
+
from enum import Enum
|
3
|
+
|
4
|
+
|
5
|
+
class CompuCategory(Enum):
|
6
|
+
IDENTICAL = "IDENTICAL"
|
7
|
+
LINEAR = "LINEAR"
|
8
|
+
SCALE_LINEAR = "SCALE-LINEAR"
|
9
|
+
TEXTTABLE = "TEXTTABLE"
|
10
|
+
COMPUCODE = "COMPUCODE"
|
11
|
+
TAB_INTP = "TAB-INTP"
|
12
|
+
RAT_FUNC = "RAT-FUNC"
|
13
|
+
SCALE_RAT_FUNC = "SCALE-RAT-FUNC"
|
@@ -8,7 +8,8 @@ from ..odxlink import OdxDocFragment
|
|
8
8
|
from ..odxtypes import AtomicOdxType, DataType
|
9
9
|
from ..progcode import ProgCode
|
10
10
|
from ..utils import dataclass_fields_asdict
|
11
|
-
from .
|
11
|
+
from .compucategory import CompuCategory
|
12
|
+
from .compumethod import CompuMethod
|
12
13
|
|
13
14
|
|
14
15
|
@dataclass
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from enum import Enum
|
4
3
|
from typing import Any, Dict, List, Optional
|
5
4
|
from xml.etree import ElementTree
|
6
5
|
|
@@ -8,21 +7,11 @@ from ..exceptions import odxraise
|
|
8
7
|
from ..odxlink import OdxDocFragment, OdxLinkDatabase, OdxLinkId
|
9
8
|
from ..odxtypes import AtomicOdxType, DataType
|
10
9
|
from ..snrefcontext import SnRefContext
|
10
|
+
from .compucategory import CompuCategory
|
11
11
|
from .compuinternaltophys import CompuInternalToPhys
|
12
12
|
from .compuphystointernal import CompuPhysToInternal
|
13
13
|
|
14
14
|
|
15
|
-
class CompuCategory(Enum):
|
16
|
-
IDENTICAL = "IDENTICAL"
|
17
|
-
LINEAR = "LINEAR"
|
18
|
-
SCALE_LINEAR = "SCALE-LINEAR"
|
19
|
-
TEXTTABLE = "TEXTTABLE"
|
20
|
-
COMPUCODE = "COMPUCODE"
|
21
|
-
TAB_INTP = "TAB-INTP"
|
22
|
-
RAT_FUNC = "RAT-FUNC"
|
23
|
-
SCALE_RAT_FUNC = "SCALE-RAT-FUNC"
|
24
|
-
|
25
|
-
|
26
15
|
@dataclass
|
27
16
|
class CompuMethod:
|
28
17
|
"""A compu method translates between the internal representation
|
odxtools/compumethods/limit.py
CHANGED
@@ -1,18 +1,12 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from enum import Enum
|
4
3
|
from typing import List, Optional, overload
|
5
4
|
from xml.etree import ElementTree
|
6
5
|
|
7
6
|
from ..exceptions import odxraise
|
8
7
|
from ..odxlink import OdxDocFragment
|
9
8
|
from ..odxtypes import AtomicOdxType, DataType, compare_odx_values
|
10
|
-
|
11
|
-
|
12
|
-
class IntervalType(Enum):
|
13
|
-
OPEN = "OPEN"
|
14
|
-
CLOSED = "CLOSED"
|
15
|
-
INFINITE = "INFINITE"
|
9
|
+
from .intervaltype import IntervalType
|
16
10
|
|
17
11
|
|
18
12
|
@dataclass
|
@@ -7,7 +7,8 @@ from ..exceptions import DecodeError, EncodeError, odxassert, odxraise
|
|
7
7
|
from ..odxlink import OdxDocFragment
|
8
8
|
from ..odxtypes import AtomicOdxType, DataType
|
9
9
|
from ..utils import dataclass_fields_asdict
|
10
|
-
from .
|
10
|
+
from .compucategory import CompuCategory
|
11
|
+
from .compumethod import CompuMethod
|
11
12
|
from .linearsegment import LinearSegment
|
12
13
|
|
13
14
|
|
@@ -7,7 +7,8 @@ from ..exceptions import DecodeError, EncodeError, odxassert, odxraise
|
|
7
7
|
from ..odxlink import OdxDocFragment
|
8
8
|
from ..odxtypes import AtomicOdxType, DataType
|
9
9
|
from ..utils import dataclass_fields_asdict
|
10
|
-
from .
|
10
|
+
from .compucategory import CompuCategory
|
11
|
+
from .compumethod import CompuMethod
|
11
12
|
from .ratfuncsegment import RatFuncSegment
|
12
13
|
|
13
14
|
|
@@ -7,8 +7,9 @@ from ..exceptions import DecodeError, EncodeError, odxassert, odxraise
|
|
7
7
|
from ..odxlink import OdxDocFragment
|
8
8
|
from ..odxtypes import AtomicOdxType, DataType
|
9
9
|
from ..utils import dataclass_fields_asdict
|
10
|
-
from .
|
11
|
-
from .
|
10
|
+
from .compucategory import CompuCategory
|
11
|
+
from .compumethod import CompuMethod
|
12
|
+
from .intervaltype import IntervalType
|
12
13
|
from .linearsegment import LinearSegment
|
13
14
|
|
14
15
|
|
@@ -7,7 +7,8 @@ from ..exceptions import DecodeError, EncodeError, odxassert, odxraise
|
|
7
7
|
from ..odxlink import OdxDocFragment
|
8
8
|
from ..odxtypes import AtomicOdxType, DataType
|
9
9
|
from ..utils import dataclass_fields_asdict
|
10
|
-
from .
|
10
|
+
from .compucategory import CompuCategory
|
11
|
+
from .compumethod import CompuMethod
|
11
12
|
from .ratfuncsegment import RatFuncSegment
|
12
13
|
|
13
14
|
|
@@ -7,8 +7,10 @@ from ..exceptions import DecodeError, EncodeError, odxassert, odxraise, odxrequi
|
|
7
7
|
from ..odxlink import OdxDocFragment
|
8
8
|
from ..odxtypes import AtomicOdxType, DataType
|
9
9
|
from ..utils import dataclass_fields_asdict
|
10
|
-
from .
|
11
|
-
from .
|
10
|
+
from .compucategory import CompuCategory
|
11
|
+
from .compumethod import CompuMethod
|
12
|
+
from .intervaltype import IntervalType
|
13
|
+
from .limit import Limit
|
12
14
|
|
13
15
|
|
14
16
|
@dataclass
|
@@ -7,7 +7,8 @@ from ..exceptions import DecodeError, EncodeError, odxassert, odxraise, odxrequi
|
|
7
7
|
from ..odxlink import OdxDocFragment
|
8
8
|
from ..odxtypes import AtomicOdxType, DataType
|
9
9
|
from ..utils import dataclass_fields_asdict
|
10
|
-
from .
|
10
|
+
from .compucategory import CompuCategory
|
11
|
+
from .compumethod import CompuMethod
|
11
12
|
from .compuscale import CompuScale
|
12
13
|
|
13
14
|
|
odxtools/description.py
CHANGED
@@ -3,26 +3,10 @@ from typing import List, Optional
|
|
3
3
|
from xml.etree import ElementTree
|
4
4
|
|
5
5
|
from .exceptions import odxrequire
|
6
|
+
from .externaldoc import ExternalDoc
|
6
7
|
from .odxlink import OdxDocFragment
|
7
8
|
|
8
9
|
|
9
|
-
@dataclass
|
10
|
-
class ExternalDoc:
|
11
|
-
description: Optional[str]
|
12
|
-
href: str
|
13
|
-
|
14
|
-
@staticmethod
|
15
|
-
def from_et(et_element: Optional[ElementTree.Element],
|
16
|
-
doc_frags: List[OdxDocFragment]) -> Optional["ExternalDoc"]:
|
17
|
-
if et_element is None:
|
18
|
-
return None
|
19
|
-
|
20
|
-
description = et_element.text
|
21
|
-
href = odxrequire(et_element.get("HREF"))
|
22
|
-
|
23
|
-
return ExternalDoc(description=description, href=href)
|
24
|
-
|
25
|
-
|
26
10
|
@dataclass
|
27
11
|
class Description:
|
28
12
|
text: str
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
2
|
+
from enum import Enum
|
3
|
+
|
4
|
+
|
5
|
+
class DiagClassType(Enum):
|
6
|
+
STARTCOMM = "STARTCOMM"
|
7
|
+
STOPCOMM = "STOPCOMM"
|
8
|
+
VARIANTIDENTIFICATION = "VARIANTIDENTIFICATION"
|
9
|
+
READ_DYN_DEFINED_MESSAGE = "READ-DYN-DEFINED-MESSAGE"
|
10
|
+
DYN_DEF_MESSAGE = "DYN-DEF-MESSAGE"
|
11
|
+
CLEAR_DYN_DEF_MESSAGE = "CLEAR-DYN-DEF-MESSAGE"
|