1 #pragma once 2 3 #include <memory> 4 #include <vector> 5 6 #include "fan.hpp" 7 #include "ec/pid.hpp" 8 9 class 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 */ 15 class PIDController 16 { 17 public: 18 PIDController(const std::string& id, 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 PIDZone* _owner; 51 52 private: 53 // parameters 54 ec::pid_info_t _pid_info; 55 float _setpoint; 56 std::string _id; 57 }; 58 59