1 #pragma once
2 #include "types.hpp"
3 
4 #include <sdbusplus/bus.hpp>
5 
6 namespace phosphor
7 {
8 namespace fan
9 {
10 namespace control
11 {
12 
13 /**
14  * @class Fan
15  *
16  * Represents a fan.  It has sensors used for setting speeds
17  * on all of the contained rotors.  There may or may not be
18  * a 1 to 1 correspondence between rotors and sensors, depending
19  * on how the hardware and hwmon is configured.
20  *
21  */
22 class Fan
23 {
24   public:
25     Fan() = delete;
26     Fan(const Fan&) = delete;
27     Fan(Fan&&) = default;
28     Fan& operator=(const Fan&) = delete;
29     Fan& operator=(Fan&&) = default;
30     ~Fan() = default;
31 
32     /**
33      * Creates a fan object with sensors specified by
34      * the fan definition data.
35      *
36      * @param[in] bus - the dbus object
37      * @param[in] def - the fan definition data
38      */
39     Fan(sdbusplus::bus_t& bus, const FanDefinition& def);
40 
41     /**
42      * Sets the speed value on all contained sensors
43      *
44      * @param[in] speed - the value to set
45      */
46     void setSpeed(uint64_t speed);
47 
48     /**
49      * @brief Get the current fan target speed
50      *
51      * @return - The target speed of the fan
52      */
getTargetSpeed() const53     inline auto getTargetSpeed() const
54     {
55         return _targetSpeed;
56     }
57 
58   private:
59     /**
60      * The dbus object
61      */
62     sdbusplus::bus_t& _bus;
63 
64     /**
65      * The inventory name of the fan
66      */
67     std::string _name;
68 
69     /**
70      * Map of target sensors to the service providing them
71      */
72     std::map<std::string, std::string> _sensors;
73 
74     /**
75      * The interface of the fan target
76      */
77     const std::string _interface;
78 
79     /**
80      * Target speed for this fan
81      */
82     uint64_t _targetSpeed;
83 };
84 
85 } // namespace control
86 } // namespace fan
87 } // namespace phosphor
88