Add func for sum value when sensor from DBus

Add a function that calculates the sum of all values.

Signed-off-by: George Liu <liuxiwei@ieisystem.com>
Change-Id: I922aab1a034be5c17f8725298ead99b113da5b5f
diff --git a/calculate.cpp b/calculate.cpp
index eee4fa4..63e3488 100644
--- a/calculate.cpp
+++ b/calculate.cpp
@@ -1,6 +1,7 @@
 #include "calculate.hpp"
 
 #include <limits>
+#include <numeric>
 
 namespace phosphor::virtual_sensor
 {
@@ -50,9 +51,19 @@
     return *maxIt;
 }
 
+double calculateSumValue(std::vector<double>& values)
+{
+    if (values.empty())
+    {
+        return std::numeric_limits<double>::quiet_NaN();
+    }
+    return std::accumulate(values.begin(), values.end(), 0.0);
+}
+
 std::map<Interface, CalculationFunc> calculationIfaces{
     {"xyz.openbmc_project.Configuration.Maximum", calculateMaximumValue},
     {"xyz.openbmc_project.Configuration.Minimum", calculateMinimumValue},
+    {"xyz.openbmc_project.Configuration.Sum", calculateSumValue},
     {"xyz.openbmc_project.Configuration.ModifiedMedian",
      calculateModifiedMedianValue}};