Matt Spinler | e2b25cb | 2017-04-10 14:33:35 -0500 | [diff] [blame] | 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 | |
Matthew Barth | 2b3db61 | 2017-10-25 10:56:51 -0500 | [diff] [blame] | 49 | /** |
| 50 | * @brief Get the current fan target speed |
| 51 | * |
| 52 | * @return - The target speed of the fan |
| 53 | */ |
| 54 | inline auto getTargetSpeed() const |
| 55 | { |
| 56 | return _targetSpeed; |
| 57 | } |
| 58 | |
Matt Spinler | e2b25cb | 2017-04-10 14:33:35 -0500 | [diff] [blame] | 59 | private: |
| 60 | |
| 61 | /** |
Matt Spinler | e2b25cb | 2017-04-10 14:33:35 -0500 | [diff] [blame] | 62 | * The dbus object |
| 63 | */ |
| 64 | sdbusplus::bus::bus& _bus; |
| 65 | |
| 66 | /** |
| 67 | * The inventory name of the fan |
| 68 | */ |
| 69 | std::string _name; |
| 70 | |
| 71 | /** |
Matthew Barth | 1061cba | 2018-05-09 14:18:16 -0500 | [diff] [blame] | 72 | * Map of hwmon target sensors to the service providing them |
Matt Spinler | e2b25cb | 2017-04-10 14:33:35 -0500 | [diff] [blame] | 73 | */ |
Matthew Barth | 1061cba | 2018-05-09 14:18:16 -0500 | [diff] [blame] | 74 | std::map<std::string, std::string> _sensors; |
Matthew Barth | 2b3db61 | 2017-10-25 10:56:51 -0500 | [diff] [blame] | 75 | |
| 76 | /** |
Lei YU | 069e440 | 2018-01-31 16:47:37 +0800 | [diff] [blame] | 77 | * The interface of the fan target |
| 78 | */ |
| 79 | const std::string _interface; |
| 80 | |
| 81 | /** |
Matthew Barth | 2b3db61 | 2017-10-25 10:56:51 -0500 | [diff] [blame] | 82 | * Target speed for this fan |
| 83 | */ |
| 84 | uint64_t _targetSpeed; |
Matt Spinler | e2b25cb | 2017-04-10 14:33:35 -0500 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | |
| 88 | } |
| 89 | } |
| 90 | } |