Add redundancy sensor and cleanup
Add fan redundancy sensor and move some class members
into the base class. Asio now protects against setting
the same number twice, allow it now to simplify code.
Change-Id: Idb6b5ff4746da92be62c4756fe442d5a5ed23f4f
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/sensors/src/ADCSensor.cpp b/sensors/src/ADCSensor.cpp
index 0955994..09c62cf 100644
--- a/sensors/src/ADCSensor.cpp
+++ b/sensors/src/ADCSensor.cpp
@@ -39,15 +39,14 @@
std::vector<thresholds::Threshold> &&_thresholds,
const double scaleFactor,
const std::string &sensorConfiguration) :
- Sensor(),
- path(path), objServer(objectServer), configuration(sensorConfiguration),
- name(boost::replace_all_copy(sensorName, " ", "_")),
+ Sensor(boost::replace_all_copy(sensorName, " ", "_"), path,
+ std::move(_thresholds)),
+ objServer(objectServer), configuration(sensorConfiguration),
scaleFactor(scaleFactor), inputDev(io, open(path.c_str(), O_RDONLY)),
waitTimer(io), errCount(0),
// todo, get these from config
maxValue(20), minValue(0)
{
- thresholds = std::move(_thresholds);
sensorInterface = objectServer.add_interface(
"/xyz/openbmc_project/sensors/voltage/" + name,
"xyz.openbmc_project.Sensor.Value");
@@ -118,15 +117,18 @@
}
else
{
- std::cerr << "Failure to read sensor " << name << " at " << path
- << " ec:" << err << "\n";
errCount++;
}
-
- // only send value update once
+ // only print once
if (errCount == warnAfterErrorCount)
{
+ std::cerr << "Failure to read sensor " << name << " at " << path
+ << " ec:" << err << "\n";
+ }
+
+ if (errCount >= warnAfterErrorCount)
+ {
updateValue(0);
}