From d6648352006d086a9241b1cdfae375e29669ca3f 2017-08-24 07:13:16 From: mperrinel Date: 2017-08-24 07:13:16 Subject: [PATCH] push method of worker return the id of the nextRange which is canceled --- diff --git a/core/include/Variable/VariableAcquisitionWorker.h b/core/include/Variable/VariableAcquisitionWorker.h index d2adf83..4c76379 100644 --- a/core/include/Variable/VariableAcquisitionWorker.h +++ b/core/include/Variable/VariableAcquisitionWorker.h @@ -28,9 +28,9 @@ public: explicit VariableAcquisitionWorker(QObject *parent = 0); virtual ~VariableAcquisitionWorker(); - void pushVariableRequest(QUuid vIdentifier, SqpRange rangeRequested, - SqpRange cacheRangeRequested, DataProviderParameters parameters, - std::shared_ptr provider); + QUuid pushVariableRequest(QUuid varRequestId, QUuid vIdentifier, SqpRange rangeRequested, + SqpRange cacheRangeRequested, DataProviderParameters parameters, + std::shared_ptr provider); void abortProgressRequested(QUuid vIdentifier); diff --git a/core/src/Variable/VariableAcquisitionWorker.cpp b/core/src/Variable/VariableAcquisitionWorker.cpp index 3d10846..4d475e0 100644 --- a/core/src/Variable/VariableAcquisitionWorker.cpp +++ b/core/src/Variable/VariableAcquisitionWorker.cpp @@ -46,16 +46,19 @@ VariableAcquisitionWorker::~VariableAcquisitionWorker() } -void VariableAcquisitionWorker::pushVariableRequest(QUuid vIdentifier, SqpRange rangeRequested, - SqpRange cacheRangeRequested, - DataProviderParameters parameters, - std::shared_ptr provider) +QUuid VariableAcquisitionWorker::pushVariableRequest(QUuid varRequestId, QUuid vIdentifier, + SqpRange rangeRequested, + SqpRange cacheRangeRequested, + DataProviderParameters parameters, + std::shared_ptr provider) { qCInfo(LOG_VariableAcquisitionWorker()) << tr("TORM VariableAcquisitionWorker::pushVariableRequest ") << cacheRangeRequested; + auto varRequestIdCanceled = QUuid(); // Request creation auto acqRequest = AcquisitionRequest{}; + acqRequest.m_VarRequestId = varRequestId; acqRequest.m_vIdentifier = vIdentifier; acqRequest.m_DataProviderParameters = parameters; acqRequest.m_RangeRequested = rangeRequested; @@ -63,6 +66,7 @@ void VariableAcquisitionWorker::pushVariableRequest(QUuid vIdentifier, SqpRange acqRequest.m_Size = parameters.m_Times.size(); acqRequest.m_Provider = provider; + // Register request impl->lockWrite(); impl->m_AcqIdentifierToAcqRequestMap.insert( @@ -71,6 +75,13 @@ void VariableAcquisitionWorker::pushVariableRequest(QUuid vIdentifier, SqpRange auto it = impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.find(vIdentifier); if (it != impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.cend()) { // A current request already exists, we can replace the next one + auto nextAcqId = it->second.second; + auto acqIdentifierToAcqRequestMapIt = impl->m_AcqIdentifierToAcqRequestMap.find(nextAcqId); + if (acqIdentifierToAcqRequestMapIt != impl->m_AcqIdentifierToAcqRequestMap.cend()) { + auto request = acqIdentifierToAcqRequestMapIt->second; + varRequestIdCanceled = request.m_VarRequestId; + } + it->second.second = acqRequest.m_AcqIdentifier; impl->unlock(); } @@ -83,6 +94,8 @@ void VariableAcquisitionWorker::pushVariableRequest(QUuid vIdentifier, SqpRange QMetaObject::invokeMethod(this, "onExecuteRequest", Qt::QueuedConnection, Q_ARG(QUuid, acqRequest.m_AcqIdentifier)); } + + return varRequestIdCanceled; } void VariableAcquisitionWorker::abortProgressRequested(QUuid vIdentifier)