Implement remaining stuff

Basic functionality milestone reached!!
This commit is contained in:
2022-10-01 15:55:49 +02:00
parent 2ef9d979b0
commit b74f0e87cd
12 changed files with 205 additions and 58 deletions

37
app/src/Controller.cxx Normal file
View File

@@ -0,0 +1,37 @@
#include <chrono>
#include <memory>
#include <Controller.h>
#include <fan/FanCurve.h>
using namespace std;
#define TIMEOUT 500
Controller::Controller(vector<shared_ptr<FanCurve>> curves)
: mFanCurves(curves), mRun(false) {}
Controller::~Controller() { StopFanControlLoop(); }
void Controller::StartFanControlLoop() {
mRun = true;
Loop();
// mWorker = make_unique<thread>(&Controller::Loop, this);
}
void Controller::StopFanControlLoop() {
mRun = false;
// if (mWorker->joinable())
// mWorker->join();
// mWorker.reset();
}
void Controller::Loop() {
while (mRun) {
for (auto c : mFanCurves) {
c->DoFanControl();
}
this_thread::sleep_for(chrono::milliseconds(TIMEOUT));
}
}