xref: /openbmc/phosphor-pid-control/conf.hpp (revision 796f06dc)
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     bool unavailableAsFailed;
31 };
32 
33 /*
34  * Structure for holding the configuration of a PID.
35  */
36 struct ControllerInfo
37 {
38     std::string type;                // fan or margin or temp?
39     std::vector<std::string> inputs; // one or more sensors.
40     double setpoint;                 // initial setpoint for thermal.
41     ec::pidinfo pidInfo;             // pid details
42     ec::StepwiseInfo stepwiseInfo;
43     double failSafePercent;
44 };
45 
46 struct CycleTime
47 {
48     /* The time interval every cycle. 0.1 seconds by default */
49     uint64_t cycleIntervalTimeMS = 100; // milliseconds
50 
51     /* The interval of updating thermals. 1 second by default */
52     uint64_t updateThermalsTimeMS = 1000; // milliseconds
53 };
54 
55 /*
56  * General zone structure used for configuration.  A zone is a list of PIDs
57  * and a set of configuration settings.  This structure gets filled out with
58  * the zone configuration settings and not the PID details.
59  */
60 struct ZoneConfig
61 {
62     /* The minimum set-point value we would ever want (typically in RPM) */
63     double minThermalOutput;
64 
65     /* If the sensors are in fail-safe mode, this is the percentage to use. */
66     double failsafePercent;
67 
68     /* Customize time settings for every cycle */
69     CycleTime cycleTime;
70 };
71 
72 using PIDConf = std::map<std::string, ControllerInfo>;
73 
74 constexpr bool DEBUG = false; // enable to print found configuration
75 
76 } // namespace conf
77 } // namespace pid_control
78