blob: 18a448e8bfc5b5b1c9aa81ef2b7124d841989798 [file] [log] [blame]
James Feist22c257a2018-08-31 14:07:12 -07001#pragma once
2
3#include "controller.hpp"
4#include "ec/pid.hpp"
5#include "fan.hpp"
6
7#include <memory>
8#include <vector>
9
10class ZoneInterface;
11
12/*
13 * Base class for PID controllers. Each PID that implements this needs to
14 * provide an input_proc, setpt_proc, and output_proc.
15 */
16class 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
28 virtual float input_proc(void) = 0;
29 virtual float setpt_proc(void) = 0;
30 virtual void output_proc(float value) = 0;
31
32 void process(void);
33
34 std::string get_id(void)
35 {
36 return _id;
37 }
38 float get_setpoint(void)
39 {
40 return _setpoint;
41 }
42 void set_setpoint(float setpoint)
43 {
44 _setpoint = setpoint;
45 }
46
47 ec::pid_info_t* get_pid_info(void)
48 {
49 return &_pid_info;
50 }
51
52 protected:
53 ZoneInterface* _owner;
54
55 private:
56 // parameters
57 ec::pid_info_t _pid_info;
58 float _setpoint;
59 std::string _id;
60};