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

Refactor limit handling #273

Merged
merged 5 commits into from
Mar 4, 2024
Merged

Conversation

andlaus
Copy link
Collaborator

@andlaus andlaus commented Feb 29, 2024

today, we set out to clean up the limit handling code. this is surprisingly difficult: the problem is that the LIMIT tag does not specify the data type (integer, float, string, bytefield) which the limit is about but the limit obviously needs to know that type in order to do something. The solution taken here is to pass the type of the limit's value to the from_et() method as an extra argument. For multiplexer cases where even the type of the limit's value is not known when the limit must be instantiated, (this is only known after the reference to the switch key has been resolved) the method Limit.set_value_type() is added.

Andreas Lauser <[email protected]>, on behalf of MBition GmbH.
Provider Information

Section 7.3.6.5 of the ASAM ODX specification defines how strings,
bytearrays and numeric objects ought to be compared, and the
proceedure for bytearrays is not completely intuitive. This has
some consequences for testing the applicability of limits.

Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Michael Hahn <[email protected]>
also, use it at the places where compu scales are tested.

Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Michael Hahn <[email protected]>
this is surprisingly difficult: the problem is that the LIMIT tag does
not specify the data type (integer, float, string, bytefield) which
the limit is about but the limit obviously needs to know that type in
order to do something. The solution taken here is to pass the type of
the limit's value to the `from_et()` method as an extra argument. For
Multiplexer cases where even the type of the limit's value is not
known when the limit must be created, (this is only known after the
switch key reference has been resolved) the method
`Limit.set_value_type()` is added.

Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Michael Hahn <[email protected]>
i.e., 0.2.2 . this one started complaining about renamed configuration
options.

Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Michael Hahn <[email protected]>
@kayoub5
Copy link
Collaborator

kayoub5 commented Mar 1, 2024

Does the limit really need to know its data type during creation?

The datatype can be simply passed as argument to complies_to_upper and complies_to_lower

@andlaus
Copy link
Collaborator Author

andlaus commented Mar 1, 2024

Does the limit really need to know its data type during creation?

not during creation, but as soon as it must check if a value adheres to the specified limit.

The datatype can be simply passed as argument to complies_to_upper and complies_to_lower

I considered doing that. It turns out that this implies that the limit value must be converted from string each and every time which a limit is checked (and the code felt quite clunky and "footgunny" because one can easily pass the wrong type to these methods...)

thanks to [at]kayoub5 for the finds.

Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Michael Hahn <[email protected]>
@andlaus
Copy link
Collaborator Author

andlaus commented Mar 4, 2024

@kayoub5: Do you think that this can be merged?

@andlaus andlaus merged commit 385561b into mercedes-benz:main Mar 4, 2024
7 checks passed
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