12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #include "databoardcore.h"
- #include "../ytDashBoardDog/dataprecess.h"
- DataBoardCore::DataBoardCore(QObject *parent) : QObject(parent)
- {
- mDay = -1;
- dbThread = new DatabaseThread(this);
- ws = new WebSocketServer(this);
- logThread = new LogThread(this);
- infoServer = new InfoCenterServer(this);
- timer = new QTimer(this);
- connect(ws,&WebSocketServer::weblog,this,&DataBoardCore::weblog);
- connect(infoServer,&InfoCenterServer::weblog,this,&DataBoardCore::weblog);
- connect(timer,&QTimer::timeout,this,&DataBoardCore::timeout);
- qRegisterMetaType<QList<QStringList>>("QList<QStringList>");
- connect(dbThread,&DatabaseThread::sendpatrol,this,&DataBoardCore::receivepatrol);
- dbThread->start();
- }
- void DataBoardCore::start()
- {
- ws->start();
- logThread->start();
- infoServer->start();
- timer->start(5);
- }
- void DataBoardCore::weblog(QString receivelog)
- {
- logThread->appendData(receivelog);
- }
- //清除超过一个月的日志文件
- void DataBoardCore::timeout()
- {
- dataProcessShm->UpTime = QDateTime::currentDateTime().toTime_t();
- if(mDay != QDate::currentDate().day()){
- mDay = QDate::currentDate().day();
- uint l_time = QDateTime::currentDateTime().toTime_t()-30*86400;
- QDir dir("/opt/log");
- QFileInfoList file_list = dir.entryInfoList(QDir::Files);
- for(int i=0;i<file_list.size();i++){
- QFileInfo f_info = file_list.at(i);
- if(f_info.lastModified().toTime_t()<l_time){
- QFile(f_info.canonicalFilePath()).remove();
- }
- }
- }
- }
- void DataBoardCore::receivepatrol(QList<QStringList > receivePatrolList)
- {
- ws->patrolrecord(receivePatrolList);
- }
|