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 const std::vector<std::string>& inputs, 22 const ec::pidinfo& initial); 23 24 FanController(const std::string& id, const std::vector<std::string>& inputs, 25 ZoneInterface* owner) : 26 PIDController(id, owner), 27 _inputs(inputs), _direction(FanSpeedDirection::NEUTRAL) 28 { 29 } 30 31 float input_proc(void) override; 32 float setpt_proc(void) override; 33 void output_proc(float value) override; 34 35 FanSpeedDirection getFanDirection(void) const 36 { 37 return _direction; 38 } 39 40 void setFanDirection(FanSpeedDirection direction) 41 { 42 _direction = direction; 43 }; 44 45 private: 46 std::vector<std::string> _inputs; 47 FanSpeedDirection _direction; 48 }; 49