Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement sub-components #352

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/somersaultecu.py
Original file line number Diff line number Diff line change
Expand Up @@ -2144,6 +2144,7 @@ class SomersaultSID(IntEnum):
comparam_refs=somersault_comparam_refs,
libraries=NamedItemList(),
prot_stack_snref=None,
sub_components=NamedItemList(),
)
somersault_protocol = Protocol(diag_layer_raw=somersault_protocol_raw)

Expand Down Expand Up @@ -2182,6 +2183,7 @@ class SomersaultSID(IntEnum):
diag_variables_raw=[],
variable_groups=NamedItemList(),
libraries=NamedItemList(),
sub_components=NamedItemList(),
dyn_defined_spec=None)
somersault_base_variant = BaseVariant(diag_layer_raw=somersault_base_variant_raw)

Expand Down Expand Up @@ -2231,6 +2233,7 @@ class SomersaultSID(IntEnum):
variable_groups=NamedItemList(),
libraries=NamedItemList(),
dyn_defined_spec=None,
sub_components=NamedItemList(),
)
somersault_lazy_ecu = EcuVariant(diag_layer_raw=somersault_lazy_ecu_raw)

Expand Down Expand Up @@ -2469,6 +2472,7 @@ class SomersaultSID(IntEnum):
variable_groups=NamedItemList(),
libraries=NamedItemList(),
dyn_defined_spec=None,
sub_components=NamedItemList(),
)
somersault_assiduous_ecu = EcuVariant(diag_layer_raw=somersault_assiduous_ecu_raw)

Expand Down
7 changes: 6 additions & 1 deletion odxtools/diaglayers/diaglayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from ..singleecujob import SingleEcuJob
from ..snrefcontext import SnRefContext
from ..specialdatagroup import SpecialDataGroup
from ..subcomponent import SubComponent
from ..unitgroup import UnitGroup
from .diaglayerraw import DiagLayerRaw
from .diaglayertype import DiagLayerType
Expand Down Expand Up @@ -261,9 +262,13 @@ def import_refs(self) -> List[OdxLinkRef]:
return self.diag_layer_raw.import_refs

@property
def libraries(self) -> List[Library]:
def libraries(self) -> NamedItemList[Library]:
return self.diag_layer_raw.libraries

@property
def sub_components(self) -> NamedItemList[SubComponent]:
return self.diag_layer_raw.sub_components

@property
def sdgs(self) -> List[SpecialDataGroup]:
return self.diag_layer_raw.sdgs
Expand Down
15 changes: 14 additions & 1 deletion odxtools/diaglayers/diaglayerraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from ..snrefcontext import SnRefContext
from ..specialdatagroup import SpecialDataGroup
from ..statechart import StateChart
from ..subcomponent import SubComponent
from ..utils import dataclass_fields_asdict
from .diaglayertype import DiagLayerType

Expand All @@ -47,7 +48,7 @@ class DiagLayerRaw(IdentifiableElement):
import_refs: List[OdxLinkRef]
state_charts: NamedItemList[StateChart]
additional_audiences: NamedItemList[AdditionalAudience]
# sub_components: List[DiagLayer] # TODO
sub_components: NamedItemList[SubComponent]
libraries: NamedItemList[Library]
sdgs: List[SpecialDataGroup]

Expand Down Expand Up @@ -154,6 +155,11 @@ def from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment]) ->
Library.from_et(el, doc_frags) for el in et_element.iterfind("LIBRARYS/LIBRARY")
]

sub_components = [
SubComponent.from_et(el, doc_frags)
for el in et_element.iterfind("SUB-COMPONENTS/SUB-COMPONENT")
]

sdgs = [
SpecialDataGroup.from_et(sdge, doc_frags) for sdge in et_element.iterfind("SDGS/SDG")
]
Expand All @@ -174,6 +180,7 @@ def from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment]) ->
state_charts=NamedItemList(state_charts),
additional_audiences=NamedItemList(additional_audiences),
libraries=NamedItemList(libraries),
sub_components=NamedItemList(sub_components),
sdgs=sdgs,
**kwargs)

Expand Down Expand Up @@ -208,6 +215,8 @@ def _build_odxlinks(self) -> Dict[OdxLinkId, Any]:
odxlinks.update(additional_audience._build_odxlinks())
for library in self.libraries:
odxlinks.update(library._build_odxlinks())
for sub_comp in self.sub_components:
odxlinks.update(sub_comp._build_odxlinks())
for sdg in self.sdgs:
odxlinks.update(sdg._build_odxlinks())

Expand Down Expand Up @@ -262,6 +271,8 @@ def _resolve_odxlinks(self, odxlinks: OdxLinkDatabase) -> None:
additional_audience._resolve_odxlinks(odxlinks)
for library in self.libraries:
library._resolve_odxlinks(odxlinks)
for sub_component in self.sub_components:
sub_component._resolve_odxlinks(odxlinks)
for sdg in self.sdgs:
sdg._resolve_odxlinks(odxlinks)

Expand Down Expand Up @@ -294,5 +305,7 @@ def _resolve_snrefs(self, context: SnRefContext) -> None:
additional_audience._resolve_snrefs(context)
for library in self.libraries:
library._resolve_snrefs(context)
for sub_component in self.sub_components:
sub_component._resolve_snrefs(context)
for sdg in self.sdgs:
sdg._resolve_snrefs(context)
Loading
Loading