xref: /openbmc/phosphor-pid-control/conf.hpp (revision a076487a)
1 #pragma once
2 
3 #include "pid/ec/pid.hpp"
4 #include "pid/ec/stepwise.hpp"
5 
6 #include <map>
7 #include <string>
8 #include <vector>
9 
10 namespace pid_control
11 {
12 namespace conf
13 {
14 
15 /*
16  * General sensor structure used for configuration.
17  */
18 struct SensorConfig
19 {
20     /* Used for listen if readPath is passive. */
21     std::string type;
22     /* Can be a sensor path or a dbus path. */
23     std::string readPath;
24     std::string writePath;
25     /* min/max values for writing a percentage or error checking. */
26     int64_t min;
27     int64_t max;
28     int64_t timeout;
29     bool ignoreDbusMinMax;
30 };
31 
32 /*
33  * Structure for holding the configuration of a PID.
34  */
35 struct ControllerInfo
36 {
37     std::string type;                // fan or margin or temp?
38     std::vector<std::string> inputs; // one or more sensors.
39     double setpoint;                 // initial setpoint for thermal.
40     union
41     {
42         ec::pidinfo pidInfo; // pid details
43         ec::StepwiseInfo stepwiseInfo;
44     };
45 };
46 
47 /*
48  * General zone structure used for configuration.  A zone is a list of PIDs
49  * and a set of configuration settings.  This structure gets filled out with
50  * the zone configuration settings and not the PID details.
51  */
52 struct ZoneConfig
53 {
54     /* The minimum set-point value we would ever want (typically in RPM) */
55     double minThermalOutput;
56 
57     /* If the sensors are in fail-safe mode, this is the percentage to use. */
58     double failsafePercent;
59 };
60 
61 using PIDConf = std::map<std::string, struct ControllerInfo>;
62 
63 } // namespace conf
64 } // namespace pid_control
65