diff options
author | Tom Joseph <tomjoseph@in.ibm.com> | 2018-02-16 09:37:43 +0530 |
---|---|---|
committer | Tom Joseph <tomjoseph@in.ibm.com> | 2018-03-01 05:34:21 +0000 |
commit | 13b87a3ee204a79d5c31dfc0c3540fb207006833 (patch) | |
tree | 9fcf4f84c1aa56cf75e5d2f6634a7f792de28647 /sensordatahandler.hpp | |
parent | 0ac0dd232627d9c44e53d41e2e6509a0471f013d (diff) | |
download | phosphor-host-ipmid-13b87a3ee204a79d5c31dfc0c3540fb207006833.tar.gz phosphor-host-ipmid-13b87a3ee204a79d5c31dfc0c3540fb207006833.zip |
sensor: Refactor get sensor reading command
Use the functor in the generated yaml to get the sensor reading
for analog sensors.
Change-Id: I2535cd5015096c3e1e2baa5f9a865fc6b27e6875
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
Diffstat (limited to 'sensordatahandler.hpp')
-rw-r--r-- | sensordatahandler.hpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sensordatahandler.hpp b/sensordatahandler.hpp index 01b8e4f..a3253b9 100644 --- a/sensordatahandler.hpp +++ b/sensordatahandler.hpp @@ -1,5 +1,6 @@ #pragma once +#include <math.h> #include "sensorhandler.h" #include "types.hpp" #include "utils.hpp" @@ -197,11 +198,13 @@ GetSensorResponse readingData(const Info& sensorInfo) sensorInfo.propertyInterfaces.begin()->first, sensorInfo.propertyInterfaces.begin()->second.begin()->first); - auto value = static_cast<uint8_t>( - (propValue.get<T>() - sensorInfo.scaledOffset) / - (sensorInfo.coefficientM ? sensorInfo.coefficientM : 1)); + double value = propValue.get<T>() * pow(10, + sensorInfo.scale - sensorInfo.exponentR); - setReading(value, responseData); + auto rawData = static_cast<uint8_t>( + (value - sensorInfo.scaledOffset) / sensorInfo.coefficientM); + + setReading(rawData, responseData); return response; } |