New progress logic and error process logic

This commit is contained in:
krad
2021-11-02 10:33:11 +08:00
parent c577a239b9
commit aec1502243

View File

@@ -184,25 +184,27 @@ 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";
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);
@@ -211,8 +213,7 @@ void DeviceManager::timerEvent(QTimerEvent *event) {
return;
} else {
//未发生错误并且,之前状态是扫描,代表正常扫描完成
if (lastStatus == SCANNING)
{
if (lastStatus == SCANNING) {
qDebug() << "Scan finished";
QVariant var(true);
qDebug() << "InvokeOperationEnd";
@@ -229,6 +230,7 @@ void DeviceManager::timerEvent(QTimerEvent *event) {
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;