1 #pragma once 2 3 #include "ec/pid.hpp" 4 #include "fan.hpp" 5 #include "pidcontroller.hpp" 6 7 #include <memory> 8 #include <string> 9 #include <vector> 10 11 /* 12 * A FanController is a PID controller that reads a number of fans and given 13 * the output then tries to set them to the goal values set by the thermal 14 * controllers. 15 */ 16 class FanController : public PIDController 17 { 18 public: 19 static std::unique_ptr<PIDController> 20 CreateFanPid(ZoneInterface* owner, const std::string& id, 21 std::vector<std::string>& inputs, ec::pidinfo initial); 22 23 FanController(const std::string& id, std::vector<std::string>& inputs, 24 ZoneInterface* owner) : 25 PIDController(id, owner), 26 _inputs(inputs), _direction(FanSpeedDirection::NEUTRAL) 27 { 28 } 29 30 float input_proc(void) override; 31 float setpt_proc(void) override; 32 void output_proc(float value) override; 33 34 FanSpeedDirection getFanDirection(void) const 35 { 36 return _direction; 37 } 38 39 void setFanDirection(FanSpeedDirection direction) 40 { 41 _direction = direction; 42 }; 43 44 private: 45 std::vector<std::string> _inputs; 46 FanSpeedDirection _direction; 47 }; 48