hardware: set sensor's oper-status when adding sensor value

It might happen that the sensor reading is obviously faulty (e.g. the
value is way out of range). So we want to set the sensor's oper-status
to nonoperational. Currently, we were setting the oper-status to "ok"
when the data reader was initialized. Now, it is set upon each reading
of the sensor value.

Change-Id: I3f0968e8a7bbeaa8b4e9418a3b817692856eaf16
diff --git a/src/ietf-hardware/IETFHardware.cpp b/src/ietf-hardware/IETFHardware.cpp
index bee10bd..a24c742 100644
--- a/src/ietf-hardware/IETFHardware.cpp
+++ b/src/ietf-hardware/IETFHardware.cpp
@@ -43,6 +43,7 @@
 {
     const auto componentPrefix = xpathForComponent(componentName);
     res[componentPrefix + "sensor-data/value"] = value;
+    res[componentPrefix + "sensor-data/oper-status"] = "ok";
 }
 }
 
@@ -161,7 +162,6 @@
                          {"sensor-data/value-type", "rpm"},
                          {"sensor-data/value-scale", "units"},
                          {"sensor-data/value-precision", "0"},
-                         {"sensor-data/oper-status", "ok"},
                      });
     }
 }
@@ -216,7 +216,6 @@
     {"sensor-data/value-type", "celsius"},
     {"sensor-data/value-scale", "milli"},
     {"sensor-data/value-precision", "0"},
-    {"sensor-data/oper-status", "ok"},
 };
 template <>
 const DataTree sysfsStaticData<SensorType::Current> = {
@@ -224,7 +223,6 @@
     {"sensor-data/value-type", "amperes"},
     {"sensor-data/value-scale", "milli"},
     {"sensor-data/value-precision", "0"},
-    {"sensor-data/oper-status", "ok"},
 };
 template <>
 const DataTree sysfsStaticData<SensorType::Power> = {
@@ -232,7 +230,6 @@
     {"sensor-data/value-type", "watts"},
     {"sensor-data/value-scale", "micro"},
     {"sensor-data/value-precision", "0"},
-    {"sensor-data/oper-status", "ok"},
 };
 template <>
 const DataTree sysfsStaticData<SensorType::VoltageAC> = {
@@ -240,14 +237,14 @@
     {"sensor-data/value-type", "volts-AC"},
     {"sensor-data/value-scale", "milli"},
     {"sensor-data/value-precision", "0"},
-    {"sensor-data/oper-status", "ok"}};
+};
 template <>
 const DataTree sysfsStaticData<SensorType::VoltageDC> = {
     {"class", "iana-hardware:sensor"},
     {"sensor-data/value-type", "volts-DC"},
     {"sensor-data/value-scale", "milli"},
     {"sensor-data/value-precision", "0"},
-    {"sensor-data/oper-status", "ok"}};
+};
 
 template <SensorType TYPE>
 SysfsValue<TYPE>::SysfsValue(std::string componentName, std::optional<std::string> parent, std::shared_ptr<sysfs::HWMon> hwmon, int sysfsChannelNr, Thresholds<int64_t> thresholds)
@@ -318,7 +315,6 @@
                      {"sensor-data/value-type", "other"},
                      {"sensor-data/value-scale", "units"},
                      {"sensor-data/value-precision", "0"},
-                     {"sensor-data/oper-status", "ok"},
                      {"sensor-data/units-display", "percent"s},
                  });
 }