1 #pragma once 2 3 #include "interface.hpp" 4 5 namespace hwmon 6 { 7 8 /** 9 * @class FanSpeed 10 * @brief Target fan speed control implementation 11 * @details Derived FanSpeedObject type that writes the target value to sysfs 12 * which in turn sets the fan speed to that target value 13 */ 14 class FanSpeed : public FanSpeedObject 15 { 16 public: 17 18 /** 19 * @brief Constructs FanSpeed Object 20 * 21 * @param[in] sysfsRoot - The hwmon class root 22 * @param[in] instance - The hwmon instance (ex. hwmon1) 23 * @param[in] id - The hwmon id 24 * @param[in] bus - Dbus bus object 25 * @param[in] objPath - Dbus object path 26 * @param[in] defer - Dbus object registration defer 27 */ 28 FanSpeed(const std::string& sysfsRoot, 29 const std::string& instance, 30 const std::string& id, 31 sdbusplus::bus::bus& bus, 32 const char* objPath, 33 bool defer) : FanSpeedObject(bus, objPath, defer), 34 sysfsRoot(sysfsRoot), 35 instance(instance), 36 id(id) 37 { 38 // Nothing to do here 39 } 40 41 /** 42 * @brief Set the value of target 43 * 44 * @return Value of target 45 */ 46 uint64_t target(uint64_t value) override; 47 48 /** 49 * @brief Writes the pwm_enable sysfs entry. 50 */ 51 void enable(); 52 53 private: 54 /** @brief hwmon class root */ 55 std::string sysfsRoot; 56 /** @brief hwmon instance */ 57 std::string instance; 58 /** @brief hwmon type */ 59 static constexpr auto type = "fan"; 60 /** @brief hwmon id */ 61 std::string id; 62 }; 63 64 } // namespace hwmon 65