Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Venture | 39199b4 | 2020-10-08 14:40:29 -0700 | [diff] [blame] | 3 | #include "conf.hpp" |
James Feist | 0c8223b | 2019-05-08 15:33:33 -0700 | [diff] [blame] | 4 | #include "pid/ec/pid.hpp" |
| 5 | |
James Feist | 5ec2027 | 2019-07-10 11:59:57 -0700 | [diff] [blame] | 6 | #include <phosphor-logging/log.hpp> |
James Feist | 0c8223b | 2019-05-08 15:33:33 -0700 | [diff] [blame] | 7 | #include <sdbusplus/bus.hpp> |
Patrick Venture | a83a3ec | 2020-08-04 09:52:05 -0700 | [diff] [blame] | 8 | |
Patrick Venture | 39199b4 | 2020-10-08 14:40:29 -0700 | [diff] [blame] | 9 | #include <cstdint> |
Patrick Venture | a83a3ec | 2020-08-04 09:52:05 -0700 | [diff] [blame] | 10 | #include <limits> |
Patrick Venture | 39199b4 | 2020-10-08 14:40:29 -0700 | [diff] [blame] | 11 | #include <map> |
Patrick Venture | da06428 | 2018-06-12 19:33:47 -0700 | [diff] [blame] | 12 | #include <string> |
| 13 | |
Patrick Venture | a076487 | 2020-08-08 07:48:43 -0700 | [diff] [blame] | 14 | namespace pid_control |
| 15 | { |
| 16 | |
Hao Jiang | b228cea | 2021-02-20 11:53:09 -0800 | [diff] [blame] | 17 | void tryRestartControlLoops(bool first = true); |
James Feist | 1fe0895 | 2019-05-07 09:17:16 -0700 | [diff] [blame] | 18 | |
James Feist | 0c8223b | 2019-05-08 15:33:33 -0700 | [diff] [blame] | 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 | |
James Feist | 0c8223b | 2019-05-08 15:33:33 -0700 | [diff] [blame] | 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 | |
James Feist | 0c8223b | 2019-05-08 15:33:33 -0700 | [diff] [blame] | 38 | /* |
| 39 | * Given a path that optionally has a glob portion, fill it out. |
| 40 | */ |
| 41 | std::string FixupPath(std::string original); |
Patrick Venture | a076487 | 2020-08-08 07:48:43 -0700 | [diff] [blame] | 42 | |
Patrick Venture | 39199b4 | 2020-10-08 14:40:29 -0700 | [diff] [blame] | 43 | /* |
Josh Lehan | 31058fd | 2023-01-13 11:06:16 -0800 | [diff] [blame] | 44 | * Splice together two vectors, "Inputs" and "TempToMargin" from JSON, |
| 45 | * into one vector of SensorInput structures containing info from both. |
| 46 | */ |
| 47 | std::vector<conf::SensorInput> |
| 48 | spliceInputs(const std::vector<std::string>& inputNames, |
Josh Lehan | 3f0f7bc | 2023-02-13 01:45:29 -0800 | [diff] [blame] | 49 | const std::vector<double>& inputTempToMargin, |
| 50 | const std::vector<std::string>& missingAcceptableNames); |
Josh Lehan | 31058fd | 2023-01-13 11:06:16 -0800 | [diff] [blame] | 51 | |
| 52 | /* |
| 53 | * Recovers the original "Inputs" vector from spliceInputs(). |
| 54 | */ |
| 55 | std::vector<std::string> |
| 56 | splitNames(const std::vector<conf::SensorInput>& sensorInputs); |
| 57 | |
| 58 | /* |
Patrick Venture | 39199b4 | 2020-10-08 14:40:29 -0700 | [diff] [blame] | 59 | * Dump active configuration. |
| 60 | */ |
| 61 | void debugPrint(const std::map<std::string, conf::SensorConfig>& sensorConfig, |
| 62 | const std::map<int64_t, conf::PIDConf>& zoneConfig, |
| 63 | const std::map<int64_t, conf::ZoneConfig>& zoneDetailsConfig); |
| 64 | |
Patrick Venture | a076487 | 2020-08-08 07:48:43 -0700 | [diff] [blame] | 65 | } // namespace pid_control |