Fix threshold data copy
Removed storing threshold data in the class as it is being stored
in sensor threshold object.
Signed-off-by: Vijay Khemka <vijaykhemka@fb.com>
Change-Id: I86a96c576531c3c2fd62110792791ab2083012ab
diff --git a/virtualSensor.cpp b/virtualSensor.cpp
index c8b70ab..fb6d456 100644
--- a/virtualSensor.cpp
+++ b/virtualSensor.cpp
@@ -81,6 +81,7 @@
auto threshold = sensorConfig.value("Threshold", empty);
if (!threshold.empty())
{
+ Threshold sensorThreshold;
sensorThreshold.criticalHigh =
threshold.value("CriticalHigh", defaultHighThreshold);
sensorThreshold.criticalLow =
@@ -89,10 +90,10 @@
threshold.value("WarningHigh", defaultHighThreshold);
sensorThreshold.warningLow =
threshold.value("WarningLow", defaultLowThreshold);
- }
- /* Set threshold value to dbus */
- setSensorThreshold();
+ /* Set threshold value to dbus */
+ setSensorThreshold(sensorThreshold);
+ }
/* Get expression string */
exprStr = sensorConfig.value("Expression", "");
@@ -167,7 +168,7 @@
ValueIface::value(value);
}
-void VirtualSensor::setSensorThreshold()
+void VirtualSensor::setSensorThreshold(Threshold& sensorThreshold)
{
CriticalInterface::criticalHigh(sensorThreshold.criticalHigh);
CriticalInterface::criticalLow(sensorThreshold.criticalLow);
diff --git a/virtualSensor.hpp b/virtualSensor.hpp
index c8fd04c..4f9de19 100644
--- a/virtualSensor.hpp
+++ b/virtualSensor.hpp
@@ -110,8 +110,6 @@
sdbusplus::bus::bus& bus;
/** @brief Expression string for virtual sensor value calculations */
std::string exprStr;
- /** @brief Sensor Threshold config values */
- struct Threshold sensorThreshold;
/** @brief symbol table from exprtk */
exprtk::symbol_table<double> symbols{};
/** @brief expression from exprtk to calculate sensor value */
@@ -122,7 +120,7 @@
*/
void initVirtualSensor(const Json& sensorConfig);
/** @brief Set Sensor Threshold to D-bus at beginning */
- void setSensorThreshold();
+ void setSensorThreshold(Threshold& sensorThreshold);
};
class VirtualSensors