James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "controller.hpp" |
| 4 | #include "ec/stepwise.hpp" |
| 5 | #include "fan.hpp" |
| 6 | |
James Feist | 3dfaafd | 2018-09-20 15:46:58 -0700 | [diff] [blame] | 7 | #include <limits> |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 8 | #include <memory> |
| 9 | #include <vector> |
| 10 | |
Patrick Venture | a076487 | 2020-08-08 07:48:43 -0700 | [diff] [blame] | 11 | namespace pid_control |
| 12 | { |
| 13 | |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 14 | class ZoneInterface; |
| 15 | |
| 16 | class StepwiseController : public Controller |
| 17 | { |
| 18 | public: |
| 19 | static std::unique_ptr<Controller> |
Patrick Venture | 563a356 | 2018-10-30 09:31:26 -0700 | [diff] [blame] | 20 | createStepwiseController(ZoneInterface* owner, const std::string& id, |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 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) |
Patrick Venture | a83a3ec | 2020-08-04 09:52:05 -0700 | [diff] [blame] | 29 | {} |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 30 | |
Patrick Venture | 5f59c0f | 2018-11-11 12:55:14 -0800 | [diff] [blame] | 31 | double inputProc(void) override; |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 32 | |
Patrick Venture | 5f59c0f | 2018-11-11 12:55:14 -0800 | [diff] [blame] | 33 | void outputProc(double value) override; |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 34 | |
| 35 | void process(void) override; |
| 36 | |
Patrick Venture | a57477f | 2018-10-30 13:28:14 -0700 | [diff] [blame] | 37 | std::string getID(void) override |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 38 | { |
| 39 | return _id; |
| 40 | } |
| 41 | |
Patrick Venture | eb42820 | 2020-08-18 09:50:46 -0700 | [diff] [blame] | 42 | ec::StepwiseInfo& getStepwiseInfo(void) |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 43 | { |
| 44 | return _stepwise_info; |
| 45 | } |
| 46 | |
Patrick Venture | a5cf208 | 2020-08-13 09:38:17 -0700 | [diff] [blame] | 47 | void setStepwiseInfo(const ec::StepwiseInfo& value) |
| 48 | { |
| 49 | _stepwise_info = value; |
| 50 | } |
| 51 | |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 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; |
Patrick Venture | 5f59c0f | 2018-11-11 12:55:14 -0800 | [diff] [blame] | 60 | double lastInput = std::numeric_limits<double>::quiet_NaN(); |
| 61 | double lastOutput = std::numeric_limits<double>::quiet_NaN(); |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 62 | }; |
Patrick Venture | a076487 | 2020-08-08 07:48:43 -0700 | [diff] [blame] | 63 | |
| 64 | } // namespace pid_control |