From c2fbcf0c0226ca85fd3d36a6abbfcc28d569ebda Mon Sep 17 00:00:00 2001 From: sunwen Date: Tue, 12 Dec 2023 10:13:59 +0800 Subject: [PATCH] Add stop drainage automatically after 30 seconds. --- src/device/DeviceManager.cpp | 4 ++++ src/forms/scan/ScanFormWidget.cpp | 12 +++++++++++- src/forms/scan/ScanFormWidget.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/device/DeviceManager.cpp b/src/device/DeviceManager.cpp index 0d931c6..b1ee9e1 100644 --- a/src/device/DeviceManager.cpp +++ b/src/device/DeviceManager.cpp @@ -138,6 +138,10 @@ void DeviceManager::initDevice() mShutDownAction->setTimeoutInterval(SHUT_DOWN_TIMEOUT); mPumpControlAction = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_PUMP, this, "responsePumpControl(const QString&)", this); mPumpControlAction->setTimeoutInterval(PUMP_TIMEOUT); + connect(mPumpControlAction, &DmsAsyncAction::timeout, this, [this]() + { + this->processPumpResult("{\"code\":-1}"); + }); connect(mGetScanProgressAction, &DmsAsyncAction::timeout, this, &DeviceManager::scanTimeout); connect(mShutDownAction, &DmsAsyncAction::timeout, this, &DeviceManager::shutdownDmsFailed); diff --git a/src/forms/scan/ScanFormWidget.cpp b/src/forms/scan/ScanFormWidget.cpp index 4e0233c..18c5b63 100644 --- a/src/forms/scan/ScanFormWidget.cpp +++ b/src/forms/scan/ScanFormWidget.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "forms/scan/PatientInformationForm.h" @@ -29,6 +30,7 @@ namespace{ const size_t PREVIEW_COL = 140; const float PIXEL_SPACING = 1.5f; const float HALF_ROI_WIDTH = 100.0f; + const unsigned int DRAINAGE_TIME = 30000; } ScanFormWidget::ScanFormWidget(QWidget* parent) @@ -47,6 +49,7 @@ ScanFormWidget::ScanFormWidget(QWidget* parent) , mLblE(new QLabel(this)) , mLblParams(new QLabel(this)) , mLblE2(new QLabel(this)) +, mDrainageTimer(new QTimer(this)) { auto layout = new QHBoxLayout(ui->commandWidget); @@ -56,7 +59,11 @@ ScanFormWidget::ScanFormWidget(QWidget* parent) initScanControlBar(layout); initScanContent(); initEvents(); - + mDrainageTimer->setSingleShot(true); + connect(mDrainageTimer, &QTimer::timeout, this, [this]() + { + mBtnDrainage->click(); + }); } void ScanFormWidget::initProtocolUI(QHBoxLayout *layout) { @@ -171,6 +178,7 @@ void ScanFormWidget::initScanControlBar(QHBoxLayout *layout){ mBtnDrainage->setEnabled(true); if(!aIsSucessful) { + mDrainageTimer->stop(); bool isChecked = mBtnDrainage->isChecked(); mBtnDrainage->setChecked(!isChecked); if(isChecked) @@ -213,6 +221,7 @@ void ScanFormWidget::initScanControlBar(QHBoxLayout *layout){ mBtnDrainage->setEnabled(false); if(aSatus == true) { + mDrainageTimer->start(DRAINAGE_TIME); QString code = "1"; mBtnDrainage->setText(tr("Drainaging")); EventCenter::Default()->triggerEvent(RequestDrainage, nullptr, (QObject*)(&code)); @@ -220,6 +229,7 @@ void ScanFormWidget::initScanControlBar(QHBoxLayout *layout){ } else { + mDrainageTimer->stop(); QString code = "0"; mBtnDrainage->setText(tr("Drainage")); EventCenter::Default()->triggerEvent(RequestDrainage, nullptr, (QObject*)(&code)); diff --git a/src/forms/scan/ScanFormWidget.h b/src/forms/scan/ScanFormWidget.h index bbdccd9..a150d60 100644 --- a/src/forms/scan/ScanFormWidget.h +++ b/src/forms/scan/ScanFormWidget.h @@ -34,6 +34,7 @@ private: QLabel* mLblE; QLabel* mLblParams; QLabel* mLblE2; + QTimer* mDrainageTimer; void initProtocolUI(QHBoxLayout *layout); void initScanControlBar(QHBoxLayout *layout); void initScanContent();