##// END OF EJS Templates
Next range of a variable synchronized is now computed using:...
perrinel -
r627:4e5df98215ef
parent child
Show More
@@ -52,7 +52,7 QUuid VariableAcquisitionWorker::pushVariableRequest(QUuid varRequestId, QUuid v
52 52 DataProviderParameters parameters,
53 53 std::shared_ptr<IDataProvider> provider)
54 54 {
55 qCInfo(LOG_VariableAcquisitionWorker())
55 qCDebug(LOG_VariableAcquisitionWorker())
56 56 << tr("TORM VariableAcquisitionWorker::pushVariableRequest ") << cacheRangeRequested;
57 57 auto varRequestIdCanceled = QUuid();
58 58
@@ -186,7 +186,7 void VariableAcquisitionWorker::onVariableDataAcquired(QUuid acqIdentifier,
186 186
187 187 void VariableAcquisitionWorker::onExecuteRequest(QUuid acqIdentifier)
188 188 {
189 qCInfo(LOG_VariableAcquisitionWorker()) << tr("onExecuteRequest") << QThread::currentThread();
189 qCDebug(LOG_VariableAcquisitionWorker()) << tr("onExecuteRequest") << QThread::currentThread();
190 190 impl->lockRead();
191 191 auto it = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier);
192 192 if (it != impl->m_AcqIdentifierToAcqRequestMap.cend()) {
@@ -1,6 +1,5
1 1 #include <Variable/Variable.h>
2 2 #include <Variable/VariableAcquisitionWorker.h>
3 #include <Variable/VariableCacheController.h>
4 3 #include <Variable/VariableCacheStrategy.h>
5 4 #include <Variable/VariableController.h>
6 5 #include <Variable/VariableModel.h>
@@ -80,7 +79,6 struct VariableController::VariableControllerPrivate {
80 79 : m_WorkingMutex{},
81 80 m_VariableModel{new VariableModel{parent}},
82 81 m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}},
83 m_VariableCacheController{std::make_unique<VariableCacheController>()},
84 82 m_VariableCacheStrategy{std::make_unique<VariableCacheStrategy>()},
85 83 m_VariableAcquisitionWorker{std::make_unique<VariableAcquisitionWorker>()},
86 84 q{parent}
@@ -123,7 +121,6 struct VariableController::VariableControllerPrivate {
123 121
124 122
125 123 TimeController *m_TimeController{nullptr};
126 std::unique_ptr<VariableCacheController> m_VariableCacheController;
127 124 std::unique_ptr<VariableCacheStrategy> m_VariableCacheStrategy;
128 125 std::unique_ptr<VariableAcquisitionWorker> m_VariableAcquisitionWorker;
129 126 QThread m_VariableAcquisitionWorkerThread;
@@ -211,8 +208,6 void VariableController::deleteVariable(std::shared_ptr<Variable> variable) noex
211 208 << tr("Number of providers deleted for variable %1: %2")
212 209 .arg(variable->name(), QString::number(nbProvidersDeleted));
213 210
214 // Clears cache
215 impl->m_VariableCacheController->clear(variable);
216 211
217 212 // Deletes from model
218 213 impl->m_VariableModel->deleteVariable(variable);
@@ -369,16 +364,16 void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable>
369 364 {
370 365 // NOTE: oldRange isn't really necessary since oldRange == variable->range().
371 366
372 qCDebug(LOG_VariableController()) << "VariableController::onRequestDataLoading"
373 << QThread::currentThread()->objectName();
374 367 // we want to load data of the variable for the dateTime.
375 368 // First we check if the cache contains some of them.
376 369 // For the other, we ask the provider to give them.
377 370
378 371 auto varRequestId = QUuid::createUuid();
372 qCInfo(LOG_VariableController()) << "VariableController::onRequestDataLoading"
373 << QThread::currentThread()->objectName() << varRequestId;
379 374
380 375 for (const auto &var : variables) {
381 qCInfo(LOG_VariableController()) << "processRequest for" << var->name() << varRequestId;
376 qCDebug(LOG_VariableController()) << "processRequest for" << var->name() << varRequestId;
382 377 impl->processRequest(var, range, varRequestId);
383 378 }
384 379
@@ -386,7 +381,8 void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable>
386 381 // Get the group ids
387 382 qCDebug(LOG_VariableController())
388 383 << "TORM VariableController::onRequestDataLoading for synchro var ENABLE";
389 auto groupIds = std::set<QUuid>();
384 auto groupIds = std::set<QUuid>{};
385 auto groupIdToOldRangeMap = std::map<QUuid, SqpRange>{};
390 386 for (const auto &var : variables) {
391 387 auto varToVarIdIt = impl->m_VariableToIdentifierMap.find(var);
392 388 if (varToVarIdIt != impl->m_VariableToIdentifierMap.cend()) {
@@ -394,6 +390,7 void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable>
394 390 auto varIdToGroupIdIt = impl->m_VariableIdGroupIdMap.find(vId);
395 391 if (varIdToGroupIdIt != impl->m_VariableIdGroupIdMap.cend()) {
396 392 auto gId = varIdToGroupIdIt->second;
393 groupIdToOldRangeMap.insert(std::make_pair(gId, var->range()));
397 394 if (groupIds.find(gId) == groupIds.cend()) {
398 395 qCDebug(LOG_VariableController()) << "Synchro detect group " << gId;
399 396 groupIds.insert(gId);
@@ -415,8 +412,9 void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable>
415 412 if (var != nullptr) {
416 413 qCDebug(LOG_VariableController()) << "processRequest synchro for"
417 414 << var->name();
418 auto vSyncRangeRequested
419 = computeSynchroRangeRequested(var->range(), range, oldRange);
415 auto vSyncRangeRequested = computeSynchroRangeRequested(
416 var->range(), range, groupIdToOldRangeMap.at(gId));
417 qCDebug(LOG_VariableController()) << "synchro RR" << vSyncRangeRequested;
420 418 impl->processRequest(var, vSyncRangeRequested, varRequestId);
421 419 }
422 420 else {
@@ -481,7 +479,6 void VariableController::VariableControllerPrivate::processRequest(std::shared_p
481 479 auto varRequest = VariableRequest{};
482 480 auto varId = m_VariableToIdentifierMap.at(var);
483 481
484
485 482 auto varStrategyRangesRequested
486 483 = m_VariableCacheStrategy->computeStrategyRanges(var->range(), rangeRequested);
487 484 auto notInCacheRangeList = var->provideNotInCacheRangeList(varStrategyRangesRequested.second);
@@ -490,6 +487,11 void VariableController::VariableControllerPrivate::processRequest(std::shared_p
490 487 if (!notInCacheRangeList.empty()) {
491 488 varRequest.m_RangeRequested = varStrategyRangesRequested.first;
492 489 varRequest.m_CacheRangeRequested = varStrategyRangesRequested.second;
490 qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM processRequest RR ") << rangeRequested;
491 qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM processRequest R ")
492 << varStrategyRangesRequested.first;
493 qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM processRequest CR ")
494 << varStrategyRangesRequested.second;
493 495 // store VarRequest
494 496 storeVariableRequest(varId, varRequestId, varRequest);
495 497
@@ -502,6 +504,8 void VariableController::VariableControllerPrivate::processRequest(std::shared_p
502 504 varProvider);
503 505
504 506 if (!varRequestIdCanceled.isNull()) {
507 qCInfo(LOG_VariableAcquisitionWorker()) << tr("varRequestIdCanceled: ")
508 << varRequestIdCanceled;
505 509 cancelVariableRequest(varRequestIdCanceled);
506 510 }
507 511 }
@@ -682,12 +686,12 void VariableController::VariableControllerPrivate::updateVariableRequest(QUuid
682 686 auto &varRequest = varIdToVarRequestMapIt->second;
683 687 var->setRange(varRequest.m_RangeRequested);
684 688 var->setCacheRange(varRequest.m_CacheRangeRequested);
685 qCInfo(LOG_VariableController()) << tr("1: onDataProvided")
689 qCDebug(LOG_VariableController()) << tr("1: onDataProvided")
686 690 << varRequest.m_RangeRequested;
687 qCInfo(LOG_VariableController()) << tr("2: onDataProvided")
691 qCDebug(LOG_VariableController()) << tr("2: onDataProvided")
688 692 << varRequest.m_CacheRangeRequested;
689 693 var->mergeDataSeries(varRequest.m_DataSeries);
690 qCInfo(LOG_VariableController()) << tr("3: onDataProvided")
694 qCDebug(LOG_VariableController()) << tr("3: onDataProvided")
691 695 << varRequest.m_DataSeries->range();
692 696 qCDebug(LOG_VariableController()) << tr("4: onDataProvided");
693 697 emit var->updated();
@@ -100,49 +100,49 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<V
100 100 auto deltaRight = oldGraphRange.m_TEnd - graphRange.m_TEnd;
101 101 graphChildRange.m_TStart += deltaLeft;
102 102 graphChildRange.m_TEnd -= deltaRight;
103 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: ZoomIn");
104 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: deltaLeft")
103 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: ZoomIn");
104 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: deltaLeft")
105 105 << deltaLeft;
106 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: deltaRight")
106 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: deltaRight")
107 107 << deltaRight;
108 qCCritical(LOG_VisualizationZoneWidget())
108 qCDebug(LOG_VisualizationZoneWidget())
109 109 << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart;
110 110
111 111 break;
112 112 }
113 113
114 114 case AcquisitionZoomType::ZoomOut: {
115 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: ZoomOut");
115 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: ZoomOut");
116 116 auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart;
117 117 auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd;
118 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: deltaLeft")
118 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: deltaLeft")
119 119 << deltaLeft;
120 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: deltaRight")
120 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: deltaRight")
121 121 << deltaRight;
122 qCCritical(LOG_VisualizationZoneWidget())
122 qCDebug(LOG_VisualizationZoneWidget())
123 123 << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart;
124 124 graphChildRange.m_TStart -= deltaLeft;
125 125 graphChildRange.m_TEnd += deltaRight;
126 126 break;
127 127 }
128 128 case AcquisitionZoomType::PanRight: {
129 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: PanRight");
129 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: PanRight");
130 130 auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd;
131 131 graphChildRange.m_TStart += deltaRight;
132 132 graphChildRange.m_TEnd += deltaRight;
133 qCCritical(LOG_VisualizationZoneWidget())
133 qCDebug(LOG_VisualizationZoneWidget())
134 134 << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart;
135 135 break;
136 136 }
137 137 case AcquisitionZoomType::PanLeft: {
138 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: PanLeft");
138 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: PanLeft");
139 139 auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart;
140 140 graphChildRange.m_TStart -= deltaLeft;
141 141 graphChildRange.m_TEnd -= deltaLeft;
142 142 break;
143 143 }
144 144 case AcquisitionZoomType::Unknown: {
145 qCCritical(LOG_VisualizationZoneWidget())
145 qCDebug(LOG_VisualizationZoneWidget())
146 146 << tr("Impossible to synchronize: zoom type unknown");
147 147 break;
148 148 }
@@ -153,11 +153,11 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<V
153 153 break;
154 154 }
155 155 graphChild->enableAcquisition(false);
156 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: Range before: ")
156 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: Range before: ")
157 157 << graphChild->graphRange();
158 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: Range after : ")
158 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: Range after : ")
159 159 << graphChildRange;
160 qCCritical(LOG_VisualizationZoneWidget())
160 qCDebug(LOG_VisualizationZoneWidget())
161 161 << tr("TORM: child dt") << graphChildRange.m_TEnd - graphChildRange.m_TStart;
162 162 graphChild->setGraphRange(graphChildRange);
163 163 graphChild->enableAcquisition(true);
@@ -130,8 +130,8 void TestAmdaAcquisition::testAcquisition()
130 130 QTimer::singleShot(timeToWaitMs, &loop, &QEventLoop::quit);
131 131 loop.exec();
132 132
133 qDebug() << count << "RANGE " << var->range();
134 qDebug() << count << "CACHERANGE" << var->cacheRange();
133 qInfo() << count << "RANGE " << var->range();
134 qInfo() << count << "CACHERANGE" << var->cacheRange();
135 135
136 136 QCOMPARE(var->range().m_TStart, nextSqpR.m_TStart);
137 137 QCOMPARE(var->range().m_TEnd, nextSqpR.m_TEnd);
@@ -144,7 +144,7 void TestAmdaAcquisition::testAcquisition()
144 144 // 2 : pan (jump) left for one hour
145 145 auto nextVarRS = QDateTime{QDate{2012, 01, 02}, QTime{2, 1, 0, 0}};
146 146 auto nextVarRE = QDateTime{QDate{2012, 01, 02}, QTime{2, 2, 0, 0}};
147 // requestDataLoading(nextVarRS, nextVarRE);
147 requestDataLoading(nextVarRS, nextVarRE);
148 148
149 149
150 150 // 3 : pan (jump) right for one hour
General Comments 0
You need to be logged in to leave comments. Login now