odxtools 9.7.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 +7 -7
- odxtools/admindata.py +14 -13
- odxtools/audience.py +17 -17
- odxtools/basecomparam.py +9 -8
- odxtools/basevariantpattern.py +9 -10
- odxtools/basicstructure.py +15 -15
- odxtools/cli/_print_utils.py +34 -22
- odxtools/cli/browse.py +8 -8
- odxtools/cli/compare.py +24 -24
- odxtools/cli/decode.py +3 -4
- odxtools/cli/find.py +4 -5
- odxtools/cli/list.py +6 -6
- odxtools/cli/main.py +2 -2
- odxtools/cli/snoop.py +3 -3
- odxtools/codec.py +3 -3
- odxtools/commrelation.py +18 -17
- odxtools/companydata.py +13 -13
- odxtools/companydocinfo.py +15 -17
- odxtools/companyrevisioninfo.py +9 -9
- odxtools/companyspecificinfo.py +11 -13
- odxtools/comparam.py +8 -7
- odxtools/comparaminstance.py +14 -14
- odxtools/comparamspec.py +10 -11
- odxtools/comparamsubset.py +17 -25
- odxtools/complexcomparam.py +14 -14
- odxtools/complexdop.py +1 -1
- odxtools/compositecodec.py +8 -8
- odxtools/compumethods/compucodecompumethod.py +7 -7
- odxtools/compumethods/compuconst.py +5 -6
- odxtools/compumethods/compudefaultvalue.py +2 -3
- odxtools/compumethods/compuinternaltophys.py +13 -12
- odxtools/compumethods/compumethod.py +10 -9
- odxtools/compumethods/compuphystointernal.py +13 -12
- odxtools/compumethods/compurationalcoeffs.py +7 -7
- odxtools/compumethods/compuscale.py +15 -16
- odxtools/compumethods/createanycompumethod.py +12 -13
- odxtools/compumethods/identicalcompumethod.py +4 -5
- odxtools/compumethods/limit.py +14 -14
- odxtools/compumethods/linearcompumethod.py +5 -5
- odxtools/compumethods/linearsegment.py +10 -11
- odxtools/compumethods/ratfunccompumethod.py +6 -6
- odxtools/compumethods/ratfuncsegment.py +7 -8
- odxtools/compumethods/scalelinearcompumethod.py +9 -9
- odxtools/compumethods/scaleratfunccompumethod.py +7 -7
- odxtools/compumethods/tabintpcompumethod.py +10 -13
- odxtools/compumethods/texttablecompumethod.py +6 -6
- odxtools/createanycomparam.py +5 -7
- odxtools/createanydiagcodedtype.py +7 -8
- odxtools/database.py +34 -31
- odxtools/dataobjectproperty.py +19 -20
- odxtools/decodestate.py +5 -5
- odxtools/description.py +9 -9
- odxtools/determinenumberofitems.py +8 -7
- odxtools/diagcodedtype.py +10 -10
- odxtools/diagcomm.py +29 -30
- odxtools/diagdatadictionaryspec.py +36 -36
- odxtools/diaglayercontainer.py +35 -34
- odxtools/diaglayers/basevariant.py +14 -12
- odxtools/diaglayers/basevariantraw.py +22 -23
- odxtools/diaglayers/diaglayer.py +24 -22
- odxtools/diaglayers/diaglayerraw.py +43 -52
- odxtools/diaglayers/diaglayertype.py +1 -2
- odxtools/diaglayers/ecushareddata.py +9 -9
- odxtools/diaglayers/ecushareddataraw.py +15 -16
- odxtools/diaglayers/ecuvariant.py +15 -13
- odxtools/diaglayers/ecuvariantraw.py +21 -22
- odxtools/diaglayers/functionalgroup.py +12 -11
- odxtools/diaglayers/functionalgroupraw.py +17 -18
- odxtools/diaglayers/hierarchyelement.py +48 -54
- odxtools/diaglayers/hierarchyelementraw.py +10 -11
- odxtools/diaglayers/protocol.py +7 -7
- odxtools/diaglayers/protocolraw.py +13 -14
- odxtools/diagnostictroublecode.py +15 -17
- odxtools/diagservice.py +28 -27
- odxtools/diagvariable.py +24 -25
- odxtools/docrevision.py +18 -17
- odxtools/dopbase.py +13 -14
- odxtools/dtcconnector.py +8 -7
- odxtools/dtcdop.py +24 -20
- odxtools/dynamicendmarkerfield.py +10 -9
- odxtools/dynamiclengthfield.py +10 -9
- odxtools/dyndefinedspec.py +10 -10
- odxtools/dynenddopref.py +9 -9
- odxtools/dyniddefmodeinfo.py +21 -21
- odxtools/ecuvariantpattern.py +8 -10
- odxtools/element.py +12 -13
- odxtools/encodestate.py +11 -11
- odxtools/encoding.py +2 -3
- odxtools/endofpdufield.py +9 -10
- odxtools/envdataconnector.py +8 -8
- odxtools/environmentdata.py +7 -9
- odxtools/environmentdatadescription.py +18 -17
- odxtools/exceptions.py +5 -5
- odxtools/externalaccessmethod.py +4 -6
- odxtools/externaldoc.py +6 -6
- odxtools/field.py +15 -15
- odxtools/functionalclass.py +9 -9
- odxtools/inputparam.py +11 -10
- odxtools/internalconstr.py +10 -11
- odxtools/isotp_state_machine.py +12 -11
- odxtools/leadinglengthinfotype.py +4 -6
- odxtools/library.py +9 -8
- odxtools/linkeddtcdop.py +9 -8
- odxtools/loadfile.py +5 -6
- odxtools/matchingbasevariantparameter.py +5 -6
- odxtools/matchingparameter.py +10 -10
- odxtools/message.py +1 -1
- odxtools/minmaxlengthtype.py +6 -7
- odxtools/modification.py +7 -6
- odxtools/multiplexer.py +54 -18
- odxtools/multiplexercase.py +13 -13
- odxtools/multiplexerdefaultcase.py +11 -10
- odxtools/multiplexerswitchkey.py +8 -8
- odxtools/nameditemlist.py +13 -13
- odxtools/negoutputparam.py +8 -8
- odxtools/obd.py +1 -2
- odxtools/odxcategory.py +14 -26
- odxtools/odxdoccontext.py +16 -0
- odxtools/odxlink.py +23 -25
- odxtools/odxtypes.py +18 -15
- odxtools/outputparam.py +9 -8
- odxtools/parameterinfo.py +1 -1
- odxtools/parameters/codedconstparameter.py +10 -10
- odxtools/parameters/createanyparameter.py +15 -16
- odxtools/parameters/dynamicparameter.py +5 -7
- odxtools/parameters/lengthkeyparameter.py +10 -10
- odxtools/parameters/matchingrequestparameter.py +6 -7
- odxtools/parameters/nrcconstparameter.py +13 -13
- odxtools/parameters/parameter.py +17 -18
- odxtools/parameters/parameterwithdop.py +13 -13
- odxtools/parameters/physicalconstantparameter.py +8 -7
- odxtools/parameters/reservedparameter.py +6 -8
- odxtools/parameters/systemparameter.py +5 -7
- odxtools/parameters/tableentryparameter.py +8 -8
- odxtools/parameters/tablekeyparameter.py +17 -17
- odxtools/parameters/tablestructparameter.py +11 -11
- odxtools/parameters/valueparameter.py +11 -11
- odxtools/paramlengthinfotype.py +10 -9
- odxtools/parentref.py +15 -13
- odxtools/physicaldimension.py +15 -15
- odxtools/physicaltype.py +5 -6
- odxtools/posresponsesuppressible.py +11 -12
- odxtools/preconditionstateref.py +11 -11
- odxtools/progcode.py +11 -10
- odxtools/protstack.py +10 -9
- odxtools/relateddiagcommref.py +5 -6
- odxtools/relateddoc.py +11 -10
- odxtools/request.py +18 -19
- odxtools/response.py +19 -20
- odxtools/scaleconstr.py +8 -9
- odxtools/servicebinner.py +5 -5
- odxtools/singleecujob.py +16 -15
- odxtools/snrefcontext.py +3 -3
- odxtools/specialdata.py +8 -7
- odxtools/specialdatagroup.py +17 -17
- odxtools/specialdatagroupcaption.py +7 -6
- odxtools/standardlengthtype.py +14 -22
- odxtools/state.py +7 -6
- odxtools/statechart.py +12 -11
- odxtools/statemachine.py +4 -3
- odxtools/statetransition.py +9 -9
- odxtools/statetransitionref.py +19 -19
- odxtools/staticfield.py +9 -7
- odxtools/structure.py +5 -6
- odxtools/subcomponent.py +20 -18
- odxtools/subcomponentparamconnector.py +10 -9
- odxtools/subcomponentpattern.py +9 -9
- odxtools/swvariable.py +6 -7
- odxtools/table.py +25 -26
- odxtools/tablediagcommconnector.py +9 -8
- odxtools/tablerow.py +64 -43
- odxtools/tablerowconnector.py +8 -8
- odxtools/teammember.py +16 -15
- odxtools/templates/macros/printParentRef.xml.jinja2 +3 -1
- odxtools/text.py +4 -5
- odxtools/uds.py +2 -3
- odxtools/unit.py +14 -13
- odxtools/unitgroup.py +11 -10
- odxtools/unitspec.py +18 -19
- odxtools/utils.py +3 -3
- odxtools/variablegroup.py +5 -6
- odxtools/variantmatcher.py +10 -10
- odxtools/variantpattern.py +5 -6
- odxtools/version.py +2 -2
- odxtools/writepdxfile.py +5 -24
- odxtools/xdoc.py +13 -12
- {odxtools-9.7.0.dist-info → odxtools-10.1.0.dist-info}/METADATA +4 -5
- odxtools-10.1.0.dist-info/RECORD +265 -0
- {odxtools-9.7.0.dist-info → odxtools-10.1.0.dist-info}/WHEEL +1 -1
- odxtools-9.7.0.dist-info/RECORD +0 -264
- {odxtools-9.7.0.dist-info → odxtools-10.1.0.dist-info}/entry_points.txt +0 -0
- {odxtools-9.7.0.dist-info → odxtools-10.1.0.dist-info}/licenses/LICENSE +0 -0
- {odxtools-9.7.0.dist-info → odxtools-10.1.0.dist-info}/top_level.txt +0 -0
@@ -1,9 +1,8 @@
|
|
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
|
6
|
-
from ..
|
5
|
+
from ..odxdoccontext import OdxDocContext
|
7
6
|
from ..odxtypes import DataType
|
8
7
|
from .compucodecompumethod import CompuCodeCompuMethod
|
9
8
|
from .compumethod import CompuMethod
|
@@ -16,38 +15,38 @@ from .tabintpcompumethod import TabIntpCompuMethod
|
|
16
15
|
from .texttablecompumethod import TexttableCompuMethod
|
17
16
|
|
18
17
|
|
19
|
-
def create_any_compu_method_from_et(et_element: ElementTree.Element,
|
20
|
-
|
18
|
+
def create_any_compu_method_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
|
19
|
+
internal_type: DataType,
|
21
20
|
physical_type: DataType) -> CompuMethod:
|
22
21
|
compu_category = odxrequire(et_element.findtext("CATEGORY"))
|
23
22
|
|
24
23
|
if compu_category == "IDENTICAL":
|
25
24
|
return IdenticalCompuMethod.compu_method_from_et(
|
26
|
-
et_element,
|
25
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
27
26
|
elif compu_category == "LINEAR":
|
28
27
|
return LinearCompuMethod.compu_method_from_et(
|
29
|
-
et_element,
|
28
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
30
29
|
elif compu_category == "SCALE-LINEAR":
|
31
30
|
return ScaleLinearCompuMethod.compu_method_from_et(
|
32
|
-
et_element,
|
31
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
33
32
|
elif compu_category == "RAT-FUNC":
|
34
33
|
return RatFuncCompuMethod.compu_method_from_et(
|
35
|
-
et_element,
|
34
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
36
35
|
elif compu_category == "SCALE-RAT-FUNC":
|
37
36
|
return ScaleRatFuncCompuMethod.compu_method_from_et(
|
38
|
-
et_element,
|
37
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
39
38
|
elif compu_category == "TEXTTABLE":
|
40
39
|
return TexttableCompuMethod.compu_method_from_et(
|
41
|
-
et_element,
|
40
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
42
41
|
elif compu_category == "COMPUCODE":
|
43
42
|
return CompuCodeCompuMethod.compu_method_from_et(
|
44
|
-
et_element,
|
43
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
45
44
|
elif compu_category == "TAB-INTP":
|
46
45
|
return TabIntpCompuMethod.compu_method_from_et(
|
47
|
-
et_element,
|
46
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
48
47
|
|
49
48
|
# TODO: Implement all categories (never instantiate the CompuMethod base class!)
|
50
49
|
odxraise(f"Warning: Computation category {compu_category} is not implemented!")
|
51
50
|
|
52
51
|
return IdenticalCompuMethod.compu_method_from_et(
|
53
|
-
et_element,
|
52
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
@@ -1,16 +1,15 @@
|
|
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
|
7
|
-
from ..
|
6
|
+
from ..odxdoccontext import OdxDocContext
|
8
7
|
from ..odxtypes import AtomicOdxType, DataType
|
9
8
|
from ..utils import dataclass_fields_asdict
|
10
9
|
from .compumethod import CompuMethod
|
11
10
|
|
12
11
|
|
13
|
-
@dataclass
|
12
|
+
@dataclass(kw_only=True)
|
14
13
|
class IdenticalCompuMethod(CompuMethod):
|
15
14
|
"""Identical compu methods just pass through the internal value.
|
16
15
|
|
@@ -18,11 +17,11 @@ class IdenticalCompuMethod(CompuMethod):
|
|
18
17
|
"""
|
19
18
|
|
20
19
|
@staticmethod
|
21
|
-
def compu_method_from_et(et_element: ElementTree.Element,
|
20
|
+
def compu_method_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
|
22
21
|
internal_type: DataType,
|
23
22
|
physical_type: DataType) -> "IdenticalCompuMethod":
|
24
23
|
cm = CompuMethod.compu_method_from_et(
|
25
|
-
et_element,
|
24
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
26
25
|
kwargs = dataclass_fields_asdict(cm)
|
27
26
|
|
28
27
|
odxassert(
|
odxtools/compumethods/limit.py
CHANGED
@@ -1,39 +1,39 @@
|
|
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
|
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:
|
15
|
-
value_type:
|
16
|
-
interval_type:
|
14
|
+
value_raw: str | None = None
|
15
|
+
value_type: DataType | None = None
|
16
|
+
interval_type: IntervalType | None = 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,
|
25
|
-
value_type:
|
24
|
+
def limit_from_et(et_element: ElementTree.Element, context: OdxDocContext,
|
25
|
+
value_type: DataType | None) -> "Limit":
|
26
26
|
...
|
27
27
|
|
28
28
|
@staticmethod
|
29
29
|
@overload
|
30
|
-
def limit_from_et(et_element: None,
|
31
|
-
value_type:
|
30
|
+
def limit_from_et(et_element: None, context: OdxDocContext,
|
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, context: OdxDocContext,
|
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,10 +1,10 @@
|
|
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
|
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)
|
@@ -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
|
@@ -8,7 +7,7 @@ from .compuscale import CompuScale
|
|
8
7
|
from .limit import Limit
|
9
8
|
|
10
9
|
|
11
|
-
@dataclass
|
10
|
+
@dataclass(kw_only=True)
|
12
11
|
class LinearSegment:
|
13
12
|
"""Helper class to represent a segment of a piecewise-linear interpolation.
|
14
13
|
|
@@ -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 = None
|
27
|
+
internal_upper_limit: Limit | None = 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,7 +51,7 @@ 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
57
|
if not isinstance(x, (int, float)):
|
@@ -75,7 +74,7 @@ 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) ->
|
77
|
+
def convert_internal_to_physical(self, internal_value: AtomicOdxType) -> float | int:
|
79
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__})")
|
@@ -90,7 +89,7 @@ class LinearSegment:
|
|
90
89
|
|
91
90
|
return result
|
92
91
|
|
93
|
-
def convert_physical_to_internal(self, physical_value: AtomicOdxType) ->
|
92
|
+
def convert_physical_to_internal(self, physical_value: AtomicOdxType) -> float | int:
|
94
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__})")
|
@@ -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:
|
@@ -1,10 +1,10 @@
|
|
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
|
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 .ratfuncsegment import RatFuncSegment
|
13
13
|
|
14
14
|
|
15
|
-
@dataclass
|
15
|
+
@dataclass(kw_only=True)
|
16
16
|
class RatFuncCompuMethod(CompuMethod):
|
17
17
|
"""A compu method using a rational function
|
18
18
|
|
@@ -30,15 +30,15 @@ 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,
|
37
|
+
def compu_method_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
|
38
38
|
internal_type: DataType,
|
39
39
|
physical_type: DataType) -> "RatFuncCompuMethod":
|
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 RatFuncCompuMethod(**kwargs)
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
|
-
from dataclasses import dataclass
|
3
|
-
from typing import List, Optional, Union
|
2
|
+
from dataclasses import dataclass, field
|
4
3
|
|
5
4
|
from ..exceptions import odxraise, odxrequire
|
6
5
|
from ..odxtypes import AtomicOdxType, DataType
|
@@ -8,17 +7,17 @@ from .compuscale import CompuScale
|
|
8
7
|
from .limit import Limit
|
9
8
|
|
10
9
|
|
11
|
-
@dataclass
|
10
|
+
@dataclass(kw_only=True)
|
12
11
|
class RatFuncSegment:
|
13
12
|
"""Helper class to represent a segment of a piecewise rational function.
|
14
13
|
"""
|
15
14
|
value_type: DataType
|
16
15
|
|
17
|
-
numerator_coeffs:
|
18
|
-
denominator_coeffs:
|
16
|
+
numerator_coeffs: list[int | float] = field(default_factory=list)
|
17
|
+
denominator_coeffs: list[int | float] = field(default_factory=list)
|
19
18
|
|
20
|
-
lower_limit:
|
21
|
-
upper_limit:
|
19
|
+
lower_limit: Limit | None = None
|
20
|
+
upper_limit: Limit | None = None
|
22
21
|
|
23
22
|
@staticmethod
|
24
23
|
def from_compu_scale(scale: CompuScale, value_type: DataType) -> "RatFuncSegment":
|
@@ -39,7 +38,7 @@ class RatFuncSegment:
|
|
39
38
|
upper_limit=upper_limit,
|
40
39
|
value_type=scale.range_type)
|
41
40
|
|
42
|
-
def convert(self, value: AtomicOdxType) ->
|
41
|
+
def convert(self, value: AtomicOdxType) -> float | int:
|
43
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__})")
|
@@ -1,10 +1,10 @@
|
|
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
|
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
|
@@ -13,7 +13,7 @@ from .intervaltype import IntervalType
|
|
13
13
|
from .linearsegment import LinearSegment
|
14
14
|
|
15
15
|
|
16
|
-
@dataclass
|
16
|
+
@dataclass(kw_only=True)
|
17
17
|
class ScaleLinearCompuMethod(CompuMethod):
|
18
18
|
"""A piecewise linear compu method which may feature discontinuities.
|
19
19
|
|
@@ -21,21 +21,21 @@ 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,
|
28
|
+
def compu_method_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
|
29
29
|
internal_type: DataType,
|
30
30
|
physical_type: DataType) -> "ScaleLinearCompuMethod":
|
31
31
|
cm = CompuMethod.compu_method_from_et(
|
32
|
-
et_element,
|
32
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
33
33
|
kwargs = dataclass_fields_asdict(cm)
|
34
34
|
|
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")
|
@@ -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,10 +1,10 @@
|
|
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
|
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 .ratfuncsegment import RatFuncSegment
|
13
13
|
|
14
14
|
|
15
|
-
@dataclass
|
15
|
+
@dataclass(kw_only=True)
|
16
16
|
class ScaleRatFuncCompuMethod(CompuMethod):
|
17
17
|
"""A compu method using a piecewise rational function
|
18
18
|
|
@@ -20,19 +20,19 @@ 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,
|
31
|
+
def compu_method_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
|
32
32
|
internal_type: DataType,
|
33
33
|
physical_type: DataType) -> "ScaleRatFuncCompuMethod":
|
34
34
|
cm = CompuMethod.compu_method_from_et(
|
35
|
-
et_element,
|
35
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
36
36
|
kwargs = dataclass_fields_asdict(cm)
|
37
37
|
|
38
38
|
return ScaleRatFuncCompuMethod(**kwargs)
|
@@ -1,10 +1,9 @@
|
|
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
|
7
|
-
from ..
|
6
|
+
from ..odxdoccontext import OdxDocContext
|
8
7
|
from ..odxtypes import AtomicOdxType, DataType
|
9
8
|
from ..utils import dataclass_fields_asdict
|
10
9
|
from .compucategory import CompuCategory
|
@@ -13,7 +12,7 @@ from .intervaltype import IntervalType
|
|
13
12
|
from .limit import Limit
|
14
13
|
|
15
14
|
|
16
|
-
@dataclass
|
15
|
+
@dataclass(kw_only=True)
|
17
16
|
class TabIntpCompuMethod(CompuMethod):
|
18
17
|
"""A table-based interpolated compu method provides a continuous
|
19
18
|
transfer function based on piecewise linear interpolation.
|
@@ -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,11 +60,11 @@ 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,
|
63
|
+
def compu_method_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
|
65
64
|
internal_type: DataType,
|
66
65
|
physical_type: DataType) -> "TabIntpCompuMethod":
|
67
66
|
cm = CompuMethod.compu_method_from_et(
|
68
|
-
et_element,
|
67
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
69
68
|
kwargs = dataclass_fields_asdict(cm)
|
70
69
|
|
71
70
|
return TabIntpCompuMethod(**kwargs)
|
@@ -74,8 +73,8 @@ 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
|
@@ -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]
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from typing import
|
3
|
+
from typing import cast
|
4
4
|
from xml.etree import ElementTree
|
5
5
|
|
6
6
|
from ..exceptions import DecodeError, EncodeError, odxassert, odxraise, odxrequire
|
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 .compuscale import CompuScale
|
13
13
|
|
14
14
|
|
15
|
-
@dataclass
|
15
|
+
@dataclass(kw_only=True)
|
16
16
|
class TexttableCompuMethod(CompuMethod):
|
17
17
|
"""Text table compute methods translate numbers to human readable
|
18
18
|
textual descriptions.
|
@@ -22,11 +22,11 @@ class TexttableCompuMethod(CompuMethod):
|
|
22
22
|
"""
|
23
23
|
|
24
24
|
@staticmethod
|
25
|
-
def compu_method_from_et(et_element: ElementTree.Element,
|
25
|
+
def compu_method_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
|
26
26
|
internal_type: DataType,
|
27
27
|
physical_type: DataType) -> "TexttableCompuMethod":
|
28
28
|
cm = CompuMethod.compu_method_from_et(
|
29
|
-
et_element,
|
29
|
+
et_element, context, internal_type=internal_type, physical_type=physical_type)
|
30
30
|
kwargs = dataclass_fields_asdict(cm)
|
31
31
|
|
32
32
|
return TexttableCompuMethod(**kwargs)
|
@@ -95,7 +95,7 @@ class TexttableCompuMethod(CompuMethod):
|
|
95
95
|
scales = []
|
96
96
|
if (citp := self.compu_internal_to_phys) is not None:
|
97
97
|
scales = citp.compu_scales
|
98
|
-
matching_scales:
|
98
|
+
matching_scales: list[CompuScale] = [x for x in scales if x.applies(internal_value)]
|
99
99
|
|
100
100
|
if len(matching_scales) == 0:
|
101
101
|
if self._compu_physical_default_value is None:
|
odxtools/createanycomparam.py
CHANGED
@@ -1,17 +1,15 @@
|
|
1
|
-
from typing import List, Union
|
2
1
|
from xml.etree import ElementTree
|
3
2
|
|
4
3
|
from .comparam import Comparam
|
5
4
|
from .complexcomparam import ComplexComparam
|
6
|
-
from .
|
5
|
+
from .odxdoccontext import OdxDocContext
|
7
6
|
|
8
7
|
|
9
|
-
def create_any_comparam_from_et(
|
10
|
-
|
11
|
-
doc_frags: List[OdxDocFragment]) -> Union[Comparam, ComplexComparam]:
|
8
|
+
def create_any_comparam_from_et(et_element: ElementTree.Element,
|
9
|
+
context: OdxDocContext) -> Comparam | ComplexComparam:
|
12
10
|
if et_element.tag == "COMPARAM":
|
13
|
-
return Comparam.from_et(et_element,
|
11
|
+
return Comparam.from_et(et_element, context)
|
14
12
|
elif et_element.tag == "COMPLEX-COMPARAM":
|
15
|
-
return ComplexComparam.from_et(et_element,
|
13
|
+
return ComplexComparam.from_et(et_element, context)
|
16
14
|
|
17
15
|
raise RuntimeError(f"Unhandled communication parameter type {et_element.tag}")
|
@@ -1,5 +1,4 @@
|
|
1
1
|
# SPDX-License-Identifier: MIT
|
2
|
-
from typing import List
|
3
2
|
from xml.etree import ElementTree
|
4
3
|
|
5
4
|
from .diagcodedtype import DiagCodedType
|
@@ -7,22 +6,22 @@ from .exceptions import odxraise
|
|
7
6
|
from .globals import xsi
|
8
7
|
from .leadinglengthinfotype import LeadingLengthInfoType
|
9
8
|
from .minmaxlengthtype import MinMaxLengthType
|
10
|
-
from .
|
9
|
+
from .odxdoccontext import OdxDocContext
|
11
10
|
from .paramlengthinfotype import ParamLengthInfoType
|
12
11
|
from .standardlengthtype import StandardLengthType
|
13
12
|
|
14
13
|
|
15
14
|
def create_any_diag_coded_type_from_et(et_element: ElementTree.Element,
|
16
|
-
|
15
|
+
context: OdxDocContext) -> DiagCodedType:
|
17
16
|
dct_type = et_element.get(f"{xsi}type")
|
18
17
|
if dct_type == "LEADING-LENGTH-INFO-TYPE":
|
19
|
-
return LeadingLengthInfoType.from_et(et_element,
|
18
|
+
return LeadingLengthInfoType.from_et(et_element, context)
|
20
19
|
elif dct_type == "MIN-MAX-LENGTH-TYPE":
|
21
|
-
return MinMaxLengthType.from_et(et_element,
|
20
|
+
return MinMaxLengthType.from_et(et_element, context)
|
22
21
|
elif dct_type == "PARAM-LENGTH-INFO-TYPE":
|
23
|
-
return ParamLengthInfoType.from_et(et_element,
|
22
|
+
return ParamLengthInfoType.from_et(et_element, context)
|
24
23
|
elif dct_type == "STANDARD-LENGTH-TYPE":
|
25
|
-
return StandardLengthType.from_et(et_element,
|
24
|
+
return StandardLengthType.from_et(et_element, context)
|
26
25
|
|
27
26
|
odxraise(f"Unknown DIAG-CODED-TYPE {dct_type}", NotImplementedError)
|
28
|
-
return DiagCodedType.from_et(et_element,
|
27
|
+
return DiagCodedType.from_et(et_element, context)
|