-
Notifications
You must be signed in to change notification settings - Fork 81
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
dop_snref Temporary plan #283
Changes from all commits
60c3265
d23c536
c434b0e
53fa94a
e5ee641
e71e384
d10641f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,9 @@ def __init__(self, | |
|
||
def refresh(self) -> None: | ||
# Create wrapper objects | ||
self._ecu_shared_datas = NamedItemList(chain(*[dlc.ecu_shared_datas | ||
for dlc in self.diag_layer_containers if dlc.ecu_shared_datas])) | ||
|
||
self._diag_layers = NamedItemList( | ||
chain(*[dlc.diag_layers for dlc in self.diag_layer_containers])) | ||
|
||
|
@@ -125,13 +128,20 @@ def refresh(self) -> None: | |
# let the diaglayers sort out the inherited objects and the | ||
# short name references | ||
for dlc in self.diag_layer_containers: | ||
dlc._finalize_init(self._odxlinks) | ||
dlc._finalize_init(self._odxlinks, self._ecu_shared_datas) | ||
|
||
@property | ||
def odxlinks(self) -> OdxLinkDatabase: | ||
"""A map from odx_id to object""" | ||
return self._odxlinks | ||
|
||
@property | ||
def ecu_shared_datas(self) -> OdxLinkDatabase: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that should return |
||
""" | ||
All ecu_shared_datas defined by this database | ||
""" | ||
return self._ecu_shared_datas | ||
|
||
@property | ||
def protocols(self) -> NamedItemList[DiagLayer]: | ||
""" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,7 +78,8 @@ def _resolve_odxlinks(self, odxlinks: OdxLinkDatabase) -> None: | |
|
||
self.diag_layer_raw._resolve_odxlinks(odxlinks) | ||
|
||
def _finalize_init(self, odxlinks: OdxLinkDatabase) -> None: | ||
def _finalize_init(self, odxlinks: OdxLinkDatabase, | ||
ecu_shared_datas: NamedItemList['DiagLayer']) -> None: | ||
"""This method deals with everything inheritance related and | ||
-- after the final set of objects covered by the diagnostic | ||
layer is determined -- resolves any short name references in | ||
|
@@ -210,6 +211,8 @@ def _finalize_init(self, odxlinks: OdxLinkDatabase) -> None: | |
sdgs=ddds_sdgs, | ||
) | ||
|
||
self._add_import_ref(ecu_shared_datas) | ||
|
||
##### | ||
# compute the communication parameters applicable to the | ||
# diagnostic layer. Note that communication parameters do | ||
|
@@ -591,6 +594,27 @@ def not_inherited_fn(parent_ref: ParentRef) -> List[str]: | |
|
||
return self._compute_available_objects(get_local_objects_fn, not_inherited_fn) | ||
|
||
def _add_import_ref(self, ecu_shared_datas) -> None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess that after #285, the IMPORT-REF mechanism is implemented. What can/should be added to |
||
if imp_refs := self.import_refs: | ||
for imp in imp_refs: | ||
doc_name = next(iter(imp.ref_docs)).doc_name | ||
doc_type = next(iter(imp.ref_docs)).doc_type | ||
# Delete the “DLC_” name prefix | ||
if doc_type == 'CONTAINER': | ||
doc_name = doc_name[4:] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the |
||
if doc_name in ecu_shared_datas: | ||
share_ddds = (ecu_shared_datas[doc_name] | ||
.diag_layer_raw.diag_data_dictionary_spec) | ||
if hasattr(share_ddds, 'all_data_object_properties'): | ||
share_ddds_all_properties = share_ddds.all_data_object_properties | ||
# diag_data_dictionary_spec | ||
if ddds_all_properties := (self.diag_layer_raw.diag_data_dictionary_spec | ||
.all_data_object_properties): | ||
ddds_all_properties.append_list(share_ddds_all_properties) | ||
else: | ||
odxraise(f"The imports-refs method used in {self.short_name} is error," | ||
f"file {doc_name} is undefined") | ||
|
||
##### | ||
# </value inheritance mechanism helpers> | ||
##### | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,17 +124,18 @@ def _resolve_odxlinks(self, odxlinks: OdxLinkDatabase) -> None: | |
for ecu_variant in self.ecu_variants: | ||
ecu_variant._resolve_odxlinks(odxlinks) | ||
|
||
def _finalize_init(self, odxlinks: OdxLinkDatabase) -> None: | ||
def _finalize_init(self, odxlinks: OdxLinkDatabase, | ||
ecu_shared_datas: NamedItemList[DiagLayer]) -> None: | ||
for ecu_shared_data in self.ecu_shared_datas: | ||
ecu_shared_data._finalize_init(odxlinks) | ||
ecu_shared_data._finalize_init(odxlinks, ecu_shared_datas) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as mentioned above, it is better pass the whole |
||
for protocol in self.protocols: | ||
protocol._finalize_init(odxlinks) | ||
protocol._finalize_init(odxlinks, ecu_shared_datas) | ||
for functional_group in self.functional_groups: | ||
functional_group._finalize_init(odxlinks) | ||
functional_group._finalize_init(odxlinks, ecu_shared_datas) | ||
for base_variant in self.base_variants: | ||
base_variant._finalize_init(odxlinks) | ||
base_variant._finalize_init(odxlinks, ecu_shared_datas) | ||
for ecu_variant in self.ecu_variants: | ||
ecu_variant._finalize_init(odxlinks) | ||
ecu_variant._finalize_init(odxlinks, ecu_shared_datas) | ||
|
||
@property | ||
def diag_layers(self) -> NamedItemList[DiagLayer]: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,19 @@ def append(self, item: T) -> None: | |
|
||
super().append(item) | ||
|
||
def append_list(self, item_list) -> None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's the difference of this and the |
||
""" | ||
An instance of a itemAttributeList class,add another instance | ||
|
||
\return The name under which item is accessible | ||
""" | ||
if item_list: | ||
for item in item_list: | ||
item_name = self._get_item_key(item) | ||
if item_name not in self._item_dict: | ||
self._item_dict[item_name] = item | ||
super().append(item) | ||
|
||
def _add_attribute_item(self, item: T) -> None: | ||
item_name = self._get_item_key(item) | ||
|
||
|
@@ -152,6 +165,9 @@ def __getattr__(self, key: str) -> T: | |
|
||
return self._item_dict[key] | ||
|
||
def __contains__(self, key) -> bool: | ||
return key in self._item_dict | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this method should be unnecessary: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all code: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure. the point is that this class primarily is a list, not a dict, and lists check for the item values, not the keys like dictionaries... |
||
|
||
def get(self, key: Union[int, str], default: Optional[T] = None) -> Optional[T]: | ||
if isinstance(key, int): | ||
if 0 <= key and key < len(self): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
from ..dopbase import DopBase | ||
from ..dtcdop import DtcDop | ||
from ..encodestate import EncodeState | ||
from ..exceptions import odxassert, odxrequire | ||
from ..exceptions import odxassert, odxrequire, odxraise | ||
from ..odxlink import OdxDocFragment, OdxLinkDatabase, OdxLinkId, OdxLinkRef | ||
from ..odxtypes import ParameterValue | ||
from ..physicaltype import PhysicalType | ||
|
@@ -66,7 +66,10 @@ def _resolve_snrefs(self, diag_layer: "DiagLayer") -> None: | |
|
||
if self.dop_snref: | ||
ddds = diag_layer.diag_data_dictionary_spec | ||
self._dop = odxrequire(ddds.all_data_object_properties.get(self.dop_snref)) | ||
if snref_shortname := ddds.all_data_object_properties.get(self.dop_snref): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That self._dop = ddds.all_data_object_properties.get(self.dop_snref) that said, I think the |
||
self._dop = odxrequire(snref_shortname) | ||
else: | ||
odxraise(f"{self.dop_snref} in not found in {diag_layer.short_name}") | ||
|
||
@property | ||
def dop(self) -> DopBase: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you need to add such an argument, make it a
Database
object, i.e., this line should becomedlc._finalize_init(self._odxlinks, self)
. I somehow doubt that this is necessary, though...