SAFE-eV / OCMF-Open-Charge-Metering-Format

24 stars 13 forks source link

List of predefined units #33

Open sieukrem opened 3 months ago

sieukrem commented 3 months ago

In the Table 20 there is list of predefined units. According to this table kWh and Wh can be used for delivered energy.

Is it allowed to use other units like mWh, dWh?

The reasons behind this question are the conversion errors caused by JSON parsers, during reading of floating point numbers.

Some certification authorities require precision up to dWh for measurement and representation to customer. Usage of integer representation would be beneficial in such cases, for calculation and text->number->text transformation.

ahzf commented 3 months ago

You should not extend your implementation weaknesses onto the protocol specification. Just use Decimal instead of Double, there you have two Integers ;) Might not work out-of-the-box, but as nearly every JSON library is Open Source you can fix this and send the result upstream.

sieukrem commented 3 months ago

You should not extend your implementation weaknesses onto the protocol specification. Just use Decimal instead of Double, there you have two Integers ;) Might not work out-of-the-box, but as nearly every JSON library is Open Source you can fix this and send the result upstream.

I agree that the contribution to Open Source is a possible way!

I still think that it is worth to have a conversation here about this topic, because OCMF builds an interface between CS and CSMS. In the mentioned wiki article the section about interoperability states "While the specifications place no limits on the magnitude or precisions of JSON number literals, the widely-used JavaScript implementation stores them as IEEE754 "binary64" quantities. For interoperability, applications should avoid transmitting numbers which cannot be represented in this way, for example 1E400 or 3.141592653589793238462643383279"

The OCMF specification needs to admit this constraint and propose a regulation way. Either it is a declaration of RV to be interpreted as decimal, despite of the number nature. Or OCMF keeps the number as JSON it specifies but uses RU as application layer extension point and allows other units to achieve the precision goals.