New progress logic and error process logic
This commit is contained in:
@@ -184,51 +184,53 @@ void DeviceManager::timerEvent(QTimerEvent *event) {
|
||||
//scanning progress timer
|
||||
if (event->timerId() !=deviceInfTimerID)
|
||||
{
|
||||
//error exit
|
||||
//error exit, callback error
|
||||
if (errorOccurred)
|
||||
{
|
||||
qDebug() << "Error occurred, exit progress timer";
|
||||
// qDebug() << "Error occurred, exit progress timer";
|
||||
// QString msg("Error occurred, exit current operation!");
|
||||
// THROW_ERROR(msg);
|
||||
goto exitTimer;
|
||||
}
|
||||
// previewing exit
|
||||
if (previewing)
|
||||
{
|
||||
//错误timer
|
||||
QString msg("Device is previewing, exit current operation!");
|
||||
THROW_ERROR(msg);
|
||||
goto exitTimer;
|
||||
}
|
||||
} else {
|
||||
// check device status=========================================
|
||||
qDebug()<<"GetStatus";
|
||||
qDebug() << "GetStatus";
|
||||
StatusInfo inf = GetStatus();
|
||||
qDebug() << "Scanning request status, status:" << getStatusString(inf.status);
|
||||
//设备正常扫描中
|
||||
if (inf.status==SCANNING)
|
||||
{
|
||||
if (inf.status == SCANNING) {
|
||||
lastStatus = SCANNING;
|
||||
//normal scan
|
||||
QVariant var(inf.progress);
|
||||
qDebug() << "Normal scan, invoke InvokeOperationProgress:" << inf.progress;
|
||||
TRIGGER_EVENT(GUIEvents::InvokeOperationProgress, nullptr, (QObject*)&var);
|
||||
TRIGGER_EVENT(GUIEvents::InvokeOperationProgress, nullptr, (QObject *) &var);
|
||||
return;
|
||||
} else{
|
||||
} else {
|
||||
//未发生错误并且,之前状态是扫描,代表正常扫描完成
|
||||
if (lastStatus == SCANNING)
|
||||
{
|
||||
qDebug() << "Scan finished" ;
|
||||
if (lastStatus == SCANNING) {
|
||||
qDebug() << "Scan finished";
|
||||
QVariant var(true);
|
||||
qDebug() << "InvokeOperationEnd" ;
|
||||
TRIGGER_EVENT(GUIEvents::InvokeOperationEnd, nullptr, (QObject*)&var);
|
||||
qDebug() << "InvokeOperationEnd";
|
||||
TRIGGER_EVENT(GUIEvents::InvokeOperationEnd, nullptr, (QObject *) &var);
|
||||
lastStatus = -1;
|
||||
previewing = false;
|
||||
QString s("%1 %2");
|
||||
s = s.arg(QDateTime::currentDateTime().toString("yyyy/MM/dd HH:mm:ss")).arg("Scan finished");
|
||||
TRIGGER_EVENT(GUIEvents::GlobalBannerMessage, nullptr,(QObject*)&s);
|
||||
TRIGGER_EVENT(GUIEvents::GlobalBannerMessage, nullptr, (QObject *) &s);
|
||||
}
|
||||
//一般不会出现其他情况
|
||||
else{
|
||||
else {
|
||||
QString msg("Unknown error in scanning progress timer");
|
||||
THROW_ERROR(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
exitTimer:
|
||||
qDebug() << "Scanning progress Timer exit";
|
||||
killTimer(timerID);
|
||||
@@ -243,6 +245,8 @@ void DeviceManager::timerEvent(QTimerEvent *event) {
|
||||
}
|
||||
|
||||
void DeviceManager::processScan(const char *json, bool empty) {
|
||||
//clear last error state first
|
||||
errorOccurred = false;
|
||||
// check device status=========================================
|
||||
qDebug() << "GetStatus";
|
||||
StatusInfo inf = GetStatus();
|
||||
@@ -269,7 +273,9 @@ void DeviceManager::processScan(const char *json, bool empty) {
|
||||
qDebug() << "ScanControl start>>>>>>>>>>>>>>>>>>>>>";
|
||||
if (!ScanControl(SCAN)) {
|
||||
qDebug() << ">>>>>>>>>>>>>>>>>>>>>ScanControl success";
|
||||
//set current state
|
||||
lastStatus = SCANNING;
|
||||
previewing = false;
|
||||
qDebug() << "Start progress timer";
|
||||
timerID = startTimer(300);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user