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 |
| 12 | * provides the set-points for the fans. |
| 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 | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 21 | class ThermalController : public PIDController |
| 22 | { |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 23 | public: |
| 24 | static std::unique_ptr<PIDController> |
Patrick Venture | 563a356 | 2018-10-30 09:31:26 -0700 | [diff] [blame] | 25 | createThermalPid(ZoneInterface* owner, const std::string& id, |
Patrick Venture | 5f59c0f | 2018-11-11 12:55:14 -0800 | [diff] [blame] | 26 | const std::vector<std::string>& inputs, |
James Feist | 734f953 | 2018-11-15 12:13:18 -0800 | [diff] [blame] | 27 | double setpoint, const ec::pidinfo& initial, |
| 28 | const ThermalType& type); |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 29 | |
Patrick Venture | 4a2dc4d | 2018-10-23 09:02:55 -0700 | [diff] [blame] | 30 | ThermalController(const std::string& id, |
| 31 | const std::vector<std::string>& inputs, |
James Feist | 734f953 | 2018-11-15 12:13:18 -0800 | [diff] [blame] | 32 | const ThermalType& type, ZoneInterface* owner) : |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 33 | PIDController(id, owner), |
James Feist | 734f953 | 2018-11-15 12:13:18 -0800 | [diff] [blame] | 34 | _inputs(inputs), type(type) |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 35 | { |
| 36 | } |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 37 | |
Patrick Venture | 5f59c0f | 2018-11-11 12:55:14 -0800 | [diff] [blame] | 38 | double inputProc(void) override; |
| 39 | double setptProc(void) override; |
| 40 | void outputProc(double value) override; |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 41 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 42 | private: |
| 43 | std::vector<std::string> _inputs; |
James Feist | 734f953 | 2018-11-15 12:13:18 -0800 | [diff] [blame] | 44 | ThermalType type; |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 45 | }; |