summaryrefslogtreecommitdiffstats
path: root/control/manager.hpp
blob: 5e831f558311c6b96f16ff77089cfd4d47c894cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#pragma once

#include <memory>
#include <vector>
#include <sdbusplus/bus.hpp>
#include <sdeventplus/event.hpp>
#include "types.hpp"
#include "zone.hpp"

namespace phosphor
{
namespace fan
{
namespace control
{

using ZoneMap = std::map<unsigned int,
                         std::unique_ptr<Zone>>;

/**
 * @class Fan control manager
 */
class Manager
{
    public:

        Manager() = delete;
        Manager(const Manager&) = delete;
        Manager(Manager&&) = default;
        Manager& operator=(const Manager&) = delete;
        Manager& operator=(Manager&&) = delete;
        ~Manager() = default;

        /**
         * Constructor
         * Creates the Zone objects based on the
         * _zoneLayouts data.
         *
         * @param[in] bus - The dbus object
         * @param[in] event - The event loop
         * @param[in] mode - The control mode
         */
        Manager(sdbusplus::bus::bus& bus,
                const sdeventplus::Event& event,
                Mode mode);

        /**
         * Does the fan control inititialization, which is
         * setting fans to full, delaying so they
         * can get there, and starting a target.
         */
        void doInit();

        /**
         * Does the fan control and chassis fan shutdown, which
         * disables the fans entirely (stops all rotors)
         */
        void doShutdown();

    private:

        /**
         * The dbus object
         */
        sdbusplus::bus::bus& _bus;

        /**
         * The sdbusplus object manager
         */
        sdbusplus::server::manager::manager _objMgr;

        /**
         * The fan zones in the system
         */
        ZoneMap _zones;

        /**
         * The fan zone layout for the system.
         * This is generated data.
         */
        static const std::vector<ZoneGroup> _zoneLayouts;

        /**
         * The number of seconds to delay after
         * fans get set to high speed on a power on
         * to give them a chance to get there.
         */
        static const unsigned int _powerOnDelay;
};


}
}
}
OpenPOWER on IntegriCloud