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