register printing#10
Open
jktjkt wants to merge 4 commits intogertvdijk:developfrom
Open
Conversation
f6620a1 to
276de10
Compare
Code which converts KMP-spcific binary representation to native Python types is useful on its own.
The KMP protocol implements a few different date/time formats. Instead of showing raw numbers, let's show a nice, properly formatted date. I do not feel like changing the RegisterOutput to support many native Python types, IMHO it's perfectly OK to stick with numbers (which will be typically fed to a time series DB or something similar) and "everything else", but let's print that "everything else" properly. I'm not 100% sure how to handle the `yy-mm-dd` format. I *think* that it's rather uncommon to see meters with 26+ years old data record today, which is why I decided to hardcode the year-2000 prefix. A non-public document mentions '99:12:31' as an example, though. Also, a proper y/m/d separator is definitely `-`, not `:`, so I'm using that for clarity.
07245d6 to
8bdd63f
Compare
The new year's eve of 2024 is from a real-world meter data, the other test is from a KMP document (adjusted for the "number of bytes" and "size and exponent" bytes).
Verified by a meter type ID of my new hot water meter; it matches the laser print on the meter's face.
8bdd63f to
a8dec38
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For my KMP log exporter, I need a reusable way of printing these registers outside of the main CLI. This PR first moves code around to make this reusable and testable, then it adds some basic tests, and then it adds support for working with non-decimal string representation.
Please see the individual commits for motivation/explanation. Maybe stacked PRs will make this doable in an easier way...