| #ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_THERMAL_CONTROLLER_OPTIMIZER_PID_PID_OPTIMIZER_H_ |
| #define THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_THERMAL_CONTROLLER_OPTIMIZER_PID_PID_OPTIMIZER_H_ |
| |
| #include <cstdint> |
| |
| #include "absl/strings/string_view.h" |
| #include "thermal_config.pb.h" |
| #include "tlbmc/thermal/controller/optimizer/optimizer_logger.h" |
| |
| namespace milotic_tlbmc { |
| namespace thermal { |
| namespace optimizer { |
| |
| struct PidOptimizerConstructParameters { |
| uint32_t tuning_cycles = 10; |
| double target_input_value = 0; |
| uint32_t loop_interval = 100; |
| double max_output = 100; |
| double min_output = 0; |
| ZieglerNicholsPidTuningMode ziegler_nichols_mode = |
| ZieglerNicholsPidTuningMode::BASIC_PID; |
| }; |
| |
| struct PidOptimizerInitializationParameters { |
| double coeff_p = 0; |
| double coeff_i = 0; |
| double coeff_d = 0; |
| }; |
| |
| struct PidOptimizerTuningParameters { |
| double input = 0; |
| uint32_t current_time_ms = 0; |
| }; |
| |
| struct PidOptimizerMetadata { |
| bool initialized = false; |
| }; |
| |
| struct PidOptimizerStates { |
| PidOptimizerInitializationParameters pid_optimizer_init_params; |
| PidOptimizerTuningParameters pid_optimizer_tuning_params; |
| PidOptimizerMetadata pid_optimizer_metadata; |
| }; |
| |
| /* |
| * `PidOptimizer` is the base class for all PID optimization algorithms. |
| */ |
| class PidOptimizer { |
| public: |
| virtual ~PidOptimizer() = default; |
| |
| virtual void Initialize( |
| const PidOptimizerInitializationParameters& params) = 0; |
| virtual double TunePid(const PidOptimizerTuningParameters& params) = 0; |
| virtual bool FinishedTuning() const = 0; |
| |
| virtual double GetCoeffP() const = 0; |
| virtual double GetCoeffI() const = 0; |
| virtual double GetCoeffD() const = 0; |
| |
| static void LogTuningMessage(absl::string_view message) { |
| OptimizerLogger::Log(message); |
| } |
| }; |
| |
| } // namespace optimizer |
| } // namespace thermal |
| } // namespace milotic_tlbmc |
| |
| #endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_THERMAL_CONTROLLER_OPTIMIZER_PID_PID_OPTIMIZER_H_ |