Matt Spinler | e2b25cb | 2017-04-10 14:33:35 -0500 | [diff] [blame] | 1 | #pragma once |
Matt Spinler | e2b25cb | 2017-04-10 14:33:35 -0500 | [diff] [blame] | 2 | #include "types.hpp" |
| 3 | |
Matthew Barth | 3e1bb27 | 2020-05-26 11:09:21 -0500 | [diff] [blame] | 4 | #include <sdbusplus/bus.hpp> |
| 5 | |
Matt Spinler | e2b25cb | 2017-04-10 14:33:35 -0500 | [diff] [blame] | 6 | namespace phosphor |
| 7 | { |
| 8 | namespace fan |
| 9 | { |
| 10 | namespace control |
| 11 | { |
| 12 | |
Matt Spinler | e2b25cb | 2017-04-10 14:33:35 -0500 | [diff] [blame] | 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 | { |
Matthew Barth | 3e1bb27 | 2020-05-26 11:09:21 -0500 | [diff] [blame] | 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; |
Matt Spinler | e2b25cb | 2017-04-10 14:33:35 -0500 | [diff] [blame] | 31 | |
Matthew Barth | 3e1bb27 | 2020-05-26 11:09:21 -0500 | [diff] [blame] | 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 | */ |
Patrick Williams | cb356d4 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 39 | Fan(sdbusplus::bus_t& bus, const FanDefinition& def); |
Matt Spinler | e2b25cb | 2017-04-10 14:33:35 -0500 | [diff] [blame] | 40 | |
Matthew Barth | 3e1bb27 | 2020-05-26 11:09:21 -0500 | [diff] [blame] | 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); |
Matt Spinler | e2b25cb | 2017-04-10 14:33:35 -0500 | [diff] [blame] | 47 | |
Matthew Barth | 3e1bb27 | 2020-05-26 11:09:21 -0500 | [diff] [blame] | 48 | /** |
| 49 | * @brief Get the current fan target speed |
| 50 | * |
| 51 | * @return - The target speed of the fan |
| 52 | */ |
| 53 | inline auto getTargetSpeed() const |
| 54 | { |
| 55 | return _targetSpeed; |
| 56 | } |
Matt Spinler | e2b25cb | 2017-04-10 14:33:35 -0500 | [diff] [blame] | 57 | |
Matthew Barth | 3e1bb27 | 2020-05-26 11:09:21 -0500 | [diff] [blame] | 58 | private: |
| 59 | /** |
| 60 | * The dbus object |
| 61 | */ |
Patrick Williams | cb356d4 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 62 | sdbusplus::bus_t& _bus; |
Matthew Barth | 2b3db61 | 2017-10-25 10:56:51 -0500 | [diff] [blame] | 63 | |
Matthew Barth | 3e1bb27 | 2020-05-26 11:09:21 -0500 | [diff] [blame] | 64 | /** |
| 65 | * The inventory name of the fan |
| 66 | */ |
| 67 | std::string _name; |
Matt Spinler | e2b25cb | 2017-04-10 14:33:35 -0500 | [diff] [blame] | 68 | |
Matthew Barth | 3e1bb27 | 2020-05-26 11:09:21 -0500 | [diff] [blame] | 69 | /** |
Chau Ly | 44872b0 | 2022-09-19 07:34:08 +0000 | [diff] [blame] | 70 | * Map of target sensors to the service providing them |
Matthew Barth | 3e1bb27 | 2020-05-26 11:09:21 -0500 | [diff] [blame] | 71 | */ |
| 72 | std::map<std::string, std::string> _sensors; |
Matt Spinler | e2b25cb | 2017-04-10 14:33:35 -0500 | [diff] [blame] | 73 | |
Matthew Barth | 3e1bb27 | 2020-05-26 11:09:21 -0500 | [diff] [blame] | 74 | /** |
| 75 | * The interface of the fan target |
| 76 | */ |
| 77 | const std::string _interface; |
Matt Spinler | e2b25cb | 2017-04-10 14:33:35 -0500 | [diff] [blame] | 78 | |
Matthew Barth | 3e1bb27 | 2020-05-26 11:09:21 -0500 | [diff] [blame] | 79 | /** |
| 80 | * Target speed for this fan |
| 81 | */ |
| 82 | uint64_t _targetSpeed; |
Matt Spinler | e2b25cb | 2017-04-10 14:33:35 -0500 | [diff] [blame] | 83 | }; |
| 84 | |
Matthew Barth | 3e1bb27 | 2020-05-26 11:09:21 -0500 | [diff] [blame] | 85 | } // namespace control |
| 86 | } // namespace fan |
| 87 | } // namespace phosphor |