Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 3 | #include "ec/pid.hpp" |
| 4 | #include "fan.hpp" |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 5 | #include "pidcontroller.hpp" |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 6 | |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 7 | #include <memory> |
| 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 11 | /* |
| 12 | * A FanController is a PID controller that reads a number of fans and given |
| 13 | * the output then tries to set them to the goal values set by the thermal |
| 14 | * controllers. |
| 15 | */ |
| 16 | class FanController : public PIDController |
| 17 | { |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 18 | public: |
| 19 | static std::unique_ptr<PIDController> |
| 20 | CreateFanPid(ZoneInterface* owner, const std::string& id, |
Patrick Venture | 4a2dc4d | 2018-10-23 09:02:55 -0700 | [diff] [blame] | 21 | const std::vector<std::string>& inputs, |
| 22 | ec::pidinfo initial); |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 23 | |
Patrick Venture | 4a2dc4d | 2018-10-23 09:02:55 -0700 | [diff] [blame] | 24 | FanController(const std::string& id, const std::vector<std::string>& inputs, |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 25 | ZoneInterface* owner) : |
| 26 | PIDController(id, owner), |
| 27 | _inputs(inputs), _direction(FanSpeedDirection::NEUTRAL) |
| 28 | { |
| 29 | } |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 30 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 31 | float input_proc(void) override; |
| 32 | float setpt_proc(void) override; |
| 33 | void output_proc(float value) override; |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 34 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 35 | FanSpeedDirection getFanDirection(void) const |
| 36 | { |
| 37 | return _direction; |
| 38 | } |
Patrick Venture | 566a151 | 2018-06-12 14:51:07 -0700 | [diff] [blame] | 39 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 40 | void setFanDirection(FanSpeedDirection direction) |
| 41 | { |
| 42 | _direction = direction; |
| 43 | }; |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 44 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 45 | private: |
| 46 | std::vector<std::string> _inputs; |
| 47 | FanSpeedDirection _direction; |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 48 | }; |