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

Untangle DiagLayer (2 of X) #133

Merged
merged 3 commits into from
Jun 2, 2023

Conversation

andlaus
Copy link
Collaborator

@andlaus andlaus commented May 31, 2023

This is the next PR in the quest to untangle the DiagLayer bowl of spaghetti. This time, the DiagLayer class is separated into DiagLayerRaw to represent the information of the XML and DiagLayer which provides the "logical" view on the diagnostic layer (i.e., it deals with inheritance et al) plus a few convenience functions.

Andreas Lauser <andreas.lauser@mercedes-benz.com>, on behalf of MBition GmbH.
Provider Information

@andlaus andlaus requested a review from kayoub5 May 31, 2023 10:31
@andlaus andlaus force-pushed the untangle_diaglayer_2 branch 2 times, most recently from a507c0d to 7087484 Compare May 31, 2023 10:36
#######
# <communication parameters>
#######

@property
def communication_parameters(self) -> NamedItemList[CommunicationParameterRef]:
"""All communication parameters including inherited ones."""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this class is a wrapper for "Diagnostic Layer" including "inherited Diagnostic Layers", then this class is no longer a "Layer", it would be more appropriate to call it a "Diagnostic Stack" (since it includes multiple layers)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while I don't disagree, the ODX spec calls the logical view on such an object -- i.e., including inheritance -- a "layer" (cf. section 7.3.2). I think we should only deviate from the spec if there is a very good reason for it...

#####
@property
def variant_type(self) -> DiagLayerType:
return self.diag_layer_raw.variant_type
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use class inheritance instead of those property wrappers ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so sure if this is a good idea. do it in a later PR? Once this saga is finished, this should be pretty easy,,,


return odxlinks
return result

def _resolve_references(self, odxlinks: OdxLinkDatabase) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at _resolve_references and _build_odxlinks, I am more convinced that you should just use class inheritance

continue

if hasattr(obj, "odx_id"):
odxlinks[obj.odx_id] = obj
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get this part, what are you doing here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some objects here (erhm, diag_data_dictionary_spec) do not have an odx_id, but contain objects which have it, so their _build_odxlinks() method needs to be called. This issue can be avoided if it is guaranteed that all objects add themselfs in _build_odxlinks() if they exhibit .odx_id. I think almost all do, but I did not have the nerves to go hunting for the ones which don't. I'll have a look...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this is a hack that needs to be fixed? maybe add TODO?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have a look...

Okay, done. the result is pretty large and I don't think this should be part of the present PR. I'll submit that cleanup once this PR is in...

self.communication_parameters,
):
if obj is None or isinstance(obj, OdxLinkRef):
continue
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would obj be an OdxLinkRef ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because .diag_comms can now contain OdxLinkRefs. (The specification mandates this. We currently have avoided to deal with this because the contents of the DIAG-COMMS tag where separated into services, single-ECU jobs and references...)

…omm references

this corresponds how diagnostic communications are handled in the
XML. For the user's convenience, we still provide separated lists, but
the filtering is now done internally by the DiagLayer class.

Signed-off-by: Andreas Lauser <andreas.lauser@mbition.io>
Signed-off-by: Gerrit Ecke <gerrit.ecke@mbition.io>
the data part represents the information of the XML one-to-one, while
the logical part takes inheritance into account (and handles
retrieving the correct communication parameters, etc).

Signed-off-by: Andreas Lauser <andreas.lauser@mbition.io>
Signed-off-by: Gerrit Ecke <gerrit.ecke@mbition.io>
instead of `NamedItemList(short_name_as_id, [])` we now use
`NamedItemList(short_name_as_id)`.

thanks to [at]kayoub5 for noticing this.

Signed-off-by: Andreas Lauser <andreas.lauser@mbition.io>
Signed-off-by: Gerrit Ecke <gerrit.ecke@mbition.io>
@andlaus andlaus merged commit 91ccd26 into mercedes-benz:main Jun 2, 2023
@andlaus andlaus deleted the untangle_diaglayer_2 branch December 7, 2023 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants