24 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
Krad
20eb8e6e4f Fix simulator stop bug. 2022-06-01 16:00:04 +08:00
Krad
000e45abd5 Add Scan complete notify. 2022-06-01 10:01:25 +08:00
Krad
932e1450c2 Fix imageswitch icon bug. 2022-05-31 09:45:08 +08:00
Krad
7822139a76 Fix json isEmptyData flag bug. 2022-05-26 15:32:25 +08:00
Krad
55a579ea50 Code clean and class constructor refactor. 2022-05-24 10:37:30 +08:00
Krad
6e8d198a7a Add finished percent judge to DeviceManager.cpp 2022-05-24 10:37:30 +08:00
Krad
d047b77907 Scan phase 2, message change. 2022-05-24 10:37:30 +08:00
Krad
cfc18ed05e Empty Scan ID Initial check.2 2022-05-24 10:37:30 +08:00
Krad
614aca056e Fix jsonobject.h bug.2 2022-05-24 10:37:30 +08:00
Krad
f9825023ad Fix jsonobject.h bug 2022-05-24 10:37:30 +08:00
Krad
fbc2d900f5 Empty Scan ID Initial check. 2022-05-17 16:16:01 +08:00
Krad
0bfa7b2377 Refactor DeviceManager 2022-05-17 16:15:20 +08:00
Krad
60fa56cc18 Enable Scan confirm setting. 2022-05-13 17:59:19 +08:00
Krad
d268d48bc2 Add a Scan confirm setting. 2022-05-13 14:20:49 +08:00
Krad
d5038bb548 Fix simulation bug. 2022-05-13 14:20:22 +08:00
14 changed files with 407 additions and 157 deletions

View File

