James Feist | 139cb57 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | #include <Utils.hpp> |
| 3 | #include <nlohmann/json.hpp> |
| 4 | |
| 5 | namespace thresholds |
| 6 | { |
| 7 | enum Level |
| 8 | { |
| 9 | WARNING, |
| 10 | CRITICAL |
| 11 | }; |
| 12 | enum Direction |
| 13 | { |
| 14 | HIGH, |
| 15 | LOW |
| 16 | }; |
| 17 | struct 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 | |
| 31 | bool ParseThresholdsFromConfig( |
| 32 | const SensorData &sensorData, |
| 33 | std::vector<thresholds::Threshold> &thresholdVector, |
| 34 | const std::string *matchLabel = nullptr); |
| 35 | |
| 36 | bool ParseThresholdsFromAttr(std::vector<thresholds::Threshold> &thresholds, |
| 37 | const std::string &input_path, |
| 38 | const double scale_factor); |
| 39 | bool HasCriticalInterface( |
| 40 | const std::vector<thresholds::Threshold> &threshold_vector); |
| 41 | bool HasWarningInterface( |
| 42 | const std::vector<thresholds::Threshold> &threshold_vector); |
| 43 | |
| 44 | void 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 |