Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 3 | #include "ec/pid.hpp" |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 4 | #include "pidcontroller.hpp" |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 5 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 6 | #include <memory> |
| 7 | #include <string> |
| 8 | #include <vector> |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 9 | |
| 10 | /* |
| 11 | * A ThermalController is a PID controller that reads a number of sensors and |
Patrick Venture | 7280e27 | 2019-02-11 10:45:32 -0800 | [diff] [blame] | 12 | * provides the setpoints for the fans. |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 13 | */ |
James Feist | 734f953 | 2018-11-15 12:13:18 -0800 | [diff] [blame] | 14 | |
| 15 | enum class ThermalType |
| 16 | { |
| 17 | margin, |
| 18 | absolute |
| 19 | }; |
| 20 | |
Patrick Venture | e94bdc4 | 2018-11-15 18:41:21 -0800 | [diff] [blame] | 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 | |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 37 | class ThermalController : public PIDController |
| 38 | { |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 39 | public: |
| 40 | static std::unique_ptr<PIDController> |
Patrick Venture | 563a356 | 2018-10-30 09:31:26 -0700 | [diff] [blame] | 41 | createThermalPid(ZoneInterface* owner, const std::string& id, |
Patrick Venture | 5f59c0f | 2018-11-11 12:55:14 -0800 | [diff] [blame] | 42 | const std::vector<std::string>& inputs, |
James Feist | 734f953 | 2018-11-15 12:13:18 -0800 | [diff] [blame] | 43 | double setpoint, const ec::pidinfo& initial, |
| 44 | const ThermalType& type); |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 45 | |
Patrick Venture | 4a2dc4d | 2018-10-23 09:02:55 -0700 | [diff] [blame] | 46 | ThermalController(const std::string& id, |
| 47 | const std::vector<std::string>& inputs, |
James Feist | 734f953 | 2018-11-15 12:13:18 -0800 | [diff] [blame] | 48 | const ThermalType& type, ZoneInterface* owner) : |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 49 | PIDController(id, owner), |
James Feist | 734f953 | 2018-11-15 12:13:18 -0800 | [diff] [blame] | 50 | _inputs(inputs), type(type) |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 51 | { |
| 52 | } |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 53 | |
Patrick Venture | 5f59c0f | 2018-11-11 12:55:14 -0800 | [diff] [blame] | 54 | double inputProc(void) override; |
| 55 | double setptProc(void) override; |
| 56 | void outputProc(double value) override; |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 57 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 58 | private: |
| 59 | std::vector<std::string> _inputs; |
James Feist | 734f953 | 2018-11-15 12:13:18 -0800 | [diff] [blame] | 60 | ThermalType type; |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 61 | }; |