blob: 5b194c66b34caae1888d7f26cb45622a6571b1dc [file] [log] [blame]
James Feist139cb572018-09-10 15:26:18 -07001#pragma once
2#include <Utils.hpp>
3#include <nlohmann/json.hpp>
4
5namespace thresholds
6{
7enum Level
8{
9 WARNING,
10 CRITICAL
11};
12enum Direction
13{
14 HIGH,
15 LOW
16};
17struct Threshold
18{
19 Threshold(const Level &lev, const Direction &dir, const double &val,
20 bool write = true) :
21 level(lev),
22 direction(dir), value(val), writeable(write)
23 {
24 }
25 Level level;
26 Direction direction;
27 double value;
28 bool writeable;
29};
30
31bool ParseThresholdsFromConfig(
32 const SensorData &sensorData,
33 std::vector<thresholds::Threshold> &thresholdVector,
34 const std::string *matchLabel = nullptr);
35
36bool ParseThresholdsFromAttr(std::vector<thresholds::Threshold> &thresholds,
37 const std::string &input_path,
38 const double scale_factor);
39bool HasCriticalInterface(
40 const std::vector<thresholds::Threshold> &threshold_vector);
41bool HasWarningInterface(
42 const std::vector<thresholds::Threshold> &threshold_vector);
43
44void persistThreshold(const std::string &baseInterface, const std::string &path,
45 const thresholds::Threshold &threshold,
46 std::shared_ptr<sdbusplus::asio::connection> &conn);
47} // namespace thresholds