Skip to content

Commit

Permalink
Merge pull request #247 from mercedes-benz/hotfix/comparam_instance
Browse files Browse the repository at this point in the history
Hotfix for ComparamInstance
  • Loading branch information
andlaus authored Dec 8, 2023
2 parents 480a5f6 + 4901b2c commit f9777bc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
16 changes: 8 additions & 8 deletions examples/somersaultecu.py
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ class SomersaultSID(IntEnum):
is_mandatory_raw=None,
is_executable_raw=None,
is_final_raw=None,
comparam_refs=NamedItemList[ComparamInstance](),
comparam_refs=[],
is_cyclic_raw=None,
is_multiple_raw=None,
addressing_raw=None,
Expand Down Expand Up @@ -1616,7 +1616,7 @@ class SomersaultSID(IntEnum):
is_mandatory_raw=None,
is_executable_raw=None,
is_final_raw=None,
comparam_refs=NamedItemList[ComparamInstance](),
comparam_refs=[],
is_cyclic_raw=None,
is_multiple_raw=None,
addressing_raw=None,
Expand Down Expand Up @@ -1650,7 +1650,7 @@ class SomersaultSID(IntEnum):
is_mandatory_raw=None,
is_executable_raw=None,
is_final_raw=None,
comparam_refs=NamedItemList[ComparamInstance](),
comparam_refs=[],
is_cyclic_raw=None,
is_multiple_raw=None,
addressing_raw=None,
Expand Down Expand Up @@ -1693,7 +1693,7 @@ class SomersaultSID(IntEnum):
is_mandatory_raw=None,
is_executable_raw=None,
is_final_raw=None,
comparam_refs=NamedItemList[ComparamInstance](),
comparam_refs=[],
is_cyclic_raw=None,
is_multiple_raw=None,
addressing_raw=None,
Expand Down Expand Up @@ -1725,7 +1725,7 @@ class SomersaultSID(IntEnum):
is_mandatory_raw=None,
is_executable_raw=None,
is_final_raw=None,
comparam_refs=NamedItemList[ComparamInstance](),
comparam_refs=[],
is_cyclic_raw=None,
is_multiple_raw=None,
addressing_raw=None,
Expand Down Expand Up @@ -1776,7 +1776,7 @@ class SomersaultSID(IntEnum):
is_mandatory_raw=None,
is_executable_raw=None,
is_final_raw=None,
comparam_refs=NamedItemList[ComparamInstance](),
comparam_refs=[],
is_cyclic_raw=None,
is_multiple_raw=None,
addressing_raw=None,
Expand Down Expand Up @@ -1821,7 +1821,7 @@ class SomersaultSID(IntEnum):
is_mandatory_raw=None,
is_executable_raw=None,
is_final_raw=None,
comparam_refs=NamedItemList[ComparamInstance](),
comparam_refs=[],
is_cyclic_raw=None,
is_multiple_raw=None,
addressing_raw=None,
Expand Down Expand Up @@ -2256,7 +2256,7 @@ class SomersaultSID(IntEnum):
neg_response_refs=[
OdxLinkRef.from_id(somersault_assiduous_negative_responses["fell_over"].odx_id),
],
comparam_refs=NamedItemList[ComparamInstance](),
comparam_refs=[],
is_cyclic_raw=None,
is_multiple_raw=None,
addressing_raw=None,
Expand Down
12 changes: 8 additions & 4 deletions odxtools/diagservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class DiagService(DiagComm):
"""Representation of a diagnostic service description.
"""

comparam_refs: NamedItemList[ComparamInstance]
comparam_refs: List[ComparamInstance]

request_ref: OdxLinkRef
pos_response_refs: List[OdxLinkRef]
Expand All @@ -56,10 +56,10 @@ def from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment]) ->

kwargs = dataclass_fields_asdict(DiagComm.from_et(et_element, doc_frags))

comparam_refs = NamedItemList([
comparam_refs = [
ComparamInstance.from_et(el, doc_frags)
for el in et_element.iterfind("COMPARAM-REFS/COMPARAM-REF")
])
]

request_ref = odxrequire(OdxLinkRef.from_et(et_element.find("REQUEST-REF"), doc_frags))

Expand Down Expand Up @@ -135,7 +135,7 @@ def negative_responses(self) -> NamedItemList[Response]:

@property
def comparams(self) -> NamedItemList[ComparamInstance]:
return self.comparam_refs
return self._comparams

@property
def addressing(self) -> Addressing:
Expand Down Expand Up @@ -181,6 +181,10 @@ def _resolve_snrefs(self, diag_layer: "DiagLayer") -> None:
for cpr in self.comparam_refs:
cpr._resolve_snrefs(diag_layer)

