xref: /openbmc/phosphor-pid-control/pid/pidloop.hpp (revision 0e8fc3980a6690d1b2be2b4e96a8018aa1eacc96)
1ce6a3f36SJames Feist #pragma once
2ce6a3f36SJames Feist 
37a98c19aSPatrick Venture #include "pid/zone_interface.hpp"
4ce6a3f36SJames Feist 
5ce6a3f36SJames Feist #include <boost/asio/steady_timer.hpp>
6ce6a3f36SJames Feist 
7a076487aSPatrick Venture namespace pid_control
8a076487aSPatrick Venture {
9a076487aSPatrick Venture 
10ce6a3f36SJames Feist /**
11ce6a3f36SJames Feist  * Main pid control loop for a given zone.
12ce6a3f36SJames Feist  * This function calls itself indefinitely in an async loop to calculate
13ce6a3f36SJames Feist  * fan outputs based on thermal inputs.
14ce6a3f36SJames Feist  *
157a98c19aSPatrick Venture  * @param[in] zone - ptr to the ZoneInterface implementation for this loop.
16ce6a3f36SJames Feist  * @param[in] timer - boost timer used for async callback.
17b6a0b89eSHao Jiang  * @param[in] isCanceling - bool ptr to indicate whether pidControlLoop is being
18b6a0b89eSHao Jiang  * canceled.
19ce6a3f36SJames Feist  * @param[in] first - boolean to denote if initialization needs to be run.
20*0e8fc398SBonnie Lo  * @param[in] cycleCnt - loop timer counter.
21ce6a3f36SJames Feist  */
225301aae3SJohnathan Mantey void pidControlLoop(std::shared_ptr<ZoneInterface> zone,
235301aae3SJohnathan Mantey                     std::shared_ptr<boost::asio::steady_timer> timer,
24b6a0b89eSHao Jiang                     const bool* isCanceling, bool first = true,
25*0e8fc398SBonnie Lo                     uint64_t cycleCnt = 0);
26a076487aSPatrick Venture 
27a076487aSPatrick Venture } // namespace pid_control
28