blob: c081ce1e4b8956f0bba9c00935caf745c1c03f55 [file] [log] [blame]
Patrick Ventured8012182018-03-08 08:21:38 -08001#pragma once
2
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07003#include "ec/pid.hpp"
4#include "fan.hpp"
James Feist22c257a2018-08-31 14:07:12 -07005#include "pidcontroller.hpp"
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07006
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,
Patrick Venture4a2dc4d2018-10-23 09:02:55 -070021 const std::vector<std::string>& inputs,
22 ec::pidinfo initial);
Patrick Ventured8012182018-03-08 08:21:38 -080023
Patrick Venture4a2dc4d2018-10-23 09:02:55 -070024 FanController(const std::string& id, const std::vector<std::string>& inputs,
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070025 ZoneInterface* owner) :
26 PIDController(id, owner),
27 _inputs(inputs), _direction(FanSpeedDirection::NEUTRAL)
28 {
29 }
Patrick Ventured8012182018-03-08 08:21:38 -080030
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070031 float input_proc(void) override;
32 float setpt_proc(void) override;
33 void output_proc(float value) override;
Patrick Ventured8012182018-03-08 08:21:38 -080034
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070035 FanSpeedDirection getFanDirection(void) const
36 {
37 return _direction;
38 }
Patrick Venture566a1512018-06-12 14:51:07 -070039
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070040 void setFanDirection(FanSpeedDirection direction)
41 {
42 _direction = direction;
43 };
Patrick Ventured8012182018-03-08 08:21:38 -080044
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070045 private:
46 std::vector<std::string> _inputs;
47 FanSpeedDirection _direction;
Patrick Ventured8012182018-03-08 08:21:38 -080048};