blob: 675dfb8dea451e5a1f07ca3e4703b9b3bbc70d5a [file] [log] [blame]
Matt Spinlere10416e2017-04-10 14:15:53 -05001#pragma once
2
3#include <memory>
4#include <vector>
5#include <sdbusplus/bus.hpp>
6#include "types.hpp"
Matt Spinler57352a32017-04-10 14:48:35 -05007#include "zone.hpp"
Matt Spinlere10416e2017-04-10 14:15:53 -05008
9namespace phosphor
10{
11namespace fan
12{
13namespace control
14{
15
Matt Spinler57352a32017-04-10 14:48:35 -050016using ZoneMap = std::map<unsigned int,
17 std::unique_ptr<Zone>>;
18
Matt Spinlere10416e2017-04-10 14:15:53 -050019/**
20 * @class Fan control manager
21 */
22class Manager
23{
24 public:
25
Matt Spinleree7f6422017-05-09 11:03:14 -050026 /**
27 * The mode the manager will run in:
28 * - init - only do the initialization steps
29 * - control - run normal control algorithms
30 */
31 enum class Mode
32 {
33 init,
34 control
35 };
36
Matt Spinlere10416e2017-04-10 14:15:53 -050037 Manager() = delete;
38 Manager(const Manager&) = delete;
39 Manager(Manager&&) = default;
40 Manager& operator=(const Manager&) = delete;
41 Manager& operator=(Manager&&) = delete;
42 ~Manager() = default;
43
44 /**
45 * Constructor
46 * Creates the Zone objects based on the
47 * _zoneLayouts data.
48 *
49 * @param[in] bus - The dbus object
Matt Spinleree7f6422017-05-09 11:03:14 -050050 * @param[in] mode - The control mode
Matt Spinlere10416e2017-04-10 14:15:53 -050051 */
Matt Spinleree7f6422017-05-09 11:03:14 -050052 Manager(sdbusplus::bus::bus& bus,
53 Mode mode);
54
55 /**
56 * Does the fan control inititialization, which is
57 * setting fans to full, delaying so they
58 * can get there, and starting a target.
59 */
60 void doInit();
Matt Spinlere10416e2017-04-10 14:15:53 -050061
62 private:
63
64 /**
Matt Spinleree7f6422017-05-09 11:03:14 -050065 * Starts the obmc-fan-control-ready dbus target
66 */
67 void startFanControlReadyTarget();
68
69 /**
Matt Spinlere10416e2017-04-10 14:15:53 -050070 * The dbus object
71 */
72 sdbusplus::bus::bus& _bus;
73
74 /**
Matt Spinler57352a32017-04-10 14:48:35 -050075 * The fan zones in the system
76 */
77 ZoneMap _zones;
78
79 /**
Matt Spinlere10416e2017-04-10 14:15:53 -050080 * The fan zone layout for the system.
81 * This is generated data.
82 */
83 static const std::vector<ZoneGroup> _zoneLayouts;
Matt Spinleree7f6422017-05-09 11:03:14 -050084
85 /**
86 * The number of seconds to delay after
87 * fans get set to high speed on a power on
88 * to give them a chance to get there.
89 */
90 static const unsigned int _powerOnDelay;
Matt Spinlere10416e2017-04-10 14:15:53 -050091};
92
93
94}
95}
96}