summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sensordatahandler.hpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/sensordatahandler.hpp b/sensordatahandler.hpp
index a3253b9..e36b71a 100644
--- a/sensordatahandler.hpp
+++ b/sensordatahandler.hpp
@@ -271,24 +271,18 @@ template<typename T>
ipmi_ret_t readingData(const SetSensorReadingReq& cmdData,
const Info& sensorInfo)
{
- auto msg = makeDbusMsg(
- "org.freedesktop.DBus.Properties",
- sensorInfo.sensorPath,
- "Set",
- sensorInfo.sensorInterface);
+ T raw_value = (sensorInfo.coefficientM * cmdData.reading) +
+ sensorInfo.scaledOffset;
- const auto& interface = sensorInfo.propertyInterfaces.begin();
- msg.append(interface->first);
+ raw_value *= pow(10, sensorInfo.exponentR - sensorInfo.scale);
- ipmi::sensor::Multiplier m = sensorInfo.coefficientM;
- if (0 == m)
- {
- m = 1; // Avoid * 0
- }
+ auto msg = makeDbusMsg("org.freedesktop.DBus.Properties",
+ sensorInfo.sensorPath,
+ "Set",
+ sensorInfo.sensorInterface);
- // TODO: Refactor this into a generated function depending on the type
- // of conversion for the value between IPMI and dbus.
- T raw_value = (m * cmdData.reading) + sensorInfo.scaledOffset;
+ const auto& interface = sensorInfo.propertyInterfaces.begin();
+ msg.append(interface->first);
for (const auto& property : interface->second)
{
OpenPOWER on IntegriCloud