Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 3 | #include "pid/ec/pid.hpp" |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 4 | #include "pid/ec/stepwise.hpp" |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 5 | |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 6 | #include <map> |
| 7 | #include <string> |
| 8 | #include <vector> |
| 9 | |
Patrick Venture | a076487 | 2020-08-08 07:48:43 -0700 | [diff] [blame] | 10 | namespace pid_control |
| 11 | { |
James Feist | 75eb769 | 2019-02-25 12:50:02 -0800 | [diff] [blame] | 12 | namespace conf |
| 13 | { |
James Feist | f81f288 | 2019-02-26 11:26:36 -0800 | [diff] [blame] | 14 | |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 15 | /* |
| 16 | * General sensor structure used for configuration. |
| 17 | */ |
Patrick Venture | f325231 | 2018-10-30 08:42:53 -0700 | [diff] [blame] | 18 | struct SensorConfig |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 19 | { |
Patrick Venture | 69c5106 | 2019-02-11 09:46:03 -0800 | [diff] [blame] | 20 | /* Used for listen if readPath is passive. */ |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 21 | std::string type; |
| 22 | /* Can be a sensor path or a dbus path. */ |
Patrick Venture | 69c5106 | 2019-02-11 09:46:03 -0800 | [diff] [blame] | 23 | std::string readPath; |
| 24 | std::string writePath; |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 25 | /* min/max values for writing a percentage or error checking. */ |
| 26 | int64_t min; |
| 27 | int64_t max; |
| 28 | int64_t timeout; |
Patrick Venture | 6b9f599 | 2019-09-10 09:18:28 -0700 | [diff] [blame] | 29 | bool ignoreDbusMinMax; |
Alex.Song | 8f73ad7 | 2021-10-07 00:18:27 +0800 | [diff] [blame] | 30 | bool unavailableAsFailed; |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | /* |
| 34 | * Structure for holding the configuration of a PID. |
| 35 | */ |
Patrick Venture | f325231 | 2018-10-30 08:42:53 -0700 | [diff] [blame] | 36 | struct ControllerInfo |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 37 | { |
| 38 | std::string type; // fan or margin or temp? |
| 39 | std::vector<std::string> inputs; // one or more sensors. |
Patrick Venture | 5f59c0f | 2018-11-11 12:55:14 -0800 | [diff] [blame] | 40 | double setpoint; // initial setpoint for thermal. |
Bonnie Lo | 0e8fc39 | 2022-10-05 10:20:55 +0800 | [diff] [blame] | 41 | ec::pidinfo pidInfo; // pid details |
| 42 | ec::StepwiseInfo stepwiseInfo; |
| 43 | }; |
| 44 | |
| 45 | struct 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 Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 52 | }; |
| 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 Venture | f325231 | 2018-10-30 08:42:53 -0700 | [diff] [blame] | 59 | struct ZoneConfig |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 60 | { |
Patrick Venture | f7a2dd5 | 2019-07-16 14:31:13 -0700 | [diff] [blame] | 61 | /* The minimum set-point value we would ever want (typically in RPM) */ |
James Feist | 3484bed | 2019-02-25 13:28:18 -0800 | [diff] [blame] | 62 | double minThermalOutput; |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 63 | |
| 64 | /* If the sensors are in fail-safe mode, this is the percentage to use. */ |
Patrick Venture | 8e2fdb3 | 2019-02-11 09:39:59 -0800 | [diff] [blame] | 65 | double failsafePercent; |
Bonnie Lo | 0e8fc39 | 2022-10-05 10:20:55 +0800 | [diff] [blame] | 66 | |
| 67 | /* Customize time settings for every cycle */ |
| 68 | CycleTime cycleTime; |
Patrick Venture | e620656 | 2018-03-08 15:36:53 -0800 | [diff] [blame] | 69 | }; |
| 70 | |
Patrick Venture | 1df9e87 | 2020-10-08 15:35:01 -0700 | [diff] [blame] | 71 | using PIDConf = std::map<std::string, ControllerInfo>; |
James Feist | f81f288 | 2019-02-26 11:26:36 -0800 | [diff] [blame] | 72 | |
Patrick Venture | 39199b4 | 2020-10-08 14:40:29 -0700 | [diff] [blame] | 73 | constexpr bool DEBUG = false; // enable to print found configuration |
| 74 | |
James Feist | f81f288 | 2019-02-26 11:26:36 -0800 | [diff] [blame] | 75 | } // namespace conf |
Patrick Venture | a076487 | 2020-08-08 07:48:43 -0700 | [diff] [blame] | 76 | } // namespace pid_control |