Implement remaining stuff
Basic functionality milestone reached!!
This commit is contained in:
37
app/src/Controller.cxx
Normal file
37
app/src/Controller.cxx
Normal 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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user