blob: 317219c0e79b55f71c781c29a6003fb9f672bf86 [file] [log] [blame]
Patrick Ventured8012182018-03-08 08:21:38 -08001#pragma once
2
Patrick Ventured8012182018-03-08 08:21:38 -08003#include "ec/pid.hpp"
James Feist22c257a2018-08-31 14:07:12 -07004#include "pidcontroller.hpp"
Patrick Ventured8012182018-03-08 08:21:38 -08005
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07006#include <memory>
7#include <string>
8#include <vector>
Patrick Ventured8012182018-03-08 08:21:38 -08009
10/*
11 * A ThermalController is a PID controller that reads a number of sensors and
12 * provides the set-points for the fans.
13 */
James Feist734f9532018-11-15 12:13:18 -080014
15enum class ThermalType
16{
17 margin,
18 absolute
19};
20
Patrick Ventured8012182018-03-08 08:21:38 -080021class ThermalController : public PIDController
22{
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070023 public:
24 static std::unique_ptr<PIDController>
Patrick Venture563a3562018-10-30 09:31:26 -070025 createThermalPid(ZoneInterface* owner, const std::string& id,
Patrick Venture5f59c0f2018-11-11 12:55:14 -080026 const std::vector<std::string>& inputs,
James Feist734f9532018-11-15 12:13:18 -080027 double setpoint, const ec::pidinfo& initial,
28 const ThermalType& type);
Patrick Ventured8012182018-03-08 08:21:38 -080029
Patrick Venture4a2dc4d2018-10-23 09:02:55 -070030 ThermalController(const std::string& id,
31 const std::vector<std::string>& inputs,
James Feist734f9532018-11-15 12:13:18 -080032 const ThermalType& type, ZoneInterface* owner) :
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070033 PIDController(id, owner),
James Feist734f9532018-11-15 12:13:18 -080034 _inputs(inputs), type(type)
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070035 {
36 }
Patrick Ventured8012182018-03-08 08:21:38 -080037
Patrick Venture5f59c0f2018-11-11 12:55:14 -080038 double inputProc(void) override;
39 double setptProc(void) override;
40 void outputProc(double value) override;
Patrick Ventured8012182018-03-08 08:21:38 -080041
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070042 private:
43 std::vector<std::string> _inputs;
James Feist734f9532018-11-15 12:13:18 -080044 ThermalType type;
Patrick Ventured8012182018-03-08 08:21:38 -080045};