summaryrefslogtreecommitdiffstats
path: root/control/fan.hpp
blob: e23d44ee04264f0baab029cc996a233a962eddbb (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
#pragma once
#include <sdbusplus/bus.hpp>
#include "types.hpp"

namespace phosphor
{
namespace fan
{
namespace control
{


/**
 * @class Fan
 *
 * Represents a fan.  It has sensors used for setting speeds
 * on all of the contained rotors.  There may or may not be
 * a 1 to 1 correspondence between rotors and sensors, depending
 * on how the hardware and hwmon is configured.
 *
 */
class Fan
{
    public:

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

        /**
         * Creates a fan object with sensors specified by
         * the fan definition data.
         *
         * @param[in] bus - the dbus object
         * @param[in] def - the fan definition data
         */
        Fan(sdbusplus::bus::bus& bus, const FanDefinition& def);

        /**
         * Sets the speed value on all contained sensors
         *
         * @param[in] speed - the value to set
         */
        void setSpeed(uint64_t speed);

    private:

        /**
         * Returns the service name to use for interacting
         * with the fan sensor passed in.
         *
         * @param[in] sensor - the fan tach sensor name
         * @return - the service name
         */
        std::string getService(const std::string& sensor);

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

        /**
         * The inventory name of the fan
         */
        std::string _name;

        /**
         * Vector of hwmon sensors for the rotors
         */
        std::vector<std::string> _sensors;
};


}
}
}
OpenPOWER on IntegriCloud