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

bug: correct precision of meter_start #646

Merged
merged 3 commits into from
May 30, 2024
Merged

Conversation

a-w50
Copy link
Contributor

@a-w50 a-w50 commented May 29, 2024

The meter start value (the energy in Wh that a powermeter reports at the beginning of a transaction) is internally represented in the transaction class (for ocpp 1.6) as a StampedEnergyWh. StampedEnergyWh records this value as a double and hence its constructor should also accept the energy as a double (it used to take an int32).
Furthermore, the set of on_transaction_started for ocpp 1.6 also only accepted int32 values. These have been changed to double too, as there should be no reason to truncate them before. Furthermore the meter_start argument is passed by value now. Passing by reference for these simple and small types is just not necessary.

Note: the same could be done for the on_transaction_stopped functions.

Describe your changes

Issue ticket number and link

Checklist before requesting a review

The meter start value (the energy in Wh that a powermeter reports
at the beginning of a transaction) is internally represented in the
transaction class (for ocpp 1.6) as a `StampedEnergyWh`.
`StampedEnergyWh` records this value as a `double` and hence its
constructor should also accept the energy as a `double` (it used to take
an `int32`).
Furthermore, the set of `on_transaction_started` for ocpp 1.6 also only
accepted `int32` values.  These have been changed to `double` too, as
there should be no reason to truncate them before.  Furthermore the
`meter_start` argument is passed by value now.  Passing by reference for
these *simple* and small types is just not necessary.

Note: the same could be done for the `on_transaction_stopped` functions.

Signed-off-by: aw <aw@pionix.de>
a-w50 added 2 commits May 29, 2024 22:29
Signed-off-by: aw <aw@pionix.de>
Signed-off-by: aw <aw@pionix.de>
@Pietfried Pietfried self-assigned this May 30, 2024
@Pietfried Pietfried merged commit 84dbfa3 into main May 30, 2024
4 checks passed
@Pietfried Pietfried deleted the bugfix/meter_start_precision branch May 30, 2024 10:27
couryrr-afs pushed a commit to US-JOET/libocpp that referenced this pull request Jun 12, 2024
* bug: correct precision of meter_start

The meter start value (the energy in Wh that a powermeter reports
at the beginning of a transaction) is internally represented in the
transaction class (for ocpp 1.6) as a `StampedEnergyWh`.
`StampedEnergyWh` records this value as a `double` and hence its
constructor should also accept the energy as a `double` (it used to take
an `int32`).
Furthermore, the set of `on_transaction_started` for ocpp 1.6 also only
accepted `int32` values.  These have been changed to `double` too, as
there should be no reason to truncate them before.  Furthermore the
`meter_start` argument is passed by value now.  Passing by reference for
these *simple* and small types is just not necessary.

Note: the same could be done for the `on_transaction_stopped` functions.
---------

Signed-off-by: aw <aw@pionix.de>
@Pietfried Pietfried linked an issue Jun 17, 2024 that may be closed by this pull request
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.

Rounding of Meter Values
2 participants