Support averaging power values
Support new env variables 'AVERAGE_power* = "true"' in hwmon config file.
When this env variable is set, power value is the calculated average value.
Otherwise, power value is from power*_input by default.
The new average of power is calculated since the last time the sensor's
values were changed and read.
average =
(cur_average*cur_average_interval - pre_average*pre_average_interval) /
(cur_average_interval - pre_average_interval)
hwmon config example:
AVERAGE_power2 = "true"
AVERAGE_power3 = "true"
AVERAGE_power4 = "true"
Tested: Set AVERAGE_power* in p0 OCC hwmon conf but not in p1 OCC hwmon conf,
then get power sensor info with restapi to check the values.
1. The values of p0*power are all average values.
2. The values of p1*power are all input values.
Note:
Delete $(CODE_COVERAGE_CPPFLAGS) in AM_CPPFLAGS in test/Makefile.am.
This option will define NDEBUG during configuration, then assert in
code doesn't work.
Resolves: openbmc/openbmc#3187
Signed-off-by: Carol Wang <wangkair@cn.ibm.com>
Change-Id: I8d97a7b2905c79cd4f2c276b32e7f5590ffc0483
diff --git a/hwmon.hpp b/hwmon.hpp
index 4f4545c..c02ec52 100644
--- a/hwmon.hpp
+++ b/hwmon.hpp
@@ -14,12 +14,16 @@
static constexpr auto ctarget = "target";
static constexpr auto cenable = "enable";
static constexpr auto cfault = "fault";
+static constexpr auto caverage = "average";
+static constexpr auto caverage_interval = "average_interval";
static const std::string input = cinput;
static const std::string label = clabel;
static const std::string target = ctarget;
static const std::string enable = cenable;
static const std::string fault = cfault;
+static const std::string average = caverage;
+static const std::string average_interval = caverage_interval;
} // namespace entry
namespace type