Preview error handle.5
This commit is contained in:
@@ -27,20 +27,26 @@ volatile int running = 1;
|
|||||||
volatile int progress = 0;
|
volatile int progress = 0;
|
||||||
volatile int status = READY;
|
volatile int status = READY;
|
||||||
volatile int stop_flag = 0;
|
volatile int stop_flag = 0;
|
||||||
|
volatile int empty = 0;
|
||||||
char output_path[256] = {0};
|
char output_path[256] = {0};
|
||||||
|
|
||||||
void ThreadFunc(void* args){
|
void ThreadFunc(void* args){
|
||||||
while (running){
|
while (running){
|
||||||
WaitForSingleObject(e1, INFINITE);
|
|
||||||
status = SCANNING;
|
|
||||||
stop_flag = 0;
|
stop_flag = 0;
|
||||||
progress = 0;
|
progress = 0;
|
||||||
for (int i = 0; i <= 50; ++i) {
|
WaitForSingleObject(e1, INFINITE);
|
||||||
if (stop_flag > 0){
|
|
||||||
stop_flag = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
status = SCANNING;
|
||||||
|
Sleep(300);
|
||||||
|
if (empty)
|
||||||
|
{
|
||||||
|
GetPreviewData();
|
||||||
|
}
|
||||||
|
for (int i = 0; i <= 50; ++i) {
|
||||||
|
if (stop_flag > 0 || status != SCANNING){
|
||||||
|
stop_flag = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (i == 20){
|
if (i == 20){
|
||||||
progress = 139;
|
progress = 139;
|
||||||
WaitForSingleObject(e2, INFINITE);
|
WaitForSingleObject(e2, INFINITE);
|
||||||
@@ -53,6 +59,10 @@ void ThreadFunc(void* args){
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
progress = i *2;
|
progress = i *2;
|
||||||
|
}
|
||||||
|
if (stop_flag > 0 || status != SCANNING){
|
||||||
|
stop_flag = 0;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
Sleep(300);
|
Sleep(300);
|
||||||
}
|
}
|
||||||
@@ -107,7 +117,8 @@ StatusInfo GetStatus() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//result, 0 success, other false
|
//result, 0 success, other false
|
||||||
int SetScanInfo(const char* jsonString, int empty) {
|
int SetScanInfo(const char* jsonString, int e) {
|
||||||
|
empty = e;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ void DeviceManager::emitErrorCallback(const char *msg) {
|
|||||||
void DeviceManager::initDevice() {
|
void DeviceManager::initDevice() {
|
||||||
InitLib(ErrorCallback);
|
InitLib(ErrorCallback);
|
||||||
|
|
||||||
deviceInfTimerID = startTimer(1000);
|
deviceInfTimerID = startTimer(10000);
|
||||||
|
|
||||||
// empty scan
|
// empty scan
|
||||||
connect(EventCenter::Default(), &EventCenter::RequestEmptyScan, [=](QObject* sender, QObject* detail) {
|
connect(EventCenter::Default(), &EventCenter::RequestEmptyScan, [=](QObject* sender, QObject* detail) {
|
||||||
@@ -207,6 +207,7 @@ void DeviceManager::timerEvent(QTimerEvent* event) {
|
|||||||
//scanning progress timer
|
//scanning progress timer
|
||||||
//error exit, callback error
|
//error exit, callback error
|
||||||
if (errorOccurred) {
|
if (errorOccurred) {
|
||||||
|
timerID = event->timerId();
|
||||||
exitScanTimer();
|
exitScanTimer();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -225,14 +226,14 @@ void DeviceManager::timerEvent(QTimerEvent* event) {
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
//未发生错误并且,之前状态是扫描,代表正常扫描完成
|
//未发生错误并且,之前状态是扫描,代表正常扫描完成
|
||||||
if (lastStatus == SCANNING) {
|
if (lastStatus == SCANNING ) {
|
||||||
prepareFinishScan();
|
prepareFinishScan();
|
||||||
}
|
}
|
||||||
//一般不会出现其他情况
|
//一般不会出现其他情况
|
||||||
else {
|
// else {
|
||||||
QString msg("Unknown error in scanning progress timer");
|
// QString msg("Unknown error in scanning progress timer");
|
||||||
THROW_ERROR(msg);
|
// THROW_ERROR(msg);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exitScanTimer();
|
exitScanTimer();
|
||||||
@@ -280,7 +281,7 @@ void DeviceManager::scanProcess(int sProgress) {
|
|||||||
|
|
||||||
void DeviceManager::exitScanTimer() {
|
void DeviceManager::exitScanTimer() {
|
||||||
qDebug() << "Scanning progress Timer exit";
|
qDebug() << "Scanning progress Timer exit";
|
||||||
killTimer(timerID);
|
if (timerID>0)killTimer(timerID);
|
||||||
timerID = -1;
|
timerID = -1;
|
||||||
lastStatus = -1;
|
lastStatus = -1;
|
||||||
previewing = false;
|
previewing = false;
|
||||||
@@ -358,7 +359,7 @@ void DeviceManager::postScanCommand() {
|
|||||||
previewing = false;
|
previewing = false;
|
||||||
scanPhase = 1;
|
scanPhase = 1;
|
||||||
qDebug() << "Start progress timer";
|
qDebug() << "Start progress timer";
|
||||||
timerID = startTimer(500);
|
timerID = startTimer(2500);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//ScanControl fail
|
//ScanControl fail
|
||||||
|
|||||||
@@ -92,12 +92,12 @@ private:
|
|||||||
void scanProcess(int progress);
|
void scanProcess(int progress);
|
||||||
|
|
||||||
int scanPhase = 1;
|
int scanPhase = 1;
|
||||||
int timerID = -1;
|
volatile int timerID = -1;
|
||||||
int deviceInfTimerID = -1;
|
int deviceInfTimerID = -1;
|
||||||
int lastStatus = -1;
|
int lastStatus = -1;
|
||||||
bool previewing = false;
|
bool previewing = false;
|
||||||
volatile bool endLoop = false;
|
volatile bool endLoop = false;
|
||||||
bool errorOccurred = false;
|
volatile bool errorOccurred = false;
|
||||||
QThread* previewDataCaller = nullptr;
|
QThread* previewDataCaller = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user