Matt Spinler | e10416e | 2017-04-10 14:15:53 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <memory> |
| 4 | #include <vector> |
| 5 | #include <sdbusplus/bus.hpp> |
| 6 | #include "types.hpp" |
Matt Spinler | 57352a3 | 2017-04-10 14:48:35 -0500 | [diff] [blame] | 7 | #include "zone.hpp" |
Matt Spinler | e10416e | 2017-04-10 14:15:53 -0500 | [diff] [blame] | 8 | |
| 9 | namespace phosphor |
| 10 | { |
| 11 | namespace fan |
| 12 | { |
| 13 | namespace control |
| 14 | { |
| 15 | |
Matt Spinler | 57352a3 | 2017-04-10 14:48:35 -0500 | [diff] [blame] | 16 | using ZoneMap = std::map<unsigned int, |
| 17 | std::unique_ptr<Zone>>; |
| 18 | |
Matt Spinler | e10416e | 2017-04-10 14:15:53 -0500 | [diff] [blame] | 19 | /** |
| 20 | * @class Fan control manager |
| 21 | */ |
| 22 | class Manager |
| 23 | { |
| 24 | public: |
| 25 | |
Matt Spinler | ee7f642 | 2017-05-09 11:03:14 -0500 | [diff] [blame^] | 26 | /** |
| 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 Spinler | e10416e | 2017-04-10 14:15:53 -0500 | [diff] [blame] | 37 | 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 Spinler | ee7f642 | 2017-05-09 11:03:14 -0500 | [diff] [blame^] | 50 | * @param[in] mode - The control mode |
Matt Spinler | e10416e | 2017-04-10 14:15:53 -0500 | [diff] [blame] | 51 | */ |
Matt Spinler | ee7f642 | 2017-05-09 11:03:14 -0500 | [diff] [blame^] | 52 | 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 Spinler | e10416e | 2017-04-10 14:15:53 -0500 | [diff] [blame] | 61 | |
| 62 | private: |
| 63 | |
| 64 | /** |
Matt Spinler | ee7f642 | 2017-05-09 11:03:14 -0500 | [diff] [blame^] | 65 | * Starts the obmc-fan-control-ready dbus target |
| 66 | */ |
| 67 | void startFanControlReadyTarget(); |
| 68 | |
| 69 | /** |
Matt Spinler | e10416e | 2017-04-10 14:15:53 -0500 | [diff] [blame] | 70 | * The dbus object |
| 71 | */ |
| 72 | sdbusplus::bus::bus& _bus; |
| 73 | |
| 74 | /** |
Matt Spinler | 57352a3 | 2017-04-10 14:48:35 -0500 | [diff] [blame] | 75 | * The fan zones in the system |
| 76 | */ |
| 77 | ZoneMap _zones; |
| 78 | |
| 79 | /** |
Matt Spinler | e10416e | 2017-04-10 14:15:53 -0500 | [diff] [blame] | 80 | * The fan zone layout for the system. |
| 81 | * This is generated data. |
| 82 | */ |
| 83 | static const std::vector<ZoneGroup> _zoneLayouts; |
Matt Spinler | ee7f642 | 2017-05-09 11:03:14 -0500 | [diff] [blame^] | 84 | |
| 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 Spinler | e10416e | 2017-04-10 14:15:53 -0500 | [diff] [blame] | 91 | }; |
| 92 | |
| 93 | |
| 94 | } |
| 95 | } |
| 96 | } |