blob: fa89ad14d2503cf7aba50de05ee642650d1e6c14 [file] [log] [blame]
Patrick Ventured8012182018-03-08 08:21:38 -08001#pragma once
2
3#include <memory>
4#include <vector>
5
6#include "fan.hpp"
7#include "ec/pid.hpp"
8
Patrick Venturea58197c2018-06-11 15:29:45 -07009class ZoneInterface;
Patrick Ventured8012182018-03-08 08:21:38 -080010
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 */
15class PIDController
16{
17 public:
Patrick Venturea58197c2018-06-11 15:29:45 -070018 PIDController(const std::string& id, ZoneInterface* owner)
Patrick Ventured8012182018-03-08 08:21:38 -080019 : _owner(owner),
20 _id(id)
21 { }
22
23 virtual ~PIDController() { }
24
25 virtual float input_proc(void) = 0;
26 virtual float setpt_proc(void) = 0;
27 virtual void output_proc(float value) = 0;
28
29 void pid_process(void);
30
31 std::string get_id(void)
32 {
33 return _id;
34 }
35 float get_setpoint(void)
36 {
37 return _setpoint;
38 }
39 void set_setpoint(float setpoint)
40 {
41 _setpoint = setpoint;
42 }
43
44 ec::pid_info_t* get_pid_info(void)
45 {
46 return &_pid_info;
47 }
48
49 protected:
Patrick Venturea58197c2018-06-11 15:29:45 -070050 ZoneInterface* _owner;
Patrick Ventured8012182018-03-08 08:21:38 -080051
52 private:
53 // parameters
54 ec::pid_info_t _pid_info;
55 float _setpoint;
56 std::string _id;
57};
58