Add debug log for real device debug
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
#include "event/EventCenter.h"
|
#include "event/EventCenter.h"
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <qdebug.h>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#else
|
#else
|
||||||
@@ -208,16 +209,18 @@ ScanFormWidget::ScanFormWidget(QWidget *parent) : TabFormWidget(parent) {
|
|||||||
patient_information->setPatientInformation((PatientInformation*)data);
|
patient_information->setPatientInformation((PatientInformation*)data);
|
||||||
});
|
});
|
||||||
connect(btnRefresh,&QToolButton::clicked,[=](){
|
connect(btnRefresh,&QToolButton::clicked,[=](){
|
||||||
QString patientInf(patient_information->getCurrentPatientJsonString(true));
|
qDebug()<<"Get patient Json string start!";
|
||||||
printf("%s\r\n",patientInf.toStdString().data());
|
QString patientInf(patient_information->getCurrentPatientJsonString(false));
|
||||||
|
qDebug()<<"Get patient Json string end! string:"<<patientInf;
|
||||||
EventCenter::Default()->triggerEvent(GUIEvents::RequestEmptyScan, nullptr, (QObject*)(&patientInf));
|
EventCenter::Default()->triggerEvent(GUIEvents::RequestEmptyScan, nullptr, (QObject*)(&patientInf));
|
||||||
});
|
});
|
||||||
connect(btnPreview,&QToolButton::clicked,[=](){
|
connect(btnPreview,&QToolButton::clicked,[=](){
|
||||||
EventCenter::Default()->triggerEvent(GUIEvents::RequestPreviewScan, nullptr, nullptr);
|
EventCenter::Default()->triggerEvent(GUIEvents::RequestPreviewScan, nullptr, nullptr);
|
||||||
});
|
});
|
||||||
connect(btnScan,&QToolButton::clicked,[=](){
|
connect(btnScan,&QToolButton::clicked,[=](){
|
||||||
|
qDebug()<<"Get patient Json string start!";
|
||||||
QString patientInf(patient_information->getCurrentPatientJsonString(false));
|
QString patientInf(patient_information->getCurrentPatientJsonString(false));
|
||||||
printf("%s\r\n",patientInf.toStdString().data());
|
qDebug()<<"Get patient Json string end! string:"<<patientInf;
|
||||||
EventCenter::Default()->triggerEvent(GUIEvents::RequestPatientScan, nullptr, (QObject*)(&patientInf));
|
EventCenter::Default()->triggerEvent(GUIEvents::RequestPatientScan, nullptr, (QObject*)(&patientInf));
|
||||||
});
|
});
|
||||||
connect(btnStop,&QToolButton::clicked,[=](){
|
connect(btnStop,&QToolButton::clicked,[=](){
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "../event/EventCenter.h"
|
#include "../event/EventCenter.h"
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QTimerEvent>
|
#include <QTimerEvent>
|
||||||
|
#include <qdebug.h>
|
||||||
|
|
||||||
#define TRIGGER_EVENT EventCenter::Default()->triggerEvent
|
#define TRIGGER_EVENT EventCenter::Default()->triggerEvent
|
||||||
|
|
||||||
@@ -47,16 +48,20 @@ void DeviceManager::initDevice() {
|
|||||||
InitLib(ErrorCallback);
|
InitLib(ErrorCallback);
|
||||||
|
|
||||||
deviceInfTimerID = startTimer(1000);
|
deviceInfTimerID = startTimer(1000);
|
||||||
|
// global error flag
|
||||||
|
connect(EventCenter::Default(),&EventCenter::GUIErrorRaise,[=](QObject* sender, QObject* detail){
|
||||||
|
this->errorOccured = true;
|
||||||
|
});
|
||||||
// empty scan
|
// empty scan
|
||||||
connect(EventCenter::Default(),&EventCenter::RequestEmptyScan,[=](QObject* sender, QObject* detail){
|
connect(EventCenter::Default(),&EventCenter::RequestEmptyScan,[=](QObject* sender, QObject* detail){
|
||||||
std::string json= getJsonFromPatInf(detail);
|
std::string json= getJsonFromPatInf(detail);
|
||||||
printf("%s\r\n",json.c_str());
|
qDebug()<<json.c_str();
|
||||||
processScan(json.c_str(), true);
|
processScan(json.c_str(), true);
|
||||||
});
|
});
|
||||||
// Patient scan
|
// Patient scan
|
||||||
connect(EventCenter::Default(),&EventCenter::RequestPatientScan,[=](QObject* sender, QObject* detail){
|
connect(EventCenter::Default(),&EventCenter::RequestPatientScan,[=](QObject* sender, QObject* detail){
|
||||||
std::string json= getJsonFromPatInf(detail);
|
std::string json= getJsonFromPatInf(detail);
|
||||||
printf("%s\r\n",json.c_str());
|
qDebug()<<json.c_str();
|
||||||
if (!json.empty())
|
if (!json.empty())
|
||||||
{
|
{
|
||||||
processScan(json.c_str());
|
processScan(json.c_str());
|
||||||
@@ -65,13 +70,17 @@ void DeviceManager::initDevice() {
|
|||||||
// stop
|
// stop
|
||||||
connect(EventCenter::Default(),&EventCenter::RequestStop,[=]() {
|
connect(EventCenter::Default(),&EventCenter::RequestStop,[=]() {
|
||||||
TRIGGER_EVENT(GUIEvents::InvokeOperationStart, nullptr, nullptr);
|
TRIGGER_EVENT(GUIEvents::InvokeOperationStart, nullptr, nullptr);
|
||||||
|
qDebug()<<"GetStatus";
|
||||||
StatusInfo inf = GetStatus();
|
StatusInfo inf = GetStatus();
|
||||||
printf("Stop request status, status:%s\r\n",getStatusString(inf.status));
|
qDebug()<<"Stop request status, status:%s"<<getStatusString(inf.status);
|
||||||
if (inf.status == SCANNING) {
|
if (inf.status == SCANNING) {
|
||||||
//ScanControl fail
|
//ScanControl fail
|
||||||
|
qDebug()<<"Request stop!";
|
||||||
if (ScanControl(STOP)) {
|
if (ScanControl(STOP)) {
|
||||||
|
qDebug()<<"Stop fail!";
|
||||||
QString msg("Stop operation fail!");
|
QString msg("Stop operation fail!");
|
||||||
THROW_ERROR(msg);
|
THROW_ERROR(msg);
|
||||||
|
qDebug()<<"Error thrown!";
|
||||||
lastStatus = -1;
|
lastStatus = -1;
|
||||||
previewing = false;
|
previewing = false;
|
||||||
return;
|
return;
|
||||||
@@ -85,13 +94,16 @@ void DeviceManager::initDevice() {
|
|||||||
// preview
|
// preview
|
||||||
connect(EventCenter::Default(),&EventCenter::RequestPreviewScan,[=](){
|
connect(EventCenter::Default(),&EventCenter::RequestPreviewScan,[=](){
|
||||||
TRIGGER_EVENT(GUIEvents::InvokeOperationStart, nullptr, nullptr);
|
TRIGGER_EVENT(GUIEvents::InvokeOperationStart, nullptr, nullptr);
|
||||||
|
qDebug()<<"GetStatus";
|
||||||
StatusInfo inf = GetStatus();
|
StatusInfo inf = GetStatus();
|
||||||
printf("PreviewScan request status, status:%s\r\n",getStatusString(inf.status));
|
qDebug() << "PreviewScan request status, status:" << getStatusString(inf.status);
|
||||||
if (inf.status==READY)
|
if (inf.status==READY)
|
||||||
{
|
{
|
||||||
//ScanControl
|
//ScanControl
|
||||||
|
qDebug()<<"Request preview!";
|
||||||
if(!ScanControl(PREVIEW_SCAN))
|
if(!ScanControl(PREVIEW_SCAN))
|
||||||
{
|
{
|
||||||
|
qDebug()<<"Preview success!";
|
||||||
lastStatus = SCANNING;
|
lastStatus = SCANNING;
|
||||||
previewing = true;
|
previewing = true;
|
||||||
// timerID = startTimer(500);
|
// timerID = startTimer(500);
|
||||||
@@ -100,52 +112,81 @@ void DeviceManager::initDevice() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
qDebug()<<"Preview fail!";
|
||||||
QString msg(inf.status!=READY?"Can't start preview,Device is not ready!":"Start preview operation fail!");
|
QString msg(inf.status!=READY?"Can't start preview,Device is not ready!":"Start preview operation fail!");
|
||||||
THROW_ERROR(msg);
|
THROW_ERROR(msg);
|
||||||
|
qDebug()<<"Error thrown!";
|
||||||
});
|
});
|
||||||
|
|
||||||
previewDataCaller = QThread::create([=](){
|
previewDataCaller = QThread::create([=](){
|
||||||
while (!endLoop)
|
while (!endLoop)
|
||||||
{
|
{
|
||||||
|
qDebug()<<"Preview data reader sleep!";
|
||||||
QThread::msleep(500);
|
QThread::msleep(500);
|
||||||
if (!previewing) continue;
|
if (!previewing) continue;
|
||||||
const char * data = GetPreviewData();
|
qDebug()<<"GetStatus";
|
||||||
QByteArray bytes =QByteArray::fromRawData(data,140*140);
|
StatusInfo inf = GetStatus();
|
||||||
|
qDebug() << "GetPreviewData request status, status:" << getStatusString(inf.status);
|
||||||
|
if (inf.status==SCANNING) {
|
||||||
|
qDebug() << "Preview data reader read start!";
|
||||||
|
const char *data = GetPreviewData();
|
||||||
|
if (!data)continue;
|
||||||
|
qDebug() << "Preview data reader read end!";
|
||||||
|
QByteArray bytes = QByteArray::fromRawData(data, 140 * 140);
|
||||||
if (!previewing) continue;
|
if (!previewing) continue;
|
||||||
TRIGGER_EVENT(GUIEvents::ResponsePreviewData, nullptr, (QObject*)(&bytes));
|
qDebug() << "Preview data response event start!";
|
||||||
|
TRIGGER_EVENT(GUIEvents::ResponsePreviewData, nullptr, (QObject *) (&bytes));
|
||||||
|
qDebug() << "Preview data response event end!";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
previewDataCaller->start();
|
previewDataCaller->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceManager::timerEvent(QTimerEvent *event) {
|
void DeviceManager::timerEvent(QTimerEvent *event) {
|
||||||
|
//scanning progress timer
|
||||||
if (event->timerId() !=deviceInfTimerID)
|
if (event->timerId() !=deviceInfTimerID)
|
||||||
{
|
{
|
||||||
|
qDebug()<<"GetStatus";
|
||||||
StatusInfo inf = GetStatus();
|
StatusInfo inf = GetStatus();
|
||||||
// printf("Timer request status, status:%s\r\n",getStatusString(inf.status));
|
qDebug() << "Scanning request status, status:" << getStatusString(inf.status);
|
||||||
|
if (errorOccured)
|
||||||
|
{
|
||||||
|
qDebug() << "Error occurred, exit progress timer" << inf.progress;
|
||||||
|
goto exitTimer;
|
||||||
|
}
|
||||||
|
if (previewing)
|
||||||
|
{
|
||||||
|
//错误timer
|
||||||
|
goto exitTimer;
|
||||||
|
}
|
||||||
|
//设备正常扫描中
|
||||||
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;
|
||||||
TRIGGER_EVENT(GUIEvents::InvokeOperationProgress, nullptr, (QObject*)&var);
|
TRIGGER_EVENT(GUIEvents::InvokeOperationProgress, nullptr, (QObject*)&var);
|
||||||
} else{
|
} else{
|
||||||
if (lastStatus == SCANNING && !errorOccured)
|
//未发生错误并且,之前状态是扫描,代表正常扫描完成
|
||||||
|
if (lastStatus == SCANNING)
|
||||||
{
|
{
|
||||||
|
qDebug() << "Scan finished" ;
|
||||||
QVariant var(true);
|
QVariant var(true);
|
||||||
|
qDebug() << "InvokeOperationEnd" ;
|
||||||
TRIGGER_EVENT(GUIEvents::InvokeOperationEnd, nullptr, (QObject*)&var);
|
TRIGGER_EVENT(GUIEvents::InvokeOperationEnd, nullptr, (QObject*)&var);
|
||||||
lastStatus = -1;
|
lastStatus = -1;
|
||||||
previewing = false;
|
previewing = false;
|
||||||
}
|
}
|
||||||
//内部错误,导致Scan停止
|
return;
|
||||||
else if (lastStatus == SCANNING && errorOccured)
|
}
|
||||||
{
|
exitTimer:
|
||||||
//正常情况下,设备应该已经调用的错误callback,然后会回归Ready状态,清理lastStatus即可
|
killTimer(timerID);
|
||||||
|
timerID=-1;
|
||||||
lastStatus = -1;
|
lastStatus = -1;
|
||||||
previewing = false;
|
previewing = false;
|
||||||
}
|
return;
|
||||||
killTimer(timerID);
|
|
||||||
}
|
|
||||||
} else{
|
} else{
|
||||||
QString temp = QString(GetDeviceInfo(MEAN_TEMPERATURE));
|
QString temp = QString(GetDeviceInfo(MEAN_TEMPERATURE));
|
||||||
TRIGGER_EVENT(GUIEvents::ResponseDeviceTemperature, nullptr, (QObject*)&temp);
|
TRIGGER_EVENT(GUIEvents::ResponseDeviceTemperature, nullptr, (QObject*)&temp);
|
||||||
@@ -155,22 +196,31 @@ void DeviceManager::timerEvent(QTimerEvent *event) {
|
|||||||
void DeviceManager::processScan(const char *json, bool empty) {
|
void DeviceManager::processScan(const char *json, bool empty) {
|
||||||
static QString msg = "Start scan...";
|
static QString msg = "Start scan...";
|
||||||
TRIGGER_EVENT(GUIEvents::InvokeOperationStart, nullptr, (QObject*)&msg);
|
TRIGGER_EVENT(GUIEvents::InvokeOperationStart, nullptr, (QObject*)&msg);
|
||||||
|
qDebug() << "SetScanInfo>>>>>>>>>>>>>>>>>>>>" ;
|
||||||
int ret = SetScanInfo(json,empty?1:0);
|
int ret = SetScanInfo(json,empty?1:0);
|
||||||
if (ret){
|
if (ret){
|
||||||
|
qDebug() << ">>>>>>>>>>>>>>>>>>>>SetScanInfo failed";
|
||||||
QString errmsg("Transfer patient information fail!");
|
QString errmsg("Transfer patient information fail!");
|
||||||
|
qDebug() << "Error thrown" ;
|
||||||
THROW_ERROR(errmsg);
|
THROW_ERROR(errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
qDebug() << ">>>>>>>>>>>>>>>>>>>>SetScanInfo success";
|
||||||
|
qDebug()<<"GetStatus";
|
||||||
StatusInfo inf = GetStatus();
|
StatusInfo inf = GetStatus();
|
||||||
printf("ProcessScan request status, status:%s\r\n",getStatusString(inf.status));
|
qDebug() << "Scan start request status, status:" << getStatusString(inf.status);
|
||||||
if (inf.status==READY)
|
if (inf.status==READY)
|
||||||
{
|
{
|
||||||
//ScanControl fail
|
//ScanControl fail
|
||||||
|
qDebug() << "ScanControl start>>>>>>>>>>>>>>>>>>>>>";
|
||||||
if(!ScanControl(SCAN)) {
|
if(!ScanControl(SCAN)) {
|
||||||
|
qDebug() << ">>>>>>>>>>>>>>>>>>>>>ScanControl success";
|
||||||
lastStatus = SCANNING;
|
lastStatus = SCANNING;
|
||||||
|
qDebug() << "Start progress timer";
|
||||||
timerID = startTimer(300);
|
timerID = startTimer(300);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
qDebug() << ">>>>>>>>>>>>>>>>>>>>>ScanControl failed";
|
||||||
}
|
}
|
||||||
QString errmsg("Start scan operation fail!");
|
QString errmsg("Start scan operation fail!");
|
||||||
THROW_ERROR(errmsg);
|
THROW_ERROR(errmsg);
|
||||||
|
|||||||
Reference in New Issue
Block a user