odxtools 10.0.0__py3-none-any.whl → 10.1.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 +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/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.0.dist-info}/METADATA +1 -1
- odxtools-10.1.0.dist-info/RECORD +265 -0
- {odxtools-10.0.0.dist-info → odxtools-10.1.0.dist-info}/WHEEL +1 -1
- odxtools-10.0.0.dist-info/RECORD +0 -264
- {odxtools-10.0.0.dist-info → odxtools-10.1.0.dist-info}/entry_points.txt +0 -0
- {odxtools-10.0.0.dist-info → odxtools-10.1.0.dist-info}/licenses/LICENSE +0 -0
- {odxtools-10.0.0.dist-info → odxtools-10.1.0.dist-info}/top_level.txt +0 -0
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,
|
@@ -2,7 +2,7 @@
|
|
2
2
|
from xml.etree import ElementTree
|
3
3
|
|
4
4
|
from ..exceptions import odxraise, odxrequire
|
5
|
-
from ..
|
5
|
+
from ..odxdoccontext import OdxDocContext
|
6
6
|
from ..odxtypes import DataType
|
7
7
|
from .compucodecompumethod import CompuCodeCompuMethod
|
8
8
|
from .compumethod import CompuMethod
|
@@ -15,38 +15,38 @@ from .tabintpcompumethod import TabIntpCompuMethod
|
|
15
15
|
from .texttablecompumethod import TexttableCompuMethod
|
16
16
|
|
17
17
|
|
18
|
-
def create_any_compu_method_from_et(et_element: ElementTree.Element,
|
19
|
-
|
18
|
+
def create_any_compu_method_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
|
19
|
+
internal_type: DataType,
|
20
20
|
physical_type: DataType) -> CompuMethod:
|
21
21
|
compu_category = odxrequire(et_element.findtext("CATEGORY"))
|
22
22
|
|
23
23
|
if compu_category == "IDENTICAL":
|
24
24
|
return IdenticalCompuMethod.compu_method_from_et(
|
25
|
-
et_element,
|
25
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
26
26
|
elif compu_category == "LINEAR":
|
27
27
|
return LinearCompuMethod.compu_method_from_et(
|
28
|
-
et_element,
|
28
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
29
29
|
elif compu_category == "SCALE-LINEAR":
|
30
30
|
return ScaleLinearCompuMethod.compu_method_from_et(
|
31
|
-
et_element,
|
31
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
32
32
|
elif compu_category == "RAT-FUNC":
|
33
33
|
return RatFuncCompuMethod.compu_method_from_et(
|
34
|
-
et_element,
|
34
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
35
35
|
elif compu_category == "SCALE-RAT-FUNC":
|
36
36
|
return ScaleRatFuncCompuMethod.compu_method_from_et(
|
37
|
-
et_element,
|
37
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
38
38
|
elif compu_category == "TEXTTABLE":
|
39
39
|
return TexttableCompuMethod.compu_method_from_et(
|
40
|
-
et_element,
|
40
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
41
41
|
elif compu_category == "COMPUCODE":
|
42
42
|
return CompuCodeCompuMethod.compu_method_from_et(
|
43
|
-
et_element,
|
43
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
44
44
|
elif compu_category == "TAB-INTP":
|
45
45
|
return TabIntpCompuMethod.compu_method_from_et(
|
46
|
-
et_element,
|
46
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
47
47
|
|
48
48
|
# TODO: Implement all categories (never instantiate the CompuMethod base class!)
|
49
49
|
odxraise(f"Warning: Computation category {compu_category} is not implemented!")
|
50
50
|
|
51
51
|
return IdenticalCompuMethod.compu_method_from_et(
|
52
|
-
et_element,
|
52
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
@@ -3,13 +3,13 @@ from dataclasses import dataclass
|
|
3
3
|
from xml.etree import ElementTree
|
4
4
|
|
5
5
|
from ..exceptions import odxassert
|
6
|
-
from ..
|
6
|
+
from ..odxdoccontext import OdxDocContext
|
7
7
|
from ..odxtypes import AtomicOdxType, DataType
|
8
8
|
from ..utils import dataclass_fields_asdict
|
9
9
|
from .compumethod import CompuMethod
|
10
10
|
|
11
11
|
|
12
|
-
@dataclass
|
12
|
+
@dataclass(kw_only=True)
|
13
13
|
class IdenticalCompuMethod(CompuMethod):
|
14
14
|
"""Identical compu methods just pass through the internal value.
|
15
15
|
|
@@ -17,11 +17,11 @@ class IdenticalCompuMethod(CompuMethod):
|
|
17
17
|
"""
|
18
18
|
|
19
19
|
@staticmethod
|
20
|
-
def compu_method_from_et(et_element: ElementTree.Element,
|
20
|
+
def compu_method_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
|
21
21
|
internal_type: DataType,
|
22
22
|
physical_type: DataType) -> "IdenticalCompuMethod":
|
23
23
|
cm = CompuMethod.compu_method_from_et(
|
24
|
-
et_element,
|
24
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
25
25
|
kwargs = dataclass_fields_asdict(cm)
|
26
26
|
|
27
27
|
odxassert(
|
odxtools/compumethods/limit.py
CHANGED
@@ -4,16 +4,16 @@ from typing import Optional, overload
|
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
6
6
|
from ..exceptions import odxraise
|
7
|
-
from ..
|
7
|
+
from ..odxdoccontext import OdxDocContext
|
8
8
|
from ..odxtypes import AtomicOdxType, DataType, compare_odx_values
|
9
9
|
from .intervaltype import IntervalType
|
10
10
|
|
11
11
|
|
12
|
-
@dataclass
|
12
|
+
@dataclass(kw_only=True)
|
13
13
|
class Limit:
|
14
|
-
value_raw: str | None
|
15
|
-
value_type: DataType | None
|
16
|
-
interval_type: IntervalType | None
|
14
|
+
value_raw: str | None = None
|
15
|
+
value_type: DataType | None = None
|
16
|
+
interval_type: IntervalType | None = None
|
17
17
|
|
18
18
|
@property
|
19
19
|
def value(self) -> AtomicOdxType | None:
|
@@ -21,18 +21,18 @@ class Limit:
|
|
21
21
|
|
22
22
|
@staticmethod
|
23
23
|
@overload
|
24
|
-
def limit_from_et(et_element: ElementTree.Element,
|
24
|
+
def limit_from_et(et_element: ElementTree.Element, context: OdxDocContext,
|
25
25
|
value_type: DataType | None) -> "Limit":
|
26
26
|
...
|
27
27
|
|
28
28
|
@staticmethod
|
29
29
|
@overload
|
30
|
-
def limit_from_et(et_element: None,
|
30
|
+
def limit_from_et(et_element: None, context: OdxDocContext,
|
31
31
|
value_type: DataType | None) -> None:
|
32
32
|
...
|
33
33
|
|
34
34
|
@staticmethod
|
35
|
-
def limit_from_et(et_element: ElementTree.Element | None,
|
35
|
+
def limit_from_et(et_element: ElementTree.Element | None, context: OdxDocContext,
|
36
36
|
value_type: DataType | None) -> Optional["Limit"]:
|
37
37
|
|
38
38
|
if et_element is None:
|
@@ -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 ..utils import dataclass_fields_asdict
|
10
10
|
from .compucategory import CompuCategory
|
@@ -12,7 +12,7 @@ from .compumethod import CompuMethod
|
|
12
12
|
from .linearsegment import LinearSegment
|
13
13
|
|
14
14
|
|
15
|
-
@dataclass
|
15
|
+
@dataclass(kw_only=True)
|
16
16
|
class LinearCompuMethod(CompuMethod):
|
17
17
|
"""A compu method which does linear interpoation
|
18
18
|
|
@@ -30,11 +30,11 @@ class LinearCompuMethod(CompuMethod):
|
|
30
30
|
return self._segment
|
31
31
|
|
32
32
|
@staticmethod
|
33
|
-
def compu_method_from_et(et_element: ElementTree.Element,
|
33
|
+
def compu_method_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
|
34
34
|
internal_type: DataType,
|
35
35
|
physical_type: DataType) -> "LinearCompuMethod":
|
36
36
|
cm = CompuMethod.compu_method_from_et(
|
37
|
-
et_element,
|
37
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
38
38
|
kwargs = dataclass_fields_asdict(cm)
|
39
39
|
|
40
40
|
return LinearCompuMethod(**kwargs)
|