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