1 #pragma once
2 
3 #include "controller.hpp"
4 #include "ec/stepwise.hpp"
5 #include "fan.hpp"
6 
7 #include <limits>
8 #include <memory>
9 #include <vector>
10 
11 namespace pid_control
12 {
13 
14 class ZoneInterface;
15 
16 class StepwiseController : public Controller
17 {
18   public:
19     static std::unique_ptr<Controller>
20         createStepwiseController(ZoneInterface* owner, const std::string& id,
21                                  const std::vector<std::string>& inputs,
22                                  const ec::StepwiseInfo& initial);
23 
24     StepwiseController(const std::string& id,
25                        const std::vector<std::string>& inputs,
26                        ZoneInterface* owner) :
27         Controller(),
28         _owner(owner), _id(id), _inputs(inputs)
29     {}
30 
31     double inputProc(void) override;
32 
33     void outputProc(double value) override;
34 
35     void process(void) override;
36 
37     std::string getID(void) override
38     {
39         return _id;
40     }
41 
42     ec::StepwiseInfo& getStepwiseInfo(void)
43     {
44         return _stepwise_info;
45     }
46 
47     void setStepwiseInfo(const ec::StepwiseInfo& value)
48     {
49         _stepwise_info = value;
50     }
51 
52   protected:
53     ZoneInterface* _owner;
54 
55   private:
56     // parameters
57     ec::StepwiseInfo _stepwise_info;
58     std::string _id;
59     std::vector<std::string> _inputs;
60     double lastInput = std::numeric_limits<double>::quiet_NaN();
61     double lastOutput = std::numeric_limits<double>::quiet_NaN();
62 };
63 
64 } // namespace pid_control
65