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 | |
Patrick Venture | 39199b4 | 2020-10-08 14:40:29 -0700 | [diff] [blame] | 6 | #include <cstdint> |
Patrick Venture | a83a3ec | 2020-08-04 09:52:05 -0700 | [diff] [blame] | 7 | #include <limits> |
Patrick Venture | 39199b4 | 2020-10-08 14:40:29 -0700 | [diff] [blame] | 8 | #include <map> |
Patrick Venture | da06428 | 2018-06-12 19:33:47 -0700 | [diff] [blame] | 9 | #include <string> |
Ed Tanous | f8b6e55 | 2025-06-27 13:27:50 -0700 | [diff] [blame^] | 10 | #include <vector> |
Patrick Venture | da06428 | 2018-06-12 19:33:47 -0700 | [diff] [blame] | 11 | |
Patrick Venture | a076487 | 2020-08-08 07:48:43 -0700 | [diff] [blame] | 12 | namespace pid_control |
| 13 | { |
| 14 | |
Hao Jiang | b228cea | 2021-02-20 11:53:09 -0800 | [diff] [blame] | 15 | void tryRestartControlLoops(bool first = true); |
James Feist | 1fe0895 | 2019-05-07 09:17:16 -0700 | [diff] [blame] | 16 | |
James Feist | 0c8223b | 2019-05-08 15:33:33 -0700 | [diff] [blame] | 17 | /* |
| 18 | * Given a configuration structure, fill out the information we use within the |
| 19 | * PID loop. |
| 20 | */ |
| 21 | void initializePIDStruct(ec::pid_info_t* info, const ec::pidinfo& initial); |
| 22 | |
| 23 | void dumpPIDStruct(ec::pid_info_t* info); |
| 24 | |
James Feist | 0c8223b | 2019-05-08 15:33:33 -0700 | [diff] [blame] | 25 | struct SensorThresholds |
| 26 | { |
| 27 | double lowerThreshold = std::numeric_limits<double>::quiet_NaN(); |
| 28 | double upperThreshold = std::numeric_limits<double>::quiet_NaN(); |
| 29 | }; |
| 30 | |
| 31 | const std::string sensorintf = "xyz.openbmc_project.Sensor.Value"; |
| 32 | const std::string criticalThreshInf = |
| 33 | "xyz.openbmc_project.Sensor.Threshold.Critical"; |
| 34 | const std::string propertiesintf = "org.freedesktop.DBus.Properties"; |
| 35 | |
James Feist | 0c8223b | 2019-05-08 15:33:33 -0700 | [diff] [blame] | 36 | /* |
| 37 | * Given a path that optionally has a glob portion, fill it out. |
| 38 | */ |
| 39 | std::string FixupPath(std::string original); |
Patrick Venture | a076487 | 2020-08-08 07:48:43 -0700 | [diff] [blame] | 40 | |
Patrick Venture | 39199b4 | 2020-10-08 14:40:29 -0700 | [diff] [blame] | 41 | /* |
Josh Lehan | 31058fd | 2023-01-13 11:06:16 -0800 | [diff] [blame] | 42 | * Splice together two vectors, "Inputs" and "TempToMargin" from JSON, |
| 43 | * into one vector of SensorInput structures containing info from both. |
| 44 | */ |
Patrick Williams | 1930027 | 2025-02-01 08:22:48 -0500 | [diff] [blame] | 45 | std::vector<conf::SensorInput> spliceInputs( |
| 46 | const std::vector<std::string>& inputNames, |
| 47 | const std::vector<double>& inputTempToMargin, |
| 48 | const std::vector<std::string>& missingAcceptableNames); |
Josh Lehan | 31058fd | 2023-01-13 11:06:16 -0800 | [diff] [blame] | 49 | |
| 50 | /* |
| 51 | * Recovers the original "Inputs" vector from spliceInputs(). |
| 52 | */ |
Patrick Williams | 1930027 | 2025-02-01 08:22:48 -0500 | [diff] [blame] | 53 | std::vector<std::string> splitNames( |
| 54 | const std::vector<conf::SensorInput>& sensorInputs); |
Josh Lehan | 31058fd | 2023-01-13 11:06:16 -0800 | [diff] [blame] | 55 | |
| 56 | /* |
Patrick Venture | 39199b4 | 2020-10-08 14:40:29 -0700 | [diff] [blame] | 57 | * Dump active configuration. |
| 58 | */ |
| 59 | void debugPrint(const std::map<std::string, conf::SensorConfig>& sensorConfig, |
| 60 | const std::map<int64_t, conf::PIDConf>& zoneConfig, |
| 61 | const std::map<int64_t, conf::ZoneConfig>& zoneDetailsConfig); |
| 62 | |
Patrick Venture | a076487 | 2020-08-08 07:48:43 -0700 | [diff] [blame] | 63 | } // namespace pid_control |