odxtools 10.0.0__py3-none-any.whl → 10.1.1__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 +5 -5
- odxtools/admindata.py +10 -9
- odxtools/audience.py +15 -15
- odxtools/basecomparam.py +7 -6
- odxtools/basevariantpattern.py +7 -7
- odxtools/basicstructure.py +9 -9
- odxtools/cli/_print_utils.py +1 -1
- odxtools/cli/browse.py +1 -1
- odxtools/cli/compare.py +143 -170
- odxtools/cli/list.py +1 -1
- odxtools/commrelation.py +14 -13
- odxtools/companydata.py +11 -11
- odxtools/companydocinfo.py +11 -13
- odxtools/companyrevisioninfo.py +7 -7
- odxtools/companyspecificinfo.py +9 -11
- odxtools/comparam.py +6 -5
- odxtools/comparaminstance.py +10 -10
- odxtools/comparamspec.py +8 -9
- odxtools/comparamsubset.py +14 -22
- odxtools/complexcomparam.py +10 -10
- odxtools/complexdop.py +1 -1
- odxtools/compositecodec.py +3 -3
- odxtools/compumethods/compucodecompumethod.py +4 -4
- odxtools/compumethods/compuconst.py +3 -3
- odxtools/compumethods/compudefaultvalue.py +2 -2
- odxtools/compumethods/compuinternaltophys.py +11 -10
- odxtools/compumethods/compumethod.py +8 -7
- odxtools/compumethods/compuphystointernal.py +11 -10
- odxtools/compumethods/compurationalcoeffs.py +6 -6
- odxtools/compumethods/compuscale.py +14 -14
- odxtools/compumethods/createanycompumethod.py +12 -12
- odxtools/compumethods/identicalcompumethod.py +4 -4
- odxtools/compumethods/limit.py +8 -8
- odxtools/compumethods/linearcompumethod.py +4 -4
- odxtools/compumethods/linearsegment.py +8 -8
- odxtools/compumethods/ratfunccompumethod.py +4 -4
- odxtools/compumethods/ratfuncsegment.py +8 -8
- odxtools/compumethods/scalelinearcompumethod.py +5 -5
- odxtools/compumethods/scaleratfunccompumethod.py +4 -4
- odxtools/compumethods/tabintpcompumethod.py +12 -12
- odxtools/compumethods/texttablecompumethod.py +4 -4
- odxtools/createanycomparam.py +4 -4
- odxtools/createanydiagcodedtype.py +7 -7
- odxtools/database.py +28 -26
- odxtools/dataobjectproperty.py +15 -16
- odxtools/description.py +7 -7
- odxtools/determinenumberofitems.py +6 -5
- odxtools/diagcodedtype.py +6 -6
- odxtools/diagcomm.py +26 -27
- odxtools/diagdatadictionaryspec.py +34 -34
- odxtools/diaglayercontainer.py +32 -31
- odxtools/diaglayers/basevariant.py +5 -4
- odxtools/diaglayers/basevariantraw.py +18 -19
- odxtools/diaglayers/diaglayer.py +5 -4
- odxtools/diaglayers/diaglayerraw.py +39 -48
- odxtools/diaglayers/ecushareddata.py +6 -6
- odxtools/diaglayers/ecushareddataraw.py +11 -12
- odxtools/diaglayers/ecuvariant.py +5 -4
- odxtools/diaglayers/ecuvariantraw.py +17 -18
- odxtools/diaglayers/functionalgroup.py +5 -5
- odxtools/diaglayers/functionalgroupraw.py +13 -14
- odxtools/diaglayers/hierarchyelement.py +9 -9
- odxtools/diaglayers/hierarchyelementraw.py +8 -9
- odxtools/diaglayers/protocol.py +4 -4
- odxtools/diaglayers/protocolraw.py +10 -11
- odxtools/diagnostictroublecode.py +12 -14
- odxtools/diagservice.py +19 -18
- odxtools/diagvariable.py +19 -20
- odxtools/docrevision.py +14 -13
- odxtools/dopbase.py +10 -11
- odxtools/dtcconnector.py +6 -5
- odxtools/dtcdop.py +15 -15
- odxtools/dynamicendmarkerfield.py +6 -6
- odxtools/dynamiclengthfield.py +6 -6
- odxtools/dyndefinedspec.py +7 -7
- odxtools/dynenddopref.py +7 -7
- odxtools/dyniddefmodeinfo.py +17 -17
- odxtools/ecuvariantpattern.py +6 -7
- odxtools/element.py +12 -12
- odxtools/endofpdufield.py +6 -7
- odxtools/envdataconnector.py +6 -6
- odxtools/environmentdata.py +7 -8
- odxtools/environmentdatadescription.py +13 -12
- odxtools/externalaccessmethod.py +4 -5
- odxtools/externaldoc.py +4 -4
- odxtools/field.py +12 -11
- odxtools/functionalclass.py +7 -7
- odxtools/inputparam.py +9 -8
- odxtools/internalconstr.py +10 -10
- odxtools/leadinglengthinfotype.py +5 -6
- odxtools/library.py +7 -6
- odxtools/linkeddtcdop.py +7 -6
- odxtools/matchingbasevariantparameter.py +5 -5
- odxtools/matchingparameter.py +6 -6
- odxtools/message.py +1 -1
- odxtools/minmaxlengthtype.py +6 -7
- odxtools/modification.py +5 -4
- odxtools/multiplexer.py +48 -12
- odxtools/multiplexercase.py +10 -10
- odxtools/multiplexerdefaultcase.py +8 -7
- odxtools/multiplexerswitchkey.py +6 -6
- odxtools/nameditemlist.py +1 -1
- odxtools/negoutputparam.py +6 -6
- odxtools/odxcategory.py +12 -24
- odxtools/odxdoccontext.py +16 -0
- odxtools/odxlink.py +11 -12
- odxtools/odxtypes.py +3 -3
- odxtools/outputparam.py +7 -6
- odxtools/parameters/codedconstparameter.py +6 -6
- odxtools/parameters/createanyparameter.py +15 -15
- odxtools/parameters/dynamicparameter.py +4 -5
- odxtools/parameters/lengthkeyparameter.py +6 -6
- odxtools/parameters/matchingrequestparameter.py +4 -4
- odxtools/parameters/nrcconstparameter.py +8 -8
- odxtools/parameters/parameter.py +12 -13
- odxtools/parameters/parameterwithdop.py +9 -9
- odxtools/parameters/physicalconstantparameter.py +5 -4
- odxtools/parameters/reservedparameter.py +4 -5
- odxtools/parameters/systemparameter.py +4 -5
- odxtools/parameters/tableentryparameter.py +6 -6
- odxtools/parameters/tablekeyparameter.py +12 -12
- odxtools/parameters/tablestructparameter.py +9 -9
- odxtools/parameters/valueparameter.py +6 -6
- odxtools/paramlengthinfotype.py +6 -7
- odxtools/parentref.py +12 -10
- odxtools/physicaldimension.py +12 -12
- odxtools/physicaltype.py +5 -5
- odxtools/posresponsesuppressible.py +11 -11
- odxtools/preconditionstateref.py +8 -8
- odxtools/progcode.py +9 -8
- odxtools/protstack.py +8 -7
- odxtools/relateddiagcommref.py +5 -5
- odxtools/relateddoc.py +8 -7
- odxtools/request.py +12 -13
- odxtools/response.py +12 -13
- odxtools/scaleconstr.py +8 -8
- odxtools/singleecujob.py +14 -13
- odxtools/snrefcontext.py +1 -1
- odxtools/specialdata.py +6 -5
- odxtools/specialdatagroup.py +13 -13
- odxtools/specialdatagroupcaption.py +5 -4
- odxtools/standardlengthtype.py +5 -13
- odxtools/state.py +5 -4
- odxtools/statechart.py +10 -9
- odxtools/statemachine.py +2 -2
- odxtools/statetransition.py +7 -7
- odxtools/statetransitionref.py +11 -11
- odxtools/staticfield.py +5 -4
- odxtools/structure.py +5 -5
- odxtools/subcomponent.py +18 -16
- odxtools/subcomponentparamconnector.py +8 -7
- odxtools/subcomponentpattern.py +7 -7
- odxtools/swvariable.py +6 -6
- odxtools/table.py +20 -21
- odxtools/tablediagcommconnector.py +7 -6
- odxtools/tablerow.py +57 -36
- odxtools/tablerowconnector.py +6 -6
- odxtools/teammember.py +14 -13
- odxtools/templates/macros/printParentRef.xml.jinja2 +3 -1
- odxtools/text.py +4 -4
- odxtools/unit.py +9 -8
- odxtools/unitgroup.py +9 -8
- odxtools/unitspec.py +15 -16
- odxtools/variablegroup.py +4 -5
- odxtools/variantpattern.py +3 -4
- odxtools/version.py +2 -2
- odxtools/writepdxfile.py +0 -19
- odxtools/xdoc.py +11 -10
- {odxtools-10.0.0.dist-info → odxtools-10.1.1.dist-info}/METADATA +1 -1
- odxtools-10.1.1.dist-info/RECORD +265 -0
- {odxtools-10.0.0.dist-info → odxtools-10.1.1.dist-info}/WHEEL +1 -1
- odxtools-10.0.0.dist-info/RECORD +0 -264
- {odxtools-10.0.0.dist-info → odxtools-10.1.1.dist-info}/entry_points.txt +0 -0
- {odxtools-10.0.0.dist-info → odxtools-10.1.1.dist-info}/licenses/LICENSE +0 -0
- {odxtools-10.0.0.dist-info → odxtools-10.1.1.dist-info}/top_level.txt +0 -0
odxtools/companyspecificinfo.py
CHANGED
@@ -1,30 +1,28 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
|
-
from dataclasses import dataclass
|
2
|
+
from dataclasses import dataclass, field
|
3
3
|
from typing import Any
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
6
|
-
from .
|
6
|
+
from .odxdoccontext import OdxDocContext
|
7
|
+
from .odxlink import OdxLinkDatabase, OdxLinkId
|
7
8
|
from .relateddoc import RelatedDoc
|
8
9
|
from .snrefcontext import SnRefContext
|
9
10
|
from .specialdatagroup import SpecialDataGroup
|
10
11
|
|
11
12
|
|
12
|
-
@dataclass
|
13
|
+
@dataclass(kw_only=True)
|
13
14
|
class CompanySpecificInfo:
|
14
|
-
related_docs: list[RelatedDoc]
|
15
|
-
sdgs: list[SpecialDataGroup]
|
15
|
+
related_docs: list[RelatedDoc] = field(default_factory=list)
|
16
|
+
sdgs: list[SpecialDataGroup] = field(default_factory=list)
|
16
17
|
|
17
18
|
@staticmethod
|
18
|
-
def from_et(et_element: ElementTree.Element,
|
19
|
-
doc_frags: list[OdxDocFragment]) -> "CompanySpecificInfo":
|
19
|
+
def from_et(et_element: ElementTree.Element, context: OdxDocContext) -> "CompanySpecificInfo":
|
20
20
|
related_docs = [
|
21
|
-
RelatedDoc.from_et(rd,
|
21
|
+
RelatedDoc.from_et(rd, context)
|
22
22
|
for rd in et_element.iterfind("RELATED-DOCS/RELATED-DOC")
|
23
23
|
]
|
24
24
|
|
25
|
-
sdgs = [
|
26
|
-
SpecialDataGroup.from_et(sdge, doc_frags) for sdge in et_element.iterfind("SDGS/SDG")
|
27
|
-
]
|
25
|
+
sdgs = [SpecialDataGroup.from_et(sdge, context) for sdge in et_element.iterfind("SDGS/SDG")]
|
28
26
|
|
29
27
|
return CompanySpecificInfo(related_docs=related_docs, sdgs=sdgs)
|
30
28
|
|
odxtools/comparam.py
CHANGED
@@ -6,13 +6,14 @@ from xml.etree import ElementTree
|
|
6
6
|
from .basecomparam import BaseComparam
|
7
7
|
from .dataobjectproperty import DataObjectProperty
|
8
8
|
from .exceptions import odxrequire
|
9
|
-
from .
|
9
|
+
from .odxdoccontext import OdxDocContext
|
10
|
+
from .odxlink import OdxLinkDatabase, OdxLinkId, OdxLinkRef
|
10
11
|
from .odxtypes import AtomicOdxType
|
11
12
|
from .snrefcontext import SnRefContext
|
12
13
|
from .utils import dataclass_fields_asdict
|
13
14
|
|
14
15
|
|
15
|
-
@dataclass
|
16
|
+
@dataclass(kw_only=True)
|
16
17
|
class Comparam(BaseComparam):
|
17
18
|
physical_default_value_raw: str
|
18
19
|
dop_ref: OdxLinkRef
|
@@ -27,11 +28,11 @@ class Comparam(BaseComparam):
|
|
27
28
|
return self._dop
|
28
29
|
|
29
30
|
@staticmethod
|
30
|
-
def from_et(et_element: ElementTree.Element,
|
31
|
-
kwargs = dataclass_fields_asdict(BaseComparam.from_et(et_element,
|
31
|
+
def from_et(et_element: ElementTree.Element, context: OdxDocContext) -> "Comparam":
|
32
|
+
kwargs = dataclass_fields_asdict(BaseComparam.from_et(et_element, context))
|
32
33
|
|
33
34
|
physical_default_value_raw = odxrequire(et_element.findtext("PHYSICAL-DEFAULT-VALUE"))
|
34
|
-
dop_ref = odxrequire(OdxLinkRef.from_et(et_element.find("DATA-OBJECT-PROP-REF"),
|
35
|
+
dop_ref = odxrequire(OdxLinkRef.from_et(et_element.find("DATA-OBJECT-PROP-REF"), context))
|
35
36
|
|
36
37
|
return Comparam(
|
37
38
|
dop_ref=dop_ref, physical_default_value_raw=physical_default_value_raw, **kwargs)
|
odxtools/comparaminstance.py
CHANGED
@@ -9,11 +9,12 @@ from .comparam import Comparam
|
|
9
9
|
from .complexcomparam import ComplexComparam, ComplexValue, create_complex_value_from_et
|
10
10
|
from .description import Description
|
11
11
|
from .exceptions import OdxWarning, odxraise, odxrequire
|
12
|
-
from .
|
12
|
+
from .odxdoccontext import OdxDocContext
|
13
|
+
from .odxlink import OdxLinkDatabase, OdxLinkId, OdxLinkRef
|
13
14
|
from .snrefcontext import SnRefContext
|
14
15
|
|
15
16
|
|
16
|
-
@dataclass
|
17
|
+
@dataclass(kw_only=True)
|
17
18
|
class ComparamInstance:
|
18
19
|
"""
|
19
20
|
This class represents a communication parameter.
|
@@ -21,9 +22,9 @@ class ComparamInstance:
|
|
21
22
|
Be aware that the ODX specification calls this class COMPARAM-REF!
|
22
23
|
"""
|
23
24
|
value: str | ComplexValue
|
24
|
-
description: Description | None
|
25
|
-
protocol_snref: str | None
|
26
|
-
prot_stack_snref: str | None
|
25
|
+
description: Description | None = None
|
26
|
+
protocol_snref: str | None = None
|
27
|
+
prot_stack_snref: str | None = None
|
27
28
|
spec_ref: OdxLinkRef
|
28
29
|
|
29
30
|
@property
|
@@ -35,9 +36,8 @@ class ComparamInstance:
|
|
35
36
|
return self.spec.short_name
|
36
37
|
|
37
38
|
@staticmethod
|
38
|
-
def from_et(et_element: ElementTree.Element,
|
39
|
-
|
40
|
-
spec_ref = odxrequire(OdxLinkRef.from_et(et_element, doc_frags))
|
39
|
+
def from_et(et_element: ElementTree.Element, context: OdxDocContext) -> "ComparamInstance":
|
40
|
+
spec_ref = odxrequire(OdxLinkRef.from_et(et_element, context))
|
41
41
|
|
42
42
|
# ODX standard v2.0.0 defined only VALUE. ODX v2.0.1 decided
|
43
43
|
# to break things and change it to a choice between SIMPLE-VALUE
|
@@ -50,7 +50,7 @@ class ComparamInstance:
|
|
50
50
|
else:
|
51
51
|
value = create_complex_value_from_et(odxrequire(et_element.find("COMPLEX-VALUE")))
|
52
52
|
|
53
|
-
description = Description.from_et(et_element.find("DESC"),
|
53
|
+
description = Description.from_et(et_element.find("DESC"), context)
|
54
54
|
|
55
55
|
protocol_snref = None
|
56
56
|
if (psnref_elem := et_element.find("PROTOCOL-SNREF")) is not None:
|
@@ -133,7 +133,7 @@ class ComparamInstance:
|
|
133
133
|
return None
|
134
134
|
|
135
135
|
result = value_list[idx]
|
136
|
-
if result is None and isinstance(subparam, Comparam
|
136
|
+
if result is None and isinstance(subparam, (Comparam, ComplexComparam)):
|
137
137
|
result = subparam.physical_default_value
|
138
138
|
if not isinstance(result, str):
|
139
139
|
odxraise()
|
odxtools/comparamspec.py
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
|
-
from dataclasses import dataclass
|
2
|
+
from dataclasses import dataclass, field
|
3
3
|
from typing import TYPE_CHECKING, Any
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
6
6
|
from .nameditemlist import NamedItemList
|
7
7
|
from .odxcategory import OdxCategory
|
8
|
-
from .
|
8
|
+
from .odxdoccontext import OdxDocContext
|
9
|
+
from .odxlink import OdxLinkDatabase, OdxLinkId
|
9
10
|
from .protstack import ProtStack
|
10
11
|
from .snrefcontext import SnRefContext
|
11
12
|
from .utils import dataclass_fields_asdict
|
@@ -14,21 +15,19 @@ if TYPE_CHECKING:
|
|
14
15
|
from .database import Database
|
15
16
|
|
16
17
|
|
17
|
-
@dataclass
|
18
|
+
@dataclass(kw_only=True)
|
18
19
|
class ComparamSpec(OdxCategory):
|
19
20
|
|
20
|
-
prot_stacks: NamedItemList[ProtStack]
|
21
|
+
prot_stacks: NamedItemList[ProtStack] = field(default_factory=NamedItemList)
|
21
22
|
|
22
23
|
@staticmethod
|
23
|
-
def from_et(et_element: ElementTree.Element,
|
24
|
+
def from_et(et_element: ElementTree.Element, context: OdxDocContext) -> "ComparamSpec":
|
24
25
|
|
25
|
-
base_obj = OdxCategory.
|
26
|
-
et_element, doc_frags, doc_type=DocType.COMPARAM_SPEC)
|
27
|
-
doc_frags = base_obj.odx_id.doc_fragments
|
26
|
+
base_obj = OdxCategory.from_et(et_element, context)
|
28
27
|
kwargs = dataclass_fields_asdict(base_obj)
|
29
28
|
|
30
29
|
prot_stacks = NamedItemList([
|
31
|
-
ProtStack.from_et(dl_element,
|
30
|
+
ProtStack.from_et(dl_element, context)
|
32
31
|
for dl_element in et_element.iterfind("PROT-STACKS/PROT-STACK")
|
33
32
|
])
|
34
33
|
|
odxtools/comparamsubset.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
|
-
from dataclasses import dataclass
|
2
|
+
from dataclasses import dataclass, field
|
3
3
|
from typing import TYPE_CHECKING, Any
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
@@ -8,7 +8,8 @@ from .complexcomparam import ComplexComparam
|
|
8
8
|
from .dataobjectproperty import DataObjectProperty
|
9
9
|
from .nameditemlist import NamedItemList
|
10
10
|
from .odxcategory import OdxCategory
|
11
|
-
from .
|
11
|
+
from .odxdoccontext import OdxDocContext
|
12
|
+
from .odxlink import OdxLinkDatabase, OdxLinkId
|
12
13
|
from .snrefcontext import SnRefContext
|
13
14
|
from .unitspec import UnitSpec
|
14
15
|
from .utils import dataclass_fields_asdict
|
@@ -17,44 +18,35 @@ if TYPE_CHECKING:
|
|
17
18
|
from .database import Database
|
18
19
|
|
19
20
|
|
20
|
-
@dataclass
|
21
|
+
@dataclass(kw_only=True)
|
21
22
|
class ComparamSubset(OdxCategory):
|
22
|
-
comparams: NamedItemList[Comparam]
|
23
|
-
complex_comparams: NamedItemList[ComplexComparam]
|
24
|
-
data_object_props: NamedItemList[DataObjectProperty]
|
25
|
-
unit_spec: UnitSpec | None
|
23
|
+
comparams: NamedItemList[Comparam] = field(default_factory=NamedItemList)
|
24
|
+
complex_comparams: NamedItemList[ComplexComparam] = field(default_factory=NamedItemList)
|
25
|
+
data_object_props: NamedItemList[DataObjectProperty] = field(default_factory=NamedItemList)
|
26
|
+
unit_spec: UnitSpec | None = None
|
26
27
|
category: str | None # mandatory in ODX 2.2, but non-existent in ODX 2.0
|
27
28
|
|
28
29
|
@staticmethod
|
29
|
-
def from_et(et_element: ElementTree.Element,
|
30
|
-
doc_frags: list[OdxDocFragment]) -> "ComparamSubset":
|
30
|
+
def from_et(et_element: ElementTree.Element, context: OdxDocContext) -> "ComparamSubset":
|
31
31
|
|
32
32
|
category_attrib = et_element.attrib.get("CATEGORY")
|
33
33
|
|
34
|
-
|
35
|
-
# refers to something else and has been replaced by
|
36
|
-
# COMPARAM-SUBSET.
|
37
|
-
# - If the 'CATEGORY' attribute is missing (ODX 2.0), use
|
38
|
-
# COMPARAM_SPEC,
|
39
|
-
# - else (ODX 2.2), use COMPARAM_SUBSET.
|
40
|
-
doc_type = DocType.COMPARAM_SUBSET if category_attrib is not None else DocType.COMPARAM_SPEC
|
41
|
-
base_obj = OdxCategory.category_from_et(et_element, doc_frags, doc_type=doc_type)
|
42
|
-
doc_frags = base_obj.odx_id.doc_fragments
|
34
|
+
base_obj = OdxCategory.from_et(et_element, context)
|
43
35
|
kwargs = dataclass_fields_asdict(base_obj)
|
44
36
|
|
45
37
|
comparams = NamedItemList(
|
46
|
-
[Comparam.from_et(el,
|
38
|
+
[Comparam.from_et(el, context) for el in et_element.iterfind("COMPARAMS/COMPARAM")])
|
47
39
|
complex_comparams = NamedItemList([
|
48
|
-
ComplexComparam.from_et(el,
|
40
|
+
ComplexComparam.from_et(el, context)
|
49
41
|
for el in et_element.iterfind("COMPLEX-COMPARAMS/COMPLEX-COMPARAM")
|
50
42
|
])
|
51
43
|
data_object_props = NamedItemList([
|
52
|
-
DataObjectProperty.from_et(el,
|
44
|
+
DataObjectProperty.from_et(el, context)
|
53
45
|
for el in et_element.iterfind("DATA-OBJECT-PROPS/DATA-OBJECT-PROP")
|
54
46
|
])
|
55
47
|
unit_spec = None
|
56
48
|
if (unit_spec_elem := et_element.find("UNIT-SPEC")) is not None:
|
57
|
-
unit_spec = UnitSpec.from_et(unit_spec_elem,
|
49
|
+
unit_spec = UnitSpec.from_et(unit_spec_elem, context)
|
58
50
|
|
59
51
|
return ComparamSubset(
|
60
52
|
category=category_attrib,
|
odxtools/complexcomparam.py
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
|
-
from dataclasses import dataclass
|
2
|
+
from dataclasses import dataclass, field
|
3
3
|
from typing import Any, Union
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
6
6
|
from .basecomparam import BaseComparam
|
7
7
|
from .nameditemlist import NamedItemList
|
8
|
-
from .
|
8
|
+
from .odxdoccontext import OdxDocContext
|
9
|
+
from .odxlink import OdxLinkDatabase, OdxLinkId
|
9
10
|
from .odxtypes import odxstr_to_bool
|
10
11
|
from .snrefcontext import SnRefContext
|
11
12
|
from .utils import dataclass_fields_asdict
|
@@ -23,20 +24,19 @@ def create_complex_value_from_et(et_element: ElementTree.Element) -> ComplexValu
|
|
23
24
|
return result
|
24
25
|
|
25
26
|
|
26
|
-
@dataclass
|
27
|
+
@dataclass(kw_only=True)
|
27
28
|
class ComplexComparam(BaseComparam):
|
28
|
-
subparams: NamedItemList[BaseComparam]
|
29
|
-
physical_default_value: ComplexValue | None
|
30
|
-
allow_multiple_values_raw: bool | None
|
29
|
+
subparams: NamedItemList[BaseComparam] = field(default_factory=NamedItemList)
|
30
|
+
physical_default_value: ComplexValue | None = None
|
31
|
+
allow_multiple_values_raw: bool | None = None
|
31
32
|
|
32
33
|
@property
|
33
34
|
def allow_multiple_values(self) -> bool:
|
34
35
|
return self.allow_multiple_values_raw is True
|
35
36
|
|
36
37
|
@staticmethod
|
37
|
-
def from_et(et_element: ElementTree.Element,
|
38
|
-
|
39
|
-
kwargs = dataclass_fields_asdict(BaseComparam.from_et(et_element, doc_frags))
|
38
|
+
def from_et(et_element: ElementTree.Element, context: OdxDocContext) -> "ComplexComparam":
|
39
|
+
kwargs = dataclass_fields_asdict(BaseComparam.from_et(et_element, context))
|
40
40
|
|
41
41
|
# to avoid a cyclic import, create_any_comparam_from_et cannot
|
42
42
|
# be imported globally. TODO: figure out if this has
|
@@ -61,7 +61,7 @@ class ComplexComparam(BaseComparam):
|
|
61
61
|
if elems[i].tag not in ("COMPARAM", "COMPLEX-COMPARAM"):
|
62
62
|
break
|
63
63
|
|
64
|
-
subparam = create_any_comparam_from_et(elems[i],
|
64
|
+
subparam = create_any_comparam_from_et(elems[i], context)
|
65
65
|
subparams.append(subparam)
|
66
66
|
i += 1
|
67
67
|
|
odxtools/complexdop.py
CHANGED
odxtools/compositecodec.py
CHANGED
@@ -84,7 +84,7 @@ def composite_codec_get_coded_const_prefix(codec: CompositeCodec,
|
|
84
84
|
|
85
85
|
for param in codec.parameters:
|
86
86
|
if (isinstance(param, MatchingRequestParameter) and param.request_byte_position < len(request_prefix)) or \
|
87
|
-
isinstance(param, CodedConstParameter
|
87
|
+
isinstance(param, (CodedConstParameter, PhysicalConstantParameter)):
|
88
88
|
param.encode_into_pdu(physical_value=None, encode_state=encode_state)
|
89
89
|
else:
|
90
90
|
break
|
@@ -132,7 +132,7 @@ def composite_codec_encode_into_pdu(codec: CompositeCodec, physical_value: Param
|
|
132
132
|
# the ODX is located last in the PDU...
|
133
133
|
encode_state.is_end_of_pdu = orig_is_end_of_pdu
|
134
134
|
|
135
|
-
if isinstance(param, LengthKeyParameter
|
135
|
+
if isinstance(param, (LengthKeyParameter, TableKeyParameter)):
|
136
136
|
# At this point, we encode a placeholder value for length-
|
137
137
|
# and table keys, since these can be specified
|
138
138
|
# implicitly (i.e., by means of parameters that use
|
@@ -159,7 +159,7 @@ def composite_codec_encode_into_pdu(codec: CompositeCodec, physical_value: Param
|
|
159
159
|
# because we allow these to be defined implicitly (i.e. they
|
160
160
|
# are defined by their respective users)
|
161
161
|
for param in codec.parameters:
|
162
|
-
if not isinstance(param, LengthKeyParameter
|
162
|
+
if not isinstance(param, (LengthKeyParameter, TableKeyParameter)):
|
163
163
|
# the current parameter is neither a length- nor a table key
|
164
164
|
continue
|
165
165
|
|
@@ -4,7 +4,7 @@ from typing import cast
|
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
6
6
|
from ..exceptions import DecodeError, EncodeError, odxassert, odxraise
|
7
|
-
from ..
|
7
|
+
from ..odxdoccontext import OdxDocContext
|
8
8
|
from ..odxtypes import AtomicOdxType, DataType
|
9
9
|
from ..progcode import ProgCode
|
10
10
|
from ..utils import dataclass_fields_asdict
|
@@ -12,7 +12,7 @@ from .compucategory import CompuCategory
|
|
12
12
|
from .compumethod import CompuMethod
|
13
13
|
|
14
14
|
|
15
|
-
@dataclass
|
15
|
+
@dataclass(kw_only=True)
|
16
16
|
class CompuCodeCompuMethod(CompuMethod):
|
17
17
|
"""A compu method specifies the tranfer functions using Java bytecode
|
18
18
|
|
@@ -34,11 +34,11 @@ class CompuCodeCompuMethod(CompuMethod):
|
|
34
34
|
return self.compu_phys_to_internal.prog_code
|
35
35
|
|
36
36
|
@staticmethod
|
37
|
-
def compu_method_from_et(et_element: ElementTree.Element,
|
37
|
+
def compu_method_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
|
38
38
|
internal_type: DataType,
|
39
39
|
physical_type: DataType) -> "CompuCodeCompuMethod":
|
40
40
|
cm = CompuMethod.compu_method_from_et(
|
41
|
-
et_element,
|
41
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
42
42
|
kwargs = dataclass_fields_asdict(cm)
|
43
43
|
|
44
44
|
return CompuCodeCompuMethod(**kwargs)
|
@@ -5,10 +5,10 @@ from xml.etree import ElementTree
|
|
5
5
|
from ..odxtypes import AtomicOdxType, DataType
|
6
6
|
|
7
7
|
|
8
|
-
@dataclass
|
8
|
+
@dataclass(kw_only=True)
|
9
9
|
class CompuConst:
|
10
|
-
v: str | None
|
11
|
-
vt: str | None
|
10
|
+
v: str | None = None
|
11
|
+
vt: str | None = None
|
12
12
|
|
13
13
|
data_type: DataType
|
14
14
|
|
@@ -8,9 +8,9 @@ from .compuconst import CompuConst
|
|
8
8
|
from .compuinversevalue import CompuInverseValue
|
9
9
|
|
10
10
|
|
11
|
-
@dataclass
|
11
|
+
@dataclass(kw_only=True)
|
12
12
|
class CompuDefaultValue(CompuConst):
|
13
|
-
compu_inverse_value: CompuInverseValue | None
|
13
|
+
compu_inverse_value: CompuInverseValue | None = None
|
14
14
|
|
15
15
|
@staticmethod
|
16
16
|
def compuvalue_from_et(et_element: ElementTree.Element, *,
|
@@ -1,9 +1,10 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
|
-
from dataclasses import dataclass
|
2
|
+
from dataclasses import dataclass, field
|
3
3
|
from typing import Any
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
6
|
-
from ..
|
6
|
+
from ..odxdoccontext import OdxDocContext
|
7
|
+
from ..odxlink import OdxLinkDatabase, OdxLinkId
|
7
8
|
from ..odxtypes import DataType
|
8
9
|
from ..progcode import ProgCode
|
9
10
|
from ..snrefcontext import SnRefContext
|
@@ -11,25 +12,25 @@ from .compudefaultvalue import CompuDefaultValue
|
|
11
12
|
from .compuscale import CompuScale
|
12
13
|
|
13
14
|
|
14
|
-
@dataclass
|
15
|
+
@dataclass(kw_only=True)
|
15
16
|
class CompuInternalToPhys:
|
16
|
-
compu_scales: list[CompuScale]
|
17
|
-
prog_code: ProgCode | None
|
18
|
-
compu_default_value: CompuDefaultValue | None
|
17
|
+
compu_scales: list[CompuScale] = field(default_factory=list)
|
18
|
+
prog_code: ProgCode | None = None
|
19
|
+
compu_default_value: CompuDefaultValue | None = None
|
19
20
|
|
20
21
|
@staticmethod
|
21
|
-
def compu_internal_to_phys_from_et(et_element: ElementTree.Element,
|
22
|
-
|
22
|
+
def compu_internal_to_phys_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
|
23
|
+
internal_type: DataType,
|
23
24
|
physical_type: DataType) -> "CompuInternalToPhys":
|
24
25
|
compu_scales = [
|
25
26
|
CompuScale.compuscale_from_et(
|
26
|
-
cse,
|
27
|
+
cse, context, domain_type=internal_type, range_type=physical_type)
|
27
28
|
for cse in et_element.iterfind("COMPU-SCALES/COMPU-SCALE")
|
28
29
|
]
|
29
30
|
|
30
31
|
prog_code = None
|
31
32
|
if (pce := et_element.find("PROG-CODE")) is not None:
|
32
|
-
prog_code = ProgCode.from_et(pce,
|
33
|
+
prog_code = ProgCode.from_et(pce, context)
|
33
34
|
|
34
35
|
compu_default_value = None
|
35
36
|
if (cdve := et_element.find("COMPU-DEFAULT-VALUE")) is not None:
|
@@ -4,7 +4,8 @@ from typing import Any
|
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
6
6
|
from ..exceptions import odxraise
|
7
|
-
from ..
|
7
|
+
from ..odxdoccontext import OdxDocContext
|
8
|
+
from ..odxlink import OdxLinkDatabase, OdxLinkId
|
8
9
|
from ..odxtypes import AtomicOdxType, DataType
|
9
10
|
from ..snrefcontext import SnRefContext
|
10
11
|
from .compucategory import CompuCategory
|
@@ -12,7 +13,7 @@ from .compuinternaltophys import CompuInternalToPhys
|
|
12
13
|
from .compuphystointernal import CompuPhysToInternal
|
13
14
|
|
14
15
|
|
15
|
-
@dataclass
|
16
|
+
@dataclass(kw_only=True)
|
16
17
|
class CompuMethod:
|
17
18
|
"""A compu method translates between the internal representation
|
18
19
|
of a value and their physical representation.
|
@@ -31,14 +32,14 @@ class CompuMethod:
|
|
31
32
|
"""
|
32
33
|
|
33
34
|
category: CompuCategory
|
34
|
-
compu_internal_to_phys: CompuInternalToPhys | None
|
35
|
-
compu_phys_to_internal: CompuPhysToInternal | None
|
35
|
+
compu_internal_to_phys: CompuInternalToPhys | None = None
|
36
|
+
compu_phys_to_internal: CompuPhysToInternal | None = None
|
36
37
|
|
37
38
|
physical_type: DataType
|
38
39
|
internal_type: DataType
|
39
40
|
|
40
41
|
@staticmethod
|
41
|
-
def compu_method_from_et(et_element: ElementTree.Element,
|
42
|
+
def compu_method_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
|
42
43
|
internal_type: DataType, physical_type: DataType) -> "CompuMethod":
|
43
44
|
cat_text = et_element.findtext("CATEGORY")
|
44
45
|
if cat_text is None:
|
@@ -54,11 +55,11 @@ class CompuMethod:
|
|
54
55
|
compu_internal_to_phys = None
|
55
56
|
if (citp_elem := et_element.find("COMPU-INTERNAL-TO-PHYS")) is not None:
|
56
57
|
compu_internal_to_phys = CompuInternalToPhys.compu_internal_to_phys_from_et(
|
57
|
-
citp_elem,
|
58
|
+
citp_elem, context, internal_type=internal_type, physical_type=physical_type)
|
58
59
|
compu_phys_to_internal = None
|
59
60
|
if (cpti_elem := et_element.find("COMPU-PHYS-TO-INTERNAL")) is not None:
|
60
61
|
compu_phys_to_internal = CompuPhysToInternal.compu_phys_to_internal_from_et(
|
61
|
-
cpti_elem,
|
62
|
+
cpti_elem, context, internal_type=internal_type, physical_type=physical_type)
|
62
63
|
|
63
64
|
return CompuMethod(
|
64
65
|
category=category,
|
@@ -1,9 +1,10 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
|
-
from dataclasses import dataclass
|
2
|
+
from dataclasses import dataclass, field
|
3
3
|
from typing import Any
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
6
|
-
from ..
|
6
|
+
from ..odxdoccontext import OdxDocContext
|
7
|
+
from ..odxlink import OdxLinkDatabase, OdxLinkId
|
7
8
|
from ..odxtypes import DataType
|
8
9
|
from ..progcode import ProgCode
|
9
10
|
from ..snrefcontext import SnRefContext
|
@@ -11,25 +12,25 @@ from .compudefaultvalue import CompuDefaultValue
|
|
11
12
|
from .compuscale import CompuScale
|
12
13
|
|
13
14
|
|
14
|
-
@dataclass
|
15
|
+
@dataclass(kw_only=True)
|
15
16
|
class CompuPhysToInternal:
|
16
|
-
compu_scales: list[CompuScale]
|
17
|
-
prog_code: ProgCode | None
|
18
|
-
compu_default_value: CompuDefaultValue | None
|
17
|
+
compu_scales: list[CompuScale] = field(default_factory=list)
|
18
|
+
prog_code: ProgCode | None = None
|
19
|
+
compu_default_value: CompuDefaultValue | None = None
|
19
20
|
|
20
21
|
@staticmethod
|
21
|
-
def compu_phys_to_internal_from_et(et_element: ElementTree.Element,
|
22
|
-
|
22
|
+
def compu_phys_to_internal_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
|
23
|
+
internal_type: DataType,
|
23
24
|
physical_type: DataType) -> "CompuPhysToInternal":
|
24
25
|
compu_scales = [
|
25
26
|
CompuScale.compuscale_from_et(
|
26
|
-
cse,
|
27
|
+
cse, context, domain_type=physical_type, range_type=internal_type)
|
27
28
|
for cse in et_element.iterfind("COMPU-SCALES/COMPU-SCALE")
|
28
29
|
]
|
29
30
|
|
30
31
|
prog_code = None
|
31
32
|
if (pce := et_element.find("PROG-CODE")) is not None:
|
32
|
-
prog_code = ProgCode.from_et(pce,
|
33
|
+
prog_code = ProgCode.from_et(pce, context)
|
33
34
|
|
34
35
|
compu_default_value = None
|
35
36
|
if (cdve := et_element.find("COMPU-DEFAULT-VALUE")) is not None:
|
@@ -1,22 +1,22 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
|
-
from dataclasses import dataclass
|
2
|
+
from dataclasses import dataclass, field
|
3
3
|
from typing import cast
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
6
6
|
from ..exceptions import odxassert, odxrequire
|
7
|
-
from ..
|
7
|
+
from ..odxdoccontext import OdxDocContext
|
8
8
|
from ..odxtypes import DataType
|
9
9
|
|
10
10
|
|
11
|
-
@dataclass
|
11
|
+
@dataclass(kw_only=True)
|
12
12
|
class CompuRationalCoeffs:
|
13
13
|
value_type: DataType
|
14
14
|
|
15
|
-
numerators: list[int | float]
|
16
|
-
denominators: list[int | float]
|
15
|
+
numerators: list[int | float] = field(default_factory=list)
|
16
|
+
denominators: list[int | float] = field(default_factory=list)
|
17
17
|
|
18
18
|
@staticmethod
|
19
|
-
def coeffs_from_et(et_element: ElementTree.Element,
|
19
|
+
def coeffs_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
|
20
20
|
value_type: DataType) -> "CompuRationalCoeffs":
|
21
21
|
odxassert(
|
22
22
|
value_type
|
@@ -3,7 +3,7 @@ from dataclasses import dataclass
|
|
3
3
|
from xml.etree import ElementTree
|
4
4
|
|
5
5
|
from ..description import Description
|
6
|
-
from ..
|
6
|
+
from ..odxdoccontext import OdxDocContext
|
7
7
|
from ..odxtypes import AtomicOdxType, DataType
|
8
8
|
from .compuconst import CompuConst
|
9
9
|
from .compuinversevalue import CompuInverseValue
|
@@ -11,18 +11,18 @@ from .compurationalcoeffs import CompuRationalCoeffs
|
|
11
11
|
from .limit import Limit
|
12
12
|
|
13
13
|
|
14
|
-
@dataclass
|
14
|
+
@dataclass(kw_only=True)
|
15
15
|
class CompuScale:
|
16
16
|
"""A COMPU-SCALE represents one value range of a COMPU-METHOD.
|
17
17
|
"""
|
18
18
|
|
19
|
-
short_label: str | None
|
20
|
-
description: Description | None
|
21
|
-
lower_limit: Limit | None
|
22
|
-
upper_limit: Limit | None
|
23
|
-
compu_inverse_value: CompuInverseValue | None
|
24
|
-
compu_const: CompuConst | None
|
25
|
-
compu_rational_coeffs: CompuRationalCoeffs | None
|
19
|
+
short_label: str | None = None
|
20
|
+
description: Description | None = None
|
21
|
+
lower_limit: Limit | None = None
|
22
|
+
upper_limit: Limit | None = None
|
23
|
+
compu_inverse_value: CompuInverseValue | None = None
|
24
|
+
compu_const: CompuConst | None = None
|
25
|
+
compu_rational_coeffs: CompuRationalCoeffs | None = None
|
26
26
|
|
27
27
|
# the following two attributes are not specified for COMPU-SCALE
|
28
28
|
# tags in the XML, but they are required to do anything useful
|
@@ -37,15 +37,15 @@ class CompuScale:
|
|
37
37
|
range_type: DataType
|
38
38
|
|
39
39
|
@staticmethod
|
40
|
-
def compuscale_from_et(et_element: ElementTree.Element,
|
40
|
+
def compuscale_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
|
41
41
|
domain_type: DataType, range_type: DataType) -> "CompuScale":
|
42
42
|
short_label = et_element.findtext("SHORT-LABEL")
|
43
|
-
description = Description.from_et(et_element.find("DESC"),
|
43
|
+
description = Description.from_et(et_element.find("DESC"), context)
|
44
44
|
|
45
45
|
lower_limit = Limit.limit_from_et(
|
46
|
-
et_element.find("LOWER-LIMIT"),
|
46
|
+
et_element.find("LOWER-LIMIT"), context, value_type=domain_type)
|
47
47
|
upper_limit = Limit.limit_from_et(
|
48
|
-
et_element.find("UPPER-LIMIT"),
|
48
|
+
et_element.find("UPPER-LIMIT"), context, value_type=domain_type)
|
49
49
|
|
50
50
|
compu_inverse_value = None
|
51
51
|
if (cive := et_element.find("COMPU-INVERSE-VALUE")) is not None:
|
@@ -58,7 +58,7 @@ class CompuScale:
|
|
58
58
|
compu_rational_coeffs: CompuRationalCoeffs | None = None
|
59
59
|
if (crc_elem := et_element.find("COMPU-RATIONAL-COEFFS")) is not None:
|
60
60
|
compu_rational_coeffs = CompuRationalCoeffs.coeffs_from_et(
|
61
|
-
crc_elem,
|
61
|
+
crc_elem, context, value_type=range_type)
|
62
62
|
|
63
63
|
return CompuScale(
|
64
64
|
short_label=short_label,
|