blob: d14aef72b968134fbf3a37d29b15cb7cde143ffa [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>
Patrick Venture563a3562018-10-30 09:31:26 -070020 createFanPid(ZoneInterface* owner, const std::string& id,
Patrick Venture4a2dc4d2018-10-23 09:02:55 -070021 const std::vector<std::string>& inputs,
Patrick Venturef77d5a52018-10-23 09:32:52 -070022 const 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)
Patrick Venturea83a3ec2020-08-04 09:52:05 -070028 {}
Patrick Ventured8012182018-03-08 08:21:38 -080029
Patrick Venture5f59c0f2018-11-11 12:55:14 -080030 double inputProc(void) override;
31 double setptProc(void) override;
32 void outputProc(double 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};