Matthew Barth | 29e9e38 | 2020-01-23 13:40:49 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <interfaces/manager_interface.hpp> |
| 4 | #include <sdbusplus/bus.hpp> |
| 5 | #include <sdbusplus/server/object.hpp> |
Matthew Barth | f2bcf1f | 2020-01-29 14:42:47 -0600 | [diff] [blame^] | 6 | #include <sdeventplus/event.hpp> |
| 7 | #include <sdeventplus/utility/timer.hpp> |
Matthew Barth | 29e9e38 | 2020-01-23 13:40:49 -0600 | [diff] [blame] | 8 | |
| 9 | namespace phosphor::power::regulators |
| 10 | { |
| 11 | |
| 12 | constexpr auto busName = "xyz.openbmc_project.Power.Regulators"; |
| 13 | constexpr auto objPath = "/xyz/openbmc_project/power/regulators/manager"; |
| 14 | |
Matthew Barth | f2bcf1f | 2020-01-29 14:42:47 -0600 | [diff] [blame^] | 15 | using Timer = sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>; |
| 16 | |
Matthew Barth | 29e9e38 | 2020-01-23 13:40:49 -0600 | [diff] [blame] | 17 | using ManagerObject = sdbusplus::server::object::object< |
| 18 | phosphor::power::regulators::interface::ManagerInterface>; |
| 19 | |
| 20 | class Manager : public ManagerObject |
| 21 | { |
| 22 | public: |
| 23 | Manager() = delete; |
| 24 | Manager(const Manager&) = delete; |
| 25 | Manager(Manager&&) = delete; |
| 26 | Manager& operator=(const Manager&) = delete; |
| 27 | Manager& operator=(Manager&&) = delete; |
| 28 | ~Manager() = default; |
| 29 | |
| 30 | /** |
| 31 | * Constructor |
| 32 | * Creates a manager over the regulators. |
| 33 | * |
| 34 | * @param[in] bus - the dbus bus |
Matthew Barth | f2bcf1f | 2020-01-29 14:42:47 -0600 | [diff] [blame^] | 35 | * @param[in] event - the sdevent event |
Matthew Barth | 29e9e38 | 2020-01-23 13:40:49 -0600 | [diff] [blame] | 36 | */ |
Matthew Barth | f2bcf1f | 2020-01-29 14:42:47 -0600 | [diff] [blame^] | 37 | Manager(sdbusplus::bus::bus& bus, const sdeventplus::Event& event); |
Matthew Barth | 29e9e38 | 2020-01-23 13:40:49 -0600 | [diff] [blame] | 38 | |
| 39 | /** |
| 40 | * @brief Overridden manager object's configure method |
| 41 | */ |
| 42 | void configure() override; |
| 43 | |
| 44 | /** |
| 45 | * @brief Overridden manager object's monitor method |
| 46 | * |
| 47 | * @param[in] enable - Enable or disable regulator monitoring |
| 48 | */ |
| 49 | void monitor(bool enable) override; |
| 50 | |
Matthew Barth | f2bcf1f | 2020-01-29 14:42:47 -0600 | [diff] [blame^] | 51 | /** |
| 52 | * @brief Timer expired callback function |
| 53 | */ |
| 54 | void timerExpired(); |
| 55 | |
Matthew Barth | 29e9e38 | 2020-01-23 13:40:49 -0600 | [diff] [blame] | 56 | private: |
| 57 | /** |
| 58 | * The dbus bus |
| 59 | */ |
| 60 | sdbusplus::bus::bus& bus; |
Matthew Barth | f2bcf1f | 2020-01-29 14:42:47 -0600 | [diff] [blame^] | 61 | |
| 62 | /** |
| 63 | * Event to loop on |
| 64 | */ |
| 65 | sdeventplus::Event eventLoop; |
| 66 | |
| 67 | /** |
| 68 | * List of event timers |
| 69 | */ |
| 70 | std::vector<Timer> timers; |
Matthew Barth | 29e9e38 | 2020-01-23 13:40:49 -0600 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | } // namespace phosphor::power::regulators |