odxtools 9.7.0__py3-none-any.whl → 10.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- odxtools/additionalaudience.py +3 -3
- odxtools/admindata.py +8 -8
- odxtools/audience.py +10 -10
- odxtools/basecomparam.py +5 -5
- odxtools/basevariantpattern.py +4 -5
- odxtools/basicstructure.py +8 -8
- odxtools/cli/_print_utils.py +35 -23
- odxtools/cli/browse.py +9 -9
- odxtools/cli/compare.py +24 -24
- odxtools/cli/decode.py +3 -4
- odxtools/cli/find.py +4 -5
- odxtools/cli/list.py +7 -7
- odxtools/cli/main.py +2 -2
- odxtools/cli/snoop.py +3 -3
- odxtools/codec.py +3 -3
- odxtools/commrelation.py +11 -11
- odxtools/companydata.py +5 -5
- odxtools/companydocinfo.py +8 -8
- odxtools/companyrevisioninfo.py +5 -5
- odxtools/companyspecificinfo.py +5 -5
- odxtools/comparam.py +3 -3
- odxtools/comparaminstance.py +10 -10
- odxtools/comparamspec.py +3 -3
- odxtools/comparamsubset.py +5 -5
- odxtools/complexcomparam.py +7 -7
- odxtools/compositecodec.py +11 -11
- odxtools/compumethods/compucodecompumethod.py +4 -4
- odxtools/compumethods/compuconst.py +4 -5
- odxtools/compumethods/compudefaultvalue.py +1 -2
- odxtools/compumethods/compuinternaltophys.py +6 -6
- odxtools/compumethods/compumethod.py +5 -5
- odxtools/compumethods/compuphystointernal.py +6 -6
- odxtools/compumethods/compurationalcoeffs.py +4 -4
- odxtools/compumethods/compuscale.py +9 -10
- odxtools/compumethods/createanycompumethod.py +1 -2
- odxtools/compumethods/identicalcompumethod.py +1 -2
- odxtools/compumethods/limit.py +12 -12
- odxtools/compumethods/linearcompumethod.py +2 -2
- odxtools/compumethods/linearsegment.py +14 -15
- odxtools/compumethods/ratfunccompumethod.py +3 -3
- odxtools/compumethods/ratfuncsegment.py +7 -8
- odxtools/compumethods/scalelinearcompumethod.py +7 -7
- odxtools/compumethods/scaleratfunccompumethod.py +4 -4
- odxtools/compumethods/tabintpcompumethod.py +15 -18
- odxtools/compumethods/texttablecompumethod.py +3 -3
- odxtools/createanycomparam.py +2 -4
- odxtools/createanydiagcodedtype.py +1 -2
- odxtools/database.py +9 -8
- odxtools/dataobjectproperty.py +10 -10
- odxtools/decodestate.py +5 -5
- odxtools/description.py +5 -5
- odxtools/determinenumberofitems.py +4 -4
- odxtools/diagcodedtype.py +7 -7
- odxtools/diagcomm.py +17 -17
- odxtools/diagdatadictionaryspec.py +6 -6
- odxtools/diaglayercontainer.py +4 -4
- odxtools/diaglayers/basevariant.py +10 -9
- odxtools/diaglayers/basevariantraw.py +9 -9
- odxtools/diaglayers/diaglayer.py +20 -19
- odxtools/diaglayers/diaglayerraw.py +10 -10
- odxtools/diaglayers/diaglayertype.py +1 -2
- odxtools/diaglayers/ecushareddata.py +4 -4
- odxtools/diaglayers/ecushareddataraw.py +6 -6
- odxtools/diaglayers/ecuvariant.py +11 -10
- odxtools/diaglayers/ecuvariantraw.py +9 -9
- odxtools/diaglayers/functionalgroup.py +8 -7
- odxtools/diaglayers/functionalgroupraw.py +7 -7
- odxtools/diaglayers/hierarchyelement.py +43 -49
- odxtools/diaglayers/hierarchyelementraw.py +4 -4
- odxtools/diaglayers/protocol.py +4 -4
- odxtools/diaglayers/protocolraw.py +6 -6
- odxtools/diagnostictroublecode.py +8 -8
- odxtools/diagservice.py +18 -18
- odxtools/diagvariable.py +14 -14
- odxtools/docrevision.py +11 -11
- odxtools/dopbase.py +6 -6
- odxtools/dtcconnector.py +3 -3
- odxtools/dtcdop.py +13 -9
- odxtools/dynamicendmarkerfield.py +5 -4
- odxtools/dynamiclengthfield.py +5 -4
- odxtools/dyndefinedspec.py +5 -5
- odxtools/dynenddopref.py +5 -5
- odxtools/dyniddefmodeinfo.py +13 -13
- odxtools/ecuvariantpattern.py +4 -5
- odxtools/element.py +5 -6
- odxtools/encodestate.py +11 -11
- odxtools/encoding.py +2 -3
- odxtools/endofpdufield.py +6 -6
- odxtools/envdataconnector.py +3 -3
- odxtools/environmentdata.py +3 -4
- odxtools/environmentdatadescription.py +11 -11
- odxtools/exceptions.py +5 -5
- odxtools/externalaccessmethod.py +1 -2
- odxtools/externaldoc.py +4 -4
- odxtools/field.py +9 -10
- odxtools/functionalclass.py +4 -4
- odxtools/inputparam.py +6 -6
- odxtools/internalconstr.py +4 -5
- odxtools/isotp_state_machine.py +12 -11
- odxtools/leadinglengthinfotype.py +2 -3
- odxtools/library.py +5 -5
- odxtools/linkeddtcdop.py +4 -4
- odxtools/loadfile.py +5 -6
- odxtools/matchingbasevariantparameter.py +2 -3
- odxtools/matchingparameter.py +7 -7
- odxtools/minmaxlengthtype.py +4 -4
- odxtools/modification.py +4 -4
- odxtools/multiplexer.py +11 -11
- odxtools/multiplexercase.py +6 -6
- odxtools/multiplexerdefaultcase.py +6 -6
- odxtools/multiplexerswitchkey.py +4 -4
- odxtools/nameditemlist.py +14 -14
- odxtools/negoutputparam.py +3 -3
- odxtools/obd.py +1 -2
- odxtools/odxcategory.py +6 -6
- odxtools/odxlink.py +19 -20
- odxtools/odxtypes.py +21 -18
- odxtools/outputparam.py +4 -4
- odxtools/parameterinfo.py +1 -1
- odxtools/parameters/codedconstparameter.py +5 -5
- odxtools/parameters/createanyparameter.py +1 -2
- odxtools/parameters/dynamicparameter.py +2 -3
- odxtools/parameters/lengthkeyparameter.py +5 -5
- odxtools/parameters/matchingrequestparameter.py +3 -4
- odxtools/parameters/nrcconstparameter.py +7 -7
- odxtools/parameters/parameter.py +11 -11
- odxtools/parameters/parameterwithdop.py +9 -9
- odxtools/parameters/physicalconstantparameter.py +4 -4
- odxtools/parameters/reservedparameter.py +3 -4
- odxtools/parameters/systemparameter.py +2 -3
- odxtools/parameters/tableentryparameter.py +3 -3
- odxtools/parameters/tablekeyparameter.py +10 -10
- odxtools/parameters/tablestructparameter.py +7 -7
- odxtools/parameters/valueparameter.py +7 -7
- odxtools/paramlengthinfotype.py +5 -3
- odxtools/parentref.py +9 -9
- odxtools/physicaldimension.py +11 -11
- odxtools/physicaltype.py +3 -4
- odxtools/posresponsesuppressible.py +9 -10
- odxtools/preconditionstateref.py +7 -7
- odxtools/progcode.py +6 -6
- odxtools/protstack.py +4 -4
- odxtools/relateddiagcommref.py +1 -2
- odxtools/relateddoc.py +6 -6
- odxtools/request.py +9 -9
- odxtools/response.py +10 -10
- odxtools/scaleconstr.py +3 -4
- odxtools/servicebinner.py +5 -5
- odxtools/singleecujob.py +4 -4
- odxtools/snrefcontext.py +2 -2
- odxtools/specialdata.py +5 -5
- odxtools/specialdatagroup.py +9 -9
- odxtools/specialdatagroupcaption.py +3 -3
- odxtools/standardlengthtype.py +10 -10
- odxtools/state.py +3 -3
- odxtools/statechart.py +4 -4
- odxtools/statemachine.py +4 -3
- odxtools/statetransition.py +4 -4
- odxtools/statetransitionref.py +18 -18
- odxtools/staticfield.py +5 -4
- odxtools/structure.py +2 -3
- odxtools/subcomponent.py +5 -5
- odxtools/subcomponentparamconnector.py +5 -5
- odxtools/subcomponentpattern.py +4 -4
- odxtools/swvariable.py +3 -4
- odxtools/table.py +14 -14
- odxtools/tablediagcommconnector.py +5 -5
- odxtools/tablerow.py +30 -30
- odxtools/tablerowconnector.py +3 -3
- odxtools/teammember.py +11 -11
- odxtools/text.py +2 -3
- odxtools/uds.py +2 -3
- odxtools/unit.py +9 -9
- odxtools/unitgroup.py +5 -5
- odxtools/unitspec.py +6 -6
- odxtools/utils.py +3 -3
- odxtools/variablegroup.py +2 -2
- odxtools/variantmatcher.py +10 -10
- odxtools/variantpattern.py +3 -3
- odxtools/version.py +2 -2
- odxtools/writepdxfile.py +5 -5
- odxtools/xdoc.py +9 -9
- {odxtools-9.7.0.dist-info → odxtools-10.0.0.dist-info}/METADATA +4 -5
- odxtools-10.0.0.dist-info/RECORD +264 -0
- odxtools-9.7.0.dist-info/RECORD +0 -264
- {odxtools-9.7.0.dist-info → odxtools-10.0.0.dist-info}/WHEEL +0 -0
- {odxtools-9.7.0.dist-info → odxtools-10.0.0.dist-info}/entry_points.txt +0 -0
- {odxtools-9.7.0.dist-info → odxtools-10.0.0.dist-info}/licenses/LICENSE +0 -0
- {odxtools-9.7.0.dist-info → odxtools-10.0.0.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from typing import Any
|
3
|
+
from typing import Any
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
6
6
|
from ..odxlink import OdxDocFragment, OdxLinkDatabase, OdxLinkId
|
@@ -13,13 +13,13 @@ from .compuscale import CompuScale
|
|
13
13
|
|
14
14
|
@dataclass
|
15
15
|
class CompuInternalToPhys:
|
16
|
-
compu_scales:
|
17
|
-
prog_code:
|
18
|
-
compu_default_value:
|
16
|
+
compu_scales: list[CompuScale]
|
17
|
+
prog_code: ProgCode | None
|
18
|
+
compu_default_value: CompuDefaultValue | None
|
19
19
|
|
20
20
|
@staticmethod
|
21
21
|
def compu_internal_to_phys_from_et(et_element: ElementTree.Element,
|
22
|
-
doc_frags:
|
22
|
+
doc_frags: list[OdxDocFragment], *, internal_type: DataType,
|
23
23
|
physical_type: DataType) -> "CompuInternalToPhys":
|
24
24
|
compu_scales = [
|
25
25
|
CompuScale.compuscale_from_et(
|
@@ -39,7 +39,7 @@ class CompuInternalToPhys:
|
|
39
39
|
return CompuInternalToPhys(
|
40
40
|
compu_scales=compu_scales, prog_code=prog_code, compu_default_value=compu_default_value)
|
41
41
|
|
42
|
-
def _build_odxlinks(self) ->
|
42
|
+
def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
|
43
43
|
result = {}
|
44
44
|
|
45
45
|
if self.prog_code is not None:
|
@@ -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 ..exceptions import odxraise
|
@@ -31,14 +31,14 @@ class CompuMethod:
|
|
31
31
|
"""
|
32
32
|
|
33
33
|
category: CompuCategory
|
34
|
-
compu_internal_to_phys:
|
35
|
-
compu_phys_to_internal:
|
34
|
+
compu_internal_to_phys: CompuInternalToPhys | None
|
35
|
+
compu_phys_to_internal: CompuPhysToInternal | None
|
36
36
|
|
37
37
|
physical_type: DataType
|
38
38
|
internal_type: DataType
|
39
39
|
|
40
40
|
@staticmethod
|
41
|
-
def compu_method_from_et(et_element: ElementTree.Element, doc_frags:
|
41
|
+
def compu_method_from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment], *,
|
42
42
|
internal_type: DataType, physical_type: DataType) -> "CompuMethod":
|
43
43
|
cat_text = et_element.findtext("CATEGORY")
|
44
44
|
if cat_text is None:
|
@@ -67,7 +67,7 @@ class CompuMethod:
|
|
67
67
|
physical_type=physical_type,
|
68
68
|
internal_type=internal_type)
|
69
69
|
|
70
|
-
def _build_odxlinks(self) ->
|
70
|
+
def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
|
71
71
|
result = {}
|
72
72
|
|
73
73
|
if self.compu_internal_to_phys is not None:
|
@@ -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 ..odxlink import OdxDocFragment, OdxLinkDatabase, OdxLinkId
|
@@ -13,13 +13,13 @@ from .compuscale import CompuScale
|
|
13
13
|
|
14
14
|
@dataclass
|
15
15
|
class CompuPhysToInternal:
|
16
|
-
compu_scales:
|
17
|
-
prog_code:
|
18
|
-
compu_default_value:
|
16
|
+
compu_scales: list[CompuScale]
|
17
|
+
prog_code: ProgCode | None
|
18
|
+
compu_default_value: CompuDefaultValue | None
|
19
19
|
|
20
20
|
@staticmethod
|
21
21
|
def compu_phys_to_internal_from_et(et_element: ElementTree.Element,
|
22
|
-
doc_frags:
|
22
|
+
doc_frags: list[OdxDocFragment], *, internal_type: DataType,
|
23
23
|
physical_type: DataType) -> "CompuPhysToInternal":
|
24
24
|
compu_scales = [
|
25
25
|
CompuScale.compuscale_from_et(
|
@@ -39,7 +39,7 @@ class CompuPhysToInternal:
|
|
39
39
|
return CompuPhysToInternal(
|
40
40
|
compu_scales=compu_scales, prog_code=prog_code, compu_default_value=compu_default_value)
|
41
41
|
|
42
|
-
def _build_odxlinks(self) ->
|
42
|
+
def _build_odxlinks(self) -> dict[OdxLinkId, Any]:
|
43
43
|
result = {}
|
44
44
|
|
45
45
|
if self.prog_code is not None:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from typing import
|
3
|
+
from typing import cast
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
6
6
|
from ..exceptions import odxassert, odxrequire
|
@@ -12,11 +12,11 @@ from ..odxtypes import DataType
|
|
12
12
|
class CompuRationalCoeffs:
|
13
13
|
value_type: DataType
|
14
14
|
|
15
|
-
numerators:
|
16
|
-
denominators:
|
15
|
+
numerators: list[int | float]
|
16
|
+
denominators: list[int | float]
|
17
17
|
|
18
18
|
@staticmethod
|
19
|
-
def coeffs_from_et(et_element: ElementTree.Element, doc_frags:
|
19
|
+
def coeffs_from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment], *,
|
20
20
|
value_type: DataType) -> "CompuRationalCoeffs":
|
21
21
|
odxassert(
|
22
22
|
value_type
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from typing import List, Optional
|
4
3
|
from xml.etree import ElementTree
|
5
4
|
|
6
5
|
from ..description import Description
|
@@ -17,13 +16,13 @@ class CompuScale:
|
|
17
16
|
"""A COMPU-SCALE represents one value range of a COMPU-METHOD.
|
18
17
|
"""
|
19
18
|
|
20
|
-
short_label:
|
21
|
-
description:
|
22
|
-
lower_limit:
|
23
|
-
upper_limit:
|
24
|
-
compu_inverse_value:
|
25
|
-
compu_const:
|
26
|
-
compu_rational_coeffs:
|
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
|
27
26
|
|
28
27
|
# the following two attributes are not specified for COMPU-SCALE
|
29
28
|
# tags in the XML, but they are required to do anything useful
|
@@ -38,7 +37,7 @@ class CompuScale:
|
|
38
37
|
range_type: DataType
|
39
38
|
|
40
39
|
@staticmethod
|
41
|
-
def compuscale_from_et(et_element: ElementTree.Element, doc_frags:
|
40
|
+
def compuscale_from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment], *,
|
42
41
|
domain_type: DataType, range_type: DataType) -> "CompuScale":
|
43
42
|
short_label = et_element.findtext("SHORT-LABEL")
|
44
43
|
description = Description.from_et(et_element.find("DESC"), doc_frags)
|
@@ -56,7 +55,7 @@ class CompuScale:
|
|
56
55
|
if (cce := et_element.find("COMPU-CONST")) is not None:
|
57
56
|
compu_const = CompuConst.compuvalue_from_et(cce, data_type=range_type)
|
58
57
|
|
59
|
-
compu_rational_coeffs:
|
58
|
+
compu_rational_coeffs: CompuRationalCoeffs | None = None
|
60
59
|
if (crc_elem := et_element.find("COMPU-RATIONAL-COEFFS")) is not None:
|
61
60
|
compu_rational_coeffs = CompuRationalCoeffs.coeffs_from_et(
|
62
61
|
crc_elem, doc_frags, value_type=range_type)
|
@@ -1,5 +1,4 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
|
-
from typing import List
|
3
2
|
from xml.etree import ElementTree
|
4
3
|
|
5
4
|
from ..exceptions import odxraise, odxrequire
|
@@ -17,7 +16,7 @@ from .texttablecompumethod import TexttableCompuMethod
|
|
17
16
|
|
18
17
|
|
19
18
|
def create_any_compu_method_from_et(et_element: ElementTree.Element,
|
20
|
-
doc_frags:
|
19
|
+
doc_frags: list[OdxDocFragment], *, internal_type: DataType,
|
21
20
|
physical_type: DataType) -> CompuMethod:
|
22
21
|
compu_category = odxrequire(et_element.findtext("CATEGORY"))
|
23
22
|
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from typing import List
|
4
3
|
from xml.etree import ElementTree
|
5
4
|
|
6
5
|
from ..exceptions import odxassert
|
@@ -18,7 +17,7 @@ class IdenticalCompuMethod(CompuMethod):
|
|
18
17
|
"""
|
19
18
|
|
20
19
|
@staticmethod
|
21
|
-
def compu_method_from_et(et_element: ElementTree.Element, doc_frags:
|
20
|
+
def compu_method_from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment], *,
|
22
21
|
internal_type: DataType,
|
23
22
|
physical_type: DataType) -> "IdenticalCompuMethod":
|
24
23
|
cm = CompuMethod.compu_method_from_et(
|
odxtools/compumethods/limit.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from typing import
|
3
|
+
from typing import Optional, overload
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
6
6
|
from ..exceptions import odxraise
|
@@ -11,29 +11,29 @@ from .intervaltype import IntervalType
|
|
11
11
|
|
12
12
|
@dataclass
|
13
13
|
class Limit:
|
14
|
-
value_raw:
|
15
|
-
value_type:
|
16
|
-
interval_type:
|
14
|
+
value_raw: str | None
|
15
|
+
value_type: DataType | None
|
16
|
+
interval_type: IntervalType | None
|
17
17
|
|
18
18
|
@property
|
19
|
-
def value(self) ->
|
19
|
+
def value(self) -> AtomicOdxType | None:
|
20
20
|
return self._value
|
21
21
|
|
22
22
|
@staticmethod
|
23
23
|
@overload
|
24
|
-
def limit_from_et(et_element: ElementTree.Element, doc_frags:
|
25
|
-
value_type:
|
24
|
+
def limit_from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment],
|
25
|
+
value_type: DataType | None) -> "Limit":
|
26
26
|
...
|
27
27
|
|
28
28
|
@staticmethod
|
29
29
|
@overload
|
30
|
-
def limit_from_et(et_element: None, doc_frags:
|
31
|
-
value_type:
|
30
|
+
def limit_from_et(et_element: None, doc_frags: list[OdxDocFragment],
|
31
|
+
value_type: DataType | None) -> None:
|
32
32
|
...
|
33
33
|
|
34
34
|
@staticmethod
|
35
|
-
def limit_from_et(et_element:
|
36
|
-
value_type:
|
35
|
+
def limit_from_et(et_element: ElementTree.Element | None, doc_frags: list[OdxDocFragment],
|
36
|
+
value_type: DataType | None) -> Optional["Limit"]:
|
37
37
|
|
38
38
|
if et_element is None:
|
39
39
|
return None
|
@@ -50,7 +50,7 @@ class Limit:
|
|
50
50
|
return Limit(value_raw=value_raw, interval_type=interval_type, value_type=value_type)
|
51
51
|
|
52
52
|
def __post_init__(self) -> None:
|
53
|
-
self._value:
|
53
|
+
self._value: AtomicOdxType | None = None
|
54
54
|
|
55
55
|
if self.value_type is not None:
|
56
56
|
self.set_value_type(self.value_type)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from typing import
|
3
|
+
from typing import cast
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
6
6
|
from ..exceptions import DecodeError, EncodeError, odxassert, odxraise
|
@@ -30,7 +30,7 @@ class LinearCompuMethod(CompuMethod):
|
|
30
30
|
return self._segment
|
31
31
|
|
32
32
|
@staticmethod
|
33
|
-
def compu_method_from_et(et_element: ElementTree.Element, doc_frags:
|
33
|
+
def compu_method_from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment], *,
|
34
34
|
internal_type: DataType,
|
35
35
|
physical_type: DataType) -> "LinearCompuMethod":
|
36
36
|
cm = CompuMethod.compu_method_from_et(
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from typing import Optional, Union
|
4
3
|
|
5
4
|
from ..exceptions import odxraise, odxrequire
|
6
5
|
from ..odxtypes import AtomicOdxType, DataType
|
@@ -24,20 +23,20 @@ class LinearSegment:
|
|
24
23
|
offset: float
|
25
24
|
factor: float
|
26
25
|
denominator: float
|
27
|
-
internal_lower_limit:
|
28
|
-
internal_upper_limit:
|
26
|
+
internal_lower_limit: Limit | None
|
27
|
+
internal_upper_limit: Limit | None
|
29
28
|
|
30
|
-
inverse_value:
|
29
|
+
inverse_value: int | float # value used as inverse if factor is 0
|
31
30
|
|
32
31
|
internal_type: DataType
|
33
32
|
physical_type: DataType
|
34
33
|
|
35
34
|
@property
|
36
|
-
def physical_lower_limit(self) ->
|
35
|
+
def physical_lower_limit(self) -> Limit | None:
|
37
36
|
return self._physical_lower_limit
|
38
37
|
|
39
38
|
@property
|
40
|
-
def physical_upper_limit(self) ->
|
39
|
+
def physical_upper_limit(self) -> Limit | None:
|
41
40
|
return self._physical_upper_limit
|
42
41
|
|
43
42
|
@staticmethod
|
@@ -52,10 +51,10 @@ class LinearSegment:
|
|
52
51
|
if len(coeffs.denominators) > 0:
|
53
52
|
denominator = coeffs.denominators[0]
|
54
53
|
|
55
|
-
inverse_value:
|
54
|
+
inverse_value: int | float = 0
|
56
55
|
if scale.compu_inverse_value is not None:
|
57
56
|
x = odxrequire(scale.compu_inverse_value).value
|
58
|
-
if not isinstance(x,
|
57
|
+
if not isinstance(x, int | float):
|
59
58
|
odxraise(f"Non-numeric COMPU-INVERSE-VALUE specified ({x!r})")
|
60
59
|
inverse_value = x
|
61
60
|
|
@@ -75,8 +74,8 @@ class LinearSegment:
|
|
75
74
|
def __post_init__(self) -> None:
|
76
75
|
self.__compute_physical_limits()
|
77
76
|
|
78
|
-
def convert_internal_to_physical(self, internal_value: AtomicOdxType) ->
|
79
|
-
if not isinstance(internal_value,
|
77
|
+
def convert_internal_to_physical(self, internal_value: AtomicOdxType) -> float | int:
|
78
|
+
if not isinstance(internal_value, int | float):
|
80
79
|
odxraise(f"Internal values of linear compumethods must "
|
81
80
|
f"either be int or float (is: {type(internal_value).__name__})")
|
82
81
|
|
@@ -90,8 +89,8 @@ class LinearSegment:
|
|
90
89
|
|
91
90
|
return result
|
92
91
|
|
93
|
-
def convert_physical_to_internal(self, physical_value: AtomicOdxType) ->
|
94
|
-
if not isinstance(physical_value,
|
92
|
+
def convert_physical_to_internal(self, physical_value: AtomicOdxType) -> float | int:
|
93
|
+
if not isinstance(physical_value, int | float):
|
95
94
|
odxraise(f"Physical values of linear compumethods must "
|
96
95
|
f"either be int or float (is: {type(physical_value).__name__})")
|
97
96
|
|
@@ -115,7 +114,7 @@ class LinearSegment:
|
|
115
114
|
This method is called by `__post_init__()`.
|
116
115
|
"""
|
117
116
|
|
118
|
-
def convert_internal_to_physical_limit(internal_limit:
|
117
|
+
def convert_internal_to_physical_limit(internal_limit: Limit | None) -> Limit | None:
|
119
118
|
"""Helper method to convert a single internal limit
|
120
119
|
"""
|
121
120
|
if internal_limit is None or internal_limit.value_raw is None:
|
@@ -152,7 +151,7 @@ class LinearSegment:
|
|
152
151
|
# Do type checks
|
153
152
|
expected_type = self.physical_type.python_type
|
154
153
|
if issubclass(expected_type, float):
|
155
|
-
if not isinstance(physical_value,
|
154
|
+
if not isinstance(physical_value, int | float):
|
156
155
|
return False
|
157
156
|
else:
|
158
157
|
if not isinstance(physical_value, expected_type):
|
@@ -173,7 +172,7 @@ class LinearSegment:
|
|
173
172
|
# Do type checks
|
174
173
|
expected_type = self.internal_type.python_type
|
175
174
|
if issubclass(expected_type, float):
|
176
|
-
if not isinstance(internal_value,
|
175
|
+
if not isinstance(internal_value, int | float):
|
177
176
|
return False
|
178
177
|
else:
|
179
178
|
if not isinstance(internal_value, expected_type):
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from typing import
|
3
|
+
from typing import cast
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
6
6
|
from ..exceptions import DecodeError, EncodeError, odxassert, odxraise
|
@@ -30,11 +30,11 @@ class RatFuncCompuMethod(CompuMethod):
|
|
30
30
|
return self._int_to_phys_segment
|
31
31
|
|
32
32
|
@property
|
33
|
-
def phys_to_int_segment(self) ->
|
33
|
+
def phys_to_int_segment(self) -> RatFuncSegment | None:
|
34
34
|
return self._phys_to_int_segment
|
35
35
|
|
36
36
|
@staticmethod
|
37
|
-
def compu_method_from_et(et_element: ElementTree.Element, doc_frags:
|
37
|
+
def compu_method_from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment], *,
|
38
38
|
internal_type: DataType,
|
39
39
|
physical_type: DataType) -> "RatFuncCompuMethod":
|
40
40
|
cm = CompuMethod.compu_method_from_et(
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from typing import List, Optional, Union
|
4
3
|
|
5
4
|
from ..exceptions import odxraise, odxrequire
|
6
5
|
from ..odxtypes import AtomicOdxType, DataType
|
@@ -14,11 +13,11 @@ class RatFuncSegment:
|
|
14
13
|
"""
|
15
14
|
value_type: DataType
|
16
15
|
|
17
|
-
numerator_coeffs:
|
18
|
-
denominator_coeffs:
|
16
|
+
numerator_coeffs: list[int | float]
|
17
|
+
denominator_coeffs: list[int | float]
|
19
18
|
|
20
|
-
lower_limit:
|
21
|
-
upper_limit:
|
19
|
+
lower_limit: Limit | None
|
20
|
+
upper_limit: Limit | None
|
22
21
|
|
23
22
|
@staticmethod
|
24
23
|
def from_compu_scale(scale: CompuScale, value_type: DataType) -> "RatFuncSegment":
|
@@ -39,8 +38,8 @@ class RatFuncSegment:
|
|
39
38
|
upper_limit=upper_limit,
|
40
39
|
value_type=scale.range_type)
|
41
40
|
|
42
|
-
def convert(self, value: AtomicOdxType) ->
|
43
|
-
if not isinstance(value,
|
41
|
+
def convert(self, value: AtomicOdxType) -> float | int:
|
42
|
+
if not isinstance(value, int | float):
|
44
43
|
odxraise(f"Internal values of linear compumethods must "
|
45
44
|
f"either be int or float (is: {type(value).__name__})")
|
46
45
|
|
@@ -70,7 +69,7 @@ class RatFuncSegment:
|
|
70
69
|
# Do type checks
|
71
70
|
expected_type = self.value_type.python_type
|
72
71
|
if issubclass(expected_type, float):
|
73
|
-
if not isinstance(value,
|
72
|
+
if not isinstance(value, int | float):
|
74
73
|
return False
|
75
74
|
else:
|
76
75
|
if not isinstance(value, expected_type):
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from typing import
|
3
|
+
from typing import cast
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
6
6
|
from ..exceptions import DecodeError, EncodeError, odxassert, odxraise
|
@@ -21,11 +21,11 @@ class ScaleLinearCompuMethod(CompuMethod):
|
|
21
21
|
"""
|
22
22
|
|
23
23
|
@property
|
24
|
-
def segments(self) ->
|
24
|
+
def segments(self) -> list[LinearSegment]:
|
25
25
|
return self._segments
|
26
26
|
|
27
27
|
@staticmethod
|
28
|
-
def compu_method_from_et(et_element: ElementTree.Element, doc_frags:
|
28
|
+
def compu_method_from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment], *,
|
29
29
|
internal_type: DataType,
|
30
30
|
physical_type: DataType) -> "ScaleLinearCompuMethod":
|
31
31
|
cm = CompuMethod.compu_method_from_et(
|
@@ -35,7 +35,7 @@ class ScaleLinearCompuMethod(CompuMethod):
|
|
35
35
|
return ScaleLinearCompuMethod(**kwargs)
|
36
36
|
|
37
37
|
def __post_init__(self) -> None:
|
38
|
-
self._segments:
|
38
|
+
self._segments: list[LinearSegment] = []
|
39
39
|
|
40
40
|
odxassert(self.category == CompuCategory.SCALE_LINEAR,
|
41
41
|
"ScaleLinearCompuMethod must exibit SCALE-LINEAR category")
|
@@ -100,7 +100,7 @@ class ScaleLinearCompuMethod(CompuMethod):
|
|
100
100
|
self._is_invertible = False
|
101
101
|
break
|
102
102
|
|
103
|
-
if not isinstance(x,
|
103
|
+
if not isinstance(x, int | float):
|
104
104
|
odxraise("Linear segments must use int or float for all quantities")
|
105
105
|
|
106
106
|
# the respective function value at the interval's
|
@@ -111,7 +111,7 @@ class ScaleLinearCompuMethod(CompuMethod):
|
|
111
111
|
self._is_invertible = False
|
112
112
|
break
|
113
113
|
|
114
|
-
def convert_physical_to_internal(self, physical_value: AtomicOdxType) ->
|
114
|
+
def convert_physical_to_internal(self, physical_value: AtomicOdxType) -> float | int:
|
115
115
|
if not self._is_invertible:
|
116
116
|
odxraise(
|
117
117
|
f"Trying to encode value {physical_value!r} using a non-invertible "
|
@@ -128,7 +128,7 @@ class ScaleLinearCompuMethod(CompuMethod):
|
|
128
128
|
|
129
129
|
return seg.convert_physical_to_internal(physical_value)
|
130
130
|
|
131
|
-
def convert_internal_to_physical(self, internal_value: AtomicOdxType) ->
|
131
|
+
def convert_internal_to_physical(self, internal_value: AtomicOdxType) -> float | int:
|
132
132
|
applicable_segments = [
|
133
133
|
seg for seg in self._segments if seg.internal_applies(internal_value)
|
134
134
|
]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from typing import
|
3
|
+
from typing import cast
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
6
6
|
from ..exceptions import DecodeError, EncodeError, odxassert, odxraise
|
@@ -20,15 +20,15 @@ class ScaleRatFuncCompuMethod(CompuMethod):
|
|
20
20
|
"""
|
21
21
|
|
22
22
|
@property
|
23
|
-
def int_to_phys_segments(self) ->
|
23
|
+
def int_to_phys_segments(self) -> list[RatFuncSegment]:
|
24
24
|
return self._int_to_phys_segments
|
25
25
|
|
26
26
|
@property
|
27
|
-
def phys_to_int_segments(self) ->
|
27
|
+
def phys_to_int_segments(self) -> list[RatFuncSegment] | None:
|
28
28
|
return self._phys_to_int_segments
|
29
29
|
|
30
30
|
@staticmethod
|
31
|
-
def compu_method_from_et(et_element: ElementTree.Element, doc_frags:
|
31
|
+
def compu_method_from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment], *,
|
32
32
|
internal_type: DataType,
|
33
33
|
physical_type: DataType) -> "ScaleRatFuncCompuMethod":
|
34
34
|
cm = CompuMethod.compu_method_from_et(
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from typing import List, Union
|
4
3
|
from xml.etree import ElementTree
|
5
4
|
|
6
5
|
from ..exceptions import DecodeError, EncodeError, odxassert, odxraise, odxrequire
|
@@ -37,11 +36,11 @@ class TabIntpCompuMethod(CompuMethod):
|
|
37
36
|
"""
|
38
37
|
|
39
38
|
@property
|
40
|
-
def internal_points(self) ->
|
39
|
+
def internal_points(self) -> list[float | int]:
|
41
40
|
return self._internal_points
|
42
41
|
|
43
42
|
@property
|
44
|
-
def physical_points(self) ->
|
43
|
+
def physical_points(self) -> list[float | int]:
|
45
44
|
return self._physical_points
|
46
45
|
|
47
46
|
@property
|
@@ -61,7 +60,7 @@ class TabIntpCompuMethod(CompuMethod):
|
|
61
60
|
return self._physical_upper_limit
|
62
61
|
|
63
62
|
@staticmethod
|
64
|
-
def compu_method_from_et(et_element: ElementTree.Element, doc_frags:
|
63
|
+
def compu_method_from_et(et_element: ElementTree.Element, doc_frags: list[OdxDocFragment], *,
|
65
64
|
internal_type: DataType,
|
66
65
|
physical_type: DataType) -> "TabIntpCompuMethod":
|
67
66
|
cm = CompuMethod.compu_method_from_et(
|
@@ -74,16 +73,16 @@ class TabIntpCompuMethod(CompuMethod):
|
|
74
73
|
odxassert(self.category == CompuCategory.TAB_INTP,
|
75
74
|
"TabIntpCompuMethod must exibit TAB-INTP category")
|
76
75
|
|
77
|
-
self._internal_points:
|
78
|
-
self._physical_points:
|
76
|
+
self._internal_points: list[int | float] = []
|
77
|
+
self._physical_points: list[int | float] = []
|
79
78
|
for scale in odxrequire(self.compu_internal_to_phys).compu_scales:
|
80
79
|
internal_point = odxrequire(scale.lower_limit).value
|
81
80
|
physical_point = odxrequire(scale.compu_const).value
|
82
81
|
|
83
|
-
if not isinstance(internal_point,
|
82
|
+
if not isinstance(internal_point, float | int):
|
84
83
|
odxraise("The type of values of tab-intp compumethods must "
|
85
84
|
"either int or float")
|
86
|
-
if not isinstance(physical_point,
|
85
|
+
if not isinstance(physical_point, float | int):
|
87
86
|
odxraise("The type of values of tab-intp compumethods must "
|
88
87
|
"either int or float")
|
89
88
|
|
@@ -130,10 +129,8 @@ class TabIntpCompuMethod(CompuMethod):
|
|
130
129
|
], "Physical data type of TAB-INTP compumethod must be one of"
|
131
130
|
" [A_INT32, A_UINT32, A_FLOAT32, A_FLOAT64]")
|
132
131
|
|
133
|
-
def __piecewise_linear_interpolate(self, x:
|
134
|
-
|
135
|
-
domain_samples: List[Union[int,
|
136
|
-
float]]) -> Union[float, None]:
|
132
|
+
def __piecewise_linear_interpolate(self, x: int | float, range_samples: list[int | float],
|
133
|
+
domain_samples: list[int | float]) -> float | None:
|
137
134
|
for i in range(0, len(range_samples) - 1):
|
138
135
|
if (x0 := range_samples[i]) <= x and x <= (x1 := range_samples[i + 1]):
|
139
136
|
y0 = domain_samples[i]
|
@@ -143,13 +140,13 @@ class TabIntpCompuMethod(CompuMethod):
|
|
143
140
|
return None
|
144
141
|
|
145
142
|
def convert_physical_to_internal(self, physical_value: AtomicOdxType) -> AtomicOdxType:
|
146
|
-
if not isinstance(physical_value,
|
143
|
+
if not isinstance(physical_value, int | float):
|
147
144
|
odxraise("The type of values of tab-intp compumethods must "
|
148
145
|
"either int or float", EncodeError)
|
149
146
|
return None
|
150
147
|
|
151
148
|
odxassert(
|
152
|
-
isinstance(physical_value,
|
149
|
+
isinstance(physical_value, int | float),
|
153
150
|
"Only integers and floats can be piecewise linearly interpolated", EncodeError)
|
154
151
|
result = self.__piecewise_linear_interpolate(physical_value, self._physical_points,
|
155
152
|
self._internal_points)
|
@@ -164,14 +161,14 @@ class TabIntpCompuMethod(CompuMethod):
|
|
164
161
|
return res
|
165
162
|
|
166
163
|
def convert_internal_to_physical(self, internal_value: AtomicOdxType) -> AtomicOdxType:
|
167
|
-
if not isinstance(internal_value,
|
164
|
+
if not isinstance(internal_value, int | float):
|
168
165
|
odxraise(
|
169
166
|
"The internal type of values of tab-intp compumethods must "
|
170
167
|
"either int or float", EncodeError)
|
171
168
|
return None
|
172
169
|
|
173
170
|
odxassert(
|
174
|
-
isinstance(internal_value,
|
171
|
+
isinstance(internal_value, int | float),
|
175
172
|
"Only integers and floats can be piecewise linearly interpolated", DecodeError)
|
176
173
|
|
177
174
|
result = self.__piecewise_linear_interpolate(internal_value, self._internal_points,
|
@@ -188,14 +185,14 @@ class TabIntpCompuMethod(CompuMethod):
|
|
188
185
|
return res
|
189
186
|
|
190
187
|
def is_valid_physical_value(self, physical_value: AtomicOdxType) -> bool:
|
191
|
-
if not isinstance(physical_value,
|
188
|
+
if not isinstance(physical_value, int | float):
|
192
189
|
return False
|
193
190
|
|
194
191
|
return min(self.physical_points) <= physical_value and physical_value <= max(
|
195
192
|
self.physical_points)
|
196
193
|
|
197
194
|
def is_valid_internal_value(self, internal_value: AtomicOdxType) -> bool:
|
198
|
-
if not isinstance(internal_value,
|
195
|
+
if not isinstance(internal_value, int | float):
|
199
196
|
return False
|
200
197
|
|
201
198
|
return min(self.internal_points) <= internal_value and internal_value <= max(
|