Change pump action to AsyncAion from SyncAction.
This commit is contained in:
@@ -37,6 +37,7 @@ namespace
|
||||
const int PREVIEW_IMAGE_WH = 140;
|
||||
const unsigned int GET_TEMPERATURE_TIME = 60000;
|
||||
const int SHUT_DOWN_TIMEOUT = 180000;//3 minitues
|
||||
const int PUMP_TIMEOUT = 3000;//3 seconds
|
||||
const QString DEFAULT_DMS_START_FAILED = "Dms start failed.";
|
||||
const QString RECON_TRANSFER_PATH = "/home/krad/TestStore";
|
||||
|
||||
@@ -118,7 +119,6 @@ void DeviceManager::initDevice()
|
||||
mGetTransferProgressAction = new DmsSyncAction(USRV_XFR, ACT_XFR_PROGRESS_PASSIVE, this, "responseGetTransferProgress(const QString&)", this);
|
||||
mCEScanAction = new DmsSyncAction(USRV_SCAN, ACT_SCAN_CE, this, "responseCEScan(const QString&)", this);
|
||||
mGetCEStatusAction = new DmsSyncAction(USRV_SCAN, ACT_SCAN_CE_STATUS, this, "responseGetCEStatus(const QString&)", this);
|
||||
mPumpControlAction = new DmsSyncAction(USRV_CONTROL, ACT_CTL_PUMP, this, "responsePumpControl(const QString&)", this);
|
||||
mSetSimulatorModeAction = new DmsSyncAction(USRV_SCAN, ACT_SCAN_SIMULATOR, this, "responseSetSimulatorMode(const QString&)", this);
|
||||
mSetHeartBeatAction = new DmsSyncAction(USRV_INFOCFG, ACT_IFCFG_HBCFG, this, "responseSetHeartBeat(const QString&)", this);
|
||||
|
||||
@@ -129,6 +129,8 @@ void DeviceManager::initDevice()
|
||||
mStopTransferAction = new DmsAsyncAction(USRV_XFR, ACT_XFR_STOP, this, "responseStopTransfer(const QString&)", this);
|
||||
mShutDownAction = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_PWRDOWN, this, "responseShutDown(const QString&)", this);
|
||||
mShutDownAction->setTimeoutInterval(SHUT_DOWN_TIMEOUT);
|
||||
mPumpControlAction = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_PUMP, this, "responsePumpControl(const QString&)", this);
|
||||
mPumpControlAction->setTimeoutInterval(PUMP_TIMEOUT);
|
||||
connect(mGetScanProgressAction, &DmsAsyncAction::timeout, this, &DeviceManager::scanTimeout);
|
||||
connect(mShutDownAction, &DmsAsyncAction::timeout, this, &DeviceManager::shutdownDmsFailed);
|
||||
|
||||
@@ -603,6 +605,7 @@ void DeviceManager::processReceiveDMSInfoResult(int aServerID, int aActionID, co
|
||||
{
|
||||
case ACT_CTL_PUMP:
|
||||
emit responsePumpControl(aContents);
|
||||
processPumpResult(aContents);
|
||||
break;
|
||||
case ACT_CTL_PWRDOWN:
|
||||
emit responseShutDown(aContents);
|
||||
@@ -1089,19 +1092,26 @@ bool DeviceManager::getCEStatus()
|
||||
void DeviceManager::controlDrainage(const QString& aCode)
|
||||
{
|
||||
mPumpControlAction->setSendData(QString("{\"pumb\":%1}").arg(aCode));
|
||||
auto result = mPumpControlAction->execute();
|
||||
if(result.mIsSucessful)
|
||||
if(!mPumpControlAction->execute())
|
||||
{
|
||||
QJsonObject jsonObj = toJsonObject(result.mData);
|
||||
if(jsonObj["code"].toInt() == 0 )
|
||||
{
|
||||
emit startPumpControlResult(true);
|
||||
return;
|
||||
}
|
||||
emit startPumpControlResult(false);
|
||||
QString msg = tr("Open pump failed.");
|
||||
THROW_ERROR(msg);
|
||||
}
|
||||
emit startPumpControlResult(false);
|
||||
QString msg = tr("Open pump failed.");
|
||||
THROW_ERROR(msg);
|
||||
}
|
||||
|
||||
void DeviceManager::processPumpResult(const QString& aResponse)
|
||||
{
|
||||
QJsonObject jsonObj = toJsonObject(aResponse);
|
||||
if(jsonObj["code"].toInt() == 0 )
|
||||
{
|
||||
emit startPumpControlResult(true);
|
||||
return;
|
||||
}
|
||||
|
||||
emit startPumpControlResult(false);
|
||||
QString msg = tr("Open pump failed.");
|
||||
THROW_ERROR(msg);
|
||||
}
|
||||
|
||||
void DeviceManager::updateReconConnectionState(bool aIsConnected)
|
||||
|
||||
Reference in New Issue
Block a user