blob: 75433cbf5110c7ad0ee4b67d5c63d9cd600a6882 [file] [log] [blame]
Patrick Venturee6206562018-03-08 15:36:53 -08001#pragma once
2
Patrick Venture39199b42020-10-08 14:40:29 -07003#include "conf.hpp"
James Feist0c8223b2019-05-08 15:33:33 -07004#include "pid/ec/pid.hpp"
5
Patrick Venture39199b42020-10-08 14:40:29 -07006#include <cstdint>
Patrick Venturea83a3ec2020-08-04 09:52:05 -07007#include <limits>
Patrick Venture39199b42020-10-08 14:40:29 -07008#include <map>
Patrick Ventureda064282018-06-12 19:33:47 -07009#include <string>
Ed Tanousf8b6e552025-06-27 13:27:50 -070010#include <vector>
Patrick Ventureda064282018-06-12 19:33:47 -070011
Patrick Venturea0764872020-08-08 07:48:43 -070012namespace pid_control
13{
14
Hao Jiangb228cea2021-02-20 11:53:09 -080015void tryRestartControlLoops(bool first = true);
James Feist1fe08952019-05-07 09:17:16 -070016
James Feist0c8223b2019-05-08 15:33:33 -070017/*
18 * Given a configuration structure, fill out the information we use within the
19 * PID loop.
20 */
21void initializePIDStruct(ec::pid_info_t* info, const ec::pidinfo& initial);
22
23void dumpPIDStruct(ec::pid_info_t* info);
24
James Feist0c8223b2019-05-08 15:33:33 -070025struct SensorThresholds
26{
27 double lowerThreshold = std::numeric_limits<double>::quiet_NaN();
28 double upperThreshold = std::numeric_limits<double>::quiet_NaN();
29};
30
James Feist0c8223b2019-05-08 15:33:33 -070031const std::string criticalThreshInf =
32 "xyz.openbmc_project.Sensor.Threshold.Critical";
33const std::string propertiesintf = "org.freedesktop.DBus.Properties";
34
James Feist0c8223b2019-05-08 15:33:33 -070035/*
36 * Given a path that optionally has a glob portion, fill it out.
37 */
38std::string FixupPath(std::string original);
Patrick Venturea0764872020-08-08 07:48:43 -070039
Patrick Venture39199b42020-10-08 14:40:29 -070040/*
Josh Lehan31058fd2023-01-13 11:06:16 -080041 * Splice together two vectors, "Inputs" and "TempToMargin" from JSON,
42 * into one vector of SensorInput structures containing info from both.
43 */
Patrick Williams19300272025-02-01 08:22:48 -050044std::vector<conf::SensorInput> spliceInputs(
45 const std::vector<std::string>& inputNames,
46 const std::vector<double>& inputTempToMargin,
47 const std::vector<std::string>& missingAcceptableNames);
Josh Lehan31058fd2023-01-13 11:06:16 -080048
49/*
50 * Recovers the original "Inputs" vector from spliceInputs().
51 */
Patrick Williams19300272025-02-01 08:22:48 -050052std::vector<std::string> splitNames(
53 const std::vector<conf::SensorInput>& sensorInputs);
Josh Lehan31058fd2023-01-13 11:06:16 -080054
55/*
Patrick Venture39199b42020-10-08 14:40:29 -070056 * Dump active configuration.
57 */
58void debugPrint(const std::map<std::string, conf::SensorConfig>& sensorConfig,
59 const std::map<int64_t, conf::PIDConf>& zoneConfig,
60 const std::map<int64_t, conf::ZoneConfig>& zoneDetailsConfig);
61
Patrick Venturea0764872020-08-08 07:48:43 -070062} // namespace pid_control