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 namespace pid_control 12 { 13 14 /* 15 * A FanController is a PID controller that reads a number of fans and given 16 * the output then tries to set them to the goal values set by the thermal 17 * controllers. 18 */ 19 class FanController : public PIDController 20 { 21 public: 22 static std::unique_ptr<PIDController> 23 createFanPid(ZoneInterface* owner, const std::string& id, 24 const std::vector<std::string>& inputs, 25 const ec::pidinfo& initial); 26 27 FanController(const std::string& id, const std::vector<std::string>& inputs, 28 ZoneInterface* owner) : 29 PIDController(id, owner), 30 _inputs(inputs), _direction(FanSpeedDirection::NEUTRAL) 31 {} 32 33 double inputProc(void) override; 34 double setptProc(void) override; 35 void outputProc(double value) override; 36 37 FanSpeedDirection getFanDirection(void) const 38 { 39 return _direction; 40 } 41 42 void setFanDirection(FanSpeedDirection direction) 43 { 44 _direction = direction; 45 }; 46 47 private: 48 std::vector<std::string> _inputs; 49 FanSpeedDirection _direction; 50 }; 51 52 } // namespace pid_control 53