blob: bb59493c33c35908b1ad129d75c4f750adaa3ac7 [file] [log] [blame]
Matt Spinlere2b25cb2017-04-10 14:33:35 -05001#pragma once
Matt Spinlere2b25cb2017-04-10 14:33:35 -05002#include "types.hpp"
3
Matthew Barth3e1bb272020-05-26 11:09:21 -05004#include <sdbusplus/bus.hpp>
5
Matt Spinlere2b25cb2017-04-10 14:33:35 -05006namespace phosphor
7{
8namespace fan
9{
10namespace control
11{
12
Matt Spinlere2b25cb2017-04-10 14:33:35 -050013/**
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 */
22class Fan
23{
Matthew Barth3e1bb272020-05-26 11:09:21 -050024 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 Spinlere2b25cb2017-04-10 14:33:35 -050031
Matthew Barth3e1bb272020-05-26 11:09:21 -050032 /**
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 Williamscb356d42022-07-22 19:26:53 -050039 Fan(sdbusplus::bus_t& bus, const FanDefinition& def);
Matt Spinlere2b25cb2017-04-10 14:33:35 -050040
Matthew Barth3e1bb272020-05-26 11:09:21 -050041 /**
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 Spinlere2b25cb2017-04-10 14:33:35 -050047
Matthew Barth3e1bb272020-05-26 11:09:21 -050048 /**
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 Spinlere2b25cb2017-04-10 14:33:35 -050057
Matthew Barth3e1bb272020-05-26 11:09:21 -050058 private:
59 /**
60 * The dbus object
61 */
Patrick Williamscb356d42022-07-22 19:26:53 -050062 sdbusplus::bus_t& _bus;
Matthew Barth2b3db612017-10-25 10:56:51 -050063
Matthew Barth3e1bb272020-05-26 11:09:21 -050064 /**
65 * The inventory name of the fan
66 */
67 std::string _name;
Matt Spinlere2b25cb2017-04-10 14:33:35 -050068
Matthew Barth3e1bb272020-05-26 11:09:21 -050069 /**
Chau Ly44872b02022-09-19 07:34:08 +000070 * Map of target sensors to the service providing them
Matthew Barth3e1bb272020-05-26 11:09:21 -050071 */
72 std::map<std::string, std::string> _sensors;
Matt Spinlere2b25cb2017-04-10 14:33:35 -050073
Matthew Barth3e1bb272020-05-26 11:09:21 -050074 /**
75 * The interface of the fan target
76 */
77 const std::string _interface;
Matt Spinlere2b25cb2017-04-10 14:33:35 -050078
Matthew Barth3e1bb272020-05-26 11:09:21 -050079 /**
80 * Target speed for this fan
81 */
82 uint64_t _targetSpeed;
Matt Spinlere2b25cb2017-04-10 14:33:35 -050083};
84
Matthew Barth3e1bb272020-05-26 11:09:21 -050085} // namespace control
86} // namespace fan
87} // namespace phosphor