#include "dogthread.h" #include "../ytCore/yt_unit_shm.h" extern YT_UNIT_SHM *ytShm; dogThread::dogThread(QObject *parent, QStringList params) : QThread(parent) { QFile db_dir(QString(DB_PATH)); QDateTime t = QDateTime::currentDateTime(); start_t = t.toTime_t(); start_h = t.time().hour(); if(!db_dir.exists()) system(QString("mkdir -p %1").arg(DB_PATH).toUtf8().data()); Params.clear(); if(params.length()>0) Params.append(params); } void dogThread::start_app() { QString cmd = QString("./%1 ").arg(APP_NAME); if(Params.length()>0) { for(int i=0;icurrentTime.YEAR = curDatetime.date().year()&0xffff; ytShm->currentTime.MONTH = curDatetime.date().month()&0xff; ytShm->currentTime.DAY = curDatetime.date().day()&0xff; ytShm->currentTime.HOUR = curDatetime.time().hour()&0xff; ytShm->currentTime.MINUTE = curDatetime.time().minute()&0xff; ytShm->currentTime.SECOND = curDatetime.time().second()&0xff; ytShm->currentTime.TIMESTAMP = chkTime; for(quint8 i=1;i<60;i++) { if(ytShm->dogTimeList.dogTime[i].ENABLED==0x01) if(ytShm->dogTimeList.dogTime[i].ENABLED==0x01){ if((ytShm->dogTimeList.dogTime[i].LASTFEED(ytShm->dogTimeList.dogTime[i].LASTFEED +ytShm->dogTimeList.dogTime[i].WAITSEC)))) { restart_app = true; break; } } } if(restart_app) { system(QString("killall %1").arg(APP_NAME).toUtf8().data()); usleep(500000); start_app(); }else if(curDatetime.time().hour()!=start_h){ system("/usr/local/bin/clean_mem.sh"); start_h = curDatetime.time().hour(); }else if((QDateTime::fromTime_t(start_t).date().day()!=curDatetime.date().day()) &&(curDatetime.time().hour()>3)&&(curDatetime.time().minute()>3)){ system("/usr/local/bin/reboot.sh"); } sleep(1); } }