blob: 4a07ca2e764e61c3b8d5784b115a8daecc2b8616 [file] [log] [blame]
James Feist139cb572018-09-10 15:26:18 -07001#pragma once
2#include <Utils.hpp>
3#include <nlohmann/json.hpp>
4
James Feistaf79dd32018-09-12 12:54:15 -07005struct Sensor;
James Feist139cb572018-09-10 15:26:18 -07006namespace thresholds
7{
8enum Level
9{
10 WARNING,
11 CRITICAL
12};
13enum Direction
14{
15 HIGH,
16 LOW
17};
18struct Threshold
19{
20 Threshold(const Level &lev, const Direction &dir, const double &val,
21 bool write = true) :
22 level(lev),
23 direction(dir), value(val), writeable(write)
24 {
25 }
26 Level level;
27 Direction direction;
28 double value;
29 bool writeable;
James Feistaf79dd32018-09-12 12:54:15 -070030 bool asserted = false;
James Feist139cb572018-09-10 15:26:18 -070031};
32
Jae Hyun Yoof78ec412018-10-25 10:42:39 -070033bool parseThresholdsFromConfig(
James Feist139cb572018-09-10 15:26:18 -070034 const SensorData &sensorData,
35 std::vector<thresholds::Threshold> &thresholdVector,
36 const std::string *matchLabel = nullptr);
37
Jae Hyun Yoof78ec412018-10-25 10:42:39 -070038bool parseThresholdsFromAttr(std::vector<thresholds::Threshold> &thresholds,
39 const std::string &inputPath,
40 const double &scaleFactor);
41bool hasCriticalInterface(
42 const std::vector<thresholds::Threshold> &thresholdVector);
James Feistaf79dd32018-09-12 12:54:15 -070043
Jae Hyun Yoof78ec412018-10-25 10:42:39 -070044bool hasWarningInterface(
45 const std::vector<thresholds::Threshold> &thresholdVector);
James Feist139cb572018-09-10 15:26:18 -070046
47void persistThreshold(const std::string &baseInterface, const std::string &path,
48 const thresholds::Threshold &threshold,
49 std::shared_ptr<sdbusplus::asio::connection> &conn);
James Feistaf79dd32018-09-12 12:54:15 -070050
51void checkThresholds(Sensor *sensor);
52void assertThresholds(Sensor *sensor, thresholds::Level level,
53 thresholds::Direction direction, bool assert);
James Feist139cb572018-09-10 15:26:18 -070054} // namespace thresholds