#include "dogcore.h"
#include "datacollector.h"

DogCore::DogCore(QObject *parent) : QObject(parent)
{
    hour = 255;

    timer = new QTimer(this);
    connect(timer,&QTimer::timeout,this,&DogCore::time_out);
}

DogCore::~DogCore()
{

}

void DogCore::time_out()
{
    chkTime = QDateTime::currentDateTime().toTime_t();
    if((chkTime - dataColShm->time)>30){
        if((system("killall ytDataCollectorCore")) != -1){
            system("/root/bin/ytDataCollectorCore &");
        }
    }
    if((chkTime - dataColShm->influtime)>30){
        if((system("killall ytDeviceTypeInfluxdbWriter")) != -1){
            system("/root/bin/ytDeviceTypeInfluxdbWriter &");
        }
    }
}


void DogCore::start()
{
    time_out();
    timer->start(5000);
}
