odxtools 9.7.0__py3-none-any.whl → 10.0.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/additionalaudience.py +3 -3
- odxtools/admindata.py +8 -8
- odxtools/audience.py +10 -10
- odxtools/basecomparam.py +5 -5
- odxtools/basevariantpattern.py +4 -5
- odxtools/basicstructure.py +8 -8
- odxtools/cli/_print_utils.py +35 -23
- odxtools/cli/browse.py +9 -9
- odxtools/cli/compare.py +24 -24
- odxtools/cli/decode.py +3 -4
- odxtools/cli/find.py +4 -5
- odxtools/cli/list.py +7 -7
- odxtools/cli/main.py +2 -2
- odxtools/cli/snoop.py +3 -3
- odxtools/codec.py +3 -3
- odxtools/commrelation.py +11 -11
- odxtools/companydata.py +5 -5
- odxtools/companydocinfo.py +8 -8
- odxtools/companyrevisioninfo.py +5 -5
- odxtools/companyspecificinfo.py +5 -5
- odxtools/comparam.py +3 -3
- odxtools/comparaminstance.py +10 -10
- odxtools/comparamspec.py +3 -3
- odxtools/comparamsubset.py +5 -5
- odxtools/complexcomparam.py +7 -7
- odxtools/compositecodec.py +11 -11
- odxtools/compumethods/compucodecompumethod.py +4 -4
- odxtools/compumethods/compuconst.py +4 -5
- odxtools/compumethods/compudefaultvalue.py +1 -2
- odxtools/compumethods/compuinternaltophys.py +6 -6
- odxtools/compumethods/compumethod.py +5 -5
- odxtools/compumethods/compuphystointernal.py +6 -6
- odxtools/compumethods/compurationalcoeffs.py +4 -4
- odxtools/compumethods/compuscale.py +9 -10
- odxtools/compumethods/createanycompumethod.py +1 -2
- odxtools/compumethods/identicalcompumethod.py +1 -2
- odxtools/compumethods/limit.py +12 -12
- odxtools/compumethods/linearcompumethod.py +2 -2
- odxtools/compumethods/linearsegment.py +14 -15
- odxtools/compumethods/ratfunccompumethod.py +3 -3
- odxtools/compumethods/ratfuncsegment.py +7 -8
- odxtools/compumethods/scalelinearcompumethod.py +7 -7
- odxtools/compumethods/scaleratfunccompumethod.py +4 -4
- odxtools/compumethods/tabintpcompumethod.py +15 -18
- odxtools/compumethods/texttablecompumethod.py +3 -3
- odxtools/createanycomparam.py +2 -4
- odxtools/createanydiagcodedtype.py +1 -2
- odxtools/database.py +9 -8
- odxtools/dataobjectproperty.py +10 -10
- odxtools/decodestate.py +5 -5
- odxtools/description.py +5 -5
- odxtools/determinenumberofitems.py +4 -4
- odxtools/diagcodedtype.py +7 -7
- odxtools/diagcomm.py +17 -17
- odxtools/diagdatadictionaryspec.py +6 -6
- odxtools/diaglayercontainer.py +4 -4
- odxtools/diaglayers/basevariant.py +10 -9
- odxtools/diaglayers/basevariantraw.py +9 -9
- odxtools/diaglayers/diaglayer.py +20 -19
- odxtools/diaglayers/diaglayerraw.py +10 -10
- odxtools/diaglayers/diaglayertype.py +1 -2
- odxtools/diaglayers/ecushareddata.py +4 -4
- odxtools/diaglayers/ecushareddataraw.py +6 -6
- odxtools/diaglayers/ecuvariant.py +11 -10
- odxtools/diaglayers/ecuvariantraw.py +9 -9
- odxtools/diaglayers/functionalgroup.py +8 -7
- odxtools/diaglayers/functionalgroupraw.py +7 -7
- odxtools/diaglayers/hierarchyelement.py +43 -49
- odxtools/diaglayers/hierarchyelementraw.py +4 -4
- odxtools/diaglayers/protocol.py +4 -4
- odxtools/diaglayers/protocolraw.py +6 -6
- odxtools/diagnostictroublecode.py +8 -8
- odxtools/diagservice.py +18 -18
- odxtools/diagvariable.py +14 -14
- odxtools/docrevision.py +11 -11
- odxtools/dopbase.py +6 -6
- odxtools/dtcconnector.py +3 -3
- odxtools/dtcdop.py +13 -9
- odxtools/dynamicendmarkerfield.py +5 -4
- odxtools/dynamiclengthfield.py +5 -4
- odxtools/dyndefinedspec.py +5 -5
- odxtools/dynenddopref.py +5 -5
- odxtools/dyniddefmodeinfo.py +13 -13
- odxtools/ecuvariantpattern.py +4 -5
- odxtools/element.py +5 -6
- odxtools/encodestate.py +11 -11
- odxtools/encoding.py +2 -3
- odxtools/endofpdufield.py +6 -6
- odxtools/envdataconnector.py +3 -3
- odxtools/environmentdata.py +3 -4
- odxtools/environmentdatadescription.py +11 -11
- odxtools/exceptions.py +5 -5
- odxtools/externalaccessmethod.py +1 -2
- odxtools/externaldoc.py +4 -4
- odxtools/field.py +9 -10
- odxtools/functionalclass.py +4 -4
- odxtools/inputparam.py +6 -6
- odxtools/internalconstr.py +4 -5
- odxtools/isotp_state_machine.py +12 -11
- odxtools/leadinglengthinfotype.py +2 -3
- odxtools/library.py +5 -5
- odxtools/linkeddtcdop.py +4 -4
- odxtools/loadfile.py +5 -6
- odxtools/matchingbasevariantparameter.py +2 -3
- odxtools/matchingparameter.py +7 -7
- odxtools/minmaxlengthtype.py +4 -4
- odxtools/modification.py +4 -4
- odxtools/multiplexer.py +11 -11
- odxtools/multiplexercase.py +6 -6
- odxtools/multiplexerdefaultcase.py +6 -6
- odxtools/multiplexerswitchkey.py +4 -4
- odxtools/nameditemlist.py +14 -14
- odxtools/negoutputparam.py +3 -3
- odxtools/obd.py +1 -2
- odxtools/odxcategory.py +6 -6
- odxtools/odxlink.py +19 -20
- odxtools/odxtypes.py +21 -18
- odxtools/outputparam.py +4 -4
- odxtools/parameterinfo.py +1 -1
- odxtools/parameters/codedconstparameter.py +5 -5
- odxtools/parameters/createanyparameter.py +1 -2
- odxtools/parameters/dynamicparameter.py +2 -3
- odxtools/parameters/lengthkeyparameter.py +5 -5
- odxtools/parameters/matchingrequestparameter.py +3 -4
- odxtools/parameters/nrcconstparameter.py +7 -7
- odxtools/parameters/parameter.py +11 -11
- odxtools/parameters/parameterwithdop.py +9 -9
- odxtools/parameters/physicalconstantparameter.py +4 -4
- odxtools/parameters/reservedparameter.py +3 -4
- odxtools/parameters/systemparameter.py +2 -3
- odxtools/parameters/tableentryparameter.py +3 -3
- odxtools/parameters/tablekeyparameter.py +10 -10
- odxtools/parameters/tablestructparameter.py +7 -7
- odxtools/parameters/valueparameter.py +7 -7
- odxtools/paramlengthinfotype.py +5 -3
- odxtools/parentref.py +9 -9
- odxtools/physicaldimension.py +11 -11
- odxtools/physicaltype.py +3 -4
- odxtools/posresponsesuppressible.py +9 -10
- odxtools/preconditionstateref.py +7 -7
- odxtools/progcode.py +6 -6
- odxtools/protstack.py +4 -4
- odxtools/relateddiagcommref.py +1 -2
- odxtools/relateddoc.py +6 -6
- odxtools/request.py +9 -9
- odxtools/response.py +10 -10
- odxtools/scaleconstr.py +3 -4
- odxtools/servicebinner.py +5 -5
- odxtools/singleecujob.py +4 -4
- odxtools/snrefcontext.py +2 -2
- odxtools/specialdata.py +5 -5
- odxtools/specialdatagroup.py +9 -9
- odxtools/specialdatagroupcaption.py +3 -3
- odxtools/standardlengthtype.py +10 -10
- odxtools/state.py +3 -3
- odxtools/statechart.py +4 -4
- odxtools/statemachine.py +4 -3
- odxtools/statetransition.py +4 -4
- odxtools/statetransitionref.py +18 -18
- odxtools/staticfield.py +5 -4
- odxtools/structure.py +2 -3
- odxtools/subcomponent.py +5 -5
- odxtools/subcomponentparamconnector.py +5 -5
- odxtools/subcomponentpattern.py +4 -4
- odxtools/swvariable.py +3 -4
- odxtools/table.py +14 -14
- odxtools/tablediagcommconnector.py +5 -5
- odxtools/tablerow.py +30 -30
- odxtools/tablerowconnector.py +3 -3
- odxtools/teammember.py +11 -11
- odxtools/text.py +2 -3
- odxtools/uds.py +2 -3
- odxtools/unit.py +9 -9
- odxtools/unitgroup.py +5 -5
- odxtools/unitspec.py +6 -6
- odxtools/utils.py +3 -3
- odxtools/variablegroup.py +2 -2
- odxtools/variantmatcher.py +10 -10
- odxtools/variantpattern.py +3 -3
- odxtools/version.py +2 -2
- odxtools/writepdxfile.py +5 -5
- odxtools/xdoc.py +9 -9
- {odxtools-9.7.0.dist-info → odxtools-10.0.0.dist-info}/METADATA +4 -5
- odxtools-10.0.0.dist-info/RECORD +264 -0
- odxtools-9.7.0.dist-info/RECORD +0 -264
- {odxtools-9.7.0.dist-info → odxtools-10.0.0.dist-info}/WHEEL +0 -0
- {odxtools-9.7.0.dist-info → odxtools-10.0.0.dist-info}/entry_points.txt +0 -0
- {odxtools-9.7.0.dist-info → odxtools-10.0.0.dist-info}/licenses/LICENSE +0 -0
- {odxtools-9.7.0.dist-info → odxtools-10.0.0.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from typing import
|
3
|
+
from typing import cast
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
6
6
|
from ..exceptions import DecodeError, EncodeError, odxassert, odxraise, odxrequire
|
@@ -22,7 +22,7 @@ class TexttableCompuMethod(CompuMethod):
|
|
22
22
|
"""
|
23
23
|
|
24
24
|
@staticmethod
|
25
|
-
def compu_method_from_et(et_element: ElementTree.Element, doc_frags:
|
25
|
+
def compu_method_from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment], *,
|
26
26
|
internal_type: DataType,
|
27
27
|
physical_type: DataType) -> "TexttableCompuMethod":
|
28
28
|
cm = CompuMethod.compu_method_from_et(
|
@@ -95,7 +95,7 @@ class TexttableCompuMethod(CompuMethod):
|
|
95
95
|
scales = []
|
96
96
|
if (citp := self.compu_internal_to_phys) is not None:
|
97
97
|
scales = citp.compu_scales
|
98
|
-
matching_scales:
|
98
|
+
matching_scales: list[CompuScale] = [x for x in scales if x.applies(internal_value)]
|
99
99
|
|
100
100
|
if len(matching_scales) == 0:
|
101
101
|
if self._compu_physical_default_value is None:
|
odxtools/createanycomparam.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
from typing import List, Union
|
2
1
|
from xml.etree import ElementTree
|
3
2
|
|
4
3
|
from .comparam import Comparam
|
@@ -6,9 +5,8 @@ from .complexcomparam import ComplexComparam
|
|
6
5
|
from .odxlink import OdxDocFragment
|
7
6
|
|
8
7
|
|
9
|
-
def create_any_comparam_from_et(
|
10
|
-
|
11
|
-
doc_frags: List[OdxDocFragment]) -> Union[Comparam, ComplexComparam]:
|
8
|
+
def create_any_comparam_from_et(et_element: ElementTree.Element,
|
9
|
+
doc_frags: list[OdxDocFragment]) -> Comparam | ComplexComparam:
|
12
10
|
if et_element.tag == "COMPARAM":
|
13
11
|
return Comparam.from_et(et_element, doc_frags)
|
14
12
|
elif et_element.tag == "COMPLEX-COMPARAM":
|
@@ -1,5 +1,4 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
|
-
from typing import List
|
3
2
|
from xml.etree import ElementTree
|
4
3
|
|
5
4
|
from .diagcodedtype import DiagCodedType
|
@@ -13,7 +12,7 @@ from .standardlengthtype import StandardLengthType
|
|
13
12
|
|
14
13
|
|
15
14
|
def create_any_diag_coded_type_from_et(et_element: ElementTree.Element,
|
16
|
-
doc_frags:
|
15
|
+
doc_frags: list[OdxDocFragment]) -> DiagCodedType:
|
17
16
|
dct_type = et_element.get(f"{xsi}type")
|
18
17
|
if dct_type == "LEADING-LENGTH-INFO-TYPE":
|
19
18
|
return LeadingLengthInfoType.from_et(et_element, doc_frags)
|
odxtools/database.py
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
|
+
from collections import OrderedDict
|
2
3
|
from itertools import chain
|
3
4
|
from os import PathLike
|
4
5
|
from pathlib import Path
|
5
|
-
from typing import IO, Any,
|
6
|
+
from typing import IO, Any, Union
|
6
7
|
from xml.etree import ElementTree
|
7
8
|
from zipfile import ZipFile
|
8
9
|
|
@@ -30,7 +31,7 @@ class Database:
|
|
30
31
|
"""
|
31
32
|
|
32
33
|
def __init__(self) -> None:
|
33
|
-
self.model_version:
|
34
|
+
self.model_version: Version | None = None
|
34
35
|
self.auxiliary_files: OrderedDict[str, IO[bytes]] = OrderedDict()
|
35
36
|
|
36
37
|
# create an empty database object
|
@@ -68,16 +69,16 @@ class Database:
|
|
68
69
|
|
69
70
|
def add_auxiliary_file(self,
|
70
71
|
aux_file_name: Union[str, "PathLike[Any]"],
|
71
|
-
aux_file_obj:
|
72
|
+
aux_file_obj: IO[bytes] | None = None) -> None:
|
72
73
|
if aux_file_obj is None:
|
73
74
|
aux_file_obj = open(aux_file_name, "rb")
|
74
75
|
|
75
76
|
self.auxiliary_files[str(aux_file_name)] = aux_file_obj
|
76
77
|
|
77
78
|
def _process_xml_tree(self, root: ElementTree.Element) -> None:
|
78
|
-
dlcs:
|
79
|
-
comparam_subsets:
|
80
|
-
comparam_specs:
|
79
|
+
dlcs: list[DiagLayerContainer] = []
|
80
|
+
comparam_subsets: list[ComparamSubset] = []
|
81
|
+
comparam_specs: list[ComparamSpec] = []
|
81
82
|
|
82
83
|
# ODX spec version
|
83
84
|
model_version = Version(root.attrib.get("MODEL-VERSION", "2.0"))
|
@@ -160,8 +161,8 @@ class Database:
|
|
160
161
|
for dlc in self.diag_layer_containers:
|
161
162
|
dlc._resolve_snrefs(context)
|
162
163
|
|
163
|
-
def _build_odxlinks(self) ->
|
164
|
-
result:
|
164
|
+
def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
|
165
|
+
result: dict[OdxLinkId, Any] = {}
|
165
166
|
|
166
167
|
for subset in self.comparam_subsets:
|
167
168
|
result.update(subset._build_odxlinks())
|
odxtools/dataobjectproperty.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from typing import Any,
|
3
|
+
from typing import Any, cast
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
6
6
|
from .compumethods.compumethod import CompuMethod
|
@@ -37,20 +37,20 @@ class DataObjectProperty(DopBase):
|
|
37
37
|
#: The type of the value in the physical world
|
38
38
|
physical_type: PhysicalType
|
39
39
|
|
40
|
-
internal_constr:
|
40
|
+
internal_constr: InternalConstr | None
|
41
41
|
|
42
42
|
#: The unit associated with physical values (e.g. 'm/s^2')
|
43
|
-
unit_ref:
|
43
|
+
unit_ref: OdxLinkRef | None
|
44
44
|
|
45
|
-
physical_constr:
|
45
|
+
physical_constr: InternalConstr | None
|
46
46
|
|
47
47
|
@property
|
48
|
-
def unit(self) ->
|
48
|
+
def unit(self) -> Unit | None:
|
49
49
|
return self._unit
|
50
50
|
|
51
51
|
@staticmethod
|
52
52
|
def from_et(et_element: ElementTree.Element,
|
53
|
-
doc_frags:
|
53
|
+
doc_frags: list[OdxDocFragment]) -> "DataObjectProperty":
|
54
54
|
"""Reads a DATA-OBJECT-PROP."""
|
55
55
|
kwargs = dataclass_fields_asdict(DopBase.from_et(et_element, doc_frags))
|
56
56
|
|
@@ -83,7 +83,7 @@ class DataObjectProperty(DopBase):
|
|
83
83
|
physical_constr=physical_constr,
|
84
84
|
**kwargs)
|
85
85
|
|
86
|
-
def _build_odxlinks(self) ->
|
86
|
+
def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
|
87
87
|
result = super()._build_odxlinks()
|
88
88
|
result.update(self.compu_method._build_odxlinks())
|
89
89
|
result.update(self.diag_coded_type._build_odxlinks())
|
@@ -96,7 +96,7 @@ class DataObjectProperty(DopBase):
|
|
96
96
|
self.compu_method._resolve_odxlinks(odxlinks)
|
97
97
|
self.diag_coded_type._resolve_odxlinks(odxlinks)
|
98
98
|
|
99
|
-
self._unit:
|
99
|
+
self._unit: Unit | None = None
|
100
100
|
if self.unit_ref:
|
101
101
|
self._unit = odxlinks.resolve(self.unit_ref, Unit)
|
102
102
|
|
@@ -106,7 +106,7 @@ class DataObjectProperty(DopBase):
|
|
106
106
|
self.compu_method._resolve_snrefs(context)
|
107
107
|
self.diag_coded_type._resolve_snrefs(context)
|
108
108
|
|
109
|
-
def get_static_bit_length(self) ->
|
109
|
+
def get_static_bit_length(self) -> int | None:
|
110
110
|
return self.diag_coded_type.get_static_bit_length()
|
111
111
|
|
112
112
|
def encode_into_pdu(self, physical_value: ParameterValue, encode_state: EncodeState) -> None:
|
@@ -118,7 +118,7 @@ class DataObjectProperty(DopBase):
|
|
118
118
|
f"The value {repr(physical_value)} of type {type(physical_value).__name__}"
|
119
119
|
f" is not a valid.")
|
120
120
|
|
121
|
-
if not isinstance(physical_value,
|
121
|
+
if not isinstance(physical_value, int | float | str | BytesTypes):
|
122
122
|
odxraise(f"Invalid type '{type(physical_value).__name__}' for physical value. "
|
123
123
|
f"(Expect atomic type!)")
|
124
124
|
internal_value = self.compu_method.convert_physical_to_internal(physical_value)
|
odxtools/decodestate.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass, field
|
3
|
-
from typing import TYPE_CHECKING
|
3
|
+
from typing import TYPE_CHECKING
|
4
4
|
|
5
5
|
from .encoding import Encoding, get_string_encoding
|
6
6
|
from .exceptions import DecodeError, odxassert, odxraise, strict_mode
|
@@ -41,22 +41,22 @@ class DecodeState:
|
|
41
41
|
cursor_bit_position: int = 0
|
42
42
|
|
43
43
|
#: values of the length key parameters decoded so far
|
44
|
-
length_keys:
|
44
|
+
length_keys: dict[str, int] = field(default_factory=dict)
|
45
45
|
|
46
46
|
#: values of the table key parameters decoded so far
|
47
|
-
table_keys:
|
47
|
+
table_keys: dict[str, "TableRow"] = field(default_factory=dict)
|
48
48
|
|
49
49
|
#: List of parameters that have been decoded so far. The journal
|
50
50
|
#: is used by some types of parameters which depend on the values of
|
51
51
|
#: other parameters; i.e., environment data description parameters
|
52
|
-
journal:
|
52
|
+
journal: list[tuple["Parameter", ParameterValue | None]] = field(default_factory=list)
|
53
53
|
|
54
54
|
def extract_atomic_value(
|
55
55
|
self,
|
56
56
|
*,
|
57
57
|
bit_length: int,
|
58
58
|
base_data_type: DataType,
|
59
|
-
base_type_encoding:
|
59
|
+
base_type_encoding: Encoding | None,
|
60
60
|
is_highlow_byte_order: bool,
|
61
61
|
) -> AtomicOdxType:
|
62
62
|
"""Extract an internal value from a blob of raw bytes.
|
odxtools/description.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
from dataclasses import dataclass
|
2
|
-
from typing import
|
2
|
+
from typing import Optional
|
3
3
|
from xml.etree import ElementTree
|
4
4
|
|
5
5
|
from .exceptions import odxrequire
|
@@ -10,13 +10,13 @@ from .odxlink import OdxDocFragment
|
|
10
10
|
@dataclass
|
11
11
|
class Description:
|
12
12
|
text: str
|
13
|
-
external_docs:
|
13
|
+
external_docs: list[ExternalDoc]
|
14
14
|
|
15
|
-
text_identifier:
|
15
|
+
text_identifier: str | None
|
16
16
|
|
17
17
|
@staticmethod
|
18
|
-
def from_et(et_element:
|
19
|
-
doc_frags:
|
18
|
+
def from_et(et_element: ElementTree.Element | None,
|
19
|
+
doc_frags: list[OdxDocFragment]) -> Optional["Description"]:
|
20
20
|
if et_element is None:
|
21
21
|
return None
|
22
22
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from typing import Any
|
3
|
+
from typing import Any
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
6
6
|
from .dataobjectproperty import DataObjectProperty
|
@@ -15,7 +15,7 @@ class DetermineNumberOfItems:
|
|
15
15
|
The object that determines the number of items of dynamic fields
|
16
16
|
"""
|
17
17
|
byte_position: int
|
18
|
-
bit_position:
|
18
|
+
bit_position: int | None
|
19
19
|
dop_ref: OdxLinkRef
|
20
20
|
|
21
21
|
@property
|
@@ -24,7 +24,7 @@ class DetermineNumberOfItems:
|
|
24
24
|
|
25
25
|
@staticmethod
|
26
26
|
def from_et(et_element: ElementTree.Element,
|
27
|
-
doc_frags:
|
27
|
+
doc_frags: list[OdxDocFragment]) -> "DetermineNumberOfItems":
|
28
28
|
byte_position = int(odxrequire(et_element.findtext("BYTE-POSITION")))
|
29
29
|
bit_position_str = et_element.findtext("BIT-POSITION")
|
30
30
|
bit_position = int(bit_position_str) if bit_position_str is not None else None
|
@@ -36,7 +36,7 @@ class DetermineNumberOfItems:
|
|
36
36
|
dop_ref=dop_ref,
|
37
37
|
)
|
38
38
|
|
39
|
-
def _build_odxlinks(self) ->
|
39
|
+
def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
|
40
40
|
return {}
|
41
41
|
|
42
42
|
def _resolve_odxlinks(self, odxlinks: OdxLinkDatabase) -> None:
|
odxtools/diagcodedtype.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from typing import Any,
|
3
|
+
from typing import Any, Literal, cast
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
6
6
|
from .decodestate import DecodeState
|
@@ -22,10 +22,10 @@ DctType = Literal[
|
|
22
22
|
|
23
23
|
@dataclass
|
24
24
|
class DiagCodedType:
|
25
|
-
base_type_encoding:
|
25
|
+
base_type_encoding: Encoding | None
|
26
26
|
base_data_type: DataType
|
27
27
|
|
28
|
-
is_highlow_byte_order_raw:
|
28
|
+
is_highlow_byte_order_raw: bool | None
|
29
29
|
|
30
30
|
@property
|
31
31
|
def dct_type(self) -> DctType:
|
@@ -39,7 +39,7 @@ class DiagCodedType:
|
|
39
39
|
|
40
40
|
@staticmethod
|
41
41
|
def from_et(et_element: ElementTree.Element,
|
42
|
-
doc_frags:
|
42
|
+
doc_frags: list[OdxDocFragment]) -> "DiagCodedType":
|
43
43
|
base_type_encoding = None
|
44
44
|
if (base_type_encoding_str := et_element.get("BASE-TYPE-ENCODING")) is not None:
|
45
45
|
try:
|
@@ -61,7 +61,7 @@ class DiagCodedType:
|
|
61
61
|
base_data_type=base_data_type,
|
62
62
|
is_highlow_byte_order_raw=is_highlow_byte_order_raw)
|
63
63
|
|
64
|
-
def _build_odxlinks(self) ->
|
64
|
+
def _build_odxlinks(self) -> dict[OdxLinkId, Any]: # noqa: B027
|
65
65
|
return {}
|
66
66
|
|
67
67
|
def _resolve_odxlinks(self, odxlinks: OdxLinkDatabase) -> None: # noqa: B027
|
@@ -72,10 +72,10 @@ class DiagCodedType:
|
|
72
72
|
"""Recursively resolve any short-name references"""
|
73
73
|
pass
|
74
74
|
|
75
|
-
def get_static_bit_length(self) ->
|
75
|
+
def get_static_bit_length(self) -> int | None:
|
76
76
|
return None
|
77
77
|
|
78
|
-
def _minimal_byte_length_of(self, internal_value:
|
78
|
+
def _minimal_byte_length_of(self, internal_value: bytes | str) -> int:
|
79
79
|
"""Helper method to get the minimal byte length.
|
80
80
|
(needed for LeadingLength- and MinMaxLengthType)
|
81
81
|
"""
|
odxtools/diagcomm.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from typing import TYPE_CHECKING, Any
|
3
|
+
from typing import TYPE_CHECKING, Any
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
6
6
|
from .admindata import AdminData
|
@@ -34,21 +34,21 @@ class DiagComm(IdentifiableElement):
|
|
34
34
|
|
35
35
|
"""
|
36
36
|
|
37
|
-
admin_data:
|
38
|
-
sdgs:
|
39
|
-
functional_class_refs:
|
40
|
-
audience:
|
41
|
-
protocol_snrefs:
|
42
|
-
related_diag_comm_refs:
|
43
|
-
pre_condition_state_refs:
|
44
|
-
state_transition_refs:
|
37
|
+
admin_data: AdminData | None
|
38
|
+
sdgs: list[SpecialDataGroup]
|
39
|
+
functional_class_refs: list[OdxLinkRef]
|
40
|
+
audience: Audience | None
|
41
|
+
protocol_snrefs: list[str]
|
42
|
+
related_diag_comm_refs: list[RelatedDiagCommRef]
|
43
|
+
pre_condition_state_refs: list[PreConditionStateRef]
|
44
|
+
state_transition_refs: list[StateTransitionRef]
|
45
45
|
|
46
46
|
# attributes
|
47
|
-
semantic:
|
48
|
-
diagnostic_class:
|
49
|
-
is_mandatory_raw:
|
50
|
-
is_executable_raw:
|
51
|
-
is_final_raw:
|
47
|
+
semantic: str | None
|
48
|
+
diagnostic_class: DiagClassType | None
|
49
|
+
is_mandatory_raw: bool | None
|
50
|
+
is_executable_raw: bool | None
|
51
|
+
is_final_raw: bool | None
|
52
52
|
|
53
53
|
@property
|
54
54
|
def functional_classes(self) -> NamedItemList[FunctionalClass]:
|
@@ -83,7 +83,7 @@ class DiagComm(IdentifiableElement):
|
|
83
83
|
return self.is_final_raw is True
|
84
84
|
|
85
85
|
@staticmethod
|
86
|
-
def from_et(et_element: ElementTree.Element, doc_frags:
|
86
|
+
def from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment]) -> "DiagComm":
|
87
87
|
kwargs = dataclass_fields_asdict(IdentifiableElement.from_et(et_element, doc_frags))
|
88
88
|
|
89
89
|
admin_data = AdminData.from_et(et_element.find("ADMIN-DATA"), doc_frags)
|
@@ -122,7 +122,7 @@ class DiagComm(IdentifiableElement):
|
|
122
122
|
|
123
123
|
semantic = et_element.attrib.get("SEMANTIC")
|
124
124
|
|
125
|
-
diagnostic_class:
|
125
|
+
diagnostic_class: DiagClassType | None = None
|
126
126
|
if (diagnostic_class_str := et_element.attrib.get("DIAGNOSTIC-CLASS")) is not None:
|
127
127
|
try:
|
128
128
|
diagnostic_class = DiagClassType(diagnostic_class_str)
|
@@ -149,7 +149,7 @@ class DiagComm(IdentifiableElement):
|
|
149
149
|
is_final_raw=is_final_raw,
|
150
150
|
**kwargs)
|
151
151
|
|
152
|
-
def _build_odxlinks(self) ->
|
152
|
+
def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
|
153
153
|
result = {self.odx_id: self}
|
154
154
|
|
155
155
|
if self.admin_data is not None:
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
3
|
from itertools import chain
|
4
|
-
from typing import Any
|
4
|
+
from typing import Any
|
5
5
|
from xml.etree import ElementTree
|
6
6
|
|
7
7
|
from .admindata import AdminData
|
@@ -26,7 +26,7 @@ from .unitspec import UnitSpec
|
|
26
26
|
|
27
27
|
@dataclass
|
28
28
|
class DiagDataDictionarySpec:
|
29
|
-
admin_data:
|
29
|
+
admin_data: AdminData | None
|
30
30
|
dtc_dops: NamedItemList[DtcDop]
|
31
31
|
env_data_descs: NamedItemList[EnvironmentDataDescription]
|
32
32
|
data_object_props: NamedItemList[DataObjectProperty]
|
@@ -37,13 +37,13 @@ class DiagDataDictionarySpec:
|
|
37
37
|
end_of_pdu_fields: NamedItemList[EndOfPduField]
|
38
38
|
muxs: NamedItemList[Multiplexer]
|
39
39
|
env_datas: NamedItemList[EnvironmentData]
|
40
|
-
unit_spec:
|
40
|
+
unit_spec: UnitSpec | None
|
41
41
|
tables: NamedItemList[Table]
|
42
|
-
sdgs:
|
42
|
+
sdgs: list[SpecialDataGroup]
|
43
43
|
|
44
44
|
@staticmethod
|
45
45
|
def from_et(et_element: ElementTree.Element,
|
46
|
-
doc_frags:
|
46
|
+
doc_frags: list[OdxDocFragment]) -> "DiagDataDictionarySpec":
|
47
47
|
admin_data = None
|
48
48
|
if (admin_data_elem := et_element.find("ADMIN-DATA")) is not None:
|
49
49
|
admin_data = AdminData.from_et(admin_data_elem, doc_frags)
|
@@ -149,7 +149,7 @@ class DiagDataDictionarySpec:
|
|
149
149
|
self.env_datas,
|
150
150
|
))
|
151
151
|
|
152
|
-
def _build_odxlinks(self) ->
|
152
|
+
def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
|
153
153
|
# note that DataDictionarySpec objects do not exhibit an ODXLINK id.
|
154
154
|
odxlinks = {}
|
155
155
|
|
odxtools/diaglayercontainer.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
3
|
from itertools import chain
|
4
|
-
from typing import TYPE_CHECKING, Any
|
4
|
+
from typing import TYPE_CHECKING, Any
|
5
5
|
from xml.etree import ElementTree
|
6
6
|
|
7
7
|
from .diaglayers.basevariant import BaseVariant
|
@@ -41,7 +41,7 @@ class DiagLayerContainer(OdxCategory):
|
|
41
41
|
|
42
42
|
@staticmethod
|
43
43
|
def from_et(et_element: ElementTree.Element,
|
44
|
-
doc_frags:
|
44
|
+
doc_frags: list[OdxDocFragment]) -> "DiagLayerContainer":
|
45
45
|
|
46
46
|
cat = OdxCategory.category_from_et(et_element, doc_frags, doc_type=DocType.CONTAINER)
|
47
47
|
doc_frags = cat.odx_id.doc_fragments
|
@@ -85,7 +85,7 @@ class DiagLayerContainer(OdxCategory):
|
|
85
85
|
self.ecu_variants,
|
86
86
|
),)
|
87
87
|
|
88
|
-
def _build_odxlinks(self) ->
|
88
|
+
def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
|
89
89
|
result = super()._build_odxlinks()
|
90
90
|
|
91
91
|
for protocol in self.protocols:
|
@@ -132,5 +132,5 @@ class DiagLayerContainer(OdxCategory):
|
|
132
132
|
def _resolve_snrefs(self, context: SnRefContext) -> None:
|
133
133
|
super()._resolve_snrefs(context)
|
134
134
|
|
135
|
-
def __getitem__(self, key:
|
135
|
+
def __getitem__(self, key: int | str) -> DiagLayer:
|
136
136
|
return self.diag_layers[key]
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
|
+
from collections.abc import Iterable
|
2
3
|
from copy import deepcopy
|
3
4
|
from dataclasses import dataclass
|
4
|
-
from typing import Any,
|
5
|
+
from typing import Any, cast
|
5
6
|
from xml.etree import ElementTree
|
6
7
|
|
7
8
|
from typing_extensions import override
|
@@ -32,19 +33,19 @@ class BaseVariant(HierarchyElement):
|
|
32
33
|
# <properties forwarded to the "raw" base variant>
|
33
34
|
#####
|
34
35
|
@property
|
35
|
-
def diag_variables_raw(self) ->
|
36
|
+
def diag_variables_raw(self) -> list[DiagVariable | OdxLinkRef]:
|
36
37
|
return self.base_variant_raw.diag_variables_raw
|
37
38
|
|
38
39
|
@property
|
39
|
-
def dyn_defined_spec(self) ->
|
40
|
+
def dyn_defined_spec(self) -> DynDefinedSpec | None:
|
40
41
|
return self.base_variant_raw.dyn_defined_spec
|
41
42
|
|
42
43
|
@property
|
43
|
-
def base_variant_pattern(self) ->
|
44
|
+
def base_variant_pattern(self) -> BaseVariantPattern | None:
|
44
45
|
return self.base_variant_raw.base_variant_pattern
|
45
46
|
|
46
47
|
@property
|
47
|
-
def parent_refs(self) ->
|
48
|
+
def parent_refs(self) -> list[ParentRef]:
|
48
49
|
return self.base_variant_raw.parent_refs
|
49
50
|
|
50
51
|
#####
|
@@ -67,7 +68,7 @@ class BaseVariant(HierarchyElement):
|
|
67
68
|
#######
|
68
69
|
|
69
70
|
@staticmethod
|
70
|
-
def from_et(et_element: ElementTree.Element, doc_frags:
|
71
|
+
def from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment]) -> "BaseVariant":
|
71
72
|
base_variant_raw = BaseVariantRaw.from_et(et_element, doc_frags)
|
72
73
|
|
73
74
|
return BaseVariant(diag_layer_raw=base_variant_raw)
|
@@ -80,7 +81,7 @@ class BaseVariant(HierarchyElement):
|
|
80
81
|
"The raw diagnostic layer passed to BaseVariant "
|
81
82
|
"must be a BaseVariantRaw")
|
82
83
|
|
83
|
-
def __deepcopy__(self, memo:
|
84
|
+
def __deepcopy__(self, memo: dict[int, Any]) -> Any:
|
84
85
|
"""Create a deep copy of the base variant
|
85
86
|
|
86
87
|
Note that the copied diagnostic layer is not fully
|
@@ -113,7 +114,7 @@ class BaseVariant(HierarchyElement):
|
|
113
114
|
|
114
115
|
return dl.diag_layer_raw.diag_variables # type: ignore[no-any-return]
|
115
116
|
|
116
|
-
def not_inherited_fn(parent_ref: ParentRef) ->
|
117
|
+
def not_inherited_fn(parent_ref: ParentRef) -> list[str]:
|
117
118
|
return parent_ref.not_inherited_variables
|
118
119
|
|
119
120
|
return self._compute_available_objects(get_local_objects_fn, not_inherited_fn)
|
@@ -127,7 +128,7 @@ class BaseVariant(HierarchyElement):
|
|
127
128
|
|
128
129
|
return dl.diag_layer_raw.variable_groups # type: ignore[no-any-return]
|
129
130
|
|
130
|
-
def not_inherited_fn(parent_ref: ParentRef) ->
|
131
|
+
def not_inherited_fn(parent_ref: ParentRef) -> list[str]:
|
131
132
|
return []
|
132
133
|
|
133
134
|
return self._compute_available_objects(get_local_objects_fn, not_inherited_fn)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from typing import Any
|
3
|
+
from typing import Any
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
6
6
|
from ..basevariantpattern import BaseVariantPattern
|
@@ -21,11 +21,11 @@ class BaseVariantRaw(HierarchyElementRaw):
|
|
21
21
|
"""This is a diagnostic layer for common functionality of an ECU
|
22
22
|
"""
|
23
23
|
|
24
|
-
diag_variables_raw:
|
24
|
+
diag_variables_raw: list[DiagVariable | OdxLinkRef]
|
25
25
|
variable_groups: NamedItemList[VariableGroup]
|
26
|
-
dyn_defined_spec:
|
27
|
-
base_variant_pattern:
|
28
|
-
parent_refs:
|
26
|
+
dyn_defined_spec: DynDefinedSpec | None
|
27
|
+
base_variant_pattern: BaseVariantPattern | None
|
28
|
+
parent_refs: list[ParentRef]
|
29
29
|
|
30
30
|
@property
|
31
31
|
def diag_variables(self) -> NamedItemList[DiagVariable]:
|
@@ -33,7 +33,7 @@ class BaseVariantRaw(HierarchyElementRaw):
|
|
33
33
|
|
34
34
|
@staticmethod
|
35
35
|
def from_et(et_element: ElementTree.Element,
|
36
|
-
doc_frags:
|
36
|
+
doc_frags: list[OdxDocFragment]) -> "BaseVariantRaw":
|
37
37
|
# objects contained by diagnostic layers exibit an additional
|
38
38
|
# document fragment for the diag layer, so we use the document
|
39
39
|
# fragments of the odx id of the diag layer for IDs of
|
@@ -42,10 +42,10 @@ class BaseVariantRaw(HierarchyElementRaw):
|
|
42
42
|
kwargs = dataclass_fields_asdict(her)
|
43
43
|
doc_frags = her.odx_id.doc_fragments
|
44
44
|
|
45
|
-
diag_variables_raw:
|
45
|
+
diag_variables_raw: list[DiagVariable | OdxLinkRef] = []
|
46
46
|
if (dv_elems := et_element.find("DIAG-VARIABLES")) is not None:
|
47
47
|
for dv_proxy_elem in dv_elems:
|
48
|
-
dv_proxy:
|
48
|
+
dv_proxy: OdxLinkRef | DiagVariable
|
49
49
|
if dv_proxy_elem.tag == "DIAG-VARIABLE-REF":
|
50
50
|
dv_proxy = OdxLinkRef.from_et(dv_proxy_elem, doc_frags)
|
51
51
|
elif dv_proxy_elem.tag == "DIAG-VARIABLE":
|
@@ -81,7 +81,7 @@ class BaseVariantRaw(HierarchyElementRaw):
|
|
81
81
|
parent_refs=parent_refs,
|
82
82
|
**kwargs)
|
83
83
|
|
84
|
-
def _build_odxlinks(self) ->
|
84
|
+
def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
|
85
85
|
result = super()._build_odxlinks()
|
86
86
|
|
87
87
|
for dv_proxy in self.diag_variables_raw:
|