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