Phase control workflow logic
This commit is contained in:
@@ -69,6 +69,10 @@ void DeviceManager::initDevice() {
|
||||
processScan(json.c_str());
|
||||
}
|
||||
});
|
||||
// Continue Scan
|
||||
connect(EventCenter::Default(), &EventCenter::RequestContinueScan, [=](QObject* sender, QObject* detail) {
|
||||
postContinueCommand(true);
|
||||
});
|
||||
// stop
|
||||
connect(EventCenter::Default(), &EventCenter::RequestStop, [=]() {
|
||||
qDebug() << "GetStatus";
|
||||
@@ -207,14 +211,36 @@ void DeviceManager::timerEvent(QTimerEvent* event) {
|
||||
qDebug() << "Scanning request status, status:" << getStatusString(inf.status);
|
||||
//设备正常扫描中
|
||||
if (inf.status == SCANNING) {
|
||||
qDebug() <<"current output path:"<<getScanOutputPath();
|
||||
lastStatus = SCANNING;
|
||||
//normal scan
|
||||
QVariant var(inf.progress);
|
||||
qDebug() << "Normal scan, invoke InvokeOperationProgress:" << inf.progress;
|
||||
TRIGGER_EVENT(GUIEvents::InvokeOperationProgress, nullptr, (QObject*)&var);
|
||||
return;
|
||||
}
|
||||
qDebug() << "current output path:" << getScanOutputPath();
|
||||
lastStatus = SCANNING;
|
||||
|
||||
//normal scan pending
|
||||
int phase = inf.progress/100 + 1;
|
||||
int progress = inf.progress % 100;
|
||||
QString extraMsg = (AppGlobalValues::EmptyScanFlag().toBool()||(scanPhase != 3))?"":", patient can leave";
|
||||
QVariant var(QString("Phase %1%3\r\n progress:%2%").arg(scanPhase).arg(progress).arg(extraMsg));
|
||||
TRIGGER_EVENT(GUIEvents::InvokeOperationProgress, nullptr, (QObject *) &var);
|
||||
if (scanPhase != phase) {
|
||||
if (phase > 3 || scanPhase > phase ){
|
||||
QString errorMsg = QString("Error Scan Phase code, current Phase code:%1, new Phase code:%2!").arg(scanPhase,phase);
|
||||
THROW_ERROR(errorMsg)
|
||||
goto exitTimer;
|
||||
}
|
||||
scanPhase = phase;
|
||||
if (scanPhase == 2){
|
||||
if (!AppGlobalValues::EmptyScanFlag().toBool()) {
|
||||
var.setValue(QString("Scan phase 2 waiting for patient!\r\n Click \"Next\" to continue!"));
|
||||
TRIGGER_EVENT(GUIEvents::InvokeOperationPending, nullptr, (QObject *) &var);
|
||||
goto exitTimer;
|
||||
}
|
||||
//empty scan no pending, auto continue
|
||||
else {
|
||||
postContinueCommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
else {
|
||||
//未发生错误并且,之前状态是扫描,代表正常扫描完成
|
||||
if (lastStatus == SCANNING) {
|
||||
@@ -293,20 +319,36 @@ void DeviceManager::processScan(const char* json, bool empty) {
|
||||
return;
|
||||
}
|
||||
qDebug() << ">>>>>>>>>>>>>>>>>>>>SetScanInfo success";
|
||||
//ScanControl fail
|
||||
qDebug() << "ScanControl start>>>>>>>>>>>>>>>>>>>>>";
|
||||
if (!ScanControl(SCAN)) {
|
||||
qDebug() << ">>>>>>>>>>>>>>>>>>>>>ScanControl success";
|
||||
//set current state
|
||||
lastStatus = SCANNING;
|
||||
previewing = false;
|
||||
qDebug() << "Start progress timer";
|
||||
timerID = startTimer(500);
|
||||
return;
|
||||
}
|
||||
QString errmsg("ScanControl start fail!");
|
||||
THROW_ERROR(errmsg);
|
||||
qDebug() << ">>>>>>>>>>>>>>>>>>>>>ScanControl failed";
|
||||
|
||||
postScanCommand();
|
||||
}
|
||||
|
||||
void DeviceManager::postScanCommand() {
|
||||
qDebug() << "ScanControl start>>>>>>>>>>>>>>>>>>>>>";
|
||||
if (!ScanControl(SCAN)) {
|
||||
qDebug() << ">>>>>>>>>>>>>>>>>>>>>ScanControl success";
|
||||
//set current state
|
||||
lastStatus = SCANNING;
|
||||
previewing = false;
|
||||
scanPhase = 1;
|
||||
qDebug() << "Start progress timer";
|
||||
timerID = startTimer(500);
|
||||
return;
|
||||
}
|
||||
//ScanControl fail
|
||||
QString errmsg("ScanControl start fail!");
|
||||
THROW_ERROR(errmsg);
|
||||
qDebug() << ">>>>>>>>>>>>>>>>>>>>>ScanControl failed";
|
||||
}
|
||||
|
||||
void DeviceManager::postContinueCommand(bool useTimer) {
|
||||
if (!ScanControl(SCAN_CONTINUE)) {
|
||||
if (useTimer)timerID = startTimer(500);
|
||||
return;
|
||||
}
|
||||
//ScanControl fail
|
||||
QString errmsg("ScanControl start fail!");
|
||||
THROW_ERROR(errmsg);
|
||||
}
|
||||
|
||||
void DeviceManager::close() {
|
||||
@@ -324,3 +366,5 @@ QString DeviceManager::getSoftwareVersion() {
|
||||
QString DeviceManager::getScanOutputPath() {
|
||||
return GetDeviceInfo(DEV_OUTPATH);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user