22 Commits

Author SHA1 Message Date
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
Krad
3d22dc1512 v0.6.11 2022-05-12 15:03:11 +08:00
Krad
ae89aeffe4 Phase control workflow logic 2022-05-12 14:53:17 +08:00
Krad
6ba9786efb InvokeOperationPending event, for phase control 2022-05-12 14:51:47 +08:00
Krad
a7a5e1e308 Add pending function to guimessagedialog. 2022-05-12 09:07:55 +08:00
Krad
d18332baed Fix ShimLib simulation logic. 2022-05-12 09:04:02 +08:00
Krad
f7540385a4 Scan Json create and save. 2022-05-11 15:44:43 +08:00
Krad
1abd387617 New ShimLib simulation logic (windows only). 2022-05-11 15:38:20 +08:00
Krad
24f6e4e97c Clean code. 2022-05-11 09:40:26 +08:00
Krad
2e9fb9960e Fix column header click bug(about current row) 2022-05-10 16:40:42 +08:00
Krad
99f19e8b5b Add date onlyBackward limit. 2022-05-09 15:30:57 +08:00
22 changed files with 602 additions and 204 deletions

View File

@@ -8,7 +8,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
# GUI Version
set(GUI_VERSION_MAJOR 0)
set(GUI_VERSION_MINOR 6)
set(GUI_VERSION_BUILD 10)
set(GUI_VERSION_BUILD 11)
set(GUI_VERSION_BETA 1)
# use AppVersion.h as a configure file
configure_file(

8
docs/v0.6.11.txt Normal file
View File

@@ -0,0 +1,8 @@
v0.6.11
1. 修复CMake导致的UI构建错误
2. ShimLib加入了DEV_OUTPATH(当前Scan的数据存储目录)功能
3. 给日期滑块加入了日期限制。
4. 修复了TableView列头点击导致的选中行丢失问题。
5. Windows下新增了异步仿真逻辑。
6. 实现了Scan json的生成。
7. 实现了新的分段Scan逻辑。

View File

@@ -4,6 +4,8 @@
#include "DateSelectDialog.h"
#include <QVBoxLayout>
#include <QLabel>
#include <QDate>
#include "components/DateSlidePickerBox.h"
DateSelectDialog::DateSelectDialog(QWidget *parent, Qt::WindowFlags f) : GUIFormBaseDialog(parent, f) {
this->setFixedSize(460, 380);
@@ -11,7 +13,12 @@ DateSelectDialog::DateSelectDialog(QWidget *parent, Qt::WindowFlags f) : GUIForm
box = new DateSlidePickerBox(formWidget);
box->setObjectName("slider_one");
box->setSelectedValue("1990-01-01");
lbl_error = new QLabel(this);
lbl_error->setObjectName("warn");
lbl_error->setVisible(false);
lbl_error->setText(tr("Date exceeded!"));
layout->addWidget(box);
layout->addWidget(lbl_error);
}
DateSelectDialog::~DateSelectDialog() {
@@ -19,6 +26,7 @@ DateSelectDialog::~DateSelectDialog() {
}
QString DateSelectDialog::getSelectedValue() {
return box->getSelectedValue();
}
@@ -28,6 +36,13 @@ void DateSelectDialog::setSelectedValue(const QString &val) {
}
bool DateSelectDialog::updateReferenceData() {
if (onlyBackward){
QDate v = QDate::fromString(box->getSelectedValue(),"yyyy-MM-dd");
bool flag = QDate::currentDate()>=v;
this->setFixedHeight(flag? 380:410);
lbl_error->setVisible(!flag);
return flag;
}
return true;
}

View File

@@ -7,6 +7,7 @@
#include "dialogs/GUIFormBaseDialog.h"
class DateSlidePickerBox;
class QLabel;
class DateSelectDialog:public GUIFormBaseDialog{
Q_OBJECT
public:
@@ -15,9 +16,14 @@ public:
QString getSelectedValue();
void setSelectedValue(const QString& val);
void showEvent(QShowEvent *) override;
void setOnlyBackward(bool val){
onlyBackward = val;
}
protected:
bool updateReferenceData() override;
DateSlidePickerBox* box;
QLabel* lbl_error = nullptr;
bool onlyBackward = true;
};

View File

@@ -1,80 +1,107 @@
#include <stdio.h>
#include <stdlib.h>
#include "ShimLib.h"
#include <Windows.h>
#include <process.h>
#include <time.h>
typedef void(*error_cb)(const char* msg);
int statusCountFlag = 0;
error_cb innerCallback = NULL;
void ThreadFunc(void*);
HANDLE th;
HANDLE e1,e2;
int InitLib(error_cb cb) {
innerCallback = cb;
innerCallback("11111");
e1 = CreateEvent(NULL, FALSE, FALSE, "e1");
e2 = CreateEvent(NULL, FALSE, FALSE, "e2");
th = _beginthread(ThreadFunc,0, NULL);
return 0;
}
volatile int running = 1;
volatile int progress = 0;
volatile int status = READY;
volatile int stop_flag = 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;
}
if (i == 20){
progress = 139;
WaitForSingleObject(e2, INFINITE);
}
else if ( i > 20 && i<35){
progress = i * 2 + 100;
}
else if(i >= 35){
progress = i * 2 + 200;
}
else{
progress = i *2;
}
Sleep(300);
}
status = READY;
}
}
int ScanControl(ScanAction actionType) {
switch (actionType) {
case SCAN:
printf("Do Scan!\r\n");
statusCountFlag = 2;
break;
case PREVIEW_SCAN:
statusCountFlag = 1;
printf("Do preview!\r\n");
break;
case STOP:
statusCountFlag = 0;
printf("Stop everything!\r\n");
break;
}
case SCAN:
printf("Do Scan!\r\n");
statusCountFlag = 2;
SYSTEMTIME st = {0};
GetLocalTime(&st);
sprintf(output_path, "%d%02d%02dT%02d%02d%02d",
st.wYear,
st.wMonth,
st.wDay,
st.wHour,
st.wMinute,
st.wSecond);
SetEvent(e1);
break;
case PREVIEW_SCAN:
statusCountFlag = 1;
status = SCANNING;
printf("Do preview!\r\n");
break;
case STOP:
statusCountFlag = 0;
stop_flag = 1;
progress = 0;
status = READY;
printf("Stop everything!\r\n");
break;
case SCAN_CONTINUE:
SetEvent(e2);
break;
}
return 0;
}
StatusInfo GetStatus() {
StatusInfo inf;
switch (statusCountFlag)
{
case 0:
inf.status = READY;
break;
case 1:
inf.status = SCANNING;
inf.progress = 0.0f;
break;
case 2:
inf.status = SCANNING;
inf.progress = 0.3f;
statusCountFlag++;
break;
case 3:
inf.status = SCANNING;
inf.progress = 0.6f;
statusCountFlag++;
break;
case 4:
inf.status = SCANNING;
inf.progress = 0.9f;
statusCountFlag++;
break;
case 5:
inf.status = SCANNING;
inf.progress = 1.0f;
statusCountFlag = 0;
break;
case 6:
// case 7:
// inf.status = BUSY;
// statusCountFlag++;
// break;
// case 8:
inf.status = BUSY;
statusCountFlag = 0;
break;
default:
inf.status = BUSY;
statusCountFlag = 0;
}
inf.status = status;
inf.progress = progress;
return inf;
}
@@ -109,12 +136,19 @@ const char* GetPreviewData() {
const char* GetDeviceInfo(DeviceInfo infoType) {
switch (infoType) {
case MEAN_TEMPERATURE:
return "28";
case VERSION:
return "6.6.06";
case DEV_OUTPATH:
return "path to store bin";
case MEAN_TEMPERATURE:
return "28";
case VERSION:
return "6.6.06";
case DEV_OUTPATH:
return output_path;
}
return "";
}
#ifdef _WIN32
void StopDevice(){
CloseHandle(e1);
CloseHandle(e2);
}
#endif

View File

@@ -16,7 +16,7 @@ typedef enum {
typedef struct StatusInfo {
DeviceStatus status;// a enum represent device current status
float progress;// percent value of operation
int progress;// percent value of operation
} StatusInfo;
@@ -25,6 +25,7 @@ typedef enum {
SCAN,// Start scan action
PREVIEW_SCAN,// Start preview scan action
STOP,// Stop current scan
SCAN_CONTINUE,//Continue pending scan
} ScanAction;
//kinds of device information
@@ -46,6 +47,11 @@ extern const char *GetPreviewData();
extern const char *GetDeviceInfo(DeviceInfo infoType);
#ifdef _WIN32
extern void StopDevice();
#endif
#ifdef __cplusplus
};
#endif

View File

@@ -8,7 +8,8 @@
#define APP_VALUES()\
ADD_APP_VALUE(InProcessing)\
ADD_APP_VALUE(LastOperationTime)\
ADD_APP_VALUE(LastOperation)
ADD_APP_VALUE(LastOperation)\
ADD_APP_VALUE(EmptyScanFlag)\
#include <QApplication>
#include <QVariant>

View File

@@ -7,9 +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)\
@@ -31,7 +32,6 @@ const char* getStatusString(int status)
return "";
}
std::string getJsonFromPatInf(QObject* obj)
{
return ((QString*)obj)->toStdString();
@@ -58,11 +58,7 @@ void DeviceManager::initDevice() {
// empty scan
connect(EventCenter::Default(), &EventCenter::RequestEmptyScan, [=](QObject* sender, QObject* detail) {
std::string json = getJsonFromPatInf(detail);
// qDebug()<<json.c_str();
// void * jss = malloc(json.size());
// memcpy(jss,json.c_str(),json.size());
// processScan((char*)jss,true);
processScan(json.c_str(), true);
startScan(json.c_str(), true);
});
// Patient scan
connect(EventCenter::Default(), &EventCenter::RequestPatientScan, [=](QObject* sender, QObject* detail) {
@@ -70,12 +66,13 @@ void DeviceManager::initDevice() {
qDebug() << json.c_str();
if (!json.empty())
{
// void * jss = malloc(json.size());
// memcpy(jss,json.c_str(),json.size());
// processScan((char*)jss);
processScan(json.c_str());
startScan(json.c_str());
}
});
// Continue Scan
connect(EventCenter::Default(), &EventCenter::RequestContinueScan, [=](QObject* sender, QObject* detail) {
postContinueCommand(true);
});
// stop
connect(EventCenter::Default(), &EventCenter::RequestStop, [=]() {
qDebug() << "GetStatus";
@@ -93,11 +90,6 @@ void DeviceManager::initDevice() {
return;
}
}
// if (inf.status == BUSY) {
// QString msg("Device is busy, Stop operation fail!");
// THROW_ERROR(msg);
// return;
// };
AppGlobalValues::setInProcessing(true);
TRIGGER_EVENT(GUIEvents::InvokeOperationStart, nullptr, nullptr);
//ScanControl fail
@@ -124,7 +116,6 @@ void DeviceManager::initDevice() {
TRIGGER_EVENT(GUIEvents::ResponseStop, nullptr, nullptr);
AppGlobalValues::setInProcessing(false);
});
// preview
connect(EventCenter::Default(), &EventCenter::RequestPreviewScan, [=]() {
// check device status=========================================
@@ -155,7 +146,7 @@ void DeviceManager::initDevice() {
THROW_ERROR(msg);
qDebug() << "Error thrown!";
});
// init the preview data caller thread
previewDataCaller = QThread::create([=]() {
while (!endLoop)
{
@@ -192,80 +183,132 @@ 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)
{
// qDebug() << "Error occurred, exit progress timer";
// QString msg("Error occurred, exit current operation!");
// THROW_ERROR(msg);
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
QVariant var(inf.progress);
qDebug() << "Normal scan, invoke InvokeOperationProgress:" << inf.progress;
TRIGGER_EVENT(GUIEvents::InvokeOperationProgress, nullptr, (QObject*)&var);
return;
}
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);
}
//一般不会出现其他情况
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;
}
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) {
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) {
prepareFinishScan();
}
//一般不会出现其他情况
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";
killTimer(timerID);
timerID = -1;
lastStatus = -1;
previewing = false;
}
void DeviceManager::prepareFinishScan() {
qDebug() << "Scan finished";
QVariant var(true);
qDebug() << "InvokeOperationEnd";
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=========================================
@@ -282,6 +325,7 @@ void DeviceManager::processScan(const char* json, bool empty) {
AppGlobalValues::setInProcessing(true);
TRIGGER_EVENT(GUIEvents::InvokeOperationStart, nullptr, (QObject*)&msg);
qDebug() << "SetScanInfo>>>>>>>>>>>>>>>>>>>>";
AppGlobalValues::setEmptyScanFlag(empty);
int ret = SetScanInfo(json, empty ? 1 : 0);
if (ret) {
qDebug() << ">>>>>>>>>>>>>>>>>>>>SetScanInfo failed";
@@ -291,23 +335,42 @@ 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() {
#ifdef _WIN32
StopDevice();
#endif
previewDataCaller->terminate();
delete previewDataCaller;
}
@@ -319,3 +382,5 @@ QString DeviceManager::getSoftwareVersion() {
QString DeviceManager::getScanOutputPath() {
return GetDeviceInfo(DEV_OUTPATH);
}

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,14 +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;
int deviceInfTimerID = -1;
int lastStatus = -1;
bool previewing = false;
volatile bool endLoop = false;
bool errorOccurred = false;
QThread* previewDataCaller;
QThread* previewDataCaller = nullptr;
};

View File

@@ -2,6 +2,8 @@
#include "guimessagedialog.h"
#include "ui_guimessagedialog.h"
#include "event/EventCenter.h"
#include <QToolButton>
#include <QHBoxLayout>
GUIMessageDialog::GUIMessageDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::GUIMessageDialog)
@@ -12,8 +14,21 @@ GUIMessageDialog::GUIMessageDialog(QWidget *parent) :
this->showFullScreen ();
ui->lbl_msg->setVisible(false);
ui->lbl_progressicon->setVisible(false);
ui->btn_main->setVisible(false);
ui->btn_main->setText("OK");
btn_main = new QToolButton(this);
btn_main->setObjectName("btn_main");
btn_main->setVisible(false);
btn_main->setText("OK");
btn_Append = new QToolButton(this);
btn_Append->setObjectName("btn_main");
btn_Append->setVisible(false);
btn_Append->setText("Stop");
QWidget* btnContainer = new QWidget(this);
QHBoxLayout* hlayout = new QHBoxLayout(btnContainer);
hlayout->setMargin(0);
hlayout->addWidget(btn_main);
hlayout->addWidget(btn_Append);
ui->widget_2->layout()->addWidget(btnContainer);
this->setWindowOpacity(0.6);
for (int i=1; i<=6;i++)
{
@@ -51,14 +66,14 @@ void GUIMessageDialog::stopLoading() {
killTimer(timerID);
timerID=-1;
}
disconnect(ui->btn_main,0,0,0);
disconnect(btn_main,0,0,0);
ui->lbl_progressicon->setVisible(false);
}
void GUIMessageDialog::startLoading() {
ui->lbl_progressicon->setVisible(true);
disconnect(ui->btn_main,0,0,0);
connect(ui->btn_main,&QToolButton::clicked,[=](){
disconnect(btn_main,0,0,0);
connect(btn_main,&QToolButton::clicked,[=](){
if (timerID != -1){
killTimer(timerID);
timerID = -1;
@@ -68,9 +83,8 @@ void GUIMessageDialog::startLoading() {
LOG_USER_OPERATION(Stop);
});
timerID = startTimer(100);
ui->btn_main->setText("Stop");
ui->btn_main->setVisible(true);
btn_main->setText("Stop");
btn_main->setVisible(true);
}
void GUIMessageDialog::showMessage(QString msg) {
@@ -79,10 +93,10 @@ void GUIMessageDialog::showMessage(QString msg) {
}
void GUIMessageDialog::showExitButton() {
ui->btn_main->setText("OK");
ui->btn_main->setVisible(true);
disconnect(ui->btn_main,0,0,0);
connect(ui->btn_main,&QToolButton::clicked,[=](){
btn_main->setText("OK");
btn_main->setVisible(true);
disconnect(btn_main,0,0,0);
connect(btn_main,&QToolButton::clicked,[=](){
if (timerID != -1){
killTimer(timerID);
timerID = -1;
@@ -98,10 +112,27 @@ void GUIMessageDialog::hideMessage() {
}
void GUIMessageDialog::hideExitButton() {
ui->btn_main->setVisible(false);
disconnect(ui->btn_main,0,0,0);
btn_main->setVisible(false);
disconnect(btn_main,0,0,0);
}
void GUIMessageDialog::setOpacity(double opacity) {
this->setWindowOpacity(opacity);
}
void GUIMessageDialog::startPending() {
disconnect(btn_Append,0,0,0);
connect(btn_Append,&QToolButton::clicked,[=](){
EventCenter::Default()->triggerEvent(GUIEvents::RequestContinueScan, nullptr, nullptr);
stopPending();
});
btn_Append->setText("Next");
btn_Append->setVisible(true);
pending = true;
}
void GUIMessageDialog::stopPending() {
disconnect(btn_Append,0,0,0);
btn_Append->setVisible(false);
pending = false;
}

View File

@@ -6,7 +6,7 @@
namespace Ui {
class GUIMessageDialog;
}
class QToolButton;
class GUIMessageDialog : public QDialog
{
Q_OBJECT
@@ -20,14 +20,22 @@ public:
void hideExitButton();
void startLoading();
void stopLoading();
void startPending();
void stopPending();
bool Pending(){
return pending;
}
void setOpacity(double);
protected:
void timerEvent(QTimerEvent* event) override ;
private:
Ui::GUIMessageDialog *ui;
QList<QString> frame;
QToolButton *btn_main;
QToolButton *btn_Append;
int frameIndex=0;
int timerID = -1;
bool pending = false;
};
#endif // GUIMESSAGEDIALOG_H

View File

@@ -96,13 +96,6 @@
</layout>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QToolButton" name="btn_main">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@@ -14,6 +14,7 @@ ADD_EVENT_VALUE(PatientSelected)\
ADD_EVENT_VALUE(RequestPreviewScan)\
ADD_EVENT_VALUE(RequestEmptyScan)\
ADD_EVENT_VALUE(RequestPatientScan)\
ADD_EVENT_VALUE(RequestContinueScan)\
ADD_EVENT_VALUE(RequestStop)\
ADD_EVENT_VALUE(ResponseDeviceTemperature)\
ADD_EVENT_VALUE(ResponsePreview)\
@@ -23,6 +24,7 @@ ADD_EVENT_VALUE(DeviceErrorRaise)\
ADD_EVENT_VALUE(ShimLibInnerFault)\
ADD_EVENT_VALUE(InvokeOperationStart)\
ADD_EVENT_VALUE(InvokeOperationProgress)\
ADD_EVENT_VALUE(InvokeOperationPending)\
ADD_EVENT_VALUE(InvokeOperationEnd)\
ADD_EVENT_VALUE(PromptDialogOpen)\
ADD_EVENT_VALUE(GlobalBannerMessage)\

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, [=]() {

View File

@@ -2,17 +2,13 @@
#include "ui_patientinformationform.h"
#include "json/cJSON.h"
#include "event/EventCenter.h"
#include "json/ScanJson.h"
PatientInformationForm::PatientInformationForm(QWidget* parent) :
QWidget(parent),
ui(new Ui::PatientInformationForm)
{
ui->setupUi(this);
//ui->lbl_ID->setText(tr(""));
//ui->lbl_Date->setText(tr(""));
//ui->lbl_Name->setText(tr(""));
//ui->lbl_Sex->setText(tr(""));
//ui->lbl_Acc->setText(tr(""));
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() {
ui->retranslateUi(this);
@@ -63,6 +59,6 @@ const char* PatientInformationForm::getCurrentPatientJsonString(bool empty) {
cJSON_AddItemToObject(root, "InstitutionAddress", cJSON_CreateString("HZ"));
delete jsonstr;
jsonstr = cJSON_Print(root);
cJSON_Delete(root);
ScanJson::Current()->store(root);
return jsonstr;
}

View File

@@ -143,6 +143,10 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
connect(table->horizontalHeader(),&QHeaderView::sectionClicked,[=](int index){
edit_patient->clearPatientInformation();
prepareButtons(false);
if(model->rowCount()>0){
table->selectRow(0);
model->selectRow(0);
}
});
// btn add slot
@@ -155,9 +159,10 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
if (dialog.exec() == QDialog::Accepted) {
table->selectRow(0);
model->selectRow(0);
LOG_USER_OPERATION(AddPatient)
btnSelect->setEnabled(true);
}
LOG_USER_OPERATION(AddPatient)
btnSelect->setEnabled(true);
});
// btn edit slot
@@ -181,7 +186,7 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
btnSelect->setEnabled(true);
});
// btn add slot
// EditPatientForm editAccept slot
connect(edit_patient, &EditPatientForm::editAccept, [=](PatientInformation* inf, bool& result) {
int selectedRow = table->currentIndex().row();
bool isAdd = inf->PatientUID.isEmpty();

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,19 @@ systemSettingForm::systemSettingForm(QWidget* parent) :
ui->btnFlt->setText(JsonObject::Instance()->defaultFilter());
ui->btnFlt->setObjectName("BigBtn");
////test begin
QGridLayout* gridLayout = (QGridLayout*)ui->block10->layout();
auto btn_needConfirm = new ImageSwitch(this);
auto lbl_needConfirm = new QLabel(this);
lbl_needConfirm->setText("Scan Confirm");
gridLayout->addWidget(btn_needConfirm, 4, 2, 1, 1);
gridLayout->addWidget(lbl_needConfirm, 4, 0, 1, 1);
btn_needConfirm->setChecked(JsonObject::Instance()->getScanConfirm());
QFrame* line5 = new QFrame(this);
line5->setFrameShape(QFrame::HLine);
line5->setFrameShadow(QFrame::Sunken);
gridLayout->addWidget(line5,5,0);
////test begin
//flag_disksize = true;
//m_disksize = 75.0;
////test end
@@ -86,6 +100,9 @@ systemSettingForm::systemSettingForm(QWidget* parent) :
////
}
});
connect(btn_needConfirm, &ImageSwitch::clicked, [=]() {
JsonObject::Instance()->setScanConfirm(btn_needConfirm->getChecked());
});
connect(ui->btn_network, &QToolButton::clicked, [=]() {
GetAdminPsw dialog(this);
if (dialog.exec() == QDialog::Accepted)

25
src/json/ScanJson.cpp Normal file
View File

@@ -0,0 +1,25 @@
//
// Created by Krad on 2022/5/11.
//
#include "ScanJson.h"
#include <QFile>
#include <QDir>
#include <QCoreApplication>
void ScanJson::save() {
if (!root) return;
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.empty()?JsonObject::Instance()->getEmptyScanID():emptyScanID.c_str()));
cJSON_AddItemToObject(root, "ScanID", cJSON_CreateString(scanID.c_str()));
char* content = cJSON_Print(root);
f.write(content);
f.flush();
f.close();
free(content);
}

47
src/json/ScanJson.h Normal file
View File

@@ -0,0 +1,47 @@
//
// Created by Krad on 2022/5/11.
//
#ifndef GUI_SCANJSON_H
#define GUI_SCANJSON_H
#include <string>
#include "cJSON.h"
#include "jsonobject.h"
class ScanJson {
public:
~ScanJson(){
if(root)cJSON_Delete(root);
}
void store(cJSON* json){
if(root){
cJSON_Delete(root);
root = nullptr;
}
root = json;
}
void setScanID(const char * id){
scanID.clear();
scanID.append(id);
}
void setEmptyScanID(const char * id){
emptyScanID.clear();
emptyScanID.append(id);
JsonObject::Instance()->setEmptyScanID(id);
setScanID(id);
}
void save();
static ScanJson* Current(){
static ScanJson instance;
return &instance;
}
private:
std::string emptyScanID;
std::string scanID;
cJSON* root = nullptr;
};
#endif //GUI_SCANJSON_H

View File

@@ -30,7 +30,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 +56,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())
@@ -396,6 +437,12 @@ void JsonObject::autoDHCP(bool ena)
setJsonString("address", "dhcp", str.toStdString().c_str());
}
bool JsonObject::getScanConfirm() {
return getBool("general","ScanConfirm");
}
void JsonObject::setScanConfirm(bool val) {
setBool("general","ScanConfirm", val, true);
}
IpAddr JsonObject::getDefaultIpAddr()
{
@@ -474,3 +521,13 @@ 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");
}

View File

@@ -87,6 +87,12 @@ public:
bool isDHCP();
void autoDHCP(bool);
bool getScanConfirm();
void setScanConfirm(bool val);
const char* getEmptyScanID();
void setEmptyScanID(const char* id);
IpAddr getDefaultIpAddr();
void setDefaultIpAddr(const IpAddr& addr);
@@ -104,6 +110,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

@@ -126,7 +126,8 @@ MainWindow::MainWindow(QWidget* parent) :
if (msg)
{
QVariant* var = (QVariant*)msg;
msgDialog->showMessage(QString("Scanning %1%").arg((int)(var->toFloat() * 100.0f)));
if (msgDialog->Pending())msgDialog->stopPending();
msgDialog->showMessage(var->toString());
}
else {
msgDialog->hideMessage();
@@ -134,6 +135,14 @@ MainWindow::MainWindow(QWidget* parent) :
// msgDialog->showFullScreen();
if (msgDialog->isHidden())msgDialog->show();
});
connect(EventCenter::Default(), &EventCenter::InvokeOperationPending, [=](QObject*, QObject* msg) {
if (!msgDialog) return;
if (!msgDialog->Pending()){
msgDialog->startPending();
QVariant* var = (QVariant*)msg;
msgDialog->showMessage(var->toString());
}
});
connect(EventCenter::Default(), &EventCenter::InvokeOperationEnd, [=]() {
if (!msgDialog) return;
if (!msgDialog->isHidden())msgDialog->accept();