108 lines
3.0 KiB
C++
108 lines
3.0 KiB
C++
#include <QDebug>
|
|
#include <QMessageBox>
|
|
#include "SecondThread.h"
|
|
#include "VerBVersion.h"
|
|
|
|
SecondThread::SecondThread(QObject* par) : QThread(par)
|
|
,m_runCount(20)
|
|
{
|
|
pDdlgShowMsg = new DlgShowMsg;
|
|
pDdlgShowMsg->hide();
|
|
pTimer10s = new QTimer();
|
|
pTimer10s->setInterval(10000);
|
|
//connect(pTimer10s, SIGNAL(timeout()), this, &SecondThread::timeoutSlot);
|
|
connect(pTimer10s, SIGNAL(timeout()), this, SLOT(timeoutSlot()),Qt::QueuedConnection);
|
|
pUpLicManager = new LicenseManger();
|
|
licState = pUpLicManager->getLicState();
|
|
if(licState)
|
|
{
|
|
//pDdlgShowMsg->showMsg(tr("license file was invalid,error code:%1").arg(licState));
|
|
emit printerLicErr(licState);
|
|
qDebug()<<"asdfsdf";
|
|
}
|
|
bLicFileUpdating = false;
|
|
}
|
|
|
|
SecondThread::~SecondThread()
|
|
{
|
|
qDebug() << "SecondThread::~SecondThread()";
|
|
}
|
|
|
|
void SecondThread::setSomething()
|
|
{
|
|
msleep(500);
|
|
QString str = QString("%1->%2,thread id:%3").arg(__FUNCTION__).arg(__FILE__).arg((int)QThread::currentThreadId());
|
|
emit message(str);
|
|
}
|
|
|
|
void SecondThread::getSomething()
|
|
{
|
|
msleep(500);
|
|
emit message(QString("%1->%2,thread id:%3").arg(__FUNCTION__).arg(__FILE__).arg((int)QThread::currentThreadId()));
|
|
}
|
|
|
|
void SecondThread::setRunCount(int count)
|
|
{
|
|
m_runCount = count;
|
|
emit message(QString("%1->%2,thread id:%3").arg(__FUNCTION__).arg(__FILE__).arg((int)QThread::currentThreadId()));
|
|
}
|
|
|
|
void SecondThread::timeoutSlot()
|
|
{
|
|
QTime curTime=QTime::currentTime();
|
|
qDebug()<<curTime.toString()<<"second thread";
|
|
qint32 remaining_time;
|
|
if(!bLicFileUpdating)
|
|
{
|
|
if(licState == LICENSE_STATE_OK)
|
|
{
|
|
remaining_time = pUpLicManager->CheckRemainingTime();
|
|
if(remaining_time <= 3)
|
|
{
|
|
licState = -LICENSE_STATE_REMAIN_TIME_REARCH;
|
|
emit printerLicErr(licState);
|
|
}
|
|
}
|
|
emit printerLicErr(licState);
|
|
}
|
|
}
|
|
void SecondThread::update_license_file()
|
|
{
|
|
pUpLicManager->UpdateLicenseFileData();
|
|
licState = pUpLicManager->getLicState();
|
|
}
|
|
void SecondThread::update_license_process()
|
|
{
|
|
qint8 updateFileState = pUpLicManager->CheckUpdateFileState();
|
|
if(updateFileState != UPDATE_LICENSE_FILE_OK)
|
|
{
|
|
//QMessageBox::critical(this,tr("错误"),tr("升级软件错误,错误码:%1").arg(updateState));
|
|
emit update_license_complete(updateFileState);
|
|
}
|
|
else
|
|
{
|
|
bLicFileUpdating = true;
|
|
update_license_file();
|
|
emit update_license_complete(UPDATE_LICENSE_FILE_OK);
|
|
bLicFileUpdating = false;
|
|
}
|
|
}
|
|
|
|
void SecondThread::set_serial_number_process(quint32 serial_number)
|
|
{
|
|
qDebug()<<"set_serial_number_process"<<serial_number;
|
|
pUpLicManager->setMachineInfo(serial_number);
|
|
}
|
|
void SecondThread::run()
|
|
{
|
|
qDebug()<<"second thread run";
|
|
pTimer10s->start();
|
|
this->exec();
|
|
}
|
|
|
|
void SecondThread::doSomething()
|
|
{
|
|
msleep(500);
|
|
emit message(QString("%1->%2,thread id:%3").arg(__FUNCTION__).arg(__FILE__).arg((int)QThread::currentThreadId()));
|
|
}
|