blob: e192fc7deac3b6b94014c73a219e2bf35e9950d6 [file] [log] [blame]
James Feist22c257a2018-08-31 14:07:12 -07001#pragma once
2
3#include "controller.hpp"
4#include "ec/stepwise.hpp"
5#include "fan.hpp"
6
James Feist3dfaafd2018-09-20 15:46:58 -07007#include <limits>
James Feist22c257a2018-08-31 14:07:12 -07008#include <memory>
9#include <vector>
10
Patrick Venturea0764872020-08-08 07:48:43 -070011namespace pid_control
12{
13
James Feist22c257a2018-08-31 14:07:12 -070014class ZoneInterface;
15
16class StepwiseController : public Controller
17{
18 public:
19 static std::unique_ptr<Controller>
Patrick Venture563a3562018-10-30 09:31:26 -070020 createStepwiseController(ZoneInterface* owner, const std::string& id,
James Feist22c257a2018-08-31 14:07:12 -070021 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)
Patrick Venturea83a3ec2020-08-04 09:52:05 -070029 {}
James Feist22c257a2018-08-31 14:07:12 -070030
Patrick Venture5f59c0f2018-11-11 12:55:14 -080031 double inputProc(void) override;
James Feist22c257a2018-08-31 14:07:12 -070032
Patrick Venture5f59c0f2018-11-11 12:55:14 -080033 void outputProc(double value) override;
James Feist22c257a2018-08-31 14:07:12 -070034
35 void process(void) override;
36
Patrick Venturea57477f2018-10-30 13:28:14 -070037 std::string getID(void) override
James Feist22c257a2018-08-31 14:07:12 -070038 {
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;
Patrick Venture5f59c0f2018-11-11 12:55:14 -080055 double lastInput = std::numeric_limits<double>::quiet_NaN();
56 double lastOutput = std::numeric_limits<double>::quiet_NaN();
James Feist22c257a2018-08-31 14:07:12 -070057};
Patrick Venturea0764872020-08-08 07:48:43 -070058
59} // namespace pid_control