Add new PID Class types "power" and "powersum"
Implements this feature:
https://github.com/openbmc/phosphor-pid-control/issues/24
In addition to the existing "temp" and "margin" classes, adding
new "power" and "powersum" Class types.
The "power" class is the same as "temp", but expects D-Bus power
sensors, instead of D-Bus temperature sensors.
The "powersum" class is the same as "power", but sums together all of
the given inputs, instead of finding the maximum.
Signed-off-by: Josh Lehan <krellan@google.com>
Change-Id: I11d8ad8385632658ed061671134be87a560cd02a
diff --git a/test/dbus_util_unittest.cpp b/test/dbus_util_unittest.cpp
index 4896e03..09d1b5c 100644
--- a/test/dbus_util_unittest.cpp
+++ b/test/dbus_util_unittest.cpp
@@ -40,7 +40,11 @@
std::make_tuple("margin", "9",
"/xyz/openbmc_project/sensors/temperature/9"),
std::make_tuple("temp", "123",
- "/xyz/openbmc_project/sensors/temperature/123")));
+ "/xyz/openbmc_project/sensors/temperature/123"),
+ std::make_tuple("power", "9000",
+ "/xyz/openbmc_project/sensors/power/9000"),
+ std::make_tuple("powersum", "total",
+ "/xyz/openbmc_project/sensors/power/total")));
class FindSensorsTest : public ::testing::Test
{
diff --git a/test/pid_thermalcontroller_unittest.cpp b/test/pid_thermalcontroller_unittest.cpp
index 4e71a3b..ab45661 100644
--- a/test/pid_thermalcontroller_unittest.cpp
+++ b/test/pid_thermalcontroller_unittest.cpp
@@ -152,6 +152,27 @@
EXPECT_EQ(5.0, p->inputProc());
}
+TEST(ThermalControllerTest, InputProc_MultipleInputsSummation)
+{
+ // This test verifies inputProc behaves as expected with multiple summation
+ // inputs.
+
+ ZoneMock z;
+
+ std::vector<std::string> inputs = {"fleeting0", "fleeting1"};
+ double setpoint = 10.0;
+ ec::pidinfo initial;
+
+ std::unique_ptr<PIDController> p = ThermalController::createThermalPid(
+ &z, "therm1", inputs, setpoint, initial, ThermalType::summation);
+ EXPECT_FALSE(p == nullptr);
+
+ EXPECT_CALL(z, getCachedValue(StrEq("fleeting0"))).WillOnce(Return(5.0));
+ EXPECT_CALL(z, getCachedValue(StrEq("fleeting1"))).WillOnce(Return(10.0));
+
+ EXPECT_EQ(15.0, p->inputProc());
+}
+
TEST(ThermalControllerTest, NegHysteresis_BehavesAsExpected)
{