1 #pragma once 2 3 #include "ec/pid.hpp" 4 #include "pidcontroller.hpp" 5 6 #include <memory> 7 #include <string> 8 #include <vector> 9 10 /* 11 * A ThermalController is a PID controller that reads a number of sensors and 12 * provides the setpoints for the fans. 13 */ 14 15 enum class ThermalType 16 { 17 margin, 18 absolute 19 }; 20 21 /** 22 * Get the ThermalType for a given string. 23 * 24 * @param[in] typeString - a string representation of a type. 25 * @return the ThermalType representation. 26 */ 27 ThermalType getThermalType(const std::string& typeString); 28 29 /** 30 * Is the type specified a thermal type? 31 * 32 * @param[in] typeString - a string representation of a PID type. 33 * @return true if it's a thermal PID type. 34 */ 35 bool isThermalType(const std::string& typeString); 36 37 class ThermalController : public PIDController 38 { 39 public: 40 static std::unique_ptr<PIDController> 41 createThermalPid(ZoneInterface* owner, const std::string& id, 42 const std::vector<std::string>& inputs, 43 double setpoint, const ec::pidinfo& initial, 44 const ThermalType& type); 45 46 ThermalController(const std::string& id, 47 const std::vector<std::string>& inputs, 48 const ThermalType& type, ZoneInterface* owner) : 49 PIDController(id, owner), 50 _inputs(inputs), type(type) 51 { 52 } 53 54 double inputProc(void) override; 55 double setptProc(void) override; 56 void outputProc(double value) override; 57 58 private: 59 std::vector<std::string> _inputs; 60 ThermalType type; 61 }; 62