# comparams named list is lazy loaded
# since ComparamInstance short_name is only valid after resolution
self._comparams = NamedItemList(self.comparam_refs)

def decode_message(self, raw_message: bytes) -> Message:
request_prefix = b''
candidate_coding_objects: List[Union[Request, Response]] = [
Expand Down
17 changes: 8 additions & 9 deletions tests/test_decoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import unittest
from typing import cast

from odxtools.comparaminstance import ComparamInstance
from odxtools.compumethods.identicalcompumethod import IdenticalCompuMethod
from odxtools.compumethods.limit import IntervalType, Limit
from odxtools.compumethods.linearcompumethod import LinearCompuMethod
Expand Down Expand Up @@ -95,7 +94,7 @@ def test_prefix_tree_construction(self) -> None:
admin_data=None,
semantic=None,
audience=None,
comparam_refs=NamedItemList[ComparamInstance](),
comparam_refs=[],
is_cyclic_raw=None,
is_multiple_raw=None,
addressing_raw=None,
Expand Down Expand Up @@ -170,7 +169,7 @@ def test_prefix_tree_construction(self) -> None:
admin_data=None,
semantic=None,
audience=None,
comparam_refs=NamedItemList[ComparamInstance](),
comparam_refs=[],
is_cyclic_raw=None,
is_multiple_raw=None,
addressing_raw=None,
Expand Down Expand Up @@ -294,7 +293,7 @@ def test_decode_request_coded_const(self) -> None:
is_executable_raw=None,
is_final_raw=None,
semantic=None,
comparam_refs=NamedItemList[ComparamInstance](),
comparam_refs=[],
is_cyclic_raw=None,
is_multiple_raw=None,
addressing_raw=None,
Expand Down Expand Up @@ -438,7 +437,7 @@ def test_decode_request_coded_const_undefined_byte_position(self) -> None:
is_final_raw=None,
admin_data=None,
semantic=None,
comparam_refs=NamedItemList[ComparamInstance](),
comparam_refs=[],
is_cyclic_raw=None,
is_multiple_raw=None,
addressing_raw=None,
Expand Down Expand Up @@ -624,7 +623,7 @@ def test_decode_request_structure(self) -> None:
is_final_raw=None,
admin_data=None,
semantic=None,
comparam_refs=NamedItemList[ComparamInstance](),
comparam_refs=[],
is_cyclic_raw=None,
is_multiple_raw=None,
addressing_raw=None,
Expand Down Expand Up @@ -829,7 +828,7 @@ def test_decode_request_end_of_pdu_field(self) -> None:
is_final_raw=None,
admin_data=None,
semantic=None,
comparam_refs=NamedItemList[ComparamInstance](),
comparam_refs=[],
is_cyclic_raw=None,
is_multiple_raw=None,
addressing_raw=None,
Expand Down Expand Up @@ -988,7 +987,7 @@ def test_decode_request_linear_compu_method(self) -> None:
is_executable_raw=None,
is_final_raw=None,
semantic=None,
comparam_refs=NamedItemList[ComparamInstance](),
comparam_refs=[],
is_cyclic_raw=None,
is_multiple_raw=None,
addressing_raw=None,
Expand Down Expand Up @@ -1184,7 +1183,7 @@ def test_decode_response(self) -> None:
is_executable_raw=None,
is_final_raw=None,
semantic=None,
comparam_refs=NamedItemList[ComparamInstance](),
comparam_refs=[],
is_cyclic_raw=None,
is_multiple_raw=None,
addressing_raw=None,
Expand Down
5 changes: 2 additions & 3 deletions tests/test_ecu_variant_matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import pytest

from odxtools.comparaminstance import ComparamInstance
from odxtools.diaglayer import DiagLayer
from odxtools.diaglayerraw import DiagLayerRaw
from odxtools.diaglayertype import DiagLayerType
Expand Down Expand Up @@ -74,7 +73,7 @@ def ident_service(monkeypatch: pytest.MonkeyPatch, dummy_response: Response) ->
is_mandatory_raw=None,
is_executable_raw=None,
is_final_raw=None,
comparam_refs=NamedItemList[ComparamInstance](),
comparam_refs=[],
is_cyclic_raw=None,
is_multiple_raw=None,
addressing_raw=None,
Expand Down Expand Up @@ -123,7 +122,7 @@ def supplier_service(monkeypatch: pytest.MonkeyPatch, dummy_response: Response)
is_mandatory_raw=None,
is_executable_raw=None,
is_final_raw=None,
comparam_refs=NamedItemList[ComparamInstance](),
comparam_refs=[],
is_cyclic_raw=None,
is_multiple_raw=None,
addressing_raw=None,
Expand Down

0 comments on commit f9777bc

Please sign in to comment.