-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackgroundservice.cpp
41 lines (38 loc) · 1.17 KB
/
backgroundservice.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "backgroundservice.h"
BackgroundService::BackgroundService(int argc, char *argv[], QObject *parent) : QObject(parent)
{
this->runningconfig=new ScoreCheckingConfig; //create an instance of ScoreCheckingConfig
this->app= new QCoreApplication(argc,argv);
}
BackgroundService::~BackgroundService()
{
this->saveonexit();
}
void BackgroundService::LoadConfig(std::string configpath)
{
loadConfigBIN(*this->runningconfig, configpath.c_str());
}
void BackgroundService::Run()
{
std::cout << "ScoringEngine background mode started...\n";
this->setup();
this->app->exec();
}
void BackgroundService::mainloop()
{
//std::cout << "More Done??...\n";
this->curtime=std::chrono::system_clock::now();
this->runningconfig->GenerateScoreReport();
}
void BackgroundService::setup()
{
this->timer=new QTimer();
connect(timer, SIGNAL(timeout()),this, SLOT(mainloop()));
if (this->runningconfig->checkSeconds<1)this->runningconfig->checkSeconds=30;
timer->start(this->runningconfig->checkSeconds*1000);
}
void BackgroundService::saveonexit()
{
saveConfigBIN(*this->runningconfig, "config.bin");
std::cout << "Config saved ... exiting\n";
}