Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <memory> |
| 4 | #include <vector> |
| 5 | |
| 6 | #include "fan.hpp" |
| 7 | #include "ec/pid.hpp" |
| 8 | |
Patrick Venture | a58197c | 2018-06-11 15:29:45 -0700 | [diff] [blame] | 9 | class ZoneInterface; |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 10 | |
| 11 | /* |
| 12 | * Base class for PID controllers. Each PID that implements this needs to |
| 13 | * provide an input_proc, setpt_proc, and output_proc. |
| 14 | */ |
| 15 | class PIDController |
| 16 | { |
| 17 | public: |
Patrick Venture | a58197c | 2018-06-11 15:29:45 -0700 | [diff] [blame] | 18 | PIDController(const std::string& id, ZoneInterface* owner) |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 19 | : _owner(owner), |
Patrick Venture | 566a151 | 2018-06-12 14:51:07 -0700 | [diff] [blame] | 20 | _setpoint(0), |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 21 | _id(id) |
| 22 | { } |
| 23 | |
| 24 | virtual ~PIDController() { } |
| 25 | |
| 26 | virtual float input_proc(void) = 0; |
| 27 | virtual float setpt_proc(void) = 0; |
| 28 | virtual void output_proc(float value) = 0; |
| 29 | |
| 30 | void pid_process(void); |
| 31 | |
| 32 | std::string get_id(void) |
| 33 | { |
| 34 | return _id; |
| 35 | } |
| 36 | float get_setpoint(void) |
| 37 | { |
| 38 | return _setpoint; |
| 39 | } |
| 40 | void set_setpoint(float setpoint) |
| 41 | { |
| 42 | _setpoint = setpoint; |
| 43 | } |
| 44 | |
| 45 | ec::pid_info_t* get_pid_info(void) |
| 46 | { |
| 47 | return &_pid_info; |
| 48 | } |
| 49 | |
| 50 | protected: |
Patrick Venture | a58197c | 2018-06-11 15:29:45 -0700 | [diff] [blame] | 51 | ZoneInterface* _owner; |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 52 | |
| 53 | private: |
| 54 | // parameters |
| 55 | ec::pid_info_t _pid_info; |
| 56 | float _setpoint; |
| 57 | std::string _id; |
| 58 | }; |
| 59 | |