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> createFanPid( 23 ZoneInterface* owner, const std::string& id, 24 const std::vector<std::string>& inputs, const ec::pidinfo& initial); 25 FanController(const std::string & id,const std::vector<std::string> & inputs,ZoneInterface * owner)26 FanController(const std::string& id, const std::vector<std::string>& inputs, 27 ZoneInterface* owner) : 28 PIDController(id, owner), _inputs(inputs), 29 _direction(FanSpeedDirection::NEUTRAL) 30 {} 31 ~FanController(); 32 double inputProc(void) override; 33 double setptProc(void) override; 34 void outputProc(double value) override; 35 getFanDirection(void) const36 FanSpeedDirection getFanDirection(void) const 37 { 38 return _direction; 39 } 40 setFanDirection(FanSpeedDirection direction)41 void setFanDirection(FanSpeedDirection direction) 42 { 43 _direction = direction; 44 }; 45 46 private: 47 std::vector<std::string> _inputs; 48 FanSpeedDirection _direction; 49 50 // Cosmetic only, to reduce frequency of repetitive messages 51 bool failsafeTransition = true; 52 bool failsafePrevState = false; 53 }; 54 55 } // namespace pid_control 56