-
Notifications
You must be signed in to change notification settings - Fork 90
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
Added temperature sensors values in Powermeter #755
Conversation
…emperature2) - added in interface a variable containing the public OCMF key (publicKeyOcmf) - added in config the following options: meter_timezone, meter_dst, SC, UV, UD - added support for setting the following parameters: meter_dst and meter_timezone - added support for V2 interface Signed-off-by: florinmihut <[email protected]>
Signed-off-by: florinmihut <[email protected]>
Signed-off-by: florinmihut <[email protected]>
Signed-off-by: florinmihut <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only one nit for rust code.
@@ -22,14 +23,33 @@ void LemDCBM400600Controller::init() { | |||
this->time_sync_helper->restart_unsafe_period(); | |||
} | |||
|
|||
std::vector<std::string> LemDCBM400600Controller::split(const std::string& str, char delimiter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be defined as a free function
Conf config; | ||
std::unique_ptr<LemDCBMTimeSyncHelper> time_sync_helper; | ||
|
||
std::vector<std::string> split(const std::string& str, char delimiter); | ||
void fetch_meter_id_from_device(); | ||
void request_device_to_start_transaction(const types::powermeter::TransactionReq& value); | ||
void request_device_to_stop_transaction(const std::string& transaction_id); | ||
std::string fetch_ocmf_result(const std::string& transaction_id); | ||
void convert_livemeasure_to_powermeter(const std::string& livemeasure, types::powermeter::Powermeter& powermeter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not part of the PR but could also be defined as a free function
types/powermeter.yaml
Outdated
@@ -299,3 +299,10 @@ types: | |||
This is intended for meters that only support signing a collection of meter values. | |||
type: object | |||
$ref: /units_signed#/SignedMeterValue | |||
temperature1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks to LEM specific to me. Not sure which temperatures it actually measures, but would it make sense to you to add more generic properties like:
- ambient_temperature
- internal_temperature
- conductor_temperature
- ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree but since this is not defined by all the power meters, this has to cover everyone.
What if I have 2 cable temps? Or a high and low temp?
Starting to give them "actual functional" names might pollute the interface with a lot of unused variables.
I spoke with Cornelius as well and he proposed to use temp 1 and 2 and their meaning is Powermeter dependent. Since anyway it is - some have it, some have it not, some measure the ambient some measure the internal some measure the high and the low.
You get the picture.
So I would be in the favor of keeping them temp 1 and 2 and their meaning is Powermeter actual implementation dependent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's really that opaque we could also just add an array of temperature values here, what if there's a third sensor for example :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree but since this is not defined by all the power meters, this has to cover everyone.
Starting to give them "actual functional" names might pollute the interface with a lot of unused variables
For this we have optional properties. There are a lot of properties in the powermeter already defined this way.
What if I have 2 cable temps? Or a high and low temp?
As @hikinggrass pointed out, what if we have 3? That is indeed specific to the powermeter and should therefore not be covered in a generic interface like powermeter like this. An interface is meant to be required by other modules. How should other modules know what temp1 or temp2 or temp3 are, especially if they mean different things for different implementations. Defining it this way doesn't seem useful to me.
If we add it like this, Id agree with @hikinggrass and add an array of temperature values, but I would rather add more meaningful properties as described above, maybe defining a type for a temperature and adding optional low / high values to it as properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think an array is a good idea
…d by reviewers Signed-off-by: florinmihut <[email protected]>
Signed-off-by: florinmihut <[email protected]>
} else { | ||
for (auto& sensor : *powermeter.temperatures) { | ||
if (sensor.identification == "temperatureL") { | ||
sensor.temperature = data.at("temperatureL"); | ||
} else if (sensor.identification == "temperatureH") { | ||
sensor.temperature = data.at("temperatureH"); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the powermeter
argument passed to this function is default initialized and the properties are then set in this function. Therefore this else
block is never executed and can be dropped. Its also not required to check for has_value()
in L202.
Apart from that I'd prefer a function signature like:
types::powermeter::Powermeter LemDCBM400600Controller::convert_livemeasure_to_powermeter(const std::string& livemeasure)
that returns the powermeter object instead of passing it as an argument, but since this is legacy code im ok with keeping the signature like that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But isn't powermeter.temperatures an optional vector so that check is still needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe I miss something but afaics the temperatures
property is always not set so the else block is never executed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because the passed powermeter
is default initialized and passed to this function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah you're right, then it's a good idea to drop the else block indeed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I didn't check where the powermeter value comes from.
Since it is created by the calling function the else branch would never execute.
Thank you for catching that.
I made the changes, including the signature of the function since I am changing it again and the change is minor.
Signed-off-by: florinmihut <[email protected]>
Signed-off-by: florinmihut <[email protected]>
Signed-off-by: florinmihut <[email protected]>
Signed-off-by: florinmihut <[email protected]>
* - added temperature sensors values in Powermeter (temperature1 and temperature2) - added in interface a variable containing the public OCMF key (publicKeyOcmf) - added in config the following options: meter_timezone, meter_dst, SC, UV, UD - added support for setting the following parameters: meter_dst and meter_timezone - added support for V2 interface * Fix tests and Rust implementation * Add temperatures as a optional vector, additional changes as requested by reviewers --------- Signed-off-by: florinmihut <[email protected]> Co-authored-by: Piet Gömpel <[email protected]>
…mperature2)
Describe your changes
Issue ticket number and link
Checklist before requesting a review