Add stepwise controller
This adds the ability to use stepwise curves alongside
pid control. This creates a base controller class that
pidcontroller and stepwise controller inherit from.
Note: Hysteresis to come in follow-on patch
Tested-by:
Created a stepwise controller and noticed that when it
crossed a threshold that it contributed to the pwm setting.
Change-Id: I6cf842f80eaccafc905d620970afe91e2092d568
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/pid/controller.hpp b/pid/controller.hpp
index 57ee43f..f52c412 100644
--- a/pid/controller.hpp
+++ b/pid/controller.hpp
@@ -3,57 +3,23 @@
#include "ec/pid.hpp"
#include "fan.hpp"
-#include <memory>
-#include <vector>
-
-class ZoneInterface;
+#include <string>
/*
- * Base class for PID controllers. Each PID that implements this needs to
- * provide an input_proc, setpt_proc, and output_proc.
+ * Base class for controllers. Each controller that implements this needs to
+ * provide an input_proc, process, and output_proc.
*/
-class PIDController
-{
- public:
- PIDController(const std::string& id, ZoneInterface* owner) :
- _owner(owner), _setpoint(0), _id(id)
- {
- }
+class ZoneInterface;
- virtual ~PIDController()
- {
- }
+struct Controller
+{
+ virtual ~Controller() = default;
virtual float input_proc(void) = 0;
- virtual float setpt_proc(void) = 0;
+
virtual void output_proc(float value) = 0;
- void pid_process(void);
+ virtual void process(void) = 0;
- std::string get_id(void)
- {
- return _id;
- }
- float get_setpoint(void)
- {
- return _setpoint;
- }
- void set_setpoint(float setpoint)
- {
- _setpoint = setpoint;
- }
-
- ec::pid_info_t* get_pid_info(void)
- {
- return &_pid_info;
- }
-
- protected:
- ZoneInterface* _owner;
-
- private:
- // parameters
- ec::pid_info_t _pid_info;
- float _setpoint;
- std::string _id;
+ virtual std::string get_id(void) = 0;
};