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