From f679b81fb499a7759ca15af1a5f3bd3b217b4583 Mon Sep 17 00:00:00 2001 From: sunwen Date: Thu, 19 Sep 2024 15:45:23 +0800 Subject: [PATCH] feat: Add progress in system correction page while empty scan data transfering. --- src/device/DeviceManager.cpp | 27 +++- src/device/DeviceManager.h | 1 + src/event/EventCenter.h | 3 + src/forms/recon/ReconStateDelegate.cpp | 4 +- src/forms/settings/SystemCorrectionForm.cpp | 70 +++++++- src/forms/settings/SystemCorrectionForm.h | 9 ++ src/translations/en_US.ts | 40 +++++ src/translations/zh_CN.ts | 169 +++++++++++++------- src/windows/MainWindow.cpp | 3 +- 9 files changed, 259 insertions(+), 67 deletions(-) diff --git a/src/device/DeviceManager.cpp b/src/device/DeviceManager.cpp index 7f1d656..bf26d3e 100644 --- a/src/device/DeviceManager.cpp +++ b/src/device/DeviceManager.cpp @@ -428,6 +428,7 @@ void DeviceManager::prepareFinishScan(bool isNormalFinish, const QString& aReaso if(mIsEmptyScan) { insertEmptyScanRecord(); + TRIGGER_EVENT(EmptyScanFinished, nullptr, nullptr); } else { @@ -446,11 +447,8 @@ void DeviceManager::prepareFinishScan(bool isNormalFinish, const QString& aReaso TRIGGER_EVENT(InvokeOperationEnd, nullptr, var); } - if(mIsEmptyScan) - { - TRIGGER_EVENT(EmptyScanFinished, nullptr, nullptr); - } - else + + if(!mIsEmptyScan) { ScanProcessSequence::getInstance()->popPosition(); startAutoLocate(); @@ -1065,7 +1063,7 @@ void DeviceManager::startTransfer() } else { - emit transferStatusUpdated(); + updateTransferState(); } } @@ -1100,7 +1098,7 @@ void DeviceManager::processTransferProgress(const QString& aProgress) break; } emitInfoCallback(tr("Scan data transfer Succeeded!"), MessageLevel::Sucess); - emit transferStatusUpdated(); + updateTransferState(); if(ReconManager::getInstance()->isConnected()) { startCreateReconRecord(); @@ -1123,6 +1121,7 @@ void DeviceManager::processTransferProgress(const QString& aProgress) } QString message = tr("Scan data transfer failed."); emitInfoCallback(message, MessageLevel::Error); + updateTransferState(); break; } } @@ -1138,6 +1137,7 @@ void DeviceManager::processReconCreateEmptyScan(bool aResult, const QString& aSc QString msg = "DB Error. Code:G504"; emitInfoCallback(msg, MessageLevel::Error); } + EventCenter::Default()->triggerEvent(EmptyScanDataStateUpdated, nullptr, nullptr); return; } @@ -1148,6 +1148,7 @@ void DeviceManager::processReconCreateEmptyScan(bool aResult, const QString& aSc QString msg = "DB Error. Code:G505"; emitInfoCallback(msg, MessageLevel::Error); } + EventCenter::Default()->triggerEvent(EmptyScanDataStateUpdated, nullptr, nullptr); } void DeviceManager::processReconCreateScan(bool aResult, const QString& aScanID, const QString& aMessage, bool aIsConnectSucceed) @@ -1267,6 +1268,18 @@ bool DeviceManager::updateTransferProgress() return false; } +void DeviceManager::updateTransferState() +{ + if(mIsTransferEmptyScan) + { + EventCenter::Default()->triggerEvent(EmptyScanDataStateUpdated, nullptr, nullptr); + } + else + { + emit transferStatusUpdated(); + } +} + int DeviceManager::getTransferProgress() { return mTransferProgress; diff --git a/src/device/DeviceManager.h b/src/device/DeviceManager.h index 212eb9e..47c7b12 100644 --- a/src/device/DeviceManager.h +++ b/src/device/DeviceManager.h @@ -130,6 +130,7 @@ private: void insertEmptyScanRecord(); void insertScanRecord(); + void updateTransferState(); private slots: diff --git a/src/event/EventCenter.h b/src/event/EventCenter.h index 014893c..3af4bbc 100644 --- a/src/event/EventCenter.h +++ b/src/event/EventCenter.h @@ -45,6 +45,9 @@ ADD_EVENT_VALUE(StopScanProcess)\ ADD_EVENT_VALUE(CurrentUserInfoChanged)\ ADD_EVENT_VALUE(EmptyScanFinished)\ ADD_EVENT_VALUE(EmptyScanDataCorrupted)\ +ADD_EVENT_VALUE(EmptyScanDataStateUpdated)\ +ADD_EVENT_VALUE(EmptyScanDataBroked)\ +ADD_EVENT_VALUE(EmptyScanDataExpire)\ ADD_EVENT_VALUE(UserVerificationSuccess)\ ADD_EVENT_VALUE(UsctStateUpdated)\ ADD_EVENT_VALUE(SetSelectedPatient)\ diff --git a/src/forms/recon/ReconStateDelegate.cpp b/src/forms/recon/ReconStateDelegate.cpp index 53db6c7..7dec5cd 100644 --- a/src/forms/recon/ReconStateDelegate.cpp +++ b/src/forms/recon/ReconStateDelegate.cpp @@ -44,7 +44,7 @@ void ReconStateDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op progressBarOption.maximum = 100; progressBarOption.progress = progress; QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarOption, painter); - + painter->restore(); return; } case 104: @@ -92,6 +92,6 @@ void ReconStateDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op } painter->drawText(option.rect, Qt::AlignCenter, displayText); - painter->restore(); } + painter->restore(); } diff --git a/src/forms/settings/SystemCorrectionForm.cpp b/src/forms/settings/SystemCorrectionForm.cpp index 50ad84d..d4ea98e 100644 --- a/src/forms/settings/SystemCorrectionForm.cpp +++ b/src/forms/settings/SystemCorrectionForm.cpp @@ -1,5 +1,6 @@ #include "SystemCorrectionForm.h" #include "db/SQLHelper.h" +#include "device/DeviceManager.h" #include "event/EventCenter.h" #include "dialogs/DialogManager.h" #include "log/LogManager.h" @@ -9,11 +10,15 @@ #include #include #include +#include SystemCorrectionForm::SystemCorrectionForm(QWidget* aParent) : QWidget(aParent) , mCurrentEmptyScanDate(new QLabel(this)) , mExpirationEmptyScanDate(new QLabel(this)) + , mCurrentEmptyScanState(new QLabel(this)) + , mTimer(new QTimer(this)) + , mEmptyScanState() { setObjectName("SystemCorrectionForm"); init(); @@ -67,6 +72,10 @@ void SystemCorrectionForm::init() mExpirationEmptyScanDate->setText(tr("Expiration date for Empty Scanning %1").arg(dateFormat)); vboxLayout->addWidget(mExpirationEmptyScanDate); + mEmptyScanState = SQLHelper::queryValue("SELECT State FROM EScan ORDER BY ScanDateTime DESC LIMIT 1").toInt(); + mCurrentEmptyScanState->setText(tr("Current state for Empty Scanning %1").arg(getStateString(mEmptyScanState))); + vboxLayout->addWidget(mCurrentEmptyScanState); + QWidget* emptyScanButtonArea = new QWidget(this); QHBoxLayout* emptyScanButtonLayout = new QHBoxLayout(emptyScanButtonArea); QPushButton* emptyScanButton = new QPushButton(this); @@ -90,6 +99,7 @@ void SystemCorrectionForm::init() emptyScanDescribe->setText(tr("Empty water scanning involves collecting ultrasound data while the tank is filled with water and free of any objects. It is essential to ensure that the tank is fully filled with water and devoid of any objects before conducting the scan. The purpose of collecting empty water data is to obtain baseline information on the time and energy variations of ultrasound propagation inside the inspection tank. This information is utilized for reconstructing reference data for transmission ultrasound imaging. Additionally, empty water data can be utilized for system status assessment and spatial calibration of the system. Therefore, empty water scanning should be performed regularly, with a frequency of once every month.")); mCurrentEmptyScanDate->setText(tr("Current date for Empty Scanning %1-%2-%3").arg(lastScanDate.year()).arg(lastScanDate.month()).arg(lastScanDate.day())); mExpirationEmptyScanDate->setText(tr("Expiration date for Empty Scanning %1").arg(dateFormat)); + mCurrentEmptyScanState->setText(tr("Current state for Empty Scanning %1").arg(getStateString(mEmptyScanState))); emptyScanButton->setText(tr("Excute empty scan")); }); @@ -105,8 +115,12 @@ void SystemCorrectionForm::init() LOG_USER_OPERATION("Start Empty Scan") }); + mTimer->setInterval(1000); + connect(mTimer, &QTimer::timeout, this, &SystemCorrectionForm::updateEmptyScanTransferProgress); connect(EventCenter::Default(), &EventCenter::EmptyScanFinished, this, &SystemCorrectionForm::updateEmptyScanDate); - + connect(EventCenter::Default(), &EventCenter::EmptyScanDataStateUpdated, this, &SystemCorrectionForm::updateEmptyScanState); + connect(EventCenter::Default(), &EventCenter::EmptyScanDataExpire, this, &SystemCorrectionForm::updateEmptyScanDateExpire); + connect(EventCenter::Default(), &EventCenter::EmptyScanDataBroked, this, &SystemCorrectionForm::updateEmptyScanBroked); } void SystemCorrectionForm::updateEmptyScanDate() @@ -117,4 +131,58 @@ void SystemCorrectionForm::updateEmptyScanDate() QString dateText = tr("%1-%2-%3").arg(expirationScanDate.year()).arg(expirationScanDate.month()).arg(expirationScanDate.day());; QString dateFormat = QString(" %1").arg(dateText); mExpirationEmptyScanDate->setText(tr("Expiration date for Empty Scanning %1").arg(dateFormat)); + mEmptyScanState = 0; + mCurrentEmptyScanState->setText(tr("Current state for Empty Scanning %1").arg(getStateString(mEmptyScanState))); +} + +void SystemCorrectionForm::updateEmptyScanState() +{ + mEmptyScanState = SQLHelper::queryValue("SELECT State FROM EScan ORDER BY ScanDateTime DESC LIMIT 1").toInt(); + if(mEmptyScanState == 100 && !mTimer->isActive()) + { + mTimer->start(); + } + else if(mEmptyScanState != 100 && mTimer->isActive()) + { + mTimer->stop(); + } + mCurrentEmptyScanState->setText(tr("Current state for Empty Scanning %1").arg(getStateString(mEmptyScanState))); +} + +void SystemCorrectionForm::updateEmptyScanTransferProgress() +{ + if(DeviceManager::Default()->updateTransferProgress()) + { + int progress = DeviceManager::Default()->getTransferProgress(); + mCurrentEmptyScanState->setText(tr("Current state for Empty Scanning %1").arg(getStateString(mEmptyScanState) + QString::number(progress) + "%")); + } +} + +void SystemCorrectionForm::updateEmptyScanBroked() +{ + mEmptyScanState = -1; + mCurrentEmptyScanState->setText(tr("Current state for Empty Scanning %1").arg(getStateString(mEmptyScanState))); +} + +void SystemCorrectionForm::updateEmptyScanDateExpire() +{ + mEmptyScanState = -2; + mCurrentEmptyScanState->setText(tr("Current state for Empty Scanning %1").arg(getStateString(mEmptyScanState))); +} + +QString SystemCorrectionForm::getStateString(int aState) +{ + switch (aState) + { + case -2: return QString("  %1").arg(tr("Expired")); + case -1: return QString("  %1").arg(tr("Broked")); + case 0: return tr("Wait To Transfer"); + case 100: return tr("Transferring"); + case 104: return QString("  %1").arg(tr("Transfer Failed")); + case 200: return tr("Transfer succeed"); + case 204: return QString("  %1").arg(tr("Recon Error")); + case 300: return tr("Normal"); + case 304: return QString("  %1").arg(tr("Recon Error")); + default: return QString("  %1").arg(tr("Unknow")); + } } diff --git a/src/forms/settings/SystemCorrectionForm.h b/src/forms/settings/SystemCorrectionForm.h index 752054e..22c0414 100644 --- a/src/forms/settings/SystemCorrectionForm.h +++ b/src/forms/settings/SystemCorrectionForm.h @@ -4,6 +4,7 @@ #include class QLabel; +class QTimer; class SystemCorrectionForm : public QWidget { @@ -15,13 +16,21 @@ public: private: void init(); + QString getStateString(int aState); private slots: void updateEmptyScanDate(); + void updateEmptyScanState(); + void updateEmptyScanTransferProgress(); + void updateEmptyScanDateExpire(); + void updateEmptyScanBroked(); private: QLabel* mCurrentEmptyScanDate; QLabel* mExpirationEmptyScanDate; + QLabel* mCurrentEmptyScanState; + QTimer* mTimer; + int mEmptyScanState; }; #endif // SYSTEMCORRECTIONFORM_H diff --git a/src/translations/en_US.ts b/src/translations/en_US.ts index 6edb307..022c78c 100644 --- a/src/translations/en_US.ts +++ b/src/translations/en_US.ts @@ -1882,6 +1882,46 @@ progress:99% Confirm Scan + + Broked + + + + Wait To Transfer + + + + Transferring + + + + Transfer Failed + + + + Recon Error + + + + Normal + + + + Unknow + + + + Transfer succeed + + + + Expired + + + + Current state for Empty Scanning %1 + + SystemSettingForm diff --git a/src/translations/zh_CN.ts b/src/translations/zh_CN.ts index 4b2a23a..451488c 100644 --- a/src/translations/zh_CN.ts +++ b/src/translations/zh_CN.ts @@ -469,9 +469,9 @@ DeviceManager - - - + + + DMS connection error DMS失去连接 @@ -497,8 +497,8 @@ progress:99% - - + + Initialize Failed. 初始化失败 @@ -518,49 +518,49 @@ progress:99% 设备状态错误,无法开始空水扫查 - + Scan completed! 扫查结束 - + Error: 错误: - + Start scan failed. Reason:time out. 扫查启动失败,原因:超时 - + Start scan failed. Reason:%1 扫查启动失败,原因:%1 - + Start CE Scan Failed. CE扫查启动失败 - + Data is currently being transmitted, please shut down later. 数据传输中,请稍后再执行关机。 - + Shut down failed, please push emergency button to shutdown. 关机失败,请按紧急按钮进行关机。 - - - + + + Scan data transfer failed. 扫查数据上传失败 - + Scan data transfer Succeeded! @@ -570,39 +570,39 @@ progress:99% 空水数据新增失败 - + Create scan data failed 扫查数据新增失败 - + Recon disconnected. 重建服务器已断开连接 - - + + Open pump failed. 排水阀打开失败 - + Recon error, can't start scan process 重建服务器错误,无法开始检查流程 - - + + Start auto locate failed 自动化定位启动失败 - + The data quality is low, please restart the data scan. 扫查数据质量较低,请重新开始检查流程 - + Device reset failed, please contact maintenance person 设备复位失败,请联系维修人员 @@ -1541,20 +1541,20 @@ progress:99% - - + + Select 选择 - - + + Scan 扫描 - - + + Recon 重建 @@ -1565,23 +1565,23 @@ progress:99% - - + + Warning 警告 - + There are %1 days left until the next empty scan. Please remind users to conduct the empty scan in time. 距离下次空水扫查还有%1天,请用户及时进行空水扫查。 - + Shut down failed, please push emergency button to shutdown. 关机失败,请按紧急按钮进行关机。 - + Due to empty scan data corruption on the server, needs to be execute the empty scan. No other operations can be conducted until the scan is complete. 服务器端空水数据损坏,需要进行空水扫查,空水扫查结束前无法进行其他操作。 @@ -1598,8 +1598,8 @@ progress:99% 管理 - - + + Settings 设置 @@ -2817,59 +2817,116 @@ parameters SystemCorrectionForm - - + + Scan Preparation 扫查准备 - - + + Empty Scan 空水扫描 - - + + Empty water scanning involves collecting ultrasound data while the tank is filled with water and free of any objects. It is essential to ensure that the tank is fully filled with water and devoid of any objects before conducting the scan. The purpose of collecting empty water data is to obtain baseline information on the time and energy variations of ultrasound propagation inside the inspection tank. This information is utilized for reconstructing reference data for transmission ultrasound imaging. Additionally, empty water data can be utilized for system status assessment and spatial calibration of the system. Therefore, empty water scanning should be performed regularly, with a frequency of once every month. 空水扫描是采集空水时的超声数据,需确保检查仓内部装满水且无物体时执行。空水数据是为了获取超声在检查仓内部传播的时间和能量的变化基准信息,用于重建透射超声图像的参考数据。另一方面,空水数据也可给系统状态的判断和系统的空间校正提供数据支持,故空水扫描需隔一个月定期执行。 - - - + + + Current date for Empty Scanning %1-%2-%3 当前空水数据扫描时间 %1年%2月%3日 - - + + %1-%2-%3 %1年%2月%3日 - - - + + + Expiration date for Empty Scanning %1 当前空水数据有效期限%1 - - + + Excute empty scan 执行空水扫描 - + Please make sure the holder is only contain water! 请确认Holder中已灌满水,并没有其他物体的情况下再启动空水扫描 - + Confirm Scan 扫查确认 + + + + + + + + + Current state for Empty Scanning %1 + 当前空水数据系统状态 %1 + + + + Expired + 过期 + + + + Broked + 损坏 + + + + Wait To Transfer + 等待传输 + + + + Transferring + 传输中 + + + + Transfer Failed + 传输失败 + + + + Transfer succeed + 传输成功 + + + + + Recon Error + 服务器端错误 + + + + Normal + 正常 + + + + Unknow + 未知 + SystemSettingForm diff --git a/src/windows/MainWindow.cpp b/src/windows/MainWindow.cpp index 86e6688..7a04b88 100644 --- a/src/windows/MainWindow.cpp +++ b/src/windows/MainWindow.cpp @@ -167,6 +167,7 @@ void MainWindow::checkEmptyScanValidity() if(lastScanDate.isNull() || currentDate.daysTo(expirationScanDate) < 0) { mTabWidget->setCurrentIndex(3); + EventCenter::Default()->triggerEvent(EmptyScanDataExpire, nullptr, nullptr); DialogManager::Default()->requestAlertMessage(tr("Please execute the empty scan, assist with system calibration, when empty scan is completed, the system should operate normally."), OkOnly, tr("Warning")); mTabWidget->setTabEnabled(2, false); mTabWidget->setTabEnabled(1, false); @@ -382,6 +383,6 @@ void MainWindow::handleEmptyScanDataCorrupted() mTabWidget->setTabEnabled(2, false); mTabWidget->setTabEnabled(1, false); mTabWidget->setTabEnabled(0, false); - + EventCenter::Default()->triggerEvent(EmptyScanDataBroked, nullptr, nullptr); DialogManager::Default()->requestAlertMessage(tr("Due to empty scan data corruption on the server, needs to be execute the empty scan. No other operations can be conducted until the scan is complete."), OkOnly, tr("Warning")); }