Add func for Minimum when sensor from DBus
Add function to calculate the minimum value.
Signed-off-by: George Liu <liuxiwei@ieisystem.com>
Change-Id: I9b2650da93795c5768ac6e90102280f9e004e23c
diff --git a/calculate.cpp b/calculate.cpp
index f433751..eee4fa4 100644
--- a/calculate.cpp
+++ b/calculate.cpp
@@ -40,8 +40,19 @@
return *maxIt;
}
+double calculateMinimumValue(std::vector<double>& values)
+{
+ auto maxIt = std::min_element(values.begin(), values.end());
+ if (maxIt == values.end())
+ {
+ return std::numeric_limits<double>::quiet_NaN();
+ }
+ return *maxIt;
+}
+
std::map<Interface, CalculationFunc> calculationIfaces{
{"xyz.openbmc_project.Configuration.Maximum", calculateMaximumValue},
+ {"xyz.openbmc_project.Configuration.Minimum", calculateMinimumValue},
{"xyz.openbmc_project.Configuration.ModifiedMedian",
calculateModifiedMedianValue}};