Matt Spinler | e812239 | 2020-09-24 13:22:18 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "fan.hpp" |
| 4 | |
| 5 | #include <nlohmann/json.hpp> |
| 6 | #include <sdbusplus/bus.hpp> |
| 7 | |
| 8 | namespace phosphor::fan::presence |
| 9 | { |
| 10 | class PresenceSensor; |
| 11 | |
| 12 | /** |
| 13 | * @class ErrorReporter |
| 14 | * |
| 15 | * This class will create event logs for missing fans. The logs are |
| 16 | * created after a fan has been missing for an amount of time |
| 17 | * specified in the JSON config file while power is on. |
| 18 | * |
| 19 | * The timers to create event logs are not started when power is off. |
| 20 | * When power is turned on, the timers for any missing fans will be |
| 21 | * be started. If any timers are running when power is turned off, |
| 22 | * they will be stopped. |
| 23 | */ |
| 24 | class ErrorReporter |
| 25 | { |
| 26 | public: |
| 27 | ErrorReporter() = delete; |
| 28 | ~ErrorReporter() = default; |
| 29 | ErrorReporter(const ErrorReporter&) = delete; |
| 30 | ErrorReporter& operator=(const ErrorReporter&) = delete; |
| 31 | ErrorReporter(ErrorReporter&&) = delete; |
| 32 | ErrorReporter& operator=(ErrorReporter&&) = delete; |
| 33 | |
| 34 | /** |
| 35 | * @brief Constructor |
| 36 | * |
| 37 | * @param[in] bus - The sdbusplus bus object |
| 38 | * @param[in] jsonConf - The 'reporting' section of the JSON config file |
| 39 | * @param[in] fans - The fans for this configuration |
| 40 | */ |
| 41 | ErrorReporter( |
| 42 | sdbusplus::bus::bus& bus, const nlohmann::json& jsonConf, |
| 43 | const std::vector< |
| 44 | std::tuple<Fan, std::vector<std::unique_ptr<PresenceSensor>>>>& |
| 45 | fans); |
| 46 | |
| 47 | private: |
| 48 | /** |
| 49 | * @brief Reads in the configuration from the JSON section |
| 50 | * |
| 51 | * @param[in] jsonConf - The 'reporting' section of the JSON |
| 52 | */ |
| 53 | void loadConfig(const nlohmann::json& jsonConf); |
| 54 | |
| 55 | /** |
| 56 | * @brief Reference to the D-Bus connection object. |
| 57 | */ |
| 58 | sdbusplus::bus::bus& _bus; |
| 59 | |
| 60 | /** |
| 61 | * @brief The amount of time in seconds that a fan must be missing |
| 62 | * before an event log is created for it. |
| 63 | */ |
| 64 | std::chrono::seconds _fanMissingErrorTime; |
| 65 | }; |
| 66 | |
| 67 | } // namespace phosphor::fan::presence |