blob: b9b015c877e4f1540dd6a2d49bb8f60dde4d8768 [file] [log] [blame]
Patrick Ventured8012182018-03-08 08:21:38 -08001#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 */
17class FanController : public PIDController
18{
19 public:
20 static std::unique_ptr<PIDController> CreateFanPid(
Patrick Venturea58197c2018-06-11 15:29:45 -070021 ZoneInterface* owner,
Patrick Ventured8012182018-03-08 08:21:38 -080022 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,
Patrick Venturea58197c2018-06-11 15:29:45 -070028 ZoneInterface* owner)
Patrick Ventured8012182018-03-08 08:21:38 -080029 : 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};