James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "controller.hpp" |
| 4 | #include "ec/pid.hpp" |
| 5 | #include "fan.hpp" |
| 6 | |
| 7 | #include <memory> |
| 8 | #include <vector> |
| 9 | |
| 10 | class ZoneInterface; |
| 11 | |
| 12 | /* |
| 13 | * Base class for PID controllers. Each PID that implements this needs to |
Patrick Venture | 563a356 | 2018-10-30 09:31:26 -0700 | [diff] [blame] | 14 | * provide an inputProc, setptProc, and outputProc. |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 15 | */ |
| 16 | class PIDController : public Controller |
| 17 | { |
| 18 | public: |
| 19 | PIDController(const std::string& id, ZoneInterface* owner) : |
| 20 | Controller(), _owner(owner), _setpoint(0), _id(id) |
| 21 | { |
| 22 | } |
| 23 | |
| 24 | virtual ~PIDController() |
| 25 | { |
| 26 | } |
| 27 | |
Patrick Venture | 5f59c0f | 2018-11-11 12:55:14 -0800 | [diff] [blame] | 28 | virtual double inputProc(void) override = 0; |
| 29 | virtual double setptProc(void) = 0; |
| 30 | virtual void outputProc(double value) override = 0; |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 31 | |
Patrick Venture | ee30648 | 2018-10-30 13:35:37 -0700 | [diff] [blame] | 32 | void process(void) override; |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 33 | |
Patrick Venture | ee30648 | 2018-10-30 13:35:37 -0700 | [diff] [blame] | 34 | std::string getID(void) override |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 35 | { |
| 36 | return _id; |
| 37 | } |
Patrick Venture | 5f59c0f | 2018-11-11 12:55:14 -0800 | [diff] [blame] | 38 | double getSetpoint(void) |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 39 | { |
| 40 | return _setpoint; |
| 41 | } |
Patrick Venture | 5f59c0f | 2018-11-11 12:55:14 -0800 | [diff] [blame] | 42 | void setSetpoint(double setpoint) |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 43 | { |
| 44 | _setpoint = setpoint; |
| 45 | } |
| 46 | |
Patrick Venture | 563a356 | 2018-10-30 09:31:26 -0700 | [diff] [blame] | 47 | ec::pid_info_t* getPIDInfo(void) |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 48 | { |
| 49 | return &_pid_info; |
| 50 | } |
| 51 | |
| 52 | protected: |
| 53 | ZoneInterface* _owner; |
| 54 | |
| 55 | private: |
| 56 | // parameters |
| 57 | ec::pid_info_t _pid_info; |
Patrick Venture | 5f59c0f | 2018-11-11 12:55:14 -0800 | [diff] [blame] | 58 | double _setpoint; |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 59 | std::string _id; |
| 60 | }; |