1 #pragma once
2 
3 #include <memory>
4 #include <vector>
5 
6 #include "fan.hpp"
7 #include "ec/pid.hpp"
8 
9 class ZoneInterface;
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:
18         PIDController(const std::string& id, ZoneInterface* owner)
19             : _owner(owner),
20               _setpoint(0),
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:
51         ZoneInterface* _owner;
52 
53     private:
54         // parameters
55         ec::pid_info_t  _pid_info;
56         float           _setpoint;
57         std::string     _id;
58 };
59 
60