blob: 57ee43fe3833a436ab94780b5032cf1ff8defabd [file] [log] [blame]
Patrick Ventured8012182018-03-08 08:21:38 -08001#pragma once
2
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07003#include "ec/pid.hpp"
4#include "fan.hpp"
5
Patrick Ventured8012182018-03-08 08:21:38 -08006#include <memory>
7#include <vector>
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{
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070017 public:
18 PIDController(const std::string& id, ZoneInterface* owner) :
19 _owner(owner), _setpoint(0), _id(id)
20 {
21 }
Patrick Ventured8012182018-03-08 08:21:38 -080022
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070023 virtual ~PIDController()
24 {
25 }
Patrick Ventured8012182018-03-08 08:21:38 -080026
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070027 virtual float input_proc(void) = 0;
28 virtual float setpt_proc(void) = 0;
29 virtual void output_proc(float value) = 0;
Patrick Ventured8012182018-03-08 08:21:38 -080030
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070031 void pid_process(void);
Patrick Ventured8012182018-03-08 08:21:38 -080032
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070033 std::string get_id(void)
34 {
35 return _id;
36 }
37 float get_setpoint(void)
38 {
39 return _setpoint;
40 }
41 void set_setpoint(float setpoint)
42 {
43 _setpoint = setpoint;
44 }
Patrick Ventured8012182018-03-08 08:21:38 -080045
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070046 ec::pid_info_t* get_pid_info(void)
47 {
48 return &_pid_info;
49 }
Patrick Ventured8012182018-03-08 08:21:38 -080050
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070051 protected:
52 ZoneInterface* _owner;
Patrick Ventured8012182018-03-08 08:21:38 -080053
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070054 private:
55 // parameters
56 ec::pid_info_t _pid_info;
57 float _setpoint;
58 std::string _id;
Patrick Ventured8012182018-03-08 08:21:38 -080059};