blob: 4220e07382c94a0e91a6cd16daf535dc9f2d21a9 [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),
Patrick Venture566a1512018-06-12 14:51:07 -070020 _setpoint(0),
Patrick Ventured8012182018-03-08 08:21:38 -080021 _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 Venturea58197c2018-06-11 15:29:45 -070051 ZoneInterface* _owner;
Patrick Ventured8012182018-03-08 08:21:38 -080052
53 private:
54 // parameters
55 ec::pid_info_t _pid_info;
56 float _setpoint;
57 std::string _id;
58};
59