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