Add base class to simplify threshold logic
Add base class for the default case check_thresholds
calls the thresholds.cpp function. This way for normal
things we can just pass sensors around as the base class.
Make it so that theshold alerts are only sent once.
Change-Id: Ic8e3ae1900aeb12b74c099f637f45bc038bd3c9a
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/sensors/include/Thresholds.hpp b/sensors/include/Thresholds.hpp
index 5b194c6..90e148c 100644
--- a/sensors/include/Thresholds.hpp
+++ b/sensors/include/Thresholds.hpp
@@ -2,6 +2,7 @@
#include <Utils.hpp>
#include <nlohmann/json.hpp>
+struct Sensor;
namespace thresholds
{
enum Level
@@ -26,6 +27,7 @@
Direction direction;
double value;
bool writeable;
+ bool asserted = false;
};
bool ParseThresholdsFromConfig(
@@ -38,10 +40,15 @@
const double scale_factor);
bool HasCriticalInterface(
const std::vector<thresholds::Threshold> &threshold_vector);
+
bool HasWarningInterface(
const std::vector<thresholds::Threshold> &threshold_vector);
void persistThreshold(const std::string &baseInterface, const std::string &path,
const thresholds::Threshold &threshold,
std::shared_ptr<sdbusplus::asio::connection> &conn);
+
+void checkThresholds(Sensor *sensor);
+void assertThresholds(Sensor *sensor, thresholds::Level level,
+ thresholds::Direction direction, bool assert);
} // namespace thresholds