From c9b6d4589620275a625121b0ea9f4cc4c93b608a Mon Sep 17 00:00:00 2001 From: Ian Goegebuer Date: Tue, 10 Nov 2020 14:20:47 -0800 Subject: [PATCH] pid/zone: Add the ability to dynamically set the failSafe percent This change advertises the failSafe percent as a FanSpeed interface added to the the FanCtrl object generated by the config.json file. The target method added in this case sets the failSafePerecent out of 255 with 255 being 100% and 0 being 0%. Example: `busctl set-property xyz.openbmc_project.State.FanCtrl /xyz/openbmc_project/settings/fanctrl/zone1 xyz.openbmc_project.Control.FanSpeed Target t 178` Sets the failSafePercent to 69.8% or ~70% `busctl set-property xyz.openbmc_project.State.FanCtrl /xyz/openbmc_project/settings/fanctrl/zone1 xyz.openbmc_project.Control.FanSpeed Target t 250` Sets the failSafePercent to 98% Signed-off-by: Ian Goegebuer Change-Id: Ief538d865dc1c654427ed9792496ab368e8803e2 --- pid/zone.cpp | 11 +++++++++++ pid/zone.hpp | 11 +++++++++-- pid/zone_interface.hpp | 1 + 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/pid/zone.cpp b/pid/zone.cpp index 441031a..24f6e84 100644 --- a/pid/zone.cpp +++ b/pid/zone.cpp @@ -120,6 +120,11 @@ double DbusPidZone::getFailSafePercent(void) const return _failSafePercent; } +void DbusPidZone::setFailSafePercent(double newFailSafe) +{ + _failSafePercent = newFailSafe; +} + double DbusPidZone::getMinThermalSetpoint(void) const { return _minThermalOutputSetPt; @@ -459,4 +464,10 @@ bool DbusPidZone::failSafe() const return getFailSafeMode(); } +uint64_t DbusPidZone::target(uint64_t value) +{ + setFailSafePercent(((double)value / 255) * 100.0); + return ModeObject::target(value); +} + } // namespace pid_control diff --git a/pid/zone.hpp b/pid/zone.hpp index 3bea9c2..c0d1d22 100644 --- a/pid/zone.hpp +++ b/pid/zone.hpp @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -22,7 +23,9 @@ template using ServerObject = typename sdbusplus::server::object::object; using ModeInterface = sdbusplus::xyz::openbmc_project::Control::server::Mode; -using ModeObject = ServerObject; +using FanSpeedInterface = + sdbusplus::xyz::openbmc_project::Control::server::FanSpeed; +using ModeObject = ServerObject; namespace pid_control { @@ -63,6 +66,7 @@ class DbusPidZone : public ZoneInterface, public ModeObject void clearSetPoints(void) override; void clearRPMCeilings(void) override; double getFailSafePercent(void) const override; + void setFailSafePercent(double) override; double getMinThermalSetpoint(void) const; Sensor* getSensor(const std::string& name) override; @@ -88,6 +92,9 @@ class DbusPidZone : public ZoneInterface, public ModeObject /* Method for reading whether in fail-safe mode over dbus */ bool failSafe() const override; + /* Method for setting the failSafePercent over dbus */ + uint64_t target(uint64_t value) override; + private: std::ofstream _log; @@ -95,7 +102,7 @@ class DbusPidZone : public ZoneInterface, public ModeObject double _maximumSetPoint = 0; bool _manualMode = false; const double _minThermalOutputSetPt; - const double _failSafePercent; + double _failSafePercent; std::set _failSafeSensors; diff --git a/pid/zone_interface.hpp b/pid/zone_interface.hpp index a024c0e..9ea89c1 100644 --- a/pid/zone_interface.hpp +++ b/pid/zone_interface.hpp @@ -70,6 +70,7 @@ class ZoneInterface * fail safe. */ virtual double getFailSafePercent() const = 0; + virtual void setFailSafePercent(double newFailSafe) = 0; /** Return if the zone is set to manual mode. false equates to automatic * mode (the default). -- 2.29.2.222.g5d2a92d10f8-goog