machine change
This commit is contained in:
@@ -51,9 +51,9 @@ void errorCallback(const char* msg)
|
||||
DeviceManager::Default()->emitErrorCallback(msg);
|
||||
}
|
||||
|
||||
void infoCallback(const char* msg,const unsigned int aInfoType)
|
||||
void infoCallback(const char* msg)
|
||||
{
|
||||
DeviceManager::Default()->emitInfoCallback(msg,aInfoType);
|
||||
DeviceManager::Default()->emitInfoCallback(msg,0);
|
||||
}
|
||||
|
||||
const char * getPhaseName(int phase){
|
||||
@@ -62,7 +62,6 @@ const char * getPhaseName(int phase){
|
||||
|
||||
void DeviceManager::initDevice() {
|
||||
InitLib(errorCallback);
|
||||
SetMessageCallback(infoCallback);
|
||||
|
||||
mDeviceInfTimerID = startTimer(10000);
|
||||
|
||||
@@ -193,6 +192,8 @@ void DeviceManager::stopScan() {
|
||||
QThread::msleep(100);
|
||||
inf = GetStatus();
|
||||
if (inf.status != SCANNING) {
|
||||
mPreviewing = false;
|
||||
AppGlobalValues::setInProcessing(false);
|
||||
TRIGGER_EVENT(ResponseStop, nullptr, nullptr);
|
||||
return;
|
||||
}
|
||||
@@ -242,6 +243,22 @@ void DeviceManager::close() {
|
||||
delete mPreviewDataCaller;
|
||||
}
|
||||
|
||||
const size_t Row = 140;
|
||||
const size_t Col = 140;
|
||||
|
||||
#define BUFFER_SIZE Row * Col
|
||||
|
||||
unsigned char* buffer = nullptr;
|
||||
void GetPreviewDataLocal(){
|
||||
|
||||
FILE* file;
|
||||
if (file = fopen("img.bin", "rb")) {
|
||||
buffer = (unsigned char*)malloc(sizeof(unsigned char) * BUFFER_SIZE);
|
||||
fread(buffer, sizeof(unsigned char), BUFFER_SIZE, file);
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceManager::initPreviewThread() {
|
||||
mPreviewDataCaller = QThread::create([=]() {
|
||||
while (!mEndLoop) {
|
||||
@@ -254,14 +271,15 @@ void DeviceManager::initPreviewThread() {
|
||||
StatusInfo inf = GetStatus();
|
||||
qDebug() << "GetPreviewData request status, status:" << getStatusString(inf.status);
|
||||
// device is preview scanning, try get preview data
|
||||
if (inf.status == SCANNING) {
|
||||
if (1) {
|
||||
qDebug() << "Preview data reader read start!";
|
||||
const char *data = GetPreviewData();
|
||||
if (!data) {
|
||||
GetPreviewDataLocal();
|
||||
if (!buffer) {
|
||||
continue;
|
||||
}
|
||||
qDebug() << "Preview data reader read end!";
|
||||
QByteArray bytes = QByteArray::fromRawData(data, PREVIEW_IMAGE_WH * PREVIEW_IMAGE_WH);
|
||||
qDebug()<<(int)buffer[5104];
|
||||
qDebug()<<(int)buffer[5105];
|
||||
//double check
|
||||
if (!mPreviewing) {
|
||||
qDebug() << "Preview data reader long sleep!";
|
||||
@@ -269,14 +287,14 @@ void DeviceManager::initPreviewThread() {
|
||||
continue;
|
||||
}
|
||||
qDebug() << "Preview data response event start!";
|
||||
TRIGGER_EVENT(ResponsePreviewData, nullptr, (QObject *) (&bytes));
|
||||
TRIGGER_EVENT(ResponsePreviewData, nullptr, (QObject *) (buffer));
|
||||
qDebug() << "Preview data response event end!";
|
||||
} else {
|
||||
mPreviewing = false;
|
||||
AppGlobalValues::setInProcessing(false);
|
||||
QThread::sleep(3);
|
||||
}
|
||||
QThread::msleep(100);
|
||||
QThread::sleep(1);
|
||||
}
|
||||
});
|
||||
mPreviewDataCaller->start();
|
||||
|
||||
Reference in New Issue
Block a user