Skip to content

Commit

Permalink
Add support for max and min values
Browse files Browse the repository at this point in the history
  • Loading branch information
epinter committed Apr 23, 2024
1 parent da0049f commit 1e76b13
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#define OPTION_HARDWARENAME L"HardwareName"
#define OPTION_HARDWARETYPE L"HardwareType"
#define OPTION_SENSORID L"SensorIdentifier"
#define OPTION_SENSORMETRICTYPE L"SensorMetricType"
#define OPTION_STALEAFTERSECS L"StaleAfterSecs"

#define SMART_ITEM_STATUS "Status"
Expand Down
11 changes: 9 additions & 2 deletions src/Measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ namespace LhwsPlugin {

try {
lhws::Sensor sensor;
if(sensorId.empty()) {
if (sensorId.empty()) {
sensor = hardwareService.getSensorByName(
boost::locale::conv::utf_to_utf<char>(sensorName),
boost::locale::conv::utf_to_utf<char>(sensorType),
Expand All @@ -232,7 +232,13 @@ namespace LhwsPlugin {
sensor = hardwareService.getSensorById(boost::locale::conv::utf_to_utf<char>(sensorId));
}

return sensor.getValue();
if (boost::iequals(sensorMetricType, "max")) {
return sensor.getMax();
} else if (boost::iequals(sensorMetricType, "min")) {
return sensor.getMin();
} else {
return sensor.getValue();
}
} catch (std::exception const &e) {
logError(e.what());
}
Expand Down Expand Up @@ -290,6 +296,7 @@ namespace LhwsPlugin {
sensorType = api.readString(OPTION_SENSORTYPE, L"");
hardwareName = api.readString(OPTION_HARDWARENAME, L"");
hardwareType = api.readString(OPTION_HARDWARETYPE, L"");
sensorMetricType = api.readString(OPTION_SENSORMETRICTYPE, L"value");
sensorId = api.readString(OPTION_SENSORID, L"");
staleAfterSecs = api.readInt(OPTION_STALEAFTERSECS, VALUE_STALE_SECS);

Expand Down
1 change: 1 addition & 0 deletions src/Measure.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace LhwsPlugin {
std::wstring hwStatusItem{};
std::wstring stringValue{};
std::wstring sensorId{};
std::wstring sensorMetricType{};
std::wstring fps{};
double lastValue = -1.0f;
int staleAfterSecs = VALUE_STALE_SECS;
Expand Down

0 comments on commit 1e76b13

Please sign in to comment.