blob: 29f1c33c5f421e912d0e0177d75d44ab3dedfefc [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 -070031/*
32 * Given a path that optionally has a glob portion, fill it out.
33 */
34std::string FixupPath(std::string original);
Patrick Venturea0764872020-08-08 07:48:43 -070035
Patrick Venture39199b42020-10-08 14:40:29 -070036/*
Josh Lehan31058fd2023-01-13 11:06:16 -080037 * Splice together two vectors, "Inputs" and "TempToMargin" from JSON,
38 * into one vector of SensorInput structures containing info from both.
39 */
Patrick Williams19300272025-02-01 08:22:48 -050040std::vector<conf::SensorInput> spliceInputs(
41 const std::vector<std::string>& inputNames,
42 const std::vector<double>& inputTempToMargin,
43 const std::vector<std::string>& missingAcceptableNames);
Josh Lehan31058fd2023-01-13 11:06:16 -080044
45/*
46 * Recovers the original "Inputs" vector from spliceInputs().
47 */
Patrick Williams19300272025-02-01 08:22:48 -050048std::vector<std::string> splitNames(
49 const std::vector<conf::SensorInput>& sensorInputs);
Josh Lehan31058fd2023-01-13 11:06:16 -080050
51/*
Patrick Venture39199b42020-10-08 14:40:29 -070052 * Dump active configuration.
53 */
54void debugPrint(const std::map<std::string, conf::SensorConfig>& sensorConfig,
55 const std::map<int64_t, conf::PIDConf>& zoneConfig,
56 const std::map<int64_t, conf::ZoneConfig>& zoneDetailsConfig);
57
Patrick Venturea0764872020-08-08 07:48:43 -070058} // namespace pid_control