Add Average and Maximum classes
These classes will implement the
xyz.openbmc_project.Sensor.Aggregation.History.Average/Maximum
interfaces. Each of these interfaces contains an array of
value/timestamp entries, where the value is either the average
or maximum power as reported by the power supply. The most recent
value will always be in element 0 of the array.
Change-Id: I41b0b84abe146c57f23629bd50acbf9e7fb746ab
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/Makefile.am b/Makefile.am
index 87250db..8fa771c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,11 +6,13 @@
-lstdc++fs \
$(PHOSPHOR_LOGGING_LIBS) \
$(SDBUSPLUS_LIBS) \
- $(PHOSPHOR_DBUS_INTERFACES_LIBS)
+ $(PHOSPHOR_DBUS_INTERFACES_LIBS) \
+ $(OPENPOWER_DBUS_INTERFACES_LIBS)
libpower_la_CXXFLAGS = \
$(PHOSPHOR_LOGGING_CFLAGS) \
$(SDBUSPLUS_CFLAGS) \
- $(PHOSPHOR_DBUS_INTERFACES_CFLAGS)
+ $(PHOSPHOR_DBUS_INTERFACES_CFLAGS) \
+ $(OPENPOWER_DBUS_INTERFACES_CFLAGS)
libpower_la_SOURCES = \
gpio.cpp \
diff --git a/configure.ac b/configure.ac
index 9d38bcc..2ec466c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -30,6 +30,8 @@
AC_MSG_ERROR(["Requires phosphor-logging package."]))
PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces],,\
AC_MSG_ERROR(["Requires phosphor-dbus-interfaces package."]))
+PKG_CHECK_MODULES([OPENPOWER_DBUS_INTERFACES], [openpower-dbus-interfaces],,\
+ AC_MSG_ERROR(["Requires openpower-dbus-interfaces package."]))
# Check for sdbus++
AC_PATH_PROG([SDBUSPLUSPLUS], [sdbus++])
AS_IF([test "x$SDBUSPLUSPLUS" == "x"],
diff --git a/power-supply/average.hpp b/power-supply/average.hpp
new file mode 100644
index 0000000..817f0bf
--- /dev/null
+++ b/power-supply/average.hpp
@@ -0,0 +1,57 @@
+#pragma once
+#include <functional>
+#include <org/open_power/Sensor/Aggregation/History/Average/server.hpp>
+
+namespace witherspoon
+{
+namespace power
+{
+namespace history
+{
+
+template <typename T>
+using ServerObject = typename sdbusplus::server::object::object<T>;
+
+using AverageInterface = sdbusplus::org::open_power::
+ Sensor::Aggregation::History::server::Average;
+
+/**
+ * @class Average
+ *
+ * Implements Sensor.Aggregation.History.Average
+ *
+ * This includes a property that is an array of timestamp/average tuples
+ * and a property to specify the scale.
+ */
+class Average : public ServerObject<AverageInterface>
+{
+ public:
+
+ static constexpr auto name = "average";
+
+ Average() = delete;
+ Average(const Average&) = delete;
+ Average& operator=(const Average&) = delete;
+ Average(Average&&) = delete;
+ Average& operator=(Average&&) = delete;
+ ~Average() = default;
+
+ /**
+ * @brief Constructor
+ *
+ * @param[in] bus - D-Bus object
+ * @param[in] objectPath - the D-Bus object path
+ */
+ Average(sdbusplus::bus::bus& bus,
+ const std::string& objectPath) :
+ ServerObject<AverageInterface>(bus, objectPath.c_str())
+ {
+ unit(Average::Unit::Watts);
+ scale(0);
+ }
+};
+
+
+}
+}
+}
diff --git a/power-supply/maximum.hpp b/power-supply/maximum.hpp
new file mode 100644
index 0000000..e1fbffc
--- /dev/null
+++ b/power-supply/maximum.hpp
@@ -0,0 +1,57 @@
+#pragma once
+#include <functional>
+#include <org/open_power/Sensor/Aggregation/History/Maximum/server.hpp>
+
+namespace witherspoon
+{
+namespace power
+{
+namespace history
+{
+
+template <typename T>
+using ServerObject = typename sdbusplus::server::object::object<T>;
+
+using MaximumInterface = sdbusplus::org::open_power::
+ Sensor::Aggregation::History::server::Maximum;
+
+/**
+ * @class Maximum
+ *
+ * Implements Sensor.Aggregation.History.Maximum
+ *
+ * This includes a property that is an array of timestamp/maximum tuples
+ * and a property to specify the scale.
+ */
+class Maximum : public ServerObject<MaximumInterface>
+{
+ public:
+
+ static constexpr auto name = "maximum";
+
+ Maximum() = delete;
+ Maximum(const Maximum&) = delete;
+ Maximum& operator=(const Maximum&) = delete;
+ Maximum(Maximum&&) = delete;
+ Maximum& operator=(Maximum&&) = delete;
+ ~Maximum() = default;
+
+ /**
+ * @brief Constructor
+ *
+ * @param[in] bus - D-Bus object
+ * @param[in] objectPath - the D-Bus object path
+ */
+ Maximum(sdbusplus::bus::bus& bus,
+ const std::string& objectPath) :
+ ServerObject<MaximumInterface>(bus, objectPath.c_str())
+ {
+ unit(Maximum::Unit::Watts);
+ scale(0);
+ }
+};
+
+
+}
+}
+}