feat: Change getDmsVersion action form sync action to async action.
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user