blob: 7eb78bfa52cb54c85b247fe9bf96533d540412aa [file] [log] [blame]
James Feistce6a3f32019-03-12 11:20:16 -07001#pragma once
2
Patrick Venture7a98c192020-08-12 08:35:16 -07003#include "pid/zone_interface.hpp"
James Feistce6a3f32019-03-12 11:20:16 -07004
5#include <boost/asio/steady_timer.hpp>
6
Ed Tanousf8b6e552025-06-27 13:27:50 -07007#include <cstdint>
8#include <memory>
9
Patrick Venturea0764872020-08-08 07:48:43 -070010namespace pid_control
11{
12
James Feistce6a3f32019-03-12 11:20:16 -070013/**
14 * Main pid control loop for a given zone.
15 * This function calls itself indefinitely in an async loop to calculate
16 * fan outputs based on thermal inputs.
17 *
Patrick Venture7a98c192020-08-12 08:35:16 -070018 * @param[in] zone - ptr to the ZoneInterface implementation for this loop.
James Feistce6a3f32019-03-12 11:20:16 -070019 * @param[in] timer - boost timer used for async callback.
Hao Jiangb6a0b892021-02-21 18:00:45 -080020 * @param[in] isCanceling - bool ptr to indicate whether pidControlLoop is being
21 * canceled.
James Feistce6a3f32019-03-12 11:20:16 -070022 * @param[in] first - boolean to denote if initialization needs to be run.
Bonnie Lo0e8fc392022-10-05 10:20:55 +080023 * @param[in] cycleCnt - loop timer counter.
James Feistce6a3f32019-03-12 11:20:16 -070024 */
Ed Tanousd2768c52025-06-26 11:42:57 -070025void pidControlLoop(const std::shared_ptr<ZoneInterface>& zone,
26 const std::shared_ptr<boost::asio::steady_timer>& timer,
Hao Jiangb6a0b892021-02-21 18:00:45 -080027 const bool* isCanceling, bool first = true,
Bonnie Lo0e8fc392022-10-05 10:20:55 +080028 uint64_t cycleCnt = 0);
Patrick Venturea0764872020-08-08 07:48:43 -070029
30} // namespace pid_control