blob: 5a8dc3b3f7948f19c1827a99ad4ae4d779903678 [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) :
Patrick Williamsbd63bca2024-08-16 15:21:10 -040027 Controller(), _owner(owner), _id(id), _inputs(inputs)
Patrick Venturea83a3ec2020-08-04 09:52:05 -070028 {}
James Feist22c257a2018-08-31 14:07:12 -070029
Patrick Venture5f59c0f2018-11-11 12:55:14 -080030 double inputProc(void) override;
James Feist22c257a2018-08-31 14:07:12 -070031
Patrick Venture5f59c0f2018-11-11 12:55:14 -080032 void outputProc(double value) override;
James Feist22c257a2018-08-31 14:07:12 -070033
34 void process(void) override;
35
Patrick Venturea57477f2018-10-30 13:28:14 -070036 std::string getID(void) override
James Feist22c257a2018-08-31 14:07:12 -070037 {
38 return _id;
39 }
40
Patrick Ventureeb428202020-08-18 09:50:46 -070041 ec::StepwiseInfo& getStepwiseInfo(void)
James Feist22c257a2018-08-31 14:07:12 -070042 {
43 return _stepwise_info;
44 }
45
Patrick Venturea5cf2082020-08-13 09:38:17 -070046 void setStepwiseInfo(const ec::StepwiseInfo& value)
47 {
48 _stepwise_info = value;
49 }
50
James Feist22c257a2018-08-31 14:07:12 -070051 protected:
52 ZoneInterface* _owner;
53
54 private:
55 // parameters
56 ec::StepwiseInfo _stepwise_info;
57 std::string _id;
58 std::vector<std::string> _inputs;
Patrick Venture5f59c0f2018-11-11 12:55:14 -080059 double lastInput = std::numeric_limits<double>::quiet_NaN();
60 double lastOutput = std::numeric_limits<double>::quiet_NaN();
James Feist22c257a2018-08-31 14:07:12 -070061};
Patrick Venturea0764872020-08-08 07:48:43 -070062
63} // namespace pid_control