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/thermalcontroller.hpp b/pid/thermalcontroller.hpp
index 8089da1..317219c 100644
--- a/pid/thermalcontroller.hpp
+++ b/pid/thermalcontroller.hpp
@@ -11,19 +11,27 @@
* A ThermalController is a PID controller that reads a number of sensors and
* provides the set-points for the fans.
*/
+
+enum class ThermalType
+{
+ margin,
+ absolute
+};
+
class ThermalController : public PIDController
{
public:
static std::unique_ptr<PIDController>
createThermalPid(ZoneInterface* owner, const std::string& id,
const std::vector<std::string>& inputs,
- double setpoint, const ec::pidinfo& initial);
+ double setpoint, const ec::pidinfo& initial,
+ const ThermalType& type);
ThermalController(const std::string& id,
const std::vector<std::string>& inputs,
- ZoneInterface* owner) :
+ const ThermalType& type, ZoneInterface* owner) :
PIDController(id, owner),
- _inputs(inputs)
+ _inputs(inputs), type(type)
{
}
@@ -33,4 +41,5 @@
private:
std::vector<std::string> _inputs;
+ ThermalType type;
};