blob: 0b1de3cccfb94db88420ecaf9e1ba1e573fb7fbd [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
9class PIDZone;
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 */
15class PIDController
16{
17 public:
18 PIDController(const std::string& id, std::shared_ptr<PIDZone> owner)
19 : _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:
50 std::shared_ptr<PIDZone> _owner;
51
52 private:
53 // parameters
54 ec::pid_info_t _pid_info;
55 float _setpoint;
56 std::string _id;
57};
58