diff options
-rw-r--r-- | control/fan.cpp | 17 | ||||
-rw-r--r-- | control/fan.hpp | 15 | ||||
-rw-r--r-- | control/zone.cpp | 5 |
3 files changed, 36 insertions, 1 deletions
diff --git a/control/fan.cpp b/control/fan.cpp index fcbf4f8..1326451 100644 --- a/control/fan.cpp +++ b/control/fan.cpp @@ -20,6 +20,7 @@ #include <string> #include "fan.hpp" #include "utility.hpp" +#include "sdbusplus.hpp" namespace phosphor { @@ -43,10 +44,22 @@ Fan::Fan(sdbusplus::bus::bus& bus, const FanDefinition& def): _bus(bus), _name(std::get<fanNamePos>(def)) { + std::string path; auto sensors = std::get<sensorListPos>(def); for (auto& s : sensors) { - _sensors.emplace_back(FAN_SENSOR_PATH + s); + path = FAN_SENSOR_PATH + s; + _sensors.emplace_back(path); + } + // All sensors associated with this fan are set to same target speed, + // so only need to read target property from one. + if (!path.empty()) + { + _targetSpeed = util::SDBusPlus::getProperty<uint64_t>( + bus, + path, + FAN_SENSOR_CONTROL_INTF, + FAN_TARGET_PROPERTY); } } @@ -84,6 +97,8 @@ void Fan::setSpeed(uint64_t speed) elog<InternalFailure>(); } } + + _targetSpeed = speed; } } diff --git a/control/fan.hpp b/control/fan.hpp index e23d44e..6975248 100644 --- a/control/fan.hpp +++ b/control/fan.hpp @@ -46,6 +46,16 @@ class Fan */ void setSpeed(uint64_t speed); + /** + * @brief Get the current fan target speed + * + * @return - The target speed of the fan + */ + inline auto getTargetSpeed() const + { + return _targetSpeed; + } + private: /** @@ -71,6 +81,11 @@ class Fan * Vector of hwmon sensors for the rotors */ std::vector<std::string> _sensors; + + /** + * Target speed for this fan + */ + uint64_t _targetSpeed; }; diff --git a/control/zone.cpp b/control/zone.cpp index 418b3ba..cb8ebfa 100644 --- a/control/zone.cpp +++ b/control/zone.cpp @@ -60,6 +60,11 @@ Zone::Zone(Mode mode, // Do not enable set speed events when in init mode if (mode != Mode::init) { + // Update target speed to current zone target speed + if (!_fans.empty()) + { + _targetSpeed = _fans.front()->getTargetSpeed(); + } // Setup signal trigger for set speed events for (auto& event : std::get<setSpeedEventsPos>(def)) { |