Allow setting setpoint based on dynamic thresholds
As we allow dynamic thresholds in dbus-sensors to track
the t-control of dimms etc, we want to be able to set a
setpoint based on a offset from a threshold. This adds
the ability to create a "SetPointOffset" that is a
threshold of the given sensor. For instance a "SetPointOffset"
of "WarningHigh" would get the sensors "WarningHigh" value
then add the "SetPoint" value to it (commonly negative for
WarningHigh/CriticalHigh).
Tested: Turned on debug print and saw correct setpoint being
loaded into config
Change-Id: Idb9760ea5a66347f24573fb26937f8f278834a19
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/util.hpp b/util.hpp
index f472bf8..e40b61f 100644
--- a/util.hpp
+++ b/util.hpp
@@ -3,6 +3,7 @@
#include "pid/ec/pid.hpp"
#include <limits>
+#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
#include <string>
@@ -117,6 +118,34 @@
bool thresholdsAsserted(sdbusplus::bus::bus& bus,
const std::string& service,
const std::string& path) override;
+
+ template <typename T>
+ void getProperty(sdbusplus::bus::bus& bus, const std::string& service,
+ const std::string& path, const std::string& interface,
+ const std::string& propertyName, T& prop)
+ {
+ namespace log = phosphor::logging;
+
+ auto msg = bus.new_method_call(service.c_str(), path.c_str(),
+ propertiesintf.c_str(), "Get");
+
+ msg.append(interface, propertyName);
+
+ std::variant<T> result;
+ try
+ {
+ auto valueResponseMsg = bus.call(msg);
+ valueResponseMsg.read(result);
+ }
+ catch (const sdbusplus::exception::SdBusError& ex)
+ {
+ log::log<log::level::ERR>("Get Property Failed",
+ log::entry("WHAT=%s", ex.what()));
+ throw;
+ }
+
+ prop = std::get<T>(result);
+ }
};
std::string getSensorPath(const std::string& type, const std::string& id);