1 #pragma once
2 #include <sdbusplus/bus.hpp>
3 #include "types.hpp"
4 
5 namespace phosphor
6 {
7 namespace fan
8 {
9 namespace control
10 {
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 
26         Fan() = delete;
27         Fan(const Fan&) = delete;
28         Fan(Fan&&) = default;
29         Fan& operator=(const Fan&) = delete;
30         Fan& operator=(Fan&&) = default;
31         ~Fan() = default;
32 
33         /**
34          * Creates a fan object with sensors specified by
35          * the fan definition data.
36          *
37          * @param[in] bus - the dbus object
38          * @param[in] def - the fan definition data
39          */
40         Fan(sdbusplus::bus::bus& bus, const FanDefinition& def);
41 
42         /**
43          * Sets the speed value on all contained sensors
44          *
45          * @param[in] speed - the value to set
46          */
47         void setSpeed(uint64_t speed);
48 
49     private:
50 
51         /**
52          * Returns the service name to use for interacting
53          * with the fan sensor passed in.
54          *
55          * @param[in] sensor - the fan tach sensor name
56          * @return - the service name
57          */
58         std::string getService(const std::string& sensor);
59 
60         /**
61          * The dbus object
62          */
63         sdbusplus::bus::bus& _bus;
64 
65         /**
66          * The inventory name of the fan
67          */
68         std::string _name;
69 
70         /**
71          * Vector of hwmon sensors for the rotors
72          */
73         std::vector<std::string> _sensors;
74 };
75 
76 
77 }
78 }
79 }
80