From 87c4dffdd5b8e4aa40544a0a4f0e0b316c9421a8 2017-09-21 08:57:57 From: mperrinel Date: 2017-09-21 08:57:57 Subject: [PATCH] Fix progression bug when aborting a request for Amda plugin --- diff --git a/core/src/Variable/VariableAcquisitionWorker.cpp b/core/src/Variable/VariableAcquisitionWorker.cpp index 0d095fc..24a88a7 100644 --- a/core/src/Variable/VariableAcquisitionWorker.cpp +++ b/core/src/Variable/VariableAcquisitionWorker.cpp @@ -109,7 +109,6 @@ QUuid VariableAcquisitionWorker::pushVariableRequest(QUuid varRequestId, QUuid v void VariableAcquisitionWorker::abortProgressRequested(QUuid vIdentifier) { - // TODO impl->lockRead(); auto it = impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.find(vIdentifier); @@ -144,6 +143,8 @@ void VariableAcquisitionWorker::abortProgressRequested(QUuid vIdentifier) void VariableAcquisitionWorker::onVariableRetrieveDataInProgress(QUuid acqIdentifier, double progress) { + qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM: onVariableRetrieveDataInProgress ") + << acqIdentifier << progress; impl->lockRead(); auto aIdToARit = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier); if (aIdToARit != impl->m_AcqIdentifierToAcqRequestMap.cend()) { @@ -155,7 +156,9 @@ void VariableAcquisitionWorker::onVariableRetrieveDataInProgress(QUuid acqIdenti auto finalProgression = currentAlreadyProgress + currentPartProgress; emit variableRequestInProgress(aIdToARit->second.m_vIdentifier, finalProgression); - + qCDebug(LOG_VariableAcquisitionWorker()) + << tr("TORM: onVariableRetrieveDataInProgress ") << aIdToARit->second.m_vIdentifier + << currentPartSize << currentAlreadyProgress << currentPartProgress << finalProgression; if (finalProgression == 100.0) { emit variableRequestInProgress(aIdToARit->second.m_vIdentifier, 0.0); } @@ -203,32 +206,8 @@ void VariableAcquisitionWorker::onVariableDataAcquired(QUuid acqIdentifier, acqRequest.m_CacheRangeRequested, aIdToADPVit->second); } - // Execute the next one - auto it - = impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.find(acqRequest.m_vIdentifier); - - if (it != impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.cend()) { - if (it->second.second.isNull()) { - // There is no next request, we can remove the variable request - impl->removeVariableRequest(acqRequest.m_vIdentifier); - } - else { - auto acqIdentifierToRemove = it->second.first; - // Move the next request to the current request - it->second.first = it->second.second; - it->second.second = QUuid(); - // Remove AcquisitionRequest and results; - impl->m_AcqIdentifierToAcqRequestMap.erase(acqIdentifierToRemove); - impl->m_AcqIdentifierToAcqDataPacketVectorMap.erase(acqIdentifierToRemove); - // Execute the current request - QMetaObject::invokeMethod(this, "onExecuteRequest", Qt::QueuedConnection, - Q_ARG(QUuid, it->second.first)); - } - } - else { - qCCritical(LOG_VariableAcquisitionWorker()) - << tr("Impossible to execute the acquisition on an unfound variable "); - } + // Update to the next request + impl->updateToNextRequest(acqRequest.m_vIdentifier); } } else { diff --git a/plugins/amda/src/AmdaProvider.cpp b/plugins/amda/src/AmdaProvider.cpp index 9b0bc8c..ec95d81 100644 --- a/plugins/amda/src/AmdaProvider.cpp +++ b/plugins/amda/src/AmdaProvider.cpp @@ -102,8 +102,8 @@ void AmdaProvider::onReplyDownloadProgress(QUuid acqIdentifier, std::shared_ptr networkRequest, double progress) { - qCDebug(LOG_AmdaProvider()) << tr("onReplyDownloadProgress") << acqIdentifier - << networkRequest.get() << progress; + qCInfo(LOG_AmdaProvider()) << tr("onReplyDownloadProgress") << acqIdentifier + << networkRequest.get() << progress; auto acqIdToRequestProgressMapIt = m_AcqIdToRequestProgressMap.find(acqIdentifier); if (acqIdToRequestProgressMapIt != m_AcqIdToRequestProgressMap.end()) { @@ -119,8 +119,11 @@ void AmdaProvider::onReplyDownloadProgress(QUuid acqIdentifier, requestProgressMapIt->second = progress; } else { - qCCritical(LOG_AmdaProvider()) << tr("Can't retrieve Request in progress") - << acqIdentifier << networkRequest.get() << progress; + // This case can happened when a progression is send after the request has been + // finished. + // Generaly the case when aborting a request + qCWarning(LOG_AmdaProvider()) << tr("Can't retrieve Request in progress") + << acqIdentifier << networkRequest.get() << progress; } } @@ -146,7 +149,9 @@ void AmdaProvider::onReplyDownloadProgress(QUuid acqIdentifier, emit dataProvidedProgress(acqIdentifier, finalProgress); } else { - emit dataProvidedProgress(acqIdentifier, 0.0); + // This case can happened when a progression is send after the request has been finished. + // Generaly the case when aborting a request + emit dataProvidedProgress(acqIdentifier, 100.0); } } @@ -197,6 +202,8 @@ void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa /// @todo ALX : debug } } + qCDebug(LOG_AmdaProvider()) << tr("acquisition requests erase because of finishing") + << dataId; m_AcqIdToRequestProgressMap.erase(dataId); } @@ -221,6 +228,8 @@ void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa } } else { + qCDebug(LOG_AmdaProvider()) + << tr("acquisition requests erase because of aborting") << dataId; m_AcqIdToRequestProgressMap.erase(dataId); } };