blob: d7d34f57b395447fcc62dd92b03bf82ab551b23e [file] [log] [blame]
Patrick Venturee6206562018-03-08 15:36:53 -08001#pragma once
2
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07003#include "pid/ec/pid.hpp"
James Feist22c257a2018-08-31 14:07:12 -07004#include "pid/ec/stepwise.hpp"
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07005
Patrick Venturee6206562018-03-08 15:36:53 -08006#include <map>
7#include <string>
8#include <vector>
9
Patrick Venturea0764872020-08-08 07:48:43 -070010namespace pid_control
11{
James Feist75eb7692019-02-25 12:50:02 -080012namespace conf
13{
James Feistf81f2882019-02-26 11:26:36 -080014
Patrick Venturee6206562018-03-08 15:36:53 -080015/*
16 * General sensor structure used for configuration.
17 */
Patrick Venturef3252312018-10-30 08:42:53 -070018struct SensorConfig
Patrick Venturee6206562018-03-08 15:36:53 -080019{
Patrick Venture69c51062019-02-11 09:46:03 -080020 /* Used for listen if readPath is passive. */
Patrick Venturee6206562018-03-08 15:36:53 -080021 std::string type;
22 /* Can be a sensor path or a dbus path. */
Patrick Venture69c51062019-02-11 09:46:03 -080023 std::string readPath;
24 std::string writePath;
Patrick Venturee6206562018-03-08 15:36:53 -080025 /* min/max values for writing a percentage or error checking. */
26 int64_t min;
27 int64_t max;
28 int64_t timeout;
Patrick Venture6b9f5992019-09-10 09:18:28 -070029 bool ignoreDbusMinMax;
Alex.Song8f73ad72021-10-07 00:18:27 +080030 bool unavailableAsFailed;
Patrick Venturee6206562018-03-08 15:36:53 -080031};
32
33/*
34 * Structure for holding the configuration of a PID.
35 */
Patrick Venturef3252312018-10-30 08:42:53 -070036struct ControllerInfo
Patrick Venturee6206562018-03-08 15:36:53 -080037{
38 std::string type; // fan or margin or temp?
39 std::vector<std::string> inputs; // one or more sensors.
Patrick Venture5f59c0f2018-11-11 12:55:14 -080040 double setpoint; // initial setpoint for thermal.
Bonnie Lo0e8fc392022-10-05 10:20:55 +080041 ec::pidinfo pidInfo; // pid details
42 ec::StepwiseInfo stepwiseInfo;
43};
44
45struct CycleTime
46{
47 /* The time interval every cycle. 0.1 seconds by default */
48 uint64_t cycleIntervalTimeMS = 100; // milliseconds
49
50 /* The interval of updating thermals. 1 second by default */
51 uint64_t updateThermalsTimeMS = 1000; // milliseconds
Patrick Venturee6206562018-03-08 15:36:53 -080052};
53
54/*
55 * General zone structure used for configuration. A zone is a list of PIDs
56 * and a set of configuration settings. This structure gets filled out with
57 * the zone configuration settings and not the PID details.
58 */
Patrick Venturef3252312018-10-30 08:42:53 -070059struct ZoneConfig
Patrick Venturee6206562018-03-08 15:36:53 -080060{
Patrick Venturef7a2dd52019-07-16 14:31:13 -070061 /* The minimum set-point value we would ever want (typically in RPM) */
James Feist3484bed2019-02-25 13:28:18 -080062 double minThermalOutput;
Patrick Venturee6206562018-03-08 15:36:53 -080063
64 /* If the sensors are in fail-safe mode, this is the percentage to use. */
Patrick Venture8e2fdb32019-02-11 09:39:59 -080065 double failsafePercent;
Bonnie Lo0e8fc392022-10-05 10:20:55 +080066
67 /* Customize time settings for every cycle */
68 CycleTime cycleTime;
Patrick Venturee6206562018-03-08 15:36:53 -080069};
70
Patrick Venture1df9e872020-10-08 15:35:01 -070071using PIDConf = std::map<std::string, ControllerInfo>;
James Feistf81f2882019-02-26 11:26:36 -080072
Patrick Venture39199b42020-10-08 14:40:29 -070073constexpr bool DEBUG = false; // enable to print found configuration
74
James Feistf81f2882019-02-26 11:26:36 -080075} // namespace conf
Patrick Venturea0764872020-08-08 07:48:43 -070076} // namespace pid_control