blob: 2b388212f6c5239e0a5825193619e181b5e50fab [file] [log] [blame]
Matthew Barth29e9e382020-01-23 13:40:49 -06001#pragma once
2
3#include <interfaces/manager_interface.hpp>
4#include <sdbusplus/bus.hpp>
5#include <sdbusplus/server/object.hpp>
Matthew Barthf2bcf1f2020-01-29 14:42:47 -06006#include <sdeventplus/event.hpp>
7#include <sdeventplus/utility/timer.hpp>
Matthew Barth29e9e382020-01-23 13:40:49 -06008
9namespace phosphor::power::regulators
10{
11
12constexpr auto busName = "xyz.openbmc_project.Power.Regulators";
13constexpr auto objPath = "/xyz/openbmc_project/power/regulators/manager";
14
Matthew Barthf2bcf1f2020-01-29 14:42:47 -060015using Timer = sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>;
16
Matthew Barth29e9e382020-01-23 13:40:49 -060017using ManagerObject = sdbusplus::server::object::object<
18 phosphor::power::regulators::interface::ManagerInterface>;
19
20class 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 Barthf2bcf1f2020-01-29 14:42:47 -060035 * @param[in] event - the sdevent event
Matthew Barth29e9e382020-01-23 13:40:49 -060036 */
Matthew Barthf2bcf1f2020-01-29 14:42:47 -060037 Manager(sdbusplus::bus::bus& bus, const sdeventplus::Event& event);
Matthew Barth29e9e382020-01-23 13:40:49 -060038
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 Barthf2bcf1f2020-01-29 14:42:47 -060051 /**
52 * @brief Timer expired callback function
53 */
54 void timerExpired();
55
Matthew Barth29e9e382020-01-23 13:40:49 -060056 private:
57 /**
58 * The dbus bus
59 */
60 sdbusplus::bus::bus& bus;
Matthew Barthf2bcf1f2020-01-29 14:42:47 -060061
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 Barth29e9e382020-01-23 13:40:49 -060071};
72
73} // namespace phosphor::power::regulators