1e2b25cb2SMatt Spinler #pragma once
2e2b25cb2SMatt Spinler #include "types.hpp"
3e2b25cb2SMatt Spinler 
43e1bb274SMatthew Barth #include <sdbusplus/bus.hpp>
53e1bb274SMatthew Barth 
6e2b25cb2SMatt Spinler namespace phosphor
7e2b25cb2SMatt Spinler {
8e2b25cb2SMatt Spinler namespace fan
9e2b25cb2SMatt Spinler {
10e2b25cb2SMatt Spinler namespace control
11e2b25cb2SMatt Spinler {
12e2b25cb2SMatt Spinler 
13e2b25cb2SMatt Spinler /**
14e2b25cb2SMatt Spinler  * @class Fan
15e2b25cb2SMatt Spinler  *
16e2b25cb2SMatt Spinler  * Represents a fan.  It has sensors used for setting speeds
17e2b25cb2SMatt Spinler  * on all of the contained rotors.  There may or may not be
18e2b25cb2SMatt Spinler  * a 1 to 1 correspondence between rotors and sensors, depending
19e2b25cb2SMatt Spinler  * on how the hardware and hwmon is configured.
20e2b25cb2SMatt Spinler  *
21e2b25cb2SMatt Spinler  */
22e2b25cb2SMatt Spinler class Fan
23e2b25cb2SMatt Spinler {
24e2b25cb2SMatt Spinler   public:
25e2b25cb2SMatt Spinler     Fan() = delete;
26e2b25cb2SMatt Spinler     Fan(const Fan&) = delete;
27e2b25cb2SMatt Spinler     Fan(Fan&&) = default;
28e2b25cb2SMatt Spinler     Fan& operator=(const Fan&) = delete;
29e2b25cb2SMatt Spinler     Fan& operator=(Fan&&) = default;
30e2b25cb2SMatt Spinler     ~Fan() = default;
31e2b25cb2SMatt Spinler 
32e2b25cb2SMatt Spinler     /**
33e2b25cb2SMatt Spinler      * Creates a fan object with sensors specified by
34e2b25cb2SMatt Spinler      * the fan definition data.
35e2b25cb2SMatt Spinler      *
36e2b25cb2SMatt Spinler      * @param[in] bus - the dbus object
37e2b25cb2SMatt Spinler      * @param[in] def - the fan definition data
38e2b25cb2SMatt Spinler      */
39cb356d48SPatrick Williams     Fan(sdbusplus::bus_t& bus, const FanDefinition& def);
40e2b25cb2SMatt Spinler 
41e2b25cb2SMatt Spinler     /**
42e2b25cb2SMatt Spinler      * Sets the speed value on all contained sensors
43e2b25cb2SMatt Spinler      *
44e2b25cb2SMatt Spinler      * @param[in] speed - the value to set
45e2b25cb2SMatt Spinler      */
46e2b25cb2SMatt Spinler     void setSpeed(uint64_t speed);
47e2b25cb2SMatt Spinler 
482b3db618SMatthew Barth     /**
492b3db618SMatthew Barth      * @brief Get the current fan target speed
502b3db618SMatthew Barth      *
512b3db618SMatthew Barth      * @return - The target speed of the fan
522b3db618SMatthew Barth      */
getTargetSpeed() const532b3db618SMatthew Barth     inline auto getTargetSpeed() const
542b3db618SMatthew Barth     {
552b3db618SMatthew Barth         return _targetSpeed;
562b3db618SMatthew Barth     }
572b3db618SMatthew Barth 
58e2b25cb2SMatt Spinler   private:
59e2b25cb2SMatt Spinler     /**
60e2b25cb2SMatt Spinler      * The dbus object
61e2b25cb2SMatt Spinler      */
62cb356d48SPatrick Williams     sdbusplus::bus_t& _bus;
63e2b25cb2SMatt Spinler 
64e2b25cb2SMatt Spinler     /**
65e2b25cb2SMatt Spinler      * The inventory name of the fan
66e2b25cb2SMatt Spinler      */
67e2b25cb2SMatt Spinler     std::string _name;
68e2b25cb2SMatt Spinler 
69e2b25cb2SMatt Spinler     /**
70*44872b07SChau Ly      * Map of target sensors to the service providing them
71e2b25cb2SMatt Spinler      */
721061cba1SMatthew Barth     std::map<std::string, std::string> _sensors;
732b3db618SMatthew Barth 
742b3db618SMatthew Barth     /**
75069e4405SLei YU      * The interface of the fan target
76069e4405SLei YU      */
77069e4405SLei YU     const std::string _interface;
78069e4405SLei YU 
79069e4405SLei YU     /**
802b3db618SMatthew Barth      * Target speed for this fan
812b3db618SMatthew Barth      */
822b3db618SMatthew Barth     uint64_t _targetSpeed;
83e2b25cb2SMatt Spinler };
84e2b25cb2SMatt Spinler 
853e1bb274SMatthew Barth } // namespace control
863e1bb274SMatthew Barth } // namespace fan
873e1bb274SMatthew Barth } // namespace phosphor
88