blob: 1eb683ccfc0a3cd05b3a4f7c579ccc100b61bfb2 [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
31const std::string sensorintf = "xyz.openbmc_project.Sensor.Value";
32const std::string criticalThreshInf =
33 "xyz.openbmc_project.Sensor.Threshold.Critical";
34const std::string propertiesintf = "org.freedesktop.DBus.Properties";
35
James Feist0c8223b2019-05-08 15:33:33 -070036/*
37 * Given a path that optionally has a glob portion, fill it out.
38 */
39std::string FixupPath(std::string original);
Patrick Venturea0764872020-08-08 07:48:43 -070040
Patrick Venture39199b42020-10-08 14:40:29 -070041/*
Josh Lehan31058fd2023-01-13 11:06:16 -080042 * Splice together two vectors, "Inputs" and "TempToMargin" from JSON,
43 * into one vector of SensorInput structures containing info from both.
44 */
Patrick Williams19300272025-02-01 08:22:48 -050045std::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 Lehan31058fd2023-01-13 11:06:16 -080049
50/*
51 * Recovers the original "Inputs" vector from spliceInputs().
52 */
Patrick Williams19300272025-02-01 08:22:48 -050053std::vector<std::string> splitNames(
54 const std::vector<conf::SensorInput>& sensorInputs);
Josh Lehan31058fd2023-01-13 11:06:16 -080055
56/*
Patrick Venture39199b42020-10-08 14:40:29 -070057 * Dump active configuration.
58 */
59void 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 Venturea0764872020-08-08 07:48:43 -070063} // namespace pid_control