xref: /openbmc/phosphor-pid-control/util.hpp (revision 17971efd)
1 #pragma once
2 
3 #include "conf.hpp"
4 #include "pid/ec/pid.hpp"
5 
6 #include <phosphor-logging/log.hpp>
7 #include <sdbusplus/bus.hpp>
8 
9 #include <cstdint>
10 #include <limits>
11 #include <map>
12 #include <string>
13 
14 namespace pid_control
15 {
16 
17 void tryRestartControlLoops(bool first = true);
18 
19 /*
20  * Given a configuration structure, fill out the information we use within the
21  * PID loop.
22  */
23 void initializePIDStruct(ec::pid_info_t* info, const ec::pidinfo& initial);
24 
25 void dumpPIDStruct(ec::pid_info_t* info);
26 
27 struct SensorThresholds
28 {
29     double lowerThreshold = std::numeric_limits<double>::quiet_NaN();
30     double upperThreshold = std::numeric_limits<double>::quiet_NaN();
31 };
32 
33 const std::string sensorintf = "xyz.openbmc_project.Sensor.Value";
34 const std::string criticalThreshInf =
35     "xyz.openbmc_project.Sensor.Threshold.Critical";
36 const std::string propertiesintf = "org.freedesktop.DBus.Properties";
37 
38 /*
39  * Given a path that optionally has a glob portion, fill it out.
40  */
41 std::string FixupPath(std::string original);
42 
43 /*
44  * Dump active configuration.
45  */
46 void debugPrint(const std::map<std::string, conf::SensorConfig>& sensorConfig,
47                 const std::map<int64_t, conf::PIDConf>& zoneConfig,
48                 const std::map<int64_t, conf::ZoneConfig>& zoneDetailsConfig);
49 
50 } // namespace pid_control
51