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 CHECK_RECON_CONNECTION_TIME = 30000;
const int SHUT_DOWN_TIMEOUT = 180000;//3 minitues const int SHUT_DOWN_TIMEOUT = 180000;//3 minitues
const int PUMP_TIMEOUT = 3000;//3 seconds const int PUMP_TIMEOUT = 3000;//3 seconds
const int GETDMSVERSION_TIMEOUT = 5000;
const int EFFECTIVE_POSITION_RADIUS = 125; const int EFFECTIVE_POSITION_RADIUS = 125;
const int EFFECTIVE_POSITION_Z_START = 150; const int EFFECTIVE_POSITION_Z_START = 150;
const int EFFECTIVE_POSITION_Z_END = 225; const int EFFECTIVE_POSITION_Z_END = 225;
@@ -88,13 +89,6 @@ QString getFullScanJson(QObject* obj)
void DeviceManager::initDevice() 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(); mReconTransferPath = JsonObject::Instance()->getReconTransferPath();
dmsmq_init(0); dmsmq_init(0);
@@ -140,7 +134,6 @@ void DeviceManager::initDevice()
mStartAutoLocateAction = new DmsSyncAction(USRV_CONTROL, ACT_CTL_MOTION_START, this, "responseStartAutoLocate(const QString&)", this); 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); 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); 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 //Async action
mGetScanProgressAction = new DmsAsyncAction(USRV_SCAN, ACT_SCAN_PROGRESS_PASSIVE, this,"responseGetScanProgress(const QString&)", this); 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 = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_PUMP, this, "responsePumpControl(const QString&)", this);
mPumpControlAction->setTimeoutInterval(PUMP_TIMEOUT); mPumpControlAction->setTimeoutInterval(PUMP_TIMEOUT);
mGetAutoLocatePositionAction = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_MOTION_POSITION, this, "responseGetAutoLocatePosition(const QString&)", this); 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]() connect(mPumpControlAction, &DmsAsyncAction::timeout, [this]()
{ {
this->processPumpResult("{\"code\":-1}"); this->processPumpResult("{\"code\":-1}");
@@ -215,14 +214,21 @@ void DeviceManager::initDevice()
mSetHeartBeatAction->setSendData("{ \"code\":0, \"info\":\"0\"}"); mSetHeartBeatAction->setSendData("{ \"code\":0, \"info\":\"0\"}");
mSetHeartBeatAction->execute(); mSetHeartBeatAction->execute();
mSoftwareVersion = "DMS Version Loading";
initDmsVersion(); mGetSoftwareVersionAction->execute();
mCheckInitStatusTimer = startTimer(500); mCheckInitStatusTimer = startTimer(500);
} }
void DeviceManager::initGUI(bool aIsInitSucceed) 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(aIsInitSucceed)
{ {
if(getDeviceStatus() != DeviceStatus::Rready) if(getDeviceStatus() != DeviceStatus::Rready)
@@ -714,6 +720,7 @@ void DeviceManager::processReceiveDMSInfoResult(int aServerID, int aActionID, co
{ {
case ACT_IFCFG_VERINFO : case ACT_IFCFG_VERINFO :
emit responseGetSoftwareVersion(aContents); emit responseGetSoftwareVersion(aContents);
processGetSoftwareVersion(aContents);
break; break;
case ACT_IFCFG_HBCFG : case ACT_IFCFG_HBCFG :
emit responseSetHeartBeat(aContents); 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(aSoftwareVersion);
QJsonObject jsonObj = toJsonObject(result.mData); if(jsonObj["code"].toInt() != 0)
if(result.mIsSucessful && jsonObj.contains("code") && jsonObj["code"].toInt() == 0)
{ {
mSoftwareVersion = jsonObj["info"].toString();; mSoftwareVersion = "DMS Version Fetch Error";
}
else
{
mSoftwareVersion = "Dms Fetch Error";
} }
mSoftwareVersion = jsonObj["info"].toString();
emit getDmsVersionResponsed(mSoftwareVersion);
} }
void DeviceManager::scanTimeout() void DeviceManager::scanTimeout()

View File

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

View File

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

View File

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