Allow multiple inputs to thermal and stepwise controllers
Use std::max to determine which input value to apply.
Also start throwing when inputs are empty as otherwise
there will be a nullptr dereference.
Tested-by: Added multiple inputs and application no longer
segfaults and verifed max was being used. Also added unit
tests.
Change-Id: I7c8eda45b99247b8e92e629f036c9a46c98d9fe2
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/pid/builder.cpp b/pid/builder.cpp
index 55f3e35..261a165 100644
--- a/pid/builder.cpp
+++ b/pid/builder.cpp
@@ -102,8 +102,19 @@
zone->addThermalInput(i);
}
+ ThermalType type;
+ if (info->type == "temp")
+ {
+ type = ThermalType::absolute;
+ }
+ else
+ {
+ type = ThermalType::margin;
+ }
+
auto pid = ThermalController::createThermalPid(
- zone.get(), name, inputs, info->setpoint, info->pidInfo);
+ zone.get(), name, inputs, info->setpoint, info->pidInfo,
+ type);
zone->addThermalPID(std::move(pid));
}