blob: a3b3965eee410d792abdd20b25aedbaae9460534 [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
Patrick Ventureeb428202020-08-18 09:50:46 -070042 ec::StepwiseInfo& getStepwiseInfo(void)
James Feist22c257a2018-08-31 14:07:12 -070043 {
44 return _stepwise_info;
45 }
46
Patrick Venturea5cf2082020-08-13 09:38:17 -070047 void setStepwiseInfo(const ec::StepwiseInfo& value)
48 {
49 _stepwise_info = value;
50 }
51
James Feist22c257a2018-08-31 14:07:12 -070052 protected:
53 ZoneInterface* _owner;
54
55 private:
56 // parameters
57 ec::StepwiseInfo _stepwise_info;
58 std::string _id;
59 std::vector<std::string> _inputs;
Patrick Venture5f59c0f2018-11-11 12:55:14 -080060 double lastInput = std::numeric_limits<double>::quiet_NaN();
61 double lastOutput = std::numeric_limits<double>::quiet_NaN();
James Feist22c257a2018-08-31 14:07:12 -070062};
Patrick Venturea0764872020-08-08 07:48:43 -070063
64} // namespace pid_control