summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward A. James <eajames@us.ibm.com>2016-08-15 16:22:25 -0500
committerEdward A. James <eajames@us.ibm.com>2016-08-18 12:39:54 -0500
commitecf8bd8f38d93fda3d08df771709bd5289a480e9 (patch)
tree6a7491d80affbf894ae3f4a98d2b8da8955dad50
parent0127d51c137dbe8063b81012763550faf5111d87 (diff)
downloadpyphosphor-ecf8bd8f38d93fda3d08df771709bd5289a480e9.tar.gz
pyphosphor-ecf8bd8f38d93fda3d08df771709bd5289a480e9.zip
change sensor scaling algorithm for exponential scales
- scale values should be exponentials (10^x) - implement adjust factor depends on Iaf2d5e30df620212dd3c9e821d6462964520dc44 Change-Id: Id4e1dfad0def21f9f1d341d859c3b2c237dea080 Signed-off-by: Edward A. James <eajames@us.ibm.com>
-rw-r--r--obmc/sensors.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/obmc/sensors.py b/obmc/sensors.py
index fcb3ee6..e5c79ef 100644
--- a/obmc/sensors.py
+++ b/obmc/sensors.py
@@ -165,20 +165,28 @@ class HwmonSensor(SensorValue, SensorThresholds):
def setByPoll(self, value):
scale = self.properties[HwmonSensor.IFACE_NAME]['scale']
offset = self.properties[HwmonSensor.IFACE_NAME]['offset']
+ try:
+ adjust = self.properties[HwmonSensor.IFACE_NAME]['adjust']
+ if adjust == 0:
+ adjust = 1
+ except:
+ adjust = 1
+
if self.value_dirty:
## new value externally set, so just return to hwmon
## process to write value
self.value_dirty = False
- val = (
+ val = int((
self.properties[SensorValue.IFACE_NAME]['value']
- - offset) * scale
+ - offset) * adjust)
return [True, val]
else:
- # Keep the val as integer. scale may be floating point
- val = int(value/scale + offset)
+ # Keep the val as integer. adjust may be floating point
+ val = int(value/adjust + offset)
if (val != self.value):
SensorValue.setValue(self, val)
- self.check_thresholds(val)
+ # scale the value to check threshold
+ self.check_thresholds(val * (10 ** scale))
self.value = val
return [False, 0]
OpenPOWER on IntegriCloud