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& get_stepwise_info(void) 43 { 44 return _stepwise_info; 45 } 46 47 protected: 48 ZoneInterface* _owner; 49 50 private: 51 // parameters 52 ec::StepwiseInfo _stepwise_info; 53 std::string _id; 54 std::vector<std::string> _inputs; 55 double lastInput = std::numeric_limits<double>::quiet_NaN(); 56 double lastOutput = std::numeric_limits<double>::quiet_NaN(); 57 }; 58 59 } // namespace pid_control 60