blob: 1a602a2c2b780d2b01b1ca807023d60a8c1f6fcc [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 Venturee94bdc42018-11-15 18:41:21 -080021/**
22 * Get the ThermalType for a given string.
23 *
24 * @param[in] typeString - a string representation of a type.
25 * @return the ThermalType representation.
26 */
27ThermalType getThermalType(const std::string& typeString);
28
29/**
30 * Is the type specified a thermal type?
31 *
32 * @param[in] typeString - a string representation of a PID type.
33 * @return true if it's a thermal PID type.
34 */
35bool isThermalType(const std::string& typeString);
36
Patrick Ventured8012182018-03-08 08:21:38 -080037class ThermalController : public PIDController
38{
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070039 public:
40 static std::unique_ptr<PIDController>
Patrick Venture563a3562018-10-30 09:31:26 -070041 createThermalPid(ZoneInterface* owner, const std::string& id,
Patrick Venture5f59c0f2018-11-11 12:55:14 -080042 const std::vector<std::string>& inputs,
James Feist734f9532018-11-15 12:13:18 -080043 double setpoint, const ec::pidinfo& initial,
44 const ThermalType& type);
Patrick Ventured8012182018-03-08 08:21:38 -080045
Patrick Venture4a2dc4d2018-10-23 09:02:55 -070046 ThermalController(const std::string& id,
47 const std::vector<std::string>& inputs,
James Feist734f9532018-11-15 12:13:18 -080048 const ThermalType& type, ZoneInterface* owner) :
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070049 PIDController(id, owner),
James Feist734f9532018-11-15 12:13:18 -080050 _inputs(inputs), type(type)
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070051 {
52 }
Patrick Ventured8012182018-03-08 08:21:38 -080053
Patrick Venture5f59c0f2018-11-11 12:55:14 -080054 double inputProc(void) override;
55 double setptProc(void) override;
56 void outputProc(double value) override;
Patrick Ventured8012182018-03-08 08:21:38 -080057
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070058 private:
59 std::vector<std::string> _inputs;
James Feist734f9532018-11-15 12:13:18 -080060 ThermalType type;
Patrick Ventured8012182018-03-08 08:21:38 -080061};