9 Commits

Author SHA1 Message Date
Krad
884071e586 Disable empty password login of usct. 2022-06-10 16:50:29 +08:00
Krad
74064d1fdf 10 volunteer study prepare fix. 2022-06-10 15:37:28 +08:00
Krad
2a891ac1de Preview error handle.7 2022-06-02 16:32:01 +08:00
Krad
b9b10b144c Preview error handle.6 2022-06-02 16:21:47 +08:00
Krad
a64178876b Preview error handle.5 2022-06-02 16:09:42 +08:00
Krad
5bd9d589e9 Preview error handle.4 2022-06-02 14:48:36 +08:00
Krad
9fb047a5db Preview error handle.3 2022-06-02 14:32:47 +08:00
Krad
244b43d146 Preview error handle.2 2022-06-02 14:22:09 +08:00
Krad
c25f31bc5c Preview error handle 2022-06-02 14:01:16 +08:00
8 changed files with 78 additions and 38 deletions

View File

@@ -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;
WaitForSingleObject(e1, INFINITE);
status = SCANNING;
Sleep(300);
if (empty)
{
GetPreviewData();
}
for (int i = 0; i <= 50; ++i) { for (int i = 0; i <= 50; ++i) {
if (stop_flag > 0){ if (stop_flag > 0 || status != SCANNING){
stop_flag = 0; stop_flag = 0;
break; 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;
} }
@@ -120,7 +131,15 @@ const size_t Col = 140;
const char* FRAME_FILE_PATH_1 = "./img1_v2.bin"; const char* FRAME_FILE_PATH_1 = "./img1_v2.bin";
const char* FRAME_FILE_PATH_2 = "./pre_image.bin"; const char* FRAME_FILE_PATH_2 = "./pre_image.bin";
int previewCount = 0;
const char* GetPreviewData() { const char* GetPreviewData() {
previewCount++;
if (previewCount>3){
status = READY;
innerCallback("22222");
return NULL;
}
FILE* file; FILE* file;
preivew_change_flag++; preivew_change_flag++;
preivew_change_flag = preivew_change_flag % 2; preivew_change_flag = preivew_change_flag % 2;

View File

@@ -6,7 +6,7 @@
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QLabel> #include <QLabel>
#include <QDate> #include <QDate>
DateSlidePickerBox::DateSlidePickerBox(QWidget *parent) { DateSlidePickerBox::DateSlidePickerBox(QWidget *parent):QWidget(parent) {
layout = new QHBoxLayout(this); layout = new QHBoxLayout(this);
myear = new SlidePickerBox(this); myear = new SlidePickerBox(this);
QStringList centry; QStringList centry;

View File

@@ -43,7 +43,7 @@ void ErrorCallback(const char* msg)
} }
void DeviceManager::emitErrorCallback(const char *msg) { void DeviceManager::emitErrorCallback(const char *msg) {
this->setErrorOccurred(true); errorOccurred=true;
printf("Error Callback , message:%s\r\n", msg); printf("Error Callback , message:%s\r\n", msg);
QString m(msg); QString m(msg);
emit raiseGlobalError( m); emit raiseGlobalError( m);
@@ -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) {
@@ -132,7 +132,7 @@ void DeviceManager::initDevice() {
if (!ScanControl(PREVIEW_SCAN)) if (!ScanControl(PREVIEW_SCAN))
{ {
qDebug() << "Preview success!"; qDebug() << "Preview success!";
lastStatus = SCANNING; // lastStatus = SCANNING;
previewing = true; previewing = true;
// timerID = startTimer(500); // timerID = startTimer(500);
TRIGGER_EVENT(GUIEvents::ResponsePreview, nullptr, nullptr); TRIGGER_EVENT(GUIEvents::ResponsePreview, nullptr, nullptr);
@@ -164,7 +164,9 @@ void DeviceManager::initDevice() {
if (inf.status == SCANNING) { if (inf.status == SCANNING) {
qDebug() << "Preview data reader read start!"; qDebug() << "Preview data reader read start!";
const char* data = GetPreviewData(); const char* data = GetPreviewData();
if (!data)continue; if (!data){
continue;
}
qDebug() << "Preview data reader read end!"; qDebug() << "Preview data reader read end!";
QByteArray bytes = QByteArray::fromRawData(data, 140 * 140); QByteArray bytes = QByteArray::fromRawData(data, 140 * 140);
//double check //double check
@@ -177,6 +179,12 @@ void DeviceManager::initDevice() {
TRIGGER_EVENT(GUIEvents::ResponsePreviewData, nullptr, (QObject*)(&bytes)); TRIGGER_EVENT(GUIEvents::ResponsePreviewData, nullptr, (QObject*)(&bytes));
qDebug() << "Preview data response event end!"; qDebug() << "Preview data response event end!";
} }
else{
// lastStatus = READY;
previewing = false;
AppGlobalValues::setInProcessing(false);
QThread::sleep(3);
}
QThread::msleep(100); QThread::msleep(100);
} }
}); });
@@ -199,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;
} }
@@ -217,14 +226,14 @@ void DeviceManager::timerEvent(QTimerEvent* event) {
return; return;
} else { } else {
//未发生错误并且,之前状态是扫描,代表正常扫描完成 //未发生错误并且,之前状态是扫描,代表正常扫描完成
if (lastStatus == SCANNING) { if (lastStatus == SCANNING && ! errorOccurred) {
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();
@@ -272,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;

View File

@@ -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;
}; };

View File

@@ -258,7 +258,9 @@ ScanFormWidget::ScanFormWidget(QWidget* parent) : TabFormWidget(parent) {
lbl_e2->setText(tr("some settings\n\nparameters\n")); lbl_e2->setText(tr("some settings\n\nparameters\n"));
}); });
connect(EventCenter::Default(), &EventCenter::DeviceErrorRaise, [=](QObject* parent, QObject* msg){
setPreviewing(false);
});
previewfunc = [=](bool val)->void { previewfunc = [=](bool val)->void {
viewer->setVisible(val); viewer->setVisible(val);

View File

@@ -167,13 +167,14 @@ void AboutWidget::initUi()
void AboutWidget::openHelpFile() void AboutWidget::openHelpFile()
{ {
QString userManulFile = QCoreApplication::applicationDirPath() + "/userManual.pdf"; qApp->exit();
// QString userManulFile = QCoreApplication::applicationDirPath() + "/userManual.pdf";
QFileInfo file(userManulFile); //
if (file.exists()) // QFileInfo file(userManulFile);
{ // if (file.exists())
QDesktopServices::openUrl(QUrl::fromLocalFile(userManulFile)); // {
} // QDesktopServices::openUrl(QUrl::fromLocalFile(userManulFile));
// }
//else //else
//{ //{
// EQ9MessageBox box; // EQ9MessageBox box;

View File

@@ -7,6 +7,7 @@
#include <QTranslator> #include <QTranslator>
#include <QDebug> #include <QDebug>
#include <QApplication> #include <QApplication>
#include <iostream>
#include "json/cJSON.h" #include "json/cJSON.h"
const char* strProductFileName = "./cfgs/usct-product.json"; const char* strProductFileName = "./cfgs/usct-product.json";
const char* strProductFileNameDefault = "./cfgs/usct-product"; const char* strProductFileNameDefault = "./cfgs/usct-product";
@@ -338,11 +339,19 @@ bool JsonObject::savecfg()
} }
char* strJsonData = cJSON_Print((cJSON*)json_root); char* strJsonData = cJSON_Print((cJSON*)json_root);
if (strlen(strJsonData)>1){
std::stringstream ss; std::stringstream ss;
ss << strJsonData; ss << strJsonData;
outFile << ss.rdbuf(); outFile << ss.rdbuf();
outFile.flush();
outFile.close(); outFile.close();
m_bLoaded = false; m_bLoaded = false;
}
else{
std::cout<<"===========================================app want write empty content to cfg json============================================="<<std::endl;
}
delete strJsonData;
return true; return true;
} }

View File

@@ -128,8 +128,8 @@ void LoginWindow::doLogin()
QString strUserCode = m_pUserCodeEdit->text(); QString strUserCode = m_pUserCodeEdit->text();
QString strPassWord = m_pPassWordEdit->text(); QString strPassWord = m_pPassWordEdit->text();
QString encryptedPassword = strPassWord; // QString encryptedPassword = strPassWord;
strPassWord = "123456"; // strPassWord = "123456";
QString encryptPwd = User::getEncryptedPassword(strPassWord); QString encryptPwd = User::getEncryptedPassword(strPassWord);
QString sql = QString("select UserCode from Account where UserCode='%1' and Password='%2'") QString sql = QString("select UserCode from Account where UserCode='%1' and Password='%2'")