blob: aaccd4b0f3271b02959bd9020e8293d04437c657 [file] [log] [blame]
Patrick Ventured8012182018-03-08 08:21:38 -08001#pragma once
2
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07003#include "controller.hpp"
4#include "ec/pid.hpp"
5#include "fan.hpp"
6
Patrick Ventured8012182018-03-08 08:21:38 -08007#include <memory>
8#include <string>
9#include <vector>
10
Patrick Ventured8012182018-03-08 08:21:38 -080011/*
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 */
16class FanController : public PIDController
17{
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070018 public:
19 static std::unique_ptr<PIDController>
20 CreateFanPid(ZoneInterface* owner, const std::string& id,
21 std::vector<std::string>& inputs, ec::pidinfo initial);
Patrick Ventured8012182018-03-08 08:21:38 -080022
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070023 FanController(const std::string& id, std::vector<std::string>& inputs,
24 ZoneInterface* owner) :
25 PIDController(id, owner),
26 _inputs(inputs), _direction(FanSpeedDirection::NEUTRAL)
27 {
28 }
Patrick Ventured8012182018-03-08 08:21:38 -080029
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070030 float input_proc(void) override;
31 float setpt_proc(void) override;
32 void output_proc(float value) override;
Patrick Ventured8012182018-03-08 08:21:38 -080033
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070034 FanSpeedDirection getFanDirection(void) const
35 {
36 return _direction;
37 }
Patrick Venture566a1512018-06-12 14:51:07 -070038
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070039 void setFanDirection(FanSpeedDirection direction)
40 {
41 _direction = direction;
42 };
Patrick Ventured8012182018-03-08 08:21:38 -080043
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070044 private:
45 std::vector<std::string> _inputs;
46 FanSpeedDirection _direction;
Patrick Ventured8012182018-03-08 08:21:38 -080047};