odxtools 9.6.1__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/addressing.py +8 -0
- odxtools/admindata.py +8 -8
- odxtools/audience.py +10 -10
- odxtools/basecomparam.py +7 -20
- odxtools/basevariantpattern.py +4 -5
- odxtools/basicstructure.py +12 -11
- 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 -186
- odxtools/commrelation.py +12 -19
- odxtools/commrelationvaluetype.py +9 -0
- 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 +191 -0
- odxtools/compumethods/compucategory.py +13 -0
- odxtools/compumethods/compucodecompumethod.py +6 -5
- odxtools/compumethods/compuconst.py +4 -5
- odxtools/compumethods/compudefaultvalue.py +1 -2
- odxtools/compumethods/compuinternaltophys.py +6 -6
- odxtools/compumethods/compumethod.py +6 -17
- 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/intervaltype.py +8 -0
- odxtools/compumethods/limit.py +13 -19
- odxtools/compumethods/linearcompumethod.py +4 -3
- odxtools/compumethods/linearsegment.py +14 -15
- odxtools/compumethods/ratfunccompumethod.py +5 -4
- odxtools/compumethods/ratfuncsegment.py +7 -8
- odxtools/compumethods/scalelinearcompumethod.py +10 -9
- odxtools/compumethods/scaleratfunccompumethod.py +6 -5
- odxtools/compumethods/tabintpcompumethod.py +19 -20
- odxtools/compumethods/texttablecompumethod.py +5 -4
- 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 +6 -22
- odxtools/determinenumberofitems.py +4 -4
- odxtools/diagclasstype.py +11 -0
- odxtools/diagcodedtype.py +7 -7
- odxtools/diagcomm.py +19 -42
- 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 +21 -97
- odxtools/diagvariable.py +14 -14
- odxtools/docrevision.py +11 -11
- odxtools/dopbase.py +6 -6
- odxtools/dtcconnector.py +45 -0
- odxtools/dtcdop.py +15 -56
- odxtools/dynamicendmarkerfield.py +5 -4
- odxtools/dynamiclengthfield.py +5 -4
- odxtools/dyndefinedspec.py +7 -159
- odxtools/dynenddopref.py +5 -5
- odxtools/dyniddefmodeinfo.py +161 -0
- 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 +49 -0
- odxtools/environmentdata.py +3 -4
- odxtools/environmentdatadescription.py +11 -11
- odxtools/exceptions.py +5 -5
- odxtools/externalaccessmethod.py +22 -0
- odxtools/externaldoc.py +23 -0
- 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 +62 -0
- odxtools/loadfile.py +5 -6
- odxtools/matchingbasevariantparameter.py +2 -3
- odxtools/matchingparameter.py +7 -7
- odxtools/minmaxlengthtype.py +5 -11
- 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 +2 -2
- 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/rowfragment.py +7 -0
- odxtools/parameters/systemparameter.py +2 -3
- odxtools/parameters/tableentryparameter.py +4 -9
- 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 +4 -12
- odxtools/posresponsesuppressible.py +72 -0
- odxtools/preconditionstateref.py +7 -7
- odxtools/progcode.py +6 -6
- odxtools/protstack.py +4 -4
- odxtools/radix.py +9 -0
- odxtools/relateddiagcommref.py +22 -0
- odxtools/relateddoc.py +6 -6
- odxtools/request.py +14 -12
- odxtools/response.py +15 -13
- odxtools/scaleconstr.py +4 -12
- 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/standardizationlevel.py +9 -0
- odxtools/standardlengthtype.py +12 -21
- odxtools/state.py +3 -3
- odxtools/statechart.py +4 -4
- odxtools/statemachine.py +4 -3
- odxtools/statetransition.py +5 -18
- odxtools/statetransitionref.py +18 -18
- odxtools/staticfield.py +5 -4
- odxtools/structure.py +2 -3
- odxtools/subcomponent.py +12 -245
- odxtools/subcomponentparamconnector.py +103 -0
- odxtools/subcomponentpattern.py +42 -0
- odxtools/swvariable.py +3 -4
- odxtools/table.py +17 -55
- odxtools/tablediagcommconnector.py +47 -0
- odxtools/tablerow.py +30 -30
- odxtools/tablerowconnector.py +46 -0
- odxtools/teammember.py +11 -11
- odxtools/templates/macros/printService.xml.jinja2 +2 -1
- odxtools/termination.py +8 -0
- odxtools/text.py +2 -3
- odxtools/transmode.py +9 -0
- odxtools/uds.py +2 -3
- odxtools/unit.py +9 -9
- odxtools/unitgroup.py +6 -11
- odxtools/unitgroupcategory.py +7 -0
- odxtools/unitspec.py +6 -6
- odxtools/usage.py +9 -0
- odxtools/utils.py +31 -2
- odxtools/validtype.py +9 -0
- 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.6.1.dist-info → odxtools-10.0.0.dist-info}/METADATA +4 -5
- odxtools-10.0.0.dist-info/RECORD +264 -0
- odxtools-9.6.1.dist-info/RECORD +0 -238
- {odxtools-9.6.1.dist-info → odxtools-10.0.0.dist-info}/WHEEL +0 -0
- {odxtools-9.6.1.dist-info → odxtools-10.0.0.dist-info}/entry_points.txt +0 -0
- {odxtools-9.6.1.dist-info → odxtools-10.0.0.dist-info}/licenses/LICENSE +0 -0
- {odxtools-9.6.1.dist-info → odxtools-10.0.0.dist-info}/top_level.txt +0 -0
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,38 +1,22 @@
|
|
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
|
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
|
29
|
-
external_docs:
|
13
|
+
external_docs: list[ExternalDoc]
|
30
14
|
|
31
|
-
text_identifier:
|
15
|
+
text_identifier: str | None
|
32
16
|
|
33
17
|
@staticmethod
|
34
|
-
def from_et(et_element:
|
35
|
-
doc_frags:
|
18
|
+
def from_et(et_element: ElementTree.Element | None,
|
19
|
+
doc_frags: list[OdxDocFragment]) -> Optional["Description"]:
|
36
20
|
if et_element is None:
|
37
21
|
return None
|
38
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:
|
@@ -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"
|
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,11 +1,11 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from
|
4
|
-
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
3
|
+
from typing import TYPE_CHECKING, Any
|
5
4
|
from xml.etree import ElementTree
|
6
5
|
|
7
6
|
from .admindata import AdminData
|
8
7
|
from .audience import Audience
|
8
|
+
from .diagclasstype import DiagClassType
|
9
9
|
from .element import IdentifiableElement
|
10
10
|
from .exceptions import odxraise, odxrequire
|
11
11
|
from .functionalclass import FunctionalClass
|
@@ -13,6 +13,7 @@ from .nameditemlist import NamedItemList
|
|
13
13
|
from .odxlink import OdxDocFragment, OdxLinkDatabase, OdxLinkId, OdxLinkRef, resolve_snref
|
14
14
|
from .odxtypes import odxstr_to_bool
|
15
15
|
from .preconditionstateref import PreConditionStateRef
|
16
|
+
from .relateddiagcommref import RelatedDiagCommRef
|
16
17
|
from .snrefcontext import SnRefContext
|
17
18
|
from .specialdatagroup import SpecialDataGroup
|
18
19
|
from .state import State
|
@@ -24,30 +25,6 @@ if TYPE_CHECKING:
|
|
24
25
|
from .diaglayers.protocol import Protocol
|
25
26
|
|
26
27
|
|
27
|
-
class DiagClassType(Enum):
|
28
|
-
STARTCOMM = "STARTCOMM"
|
29
|
-
STOPCOMM = "STOPCOMM"
|
30
|
-
VARIANTIDENTIFICATION = "VARIANTIDENTIFICATION"
|
31
|
-
READ_DYN_DEFINED_MESSAGE = "READ-DYN-DEFINED-MESSAGE"
|
32
|
-
DYN_DEF_MESSAGE = "DYN-DEF-MESSAGE"
|
33
|
-
CLEAR_DYN_DEF_MESSAGE = "CLEAR-DYN-DEF-MESSAGE"
|
34
|
-
|
35
|
-
|
36
|
-
@dataclass
|
37
|
-
class RelatedDiagCommRef(OdxLinkRef):
|
38
|
-
relation_type: str
|
39
|
-
|
40
|
-
@staticmethod
|
41
|
-
def from_et( # type: ignore[override]
|
42
|
-
et_element: ElementTree.Element,
|
43
|
-
doc_frags: List[OdxDocFragment]) -> "RelatedDiagCommRef":
|
44
|
-
kwargs = dataclass_fields_asdict(odxrequire(OdxLinkRef.from_et(et_element, doc_frags)))
|
45
|
-
|
46
|
-
relation_type = odxrequire(et_element.findtext("RELATION-TYPE"))
|
47
|
-
|
48
|
-
return RelatedDiagCommRef(relation_type=relation_type, **kwargs)
|
49
|
-
|
50
|
-
|
51
28
|
@dataclass
|
52
29
|
class DiagComm(IdentifiableElement):
|
53
30
|
"""Representation of a diagnostic communication object.
|
@@ -57,21 +34,21 @@ class DiagComm(IdentifiableElement):
|
|
57
34
|
|
58
35
|
"""
|
59
36
|
|
60
|
-
admin_data:
|
61
|
-
sdgs:
|
62
|
-
functional_class_refs:
|
63
|
-
audience:
|
64
|
-
protocol_snrefs:
|
65
|
-
related_diag_comm_refs:
|
66
|
-
pre_condition_state_refs:
|
67
|
-
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]
|
68
45
|
|
69
46
|
# attributes
|
70
|
-
semantic:
|
71
|
-
diagnostic_class:
|
72
|
-
is_mandatory_raw:
|
73
|
-
is_executable_raw:
|
74
|
-
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
|
75
52
|
|
76
53
|
@property
|
77
54
|
def functional_classes(self) -> NamedItemList[FunctionalClass]:
|
@@ -106,7 +83,7 @@ class DiagComm(IdentifiableElement):
|
|
106
83
|
return self.is_final_raw is True
|
107
84
|
|
108
85
|
@staticmethod
|
109
|
-
def from_et(et_element: ElementTree.Element, doc_frags:
|
86
|
+
def from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment]) -> "DiagComm":
|
110
87
|
kwargs = dataclass_fields_asdict(IdentifiableElement.from_et(et_element, doc_frags))
|
111
88
|
|
112
89
|
admin_data = AdminData.from_et(et_element.find("ADMIN-DATA"), doc_frags)
|
@@ -145,7 +122,7 @@ class DiagComm(IdentifiableElement):
|
|
145
122
|
|
146
123
|
semantic = et_element.attrib.get("SEMANTIC")
|
147
124
|
|
148
|
-
diagnostic_class:
|
125
|
+
diagnostic_class: DiagClassType | None = None
|
149
126
|
if (diagnostic_class_str := et_element.attrib.get("DIAGNOSTIC-CLASS")) is not None:
|
150
127
|
try:
|
151
128
|
diagnostic_class = DiagClassType(diagnostic_class_str)
|
@@ -172,7 +149,7 @@ class DiagComm(IdentifiableElement):
|
|
172
149
|
is_final_raw=is_final_raw,
|
173
150
|
**kwargs)
|
174
151
|
|
175
|
-
def _build_odxlinks(self) ->
|
152
|
+
def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
|
176
153
|
result = {self.odx_id: self}
|
177
154
|
|
178
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:
|