1*d8012181SPatrick Venture #pragma once 2*d8012181SPatrick Venture 3*d8012181SPatrick Venture #include <memory> 4*d8012181SPatrick Venture #include <vector> 5*d8012181SPatrick Venture 6*d8012181SPatrick Venture #include "fan.hpp" 7*d8012181SPatrick Venture #include "ec/pid.hpp" 8*d8012181SPatrick Venture 9*d8012181SPatrick Venture class PIDZone; 10*d8012181SPatrick Venture 11*d8012181SPatrick Venture /* 12*d8012181SPatrick Venture * Base class for PID controllers. Each PID that implements this needs to 13*d8012181SPatrick Venture * provide an input_proc, setpt_proc, and output_proc. 14*d8012181SPatrick Venture */ 15*d8012181SPatrick Venture class PIDController 16*d8012181SPatrick Venture { 17*d8012181SPatrick Venture public: 18*d8012181SPatrick Venture PIDController(const std::string& id, std::shared_ptr<PIDZone> owner) 19*d8012181SPatrick Venture : _owner(owner), 20*d8012181SPatrick Venture _id(id) 21*d8012181SPatrick Venture { } 22*d8012181SPatrick Venture 23*d8012181SPatrick Venture virtual ~PIDController() { } 24*d8012181SPatrick Venture 25*d8012181SPatrick Venture virtual float input_proc(void) = 0; 26*d8012181SPatrick Venture virtual float setpt_proc(void) = 0; 27*d8012181SPatrick Venture virtual void output_proc(float value) = 0; 28*d8012181SPatrick Venture 29*d8012181SPatrick Venture void pid_process(void); 30*d8012181SPatrick Venture 31*d8012181SPatrick Venture std::string get_id(void) 32*d8012181SPatrick Venture { 33*d8012181SPatrick Venture return _id; 34*d8012181SPatrick Venture } 35*d8012181SPatrick Venture float get_setpoint(void) 36*d8012181SPatrick Venture { 37*d8012181SPatrick Venture return _setpoint; 38*d8012181SPatrick Venture } 39*d8012181SPatrick Venture void set_setpoint(float setpoint) 40*d8012181SPatrick Venture { 41*d8012181SPatrick Venture _setpoint = setpoint; 42*d8012181SPatrick Venture } 43*d8012181SPatrick Venture 44*d8012181SPatrick Venture ec::pid_info_t* get_pid_info(void) 45*d8012181SPatrick Venture { 46*d8012181SPatrick Venture return &_pid_info; 47*d8012181SPatrick Venture } 48*d8012181SPatrick Venture 49*d8012181SPatrick Venture protected: 50*d8012181SPatrick Venture std::shared_ptr<PIDZone> _owner; 51*d8012181SPatrick Venture 52*d8012181SPatrick Venture private: 53*d8012181SPatrick Venture // parameters 54*d8012181SPatrick Venture ec::pid_info_t _pid_info; 55*d8012181SPatrick Venture float _setpoint; 56*d8012181SPatrick Venture std::string _id; 57*d8012181SPatrick Venture }; 58*d8012181SPatrick Venture 59