feat: Change getDmsVersion action form sync action to async action.

This commit is contained in:
sunwen
2024-06-26 10:36:15 +08:00
parent 4f9e007868
commit 1d1c1f4137
4 changed files with 39 additions and 27 deletions

View File

@@ -39,6 +39,7 @@ namespace
const int CHECK_RECON_CONNECTION_TIME = 30000;
const int SHUT_DOWN_TIMEOUT = 180000;//3 minitues
const int PUMP_TIMEOUT = 3000;//3 seconds
const int GETDMSVERSION_TIMEOUT = 5000;
const int EFFECTIVE_POSITION_RADIUS = 125;
const int EFFECTIVE_POSITION_Z_START = 150;
const int EFFECTIVE_POSITION_Z_END = 225;
@@ -88,13 +89,6 @@ QString getFullScanJson(QObject* obj)
void DeviceManager::initDevice()
{
if(!AppGlobalValues::DBconnected().toBool())
{
emitErrorCallback(tr("Fail to connect to DB!Reboot device to try!"));
emit initializeFinished();
return;
}
mReconTransferPath = JsonObject::Instance()->getReconTransferPath();
dmsmq_init(0);
@@ -140,7 +134,6 @@ void DeviceManager::initDevice()
mStartAutoLocateAction = new DmsSyncAction(USRV_CONTROL, ACT_CTL_MOTION_START, this, "responseStartAutoLocate(const QString&)", this);
mStopAutoLocateAction = new DmsSyncAction(USRV_CONTROL, ACT_CTL_MOTION_STOP, this, "responseStopAutoLocate(const QString&)", this);
mCheckDataQualityAction = new DmsSyncAction(USRV_SCAN, ACT_SCAN_IMGQUALITI, this, "responseCheckDataQuality(const QString&)", this);
mGetSoftwareVersionAction = new DmsSyncAction(USRV_INFOCFG, ACT_IFCFG_VERINFO, this,"responseGetSoftwareVersion(const QString&)", this);
//Async action
mGetScanProgressAction = new DmsAsyncAction(USRV_SCAN, ACT_SCAN_PROGRESS_PASSIVE, this,"responseGetScanProgress(const QString&)", this);
@@ -151,6 +144,12 @@ void DeviceManager::initDevice()
mPumpControlAction = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_PUMP, this, "responsePumpControl(const QString&)", this);
mPumpControlAction->setTimeoutInterval(PUMP_TIMEOUT);
mGetAutoLocatePositionAction = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_MOTION_POSITION, this, "responseGetAutoLocatePosition(const QString&)", this);
mGetSoftwareVersionAction = new DmsAsyncAction(USRV_INFOCFG, ACT_IFCFG_VERINFO, this,"responseGetSoftwareVersion(const QString&)", this);
mGetSoftwareVersionAction->setTimeoutInterval(GETDMSVERSION_TIMEOUT);
connect(mGetSoftwareVersionAction, &DmsAsyncAction::timeout, [this]()
{
emit getDmsVersionResponsed("DMS Version Fetch Error");
});
connect(mPumpControlAction, &DmsAsyncAction::timeout, [this]()
{
this->processPumpResult("{\"code\":-1}");
@@ -215,14 +214,21 @@ void DeviceManager::initDevice()
mSetHeartBeatAction->setSendData("{ \"code\":0, \"info\":\"0\"}");
mSetHeartBeatAction->execute();
initDmsVersion();
mSoftwareVersion = "DMS Version Loading";
mGetSoftwareVersionAction->execute();
mCheckInitStatusTimer = startTimer(500);
}
void DeviceManager::initGUI(bool aIsInitSucceed)
{
if(!AppGlobalValues::DBconnected().toBool())
{
emitErrorCallback(tr("Fail to connect to DB!Reboot device to try!"));
emit initializeFinished();
return;
}
if(aIsInitSucceed)
{
if(getDeviceStatus() != DeviceStatus::Rready)
@@ -714,6 +720,7 @@ void DeviceManager::processReceiveDMSInfoResult(int aServerID, int aActionID, co
{
case ACT_IFCFG_VERINFO :
emit responseGetSoftwareVersion(aContents);
processGetSoftwareVersion(aContents);
break;
case ACT_IFCFG_HBCFG :
emit responseSetHeartBeat(aContents);
@@ -779,18 +786,15 @@ void DeviceManager::processAlarm(const QString& aAlarm)
}
}
void DeviceManager::initDmsVersion()
void DeviceManager::processGetSoftwareVersion(const QString& aSoftwareVersion)
{
DmsSyncActionResult result = mGetSoftwareVersionAction->execute();
QJsonObject jsonObj = toJsonObject(result.mData);
if(result.mIsSucessful && jsonObj.contains("code") && jsonObj["code"].toInt() == 0)
QJsonObject jsonObj = toJsonObject(aSoftwareVersion);
if(jsonObj["code"].toInt() != 0)
{
mSoftwareVersion = jsonObj["info"].toString();;
}
else
{
mSoftwareVersion = "Dms Fetch Error";
mSoftwareVersion = "DMS Version Fetch Error";
}
mSoftwareVersion = jsonObj["info"].toString();
emit getDmsVersionResponsed(mSoftwareVersion);
}
void DeviceManager::scanTimeout()

View File

@@ -112,7 +112,6 @@ private:
void stopAutoLocate();
void initGUI(bool aIsInitSucceed);
void checkDataQuality();
void initDmsVersion();
void processScanProgress(const QString& aProgress);
void processAutoLocatePosition(const QString& aProgress);
@@ -125,6 +124,7 @@ private:
void processTransferProgress(const QString& aProgress);
void processShutDownDms(const QString& aResponse);
void processPumpResult(const QString& aResponse);
void processGetSoftwareVersion(const QString& aResponse);
void insertEmptyScanRecord();
void insertScanRecord();
@@ -184,6 +184,7 @@ signals:
void autolocatePositionEffective();
void shutdownDmsSended();
void shutdownDmsFailed();
void getDmsVersionResponsed(const QString& aDmsVersion);
private:
@@ -229,7 +230,6 @@ private:
DmsSyncAction* mStartAutoLocateAction = nullptr;
DmsSyncAction* mStopAutoLocateAction = nullptr;
DmsSyncAction* mCheckDataQualityAction = nullptr;
DmsSyncAction* mGetSoftwareVersionAction = nullptr;
DmsAsyncAction* mGetDeviceTemperatureAction = nullptr;
DmsAsyncAction* mGetScanProgressAction = nullptr;
@@ -237,6 +237,7 @@ private:
DmsAsyncAction* mShutDownAction = nullptr;
DmsAsyncAction* mPumpControlAction = nullptr;
DmsAsyncAction* mGetAutoLocatePositionAction = nullptr;
DmsAsyncAction* mGetSoftwareVersionAction = nullptr;
InfoReceiveWorker* mInfoReceiveWorker = nullptr;

View File

@@ -20,7 +20,8 @@
AboutForm::AboutForm(QWidget* aParent)
: QWidget(aParent)
,mReconSotfVer( new QLabel(this))
, mReconSotfVer( new QLabel(this))
, mDmsVersion(new QLabel(this))
{
initUiWidget();
mReconSotfVer->setSizePolicy(QSizePolicy::Policy::Expanding,QSizePolicy::Policy::Expanding);
@@ -47,7 +48,6 @@ void AboutForm::initUiWidget()
QPushButton* pBtnHelp;
QLabel* pCompanyCopyRight;
QLabel* pMainVer;
QLabel* pEmbededSoftVer;
QLabel* pFEBVer;
QLabel* pQtVer;
QLabel* pQtCopyright;
@@ -94,9 +94,8 @@ void AboutForm::initUiWidget()
pMainVer->setText(QString(tr("USCT Software V0.1.0")));
pMainLayout->addWidget(pMainVer);
pEmbededSoftVer = new QLabel(this);
pEmbededSoftVer->setText(DeviceManager::Default()->getSoftwareVersion());
pMainLayout->addWidget(pEmbededSoftVer);
mDmsVersion->setText(DeviceManager::Default()->getSoftwareVersion());
pMainLayout->addWidget(mDmsVersion);
mReconSotfVer->setText(tr("Reconstruction Software Loading..."));
@@ -150,6 +149,7 @@ void AboutForm::initUiWidget()
QMetaObject::invokeMethod(ReconManager::getInstance(), "getReconVersion", Qt::QueuedConnection);
connect(ReconManager::getInstance(), &ReconManager::getReconVersionResponsed,this,&AboutForm::setReconVersion,Qt::QueuedConnection);
connect(DeviceManager::Default(), &DeviceManager::getDmsVersionResponsed,this,&AboutForm::setDmsVersion,Qt::QueuedConnection);
connect(pBtnHelp, SIGNAL(clicked()), this, SLOT(openHelpFile()));
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() {
@@ -157,7 +157,7 @@ void AboutForm::initUiWidget()
pBtnHelp->setText(tr("?"));
pCompanyCopyRight->setText(tr("Copyright © 2017-2020 Zhejiang Equilibrium Nine Medical Equipment Co., Ltd. All Rights Reversed"));
pMainVer->setText(QString(tr("GUI Software V%1")).arg(getGUIVersion()));
pEmbededSoftVer->setText(tr("Embedded Software %1").arg(getEmbVersion()));
mDmsVersion->setText(tr("Embedded Software %1").arg(getEmbVersion()));
mReconSotfVer->setText(tr("Reconstruction Software V1.2"));
pFEBVer->setText(tr("FEB Information"));
});
@@ -187,3 +187,8 @@ QString AboutForm::getEmbVersion()
{
return DeviceManager::Default()->getSoftwareVersion();
}
void AboutForm::setDmsVersion(const QString& aVersion)
{
mDmsVersion->setText(aVersion);
}

View File

@@ -23,10 +23,12 @@ public:
private slots:
void openHelpFile();
void setReconVersion(const QString& version);
void setDmsVersion(const QString& aVersion);
private:
void initUiWidget();
QLabel* mReconSotfVer;
QLabel* mDmsVersion;
};