mercedes-benz / odxtools

odxtools is a collection of utilities to interact with the diagnostic functionality of automotive electronic control units using python
MIT License
180 stars 75 forks source link

Refactor the compu methods #306

Closed andlaus closed 5 months ago

andlaus commented 5 months ago

This PR is quite a whopper (sorry), but all of the changes are closely related to the compu methods and I could not think of a good way of splitting this into smaller chunks.

With this PR, compu methods work as they are defined by the XSD: All parameters of all compu methods are specified using attributes of the basic CompuMethod class (i.e., mainly COMPU-INTERNAL-TO-PHYS and COMPU-PHYS-TO-INTERNAL) and the specific behavior of the individual categories are implemented in subclasses. "Specific behavior" encompasses extracting the data relevant for the concrete compu method from their generic form via __post_init__() methods in the subclasses and, based on this, the actual computations to translate internal values to/from physical ones. This approach has the advantages that it is quite a bit cleaner than the previous code (albeit still quite messy IMO), that all compu methods can be handled using the same output writing code and -- most importantly -- that the code now reflects the specification reasonably closely now.

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