#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)); 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<64;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(); } sleep(1); } }