Add functions to return the averages and maximums

Add functions to return the input history in a format
that can be used to write the D-Bus properties.

Change-Id: I7a395568dcdce89b5f3e4b6a73d58dc84adaaa7c
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/power-supply/record_manager.cpp b/power-supply/record_manager.cpp
index c3f8984..ec6e917 100644
--- a/power-supply/record_manager.cpp
+++ b/power-supply/record_manager.cpp
@@ -94,6 +94,32 @@
     return true;
 }
 
+auto RecordManager::getAverageRecords() -> DBusRecordList
+{
+    DBusRecordList list;
+
+    for (const auto& r : records)
+    {
+        list.emplace_back(std::get<recTimePos>(r),
+                          std::get<recAvgPos>(r));
+    }
+
+    return list;
+}
+
+auto RecordManager::getMaximumRecords() -> DBusRecordList
+{
+    DBusRecordList list;
+
+    for (const auto& r : records)
+    {
+        list.emplace_back(std::get<recTimePos>(r),
+                          std::get<recMaxPos>(r));
+    }
+
+    return list;
+}
+
 size_t RecordManager::getRawRecordID(
         const std::vector<uint8_t>& data) const
 {
diff --git a/power-supply/record_manager.hpp b/power-supply/record_manager.hpp
index e1a2cfc..8504803 100644
--- a/power-supply/record_manager.hpp
+++ b/power-supply/record_manager.hpp
@@ -108,6 +108,24 @@
         bool add(const std::vector<uint8_t>& rawRecord);
 
         /**
+         * @brief Returns the history of average input power
+         *        in a representation used by D-Bus.
+         *
+         * @return DBusRecordList - A list of averages with
+         *         a timestamp for each entry.
+         */
+        DBusRecordList getAverageRecords();
+
+        /**
+         * @brief Returns the history of maximum input power
+         *        in a representation used by D-Bus.
+         *
+         * @return DBusRecordList - A list of maximums with
+         *         a timestamp for each entry.
+         */
+        DBusRecordList getMaximumRecords();
+
+        /**
          * @brief Converts a Linear Format power number to an integer
          *
          * The PMBus spec describes a 2 byte Linear Format