From 4e5df98215ef602f74e9cfad78cd381ac7eec44b 2017-08-24 07:13:16 From: mperrinel Date: 2017-08-24 07:13:16 Subject: [PATCH] Next range of a variable synchronized is now computed using: its current range the current range of the key reference variable the next range requested of the key reference variable --- diff --git a/core/src/Variable/VariableAcquisitionWorker.cpp b/core/src/Variable/VariableAcquisitionWorker.cpp index 4d475e0..93aa9bb 100644 --- a/core/src/Variable/VariableAcquisitionWorker.cpp +++ b/core/src/Variable/VariableAcquisitionWorker.cpp @@ -52,7 +52,7 @@ QUuid VariableAcquisitionWorker::pushVariableRequest(QUuid varRequestId, QUuid v DataProviderParameters parameters, std::shared_ptr provider) { - qCInfo(LOG_VariableAcquisitionWorker()) + qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM VariableAcquisitionWorker::pushVariableRequest ") << cacheRangeRequested; auto varRequestIdCanceled = QUuid(); @@ -186,7 +186,7 @@ void VariableAcquisitionWorker::onVariableDataAcquired(QUuid acqIdentifier, void VariableAcquisitionWorker::onExecuteRequest(QUuid acqIdentifier) { - qCInfo(LOG_VariableAcquisitionWorker()) << tr("onExecuteRequest") << QThread::currentThread(); + qCDebug(LOG_VariableAcquisitionWorker()) << tr("onExecuteRequest") << QThread::currentThread(); impl->lockRead(); auto it = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier); if (it != impl->m_AcqIdentifierToAcqRequestMap.cend()) { diff --git a/core/src/Variable/VariableController.cpp b/core/src/Variable/VariableController.cpp index c2f4d86..fa8e248 100644 --- a/core/src/Variable/VariableController.cpp +++ b/core/src/Variable/VariableController.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -80,7 +79,6 @@ struct VariableController::VariableControllerPrivate { : m_WorkingMutex{}, m_VariableModel{new VariableModel{parent}}, m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}}, - m_VariableCacheController{std::make_unique()}, m_VariableCacheStrategy{std::make_unique()}, m_VariableAcquisitionWorker{std::make_unique()}, q{parent} @@ -123,7 +121,6 @@ struct VariableController::VariableControllerPrivate { TimeController *m_TimeController{nullptr}; - std::unique_ptr m_VariableCacheController; std::unique_ptr m_VariableCacheStrategy; std::unique_ptr m_VariableAcquisitionWorker; QThread m_VariableAcquisitionWorkerThread; @@ -211,8 +208,6 @@ void VariableController::deleteVariable(std::shared_ptr variable) noex << tr("Number of providers deleted for variable %1: %2") .arg(variable->name(), QString::number(nbProvidersDeleted)); - // Clears cache - impl->m_VariableCacheController->clear(variable); // Deletes from model impl->m_VariableModel->deleteVariable(variable); @@ -369,16 +364,16 @@ void VariableController::onRequestDataLoading(QVector { // NOTE: oldRange isn't really necessary since oldRange == variable->range(). - qCDebug(LOG_VariableController()) << "VariableController::onRequestDataLoading" - << QThread::currentThread()->objectName(); // we want to load data of the variable for the dateTime. // First we check if the cache contains some of them. // For the other, we ask the provider to give them. auto varRequestId = QUuid::createUuid(); + qCInfo(LOG_VariableController()) << "VariableController::onRequestDataLoading" + << QThread::currentThread()->objectName() << varRequestId; for (const auto &var : variables) { - qCInfo(LOG_VariableController()) << "processRequest for" << var->name() << varRequestId; + qCDebug(LOG_VariableController()) << "processRequest for" << var->name() << varRequestId; impl->processRequest(var, range, varRequestId); } @@ -386,7 +381,8 @@ void VariableController::onRequestDataLoading(QVector // Get the group ids qCDebug(LOG_VariableController()) << "TORM VariableController::onRequestDataLoading for synchro var ENABLE"; - auto groupIds = std::set(); + auto groupIds = std::set{}; + auto groupIdToOldRangeMap = std::map{}; for (const auto &var : variables) { auto varToVarIdIt = impl->m_VariableToIdentifierMap.find(var); if (varToVarIdIt != impl->m_VariableToIdentifierMap.cend()) { @@ -394,6 +390,7 @@ void VariableController::onRequestDataLoading(QVector auto varIdToGroupIdIt = impl->m_VariableIdGroupIdMap.find(vId); if (varIdToGroupIdIt != impl->m_VariableIdGroupIdMap.cend()) { auto gId = varIdToGroupIdIt->second; + groupIdToOldRangeMap.insert(std::make_pair(gId, var->range())); if (groupIds.find(gId) == groupIds.cend()) { qCDebug(LOG_VariableController()) << "Synchro detect group " << gId; groupIds.insert(gId); @@ -415,8 +412,9 @@ void VariableController::onRequestDataLoading(QVector if (var != nullptr) { qCDebug(LOG_VariableController()) << "processRequest synchro for" << var->name(); - auto vSyncRangeRequested - = computeSynchroRangeRequested(var->range(), range, oldRange); + auto vSyncRangeRequested = computeSynchroRangeRequested( + var->range(), range, groupIdToOldRangeMap.at(gId)); + qCDebug(LOG_VariableController()) << "synchro RR" << vSyncRangeRequested; impl->processRequest(var, vSyncRangeRequested, varRequestId); } else { @@ -481,7 +479,6 @@ void VariableController::VariableControllerPrivate::processRequest(std::shared_p auto varRequest = VariableRequest{}; auto varId = m_VariableToIdentifierMap.at(var); - auto varStrategyRangesRequested = m_VariableCacheStrategy->computeStrategyRanges(var->range(), rangeRequested); auto notInCacheRangeList = var->provideNotInCacheRangeList(varStrategyRangesRequested.second); @@ -490,6 +487,11 @@ void VariableController::VariableControllerPrivate::processRequest(std::shared_p if (!notInCacheRangeList.empty()) { varRequest.m_RangeRequested = varStrategyRangesRequested.first; varRequest.m_CacheRangeRequested = varStrategyRangesRequested.second; + qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM processRequest RR ") << rangeRequested; + qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM processRequest R ") + << varStrategyRangesRequested.first; + qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM processRequest CR ") + << varStrategyRangesRequested.second; // store VarRequest storeVariableRequest(varId, varRequestId, varRequest); @@ -502,6 +504,8 @@ void VariableController::VariableControllerPrivate::processRequest(std::shared_p varProvider); if (!varRequestIdCanceled.isNull()) { + qCInfo(LOG_VariableAcquisitionWorker()) << tr("varRequestIdCanceled: ") + << varRequestIdCanceled; cancelVariableRequest(varRequestIdCanceled); } } @@ -682,13 +686,13 @@ void VariableController::VariableControllerPrivate::updateVariableRequest(QUuid auto &varRequest = varIdToVarRequestMapIt->second; var->setRange(varRequest.m_RangeRequested); var->setCacheRange(varRequest.m_CacheRangeRequested); - qCInfo(LOG_VariableController()) << tr("1: onDataProvided") - << varRequest.m_RangeRequested; - qCInfo(LOG_VariableController()) << tr("2: onDataProvided") - << varRequest.m_CacheRangeRequested; + qCDebug(LOG_VariableController()) << tr("1: onDataProvided") + << varRequest.m_RangeRequested; + qCDebug(LOG_VariableController()) << tr("2: onDataProvided") + << varRequest.m_CacheRangeRequested; var->mergeDataSeries(varRequest.m_DataSeries); - qCInfo(LOG_VariableController()) << tr("3: onDataProvided") - << varRequest.m_DataSeries->range(); + qCDebug(LOG_VariableController()) << tr("3: onDataProvided") + << varRequest.m_DataSeries->range(); qCDebug(LOG_VariableController()) << tr("4: onDataProvided"); emit var->updated(); } diff --git a/gui/src/Visualization/VisualizationZoneWidget.cpp b/gui/src/Visualization/VisualizationZoneWidget.cpp index 612fd3d..c49b616 100644 --- a/gui/src/Visualization/VisualizationZoneWidget.cpp +++ b/gui/src/Visualization/VisualizationZoneWidget.cpp @@ -100,49 +100,49 @@ VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptrenableAcquisition(false); - qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: Range before: ") - << graphChild->graphRange(); - qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: Range after : ") - << graphChildRange; - qCCritical(LOG_VisualizationZoneWidget()) + qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: Range before: ") + << graphChild->graphRange(); + qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: Range after : ") + << graphChildRange; + qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: child dt") << graphChildRange.m_TEnd - graphChildRange.m_TStart; graphChild->setGraphRange(graphChildRange); graphChild->enableAcquisition(true); diff --git a/plugins/amda/tests/TestAmdaAcquisition.cpp b/plugins/amda/tests/TestAmdaAcquisition.cpp index 5df8fc8..60662bb 100644 --- a/plugins/amda/tests/TestAmdaAcquisition.cpp +++ b/plugins/amda/tests/TestAmdaAcquisition.cpp @@ -130,8 +130,8 @@ void TestAmdaAcquisition::testAcquisition() QTimer::singleShot(timeToWaitMs, &loop, &QEventLoop::quit); loop.exec(); - qDebug() << count << "RANGE " << var->range(); - qDebug() << count << "CACHERANGE" << var->cacheRange(); + qInfo() << count << "RANGE " << var->range(); + qInfo() << count << "CACHERANGE" << var->cacheRange(); QCOMPARE(var->range().m_TStart, nextSqpR.m_TStart); QCOMPARE(var->range().m_TEnd, nextSqpR.m_TEnd); @@ -144,7 +144,7 @@ void TestAmdaAcquisition::testAcquisition() // 2 : pan (jump) left for one hour auto nextVarRS = QDateTime{QDate{2012, 01, 02}, QTime{2, 1, 0, 0}}; auto nextVarRE = QDateTime{QDate{2012, 01, 02}, QTime{2, 2, 0, 0}}; - // requestDataLoading(nextVarRS, nextVarRE); + requestDataLoading(nextVarRS, nextVarRE); // 3 : pan (jump) right for one hour