@@ -27,20 +27,26 @@ volatile int running = 1;
volatile int progress = 0;
volatile int status = READY;
volatile int stop_flag = 0;
volatile int empty = 0;
char output_path[256] = {0};
void ThreadFunc(void* args){
while (running){
WaitForSingleObject(e1, INFINITE);
status = SCANNING;
stop_flag = 0;
progress = 0;
for (int i = 0; i < 50; ++i) {
if (stop_flag > 0){
stop_flag = 0;
break;
}
progress = 0;
WaitForSingleObject(e1, INFINITE);
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){
progress = 139;
WaitForSingleObject(e2, INFINITE);
@@ -53,6 +59,10 @@ void ThreadFunc(void* args){
}
else{
progress = i *2;
}
if (stop_flag > 0 || status != SCANNING){
stop_flag = 0;
break;
}
Sleep(300);
}
@@ -79,6 +89,7 @@ int ScanControl(ScanAction actionType) {
break;
case PREVIEW_SCAN:
statusCountFlag = 1;
status = SCANNING;
printf("Do preview!\r\n");
break;
case STOP:
@@ -86,6 +97,7 @@ int ScanControl(ScanAction actionType) {
stop_flag = 1;
progress = 0;
status = READY;
SetEvent(e2);
printf("Stop everything!\r\n");
break;
case SCAN_CONTINUE:
@@ -105,7 +117,8 @@ StatusInfo GetStatus() {
}
//result, 0 success, other false
int SetScanInfo(const char* jsonString, int empty) {
int SetScanInfo(const char* jsonString, int e) {
empty = e;
return 0;
}
@@ -118,7 +131,15 @@ const size_t Col = 140;
const char* FRAME_FILE_PATH_1 = "./img1_v2.bin";
const char* FRAME_FILE_PATH_2 = "./pre_image.bin";
int previewCount = 0;
const char* GetPreviewData() {
previewCount++;
if (previewCount>3){
status = READY;
innerCallback("22222");
return NULL;
}
FILE* file;
preivew_change_flag++;
preivew_change_flag = preivew_change_flag % 2;

View File

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

View File

@@ -26,7 +26,8 @@ public:
enum ButtonStyle {
ButtonStyle_1 = 0, //开关样式1
ButtonStyle_2 = 1, //开关样式2
ButtonStyle_3 = 2 //开关样式3
ButtonStyle_3 = 2, //开关样式3
None = 3 //开关样式3
};
explicit ImageSwitch(QWidget *parent = 0);
@@ -37,7 +38,7 @@ protected:
private:
bool isChecked;
ButtonStyle buttonStyle;
ButtonStyle buttonStyle = None;
QString imgOffFile;
QString imgOnFile;

View File

@@ -7,10 +7,10 @@
#include <QVariant>
#include <QTimerEvent>
#include <QDate>
#include <QDateTime>
#include <qdebug.h>
#include "appvals/AppGlobalValues.h"
#include "json/ScanJson.h"
#include "json/jsonobject.h"
#define TRIGGER_EVENT EventCenter::Default()->triggerEvent
#define THROW_ERROR(errormsg)\
@@ -43,7 +43,7 @@ void ErrorCallback(const char* msg)
}
void DeviceManager::emitErrorCallback(const char *msg) {
this->setErrorOccurred(true);
errorOccurred=true;
printf("Error Callback , message:%s\r\n", msg);
QString m(msg);
emit raiseGlobalError( m);
@@ -53,12 +53,12 @@ void DeviceManager::emitErrorCallback(const char *msg) {
void DeviceManager::initDevice() {
InitLib(ErrorCallback);
deviceInfTimerID = startTimer(1000);
deviceInfTimerID = startTimer(10000);
// empty scan
connect(EventCenter::Default(), &EventCenter::RequestEmptyScan, [=](QObject* sender, QObject* detail) {
std::string json = getJsonFromPatInf(detail);
processScan(json.c_str(), true);
startScan(json.c_str(), true);
});
// Patient scan
connect(EventCenter::Default(), &EventCenter::RequestPatientScan, [=](QObject* sender, QObject* detail) {
@@ -66,7 +66,7 @@ void DeviceManager::initDevice() {
qDebug() << json.c_str();
if (!json.empty())
{
processScan(json.c_str());
startScan(json.c_str());
}
});
// Continue Scan
@@ -112,11 +112,11 @@ void DeviceManager::initDevice() {
QString s("%1 %2");
s = s.arg(QDateTime::currentDateTime().toString("yyyy/MM/dd HH:mm:ss"), ("Scan Stopped!"));
TRIGGER_EVENT(GUIEvents::GlobalBannerMessage, nullptr, (QObject*)&s);
// preview end
TRIGGER_EVENT(GUIEvents::InvokeOperationEnd, nullptr, nullptr);
TRIGGER_EVENT(GUIEvents::ResponseStop, nullptr, nullptr);
AppGlobalValues::setInProcessing(false);
});
// preview
connect(EventCenter::Default(), &EventCenter::RequestPreviewScan, [=]() {
// check device status=========================================
@@ -132,10 +132,11 @@ void DeviceManager::initDevice() {
if (!ScanControl(PREVIEW_SCAN))
{
qDebug() << "Preview success!";
lastStatus = SCANNING;
// lastStatus = SCANNING;
previewing = true;
// timerID = startTimer(500);
TRIGGER_EVENT(GUIEvents::ResponsePreview, nullptr, nullptr);
// end scan without prompt
TRIGGER_EVENT(GUIEvents::InvokeOperationEnd, nullptr, nullptr);
QString s("Device Previewing!");
TRIGGER_EVENT(GUIEvents::GlobalBannerMessage, nullptr, (QObject*)&s);
@@ -147,7 +148,7 @@ void DeviceManager::initDevice() {
THROW_ERROR(msg);
qDebug() << "Error thrown!";
});
// init the preview data caller thread
previewDataCaller = QThread::create([=]() {
while (!endLoop)
{
@@ -163,7 +164,9 @@ void DeviceManager::initDevice() {
if (inf.status == SCANNING) {
qDebug() << "Preview data reader read start!";
const char* data = GetPreviewData();
if (!data)continue;
if (!data){
continue;
}
qDebug() << "Preview data reader read end!";
QByteArray bytes = QByteArray::fromRawData(data, 140 * 140);
//double check
@@ -176,6 +179,12 @@ void DeviceManager::initDevice() {
TRIGGER_EVENT(GUIEvents::ResponsePreviewData, nullptr, (QObject*)(&bytes));
qDebug() << "Preview data response event end!";
}
else{
// lastStatus = READY;
previewing = false;
AppGlobalValues::setInProcessing(false);
QThread::sleep(3);
}
QThread::msleep(100);
}
});
@@ -184,115 +193,133 @@ void DeviceManager::initDevice() {
}
const char * getPhaseName(int phase){
const char* names[3] = {"Initializing","Scanning", "CE Measuring"};
return names[phase-1];
}
void DeviceManager::timerEvent(QTimerEvent* event) {
if (event->timerId() == deviceInfTimerID) {
QString temp = QString(GetDeviceInfo(MEAN_TEMPERATURE));
TRIGGER_EVENT(GUIEvents::ResponseDeviceTemperature, nullptr, (QObject*)&temp);
return;
}
//scanning progress timer
{
//error exit, callback error
if (errorOccurred)
{
goto exitTimer;
}
// previewing exit
if (previewing)
{
QString msg("Device is previewing, exit current operation!");
THROW_ERROR(msg);
goto exitTimer;
}
else {
// check device status=========================================
qDebug() << "GetStatus";
StatusInfo inf = GetStatus();
qDebug() << "Scanning request status, status:" << getStatusString(inf.status);
//设备正常扫描中
if (inf.status == SCANNING) {
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;
if (event->timerId() == deviceInfTimerID) {
QString temp = QString(GetDeviceInfo(MEAN_TEMPERATURE));
TRIGGER_EVENT(GUIEvents::ResponseDeviceTemperature, nullptr, (QObject *) &temp);
return;
}
//scanning progress timer
//error exit, callback error
if (errorOccurred) {
timerID = event->timerId();
exitScanTimer();
return;
}
// previewing exit
if (previewing) {
QString msg("Device is previewing, exit current operation!");
THROW_ERROR(msg);
} else {
// check device status=========================================
qDebug() << "GetStatus";
StatusInfo inf = GetStatus();
qDebug() << "Scanning request status, status:" << getStatusString(inf.status);
//设备正常扫描中
if (inf.status == SCANNING) {
scanProcess(inf.progress);
return;
} else {
//未发生错误并且,之前状态是扫描,代表正常扫描完成
if (lastStatus == SCANNING && ! errorOccurred) {
prepareFinishScan();
}
else {
//未发生错误并且,之前状态是扫描,代表正常扫描完成
if (lastStatus == SCANNING) {
qDebug() << "Scan finished";
QVariant var(true);
qDebug() << "InvokeOperationEnd";
TRIGGER_EVENT(GUIEvents::InvokeOperationEnd, nullptr, (QObject*)&var);
AppGlobalValues::setInProcessing(false);
lastStatus = -1;
previewing = false;
QString s("%1 %2");
s = s.arg(QDateTime::currentDateTime().toString("yyyy/MM/dd HH:mm:ss")).arg("Scan finished");
TRIGGER_EVENT(GUIEvents::GlobalBannerMessage, nullptr, (QObject*)&s);
QString outputPath = GetDeviceInfo(DeviceInfo::DEV_OUTPATH);
outputPath = outputPath.replace("\\","/");
if (outputPath.endsWith('/')) outputPath = outputPath.remove(outputPath.length()-1,1);
QStringList list = outputPath.split('/');
if (list.length()){
if (AppGlobalValues::EmptyScanFlag().toBool()){
ScanJson::Current()->setEmptyScanID(list.last().toStdString().c_str());
}else{
ScanJson::Current()->setScanID(list.last().toStdString().c_str());
}
ScanJson::Current()->save();
}
else{
QString msg("Scan Output Path error!");
THROW_ERROR(msg);
}
}
//一般不会出现其他情况
else {
QString msg("Unknown error in scanning progress timer");
THROW_ERROR(msg);
}
}
}
exitTimer:
qDebug() << "Scanning progress Timer exit";
killTimer(timerID);
timerID = -1;
lastStatus = -1;
previewing = false;
return;
}
//一般不会出现其他情况
// else {
// QString msg("Unknown error in scanning progress timer");
// THROW_ERROR(msg);
// }
}
}
exitScanTimer();
}
void DeviceManager::scanProcess(int sProgress) {
qDebug() << "current output path:" << getScanOutputPath();
lastStatus = SCANNING;
//normal scan pending
int phase = sProgress / 100 + 1;
int progress = sProgress % 100;
// scan with phase 3 has a different message
QString extraMsg = (AppGlobalValues::EmptyScanFlag().toBool() ||
(scanPhase != 3)) ? "": ", patient can leave";
QVariant var(QString("%1%3\r\n progress:%2%").arg(getPhaseName(scanPhase)).arg(progress).arg(extraMsg));
TRIGGER_EVENT(InvokeOperationProgress, nullptr, (QObject *) &var);
// 300 means finished
if (sProgress == 300) return;
//phase control
//no change return
if (scanPhase == phase) return;
// error phase
if (phase > 3 || scanPhase > phase) {
QString errorMsg = QString("Error Scan Phase code, current Phase code:%1, new Phase code:%2!").arg(
scanPhase).arg(phase);
THROW_ERROR(errorMsg)
exitScanTimer();
return;
}
// enter phase 2
if ((scanPhase = phase) == 2) {
if (!AppGlobalValues::EmptyScanFlag().toBool() && JsonObject::Instance()->getScanConfirm()) {
var.setValue(QString("Waiting for operator to start scan!\r\n Click \"Next\" to continue!"));
TRIGGER_EVENT(InvokeOperationPending, nullptr, (QObject *) &var);
exitScanTimer();
}
//empty scan no pending, auto continue
else {
postContinueCommand();
}
}
}
void DeviceManager::processScan(const char* json, bool empty) {
void DeviceManager::exitScanTimer() {
qDebug() << "Scanning progress Timer exit";
if (timerID>0)killTimer(timerID);
timerID = -1;
lastStatus = -1;
previewing = false;
}
void DeviceManager::prepareFinishScan() {
qDebug() << "Scan finished";
QVariant var(JsonObject::Instance()->getCompleteNotify());
qDebug() << "InvokeOperationEnd";
// stop normal scan with prompt
TRIGGER_EVENT(InvokeOperationEnd, nullptr, (QObject *) &var);
AppGlobalValues::setInProcessing(false);
// log, no need
// QString s("%1 %2");
// s = s.arg(QDateTime::currentDateTime().toString("yyyy/MM/dd HH:mm:ss")).arg("Scan finished");
// TRIGGER_EVENT(GlobalBannerMessage, nullptr, (QObject *) &s);
// get output data path
QString outputPath = GetDeviceInfo(DEV_OUTPATH);
outputPath = outputPath.replace("\\", "/");
// get scan ID from path
if (outputPath.endsWith('/')) outputPath = outputPath.remove(outputPath.length() - 1, 1);
QStringList list = outputPath.split('/');
if (list.length()) {
if (AppGlobalValues::EmptyScanFlag().toBool()) {
ScanJson::Current()->setEmptyScanID(list.last().toStdString().c_str());
} else {
ScanJson::Current()->setScanID(list.last().toStdString().c_str());
}
// save json
ScanJson::Current()->save();
} else {
QString msg("Scan Output Path error!");
THROW_ERROR(msg);
}
}
void DeviceManager::startScan(const char* json, bool empty) {
//clear last error state first
errorOccurred = false;
// check device status=========================================

View File

@@ -15,13 +15,37 @@ public:
static DeviceManager manager;
return &manager;
}
DeviceManager() = default;
~DeviceManager() override = default ;
DeviceManager(const DeviceManager&) = delete;
DeviceManager operator=(const DeviceManager&) = delete;
/**
* init device, include Shimlib and it's error call back,
* deviceInfTimer to get temperature of water, and the
* preview data caller thread.
*/
void initDevice();
/**
* close and release the device reference resource.
*/
void close();
/**
* Get Firm ware version
* @return Firm ware version
*/
QString getSoftwareVersion();
/**
* Get Scan data output path
* @return Scan data output path
*/
QString getScanOutputPath();
void setErrorOccurred(bool v){
errorOccurred = v;
}
QString getSoftwareVersion();
QString getScanOutputPath();
bool getErrorOccurred(){
return errorOccurred;
}
@@ -33,17 +57,48 @@ protected:
void timerEvent(QTimerEvent* event) override;
private:
void processScan(const char* json, bool empty = false);
/**
* To start a new scan operation
* @param json The patient information json string
* @param empty Empty scan flag
*/
void startScan(const char* json, bool empty = false);
/**
* Post Scan start command to Shimlib
*/
void postScanCommand();
/**
* Post Continue Scan command to Shimlib
* @param useTimer start a new timer flag
*/
void postContinueCommand(bool useTimer = false);
/**
* Prepare for finishing the Scan
*/
void prepareFinishScan();
/**
* exit the current Scan process timer
*/
void exitScanTimer();
/**
* Process scan progress change
* @param Scan progress
*/
void scanProcess(int progress);
int scanPhase = 1;
int timerID = -1;
volatile int timerID = -1;
int deviceInfTimerID = -1;
int lastStatus = -1;
bool previewing = false;
volatile bool endLoop = false;
bool errorOccurred = false;
QThread* previewDataCaller;
volatile bool errorOccurred = false;
QThread* previewDataCaller = nullptr;
};

View File

@@ -16,6 +16,7 @@
#include <qdebug.h>
#include "log/UserOperationLog.h"
#include <QLabel>
#include "json/jsonobject.h"
#ifdef WIN32
#else
@@ -218,7 +219,7 @@ ScanFormWidget::ScanFormWidget(QWidget* parent) : TabFormWidget(parent) {
patient_information->setPatientInformation((PatientInformation*)data);
});
connect(btnRefresh, &QToolButton::clicked, [=]() {
QString patientInf(patient_information->getCurrentPatientJsonString(false));
QString patientInf(patient_information->getCurrentPatientJsonString(true));
LOG_USER_OPERATION(StartRefresh);
EventCenter::Default()->triggerEvent(GUIEvents::RequestEmptyScan, nullptr, (QObject*)(&patientInf));
});
@@ -229,6 +230,11 @@ ScanFormWidget::ScanFormWidget(QWidget* parent) : TabFormWidget(parent) {
connect(btnScan, &QToolButton::clicked, [=]() {
QString patientInf(patient_information->getCurrentPatientJsonString(false));
LOG_USER_OPERATION(StartScan);
if (!JsonObject::Instance()->getEmptyScanID()){
QString msg(tr("No refresh data exists, please do Refresh operation first."));
EventCenter::Default()->triggerEvent(GUIEvents::DeviceErrorRaise, nullptr, (QObject*)(&msg));
return;
}
EventCenter::Default()->triggerEvent(GUIEvents::RequestPatientScan, nullptr, (QObject*)(&patientInf));
});
connect(btnStop, &QToolButton::clicked, [=]() {
@@ -252,9 +258,11 @@ ScanFormWidget::ScanFormWidget(QWidget* parent) : TabFormWidget(parent) {
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);
btnPreview->setCheckable(val);
btnPreview->setChecked(val);

View File

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

View File

@@ -5,6 +5,8 @@
#include <QDebug>
#include <QLineEdit>
#include <QToolButton>
#include <QGridLayout>
#include "src/dialogs/SelectDialog.h"
#include "network/networkcfgdialog.h"
@@ -48,7 +50,30 @@ systemSettingForm::systemSettingForm(QWidget* parent) :
ui->btnFlt->setText(JsonObject::Instance()->defaultFilter());
ui->btnFlt->setObjectName("BigBtn");
////test begin
QGridLayout* gridLayout = (QGridLayout*)ui->block10->layout();
auto btn_scanConfirm = new ImageSwitch(this);
auto lbl_scanConfirm = new QLabel(this);
lbl_scanConfirm->setText("Scan Confirm");
gridLayout->addWidget(btn_scanConfirm, 4, 2, 1, 1);
gridLayout->addWidget(lbl_scanConfirm, 4, 0, 1, 1);
btn_scanConfirm->setChecked(JsonObject::Instance()->getScanConfirm());
QFrame* line5 = new QFrame(this);
line5->setFrameShape(QFrame::HLine);
line5->setFrameShadow(QFrame::Sunken);
gridLayout->addWidget(line5,5,0);
auto btn_scanComplete = new ImageSwitch(this);
auto lbl_scanComplete = new QLabel(this);
lbl_scanComplete->setText("Complete Notify");
gridLayout->addWidget(btn_scanComplete, 6, 2, 1, 1);
gridLayout->addWidget(lbl_scanComplete, 6, 0, 1, 1);
btn_scanComplete->setChecked(JsonObject::Instance()->getCompleteNotify());
QFrame* line6 = new QFrame(this);
line6->setFrameShape(QFrame::HLine);
line6->setFrameShadow(QFrame::Sunken);
gridLayout->addWidget(line6,7,0);
////test begin
//flag_disksize = true;
//m_disksize = 75.0;
////test end
@@ -86,6 +111,12 @@ systemSettingForm::systemSettingForm(QWidget* parent) :
////
}
});
connect(btn_scanConfirm, &ImageSwitch::clicked, [=]() {
JsonObject::Instance()->setScanConfirm(btn_scanConfirm->getChecked());
});
connect(btn_scanComplete, &ImageSwitch::clicked, [=]() {
JsonObject::Instance()->setCompleteNotify(btn_scanComplete->getChecked());
});
connect(ui->btn_network, &QToolButton::clicked, [=]() {
GetAdminPsw dialog(this);
if (dialog.exec() == QDialog::Accepted)

View File

@@ -8,9 +8,14 @@
#include <QCoreApplication>
void ScanJson::save() {
if (!root) return;
QFile f(QString("%1/%2.json").arg(QCoreApplication::applicationDirPath(),scanID.c_str()));
QDir d(QCoreApplication::applicationDirPath());
if (!d.exists("jsons")){
d.mkdir("jsons");
}
QFile f(QString("%1/jsons/%2.json").arg(QCoreApplication::applicationDirPath(),scanID.c_str()));
f.open(QFileDevice::ReadWrite);
cJSON_AddItemToObject(root, "EmptyScanID", cJSON_CreateString(emptyScanID.c_str()));
cJSON_AddItemToObject(root, "EmptyScanID",
cJSON_CreateString(emptyScanID.empty()?JsonObject::Instance()->getEmptyScanID():emptyScanID.c_str()));
cJSON_AddItemToObject(root, "ScanID", cJSON_CreateString(scanID.c_str()));
char* content = cJSON_Print(root);
f.write(content);

View File

@@ -7,6 +7,7 @@
#include <string>
#include "cJSON.h"
#include "jsonobject.h"
class ScanJson {
public:
@@ -27,8 +28,10 @@ public:
void setEmptyScanID(const char * id){
emptyScanID.clear();
emptyScanID.append(id);
JsonObject::Instance()->setEmptyScanID(id);
setScanID(id);
}
void save();
static ScanJson* Current(){
static ScanJson instance;

View File

@@ -7,6 +7,7 @@
#include <QTranslator>
#include <QDebug>
#include <QApplication>
#include <iostream>
#include "json/cJSON.h"
const char* strProductFileName = "./cfgs/usct-product.json";
const char* strProductFileNameDefault = "./cfgs/usct-product";
@@ -30,7 +31,13 @@ void JsonObject::setJsonString(const char* catergory, const char* stringName, co
if (!first) return;
cJSON* Item = cJSON_CreateString(stringValue);
cJSON_ReplaceItemInObject(first, stringName, Item);
cJSON* valItem = cJSON_GetObjectItem(first, stringName);
if (valItem){
cJSON_ReplaceItemInObject(first, stringName, Item);
}
else{
cJSON_AddItemToObject(first, stringName , Item);
}
if (save)
{
savecfg();
@@ -50,6 +57,41 @@ char* JsonObject::getJsonString(const char* catergory, const char* stringName)
return second->valuestring;
}
void JsonObject::setBool(const char *catergory, const char *stringName, bool val, bool save) {
if (!loadcfg())
return;
cJSON* first = cJSON_GetObjectItem((cJSON*)json_root, catergory);
if (!first) return;
cJSON* Item = cJSON_CreateBool(val?1:0);
cJSON* valItem = cJSON_GetObjectItem(first, stringName);
if (valItem){
cJSON_ReplaceItemInObject(first, stringName, Item);
}
else{
cJSON_AddItemToObject(first, stringName , Item);
}
if (save)
{
savecfg();
}
}
bool JsonObject::getBool(const char* catergory, const char* stringName)
{
if (!loadcfg())
return false;
cJSON* first = cJSON_GetObjectItem((cJSON*)json_root, catergory);
if (!first) return false;
cJSON* second = cJSON_GetObjectItem(first, stringName);
if (!second) return false;
return second->valueint;
}
char* JsonObject::getArrayNode(const char* catergory, const char* stringName, int index, const char* id)
{
if (!loadcfg())
@@ -297,11 +339,19 @@ bool JsonObject::savecfg()
}
char* strJsonData = cJSON_Print((cJSON*)json_root);
std::stringstream ss;
ss << strJsonData;
outFile << ss.rdbuf();
outFile.close();
m_bLoaded = false;
if (strlen(strJsonData)>1){
std::stringstream ss;
ss << strJsonData;
outFile << ss.rdbuf();
outFile.flush();
outFile.close();
m_bLoaded = false;
}
else{
std::cout<<"===========================================app want write empty content to cfg json============================================="<<std::endl;
}
delete strJsonData;
return true;
}
@@ -396,7 +446,6 @@ void JsonObject::autoDHCP(bool ena)
setJsonString("address", "dhcp", str.toStdString().c_str());
}
IpAddr JsonObject::getDefaultIpAddr()
{
IpAddr obj;
@@ -474,3 +523,29 @@ void JsonObject::setIpRouteList(const QList<QStringList>& list)
}
savecfg();
}
void JsonObject::setEmptyScanID(const char *id) {
setJsonString("deviceparam","EmptyScanID",id, true);
}
const char *JsonObject::getEmptyScanID() {
return getJsonString("deviceparam","EmptyScanID");
}
bool JsonObject::getScanConfirm() {
return getBool("general","ScanConfirm");
}
void JsonObject::setScanConfirm(bool val) {
setBool("general","ScanConfirm", val, true);
}
bool JsonObject::getCompleteNotify() {
return getBool("general","CompleteNotify");
}
void JsonObject::setCompleteNotify(bool val) {
setBool("general","CompleteNotify", val, true);
}

View File

@@ -87,6 +87,15 @@ public:
bool isDHCP();
void autoDHCP(bool);
bool getScanConfirm();
void setScanConfirm(bool val);
bool getCompleteNotify();
void setCompleteNotify(bool val);
const char* getEmptyScanID();
void setEmptyScanID(const char* id);
IpAddr getDefaultIpAddr();
void setDefaultIpAddr(const IpAddr& addr);
@@ -104,6 +113,9 @@ private:
void setJsonString(const char* catergory, const char* stringName, const char* stringValue, bool save = true);
char* getJsonString(const char* catergory, const char* stringName);
void setBool(const char* catergory, const char* stringName,bool val, bool save = true);
bool getBool(const char* catergory, const char* stringName);
char* getArrayNode(const char* catergory, const char* stringName, int index, const char* id);
void setArrayNode(const char* catergory, const char* stringName, int index, const char* id, const char* stringValue);
int getArraySize(const char* catergory, const char* stringName);

View File

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

View File

@@ -143,13 +143,24 @@ MainWindow::MainWindow(QWidget* parent) :
msgDialog->showMessage(var->toString());
}
});
connect(EventCenter::Default(), &EventCenter::InvokeOperationEnd, [=]() {
connect(EventCenter::Default(), &EventCenter::InvokeOperationEnd, [=](QObject*, QObject* v) {
if (!msgDialog) return;
if (!msgDialog->isHidden())msgDialog->accept();
delete msgDialog;
msgDialog = nullptr;
AppGlobalValues::setInProcessing(false);
});
if (!msgDialog->isHidden()){
if (v && ((QVariant*)v)->toBool()) {
msgDialog->stopLoading();
msgDialog->showMessage("Scan completed!");
msgDialog->showExitButton();
msgDialog->setWindowModality(Qt::WindowModal);
msgDialog->exec();
}
else{
msgDialog->accept();
}
delete msgDialog;
msgDialog = nullptr;
AppGlobalValues::setInProcessing(false);
}
});
connect(EventCenter::Default(), &EventCenter::RequestLogin, [=](QObject*, QObject* msg) {
this->requestLogin();
});