blob: 7617562de11222b9b40adccfd78ba06c957e9692 [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
James Feist5ec20272019-07-10 11:59:57 -07006#include <phosphor-logging/log.hpp>
James Feist0c8223b2019-05-08 15:33:33 -07007#include <sdbusplus/bus.hpp>
Patrick Venturea83a3ec2020-08-04 09:52:05 -07008
Patrick Venture39199b42020-10-08 14:40:29 -07009#include <cstdint>
Patrick Venturea83a3ec2020-08-04 09:52:05 -070010#include <limits>
Patrick Venture39199b42020-10-08 14:40:29 -070011#include <map>
Patrick Ventureda064282018-06-12 19:33:47 -070012#include <string>
13
Patrick Venturea0764872020-08-08 07:48:43 -070014namespace pid_control
15{
16
Hao Jiangb228cea2021-02-20 11:53:09 -080017void tryRestartControlLoops(bool first = true);
James Feist1fe08952019-05-07 09:17:16 -070018
James Feist0c8223b2019-05-08 15:33:33 -070019/*
20 * Given a configuration structure, fill out the information we use within the
21 * PID loop.
22 */
23void initializePIDStruct(ec::pid_info_t* info, const ec::pidinfo& initial);
24
25void dumpPIDStruct(ec::pid_info_t* info);
26
James Feist0c8223b2019-05-08 15:33:33 -070027struct SensorThresholds
28{
29 double lowerThreshold = std::numeric_limits<double>::quiet_NaN();
30 double upperThreshold = std::numeric_limits<double>::quiet_NaN();
31};
32
33const std::string sensorintf = "xyz.openbmc_project.Sensor.Value";
34const std::string criticalThreshInf =
35 "xyz.openbmc_project.Sensor.Threshold.Critical";
36const std::string propertiesintf = "org.freedesktop.DBus.Properties";
37
James Feist0c8223b2019-05-08 15:33:33 -070038/*
39 * Given a path that optionally has a glob portion, fill it out.
40 */
41std::string FixupPath(std::string original);
Patrick Venturea0764872020-08-08 07:48:43 -070042
Patrick Venture39199b42020-10-08 14:40:29 -070043/*
Josh Lehan31058fd2023-01-13 11:06:16 -080044 * Splice together two vectors, "Inputs" and "TempToMargin" from JSON,
45 * into one vector of SensorInput structures containing info from both.
46 */
47std::vector<conf::SensorInput>
48 spliceInputs(const std::vector<std::string>& inputNames,
Josh Lehan3f0f7bc2023-02-13 01:45:29 -080049 const std::vector<double>& inputTempToMargin,
50 const std::vector<std::string>& missingAcceptableNames);
Josh Lehan31058fd2023-01-13 11:06:16 -080051
52/*
53 * Recovers the original "Inputs" vector from spliceInputs().
54 */
55std::vector<std::string>
56 splitNames(const std::vector<conf::SensorInput>& sensorInputs);
57
58/*
Patrick Venture39199b42020-10-08 14:40:29 -070059 * Dump active configuration.
60 */
61void 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 Venturea0764872020-08-08 07:48:43 -070065} // namespace pid_control