ok
@@ -102,6 +102,7 public slots: | |||
|
102 | 102 | /// synchronization group methods |
|
103 | 103 | void onAddSynchronizationGroupId(QUuid synchronizationGroupId); |
|
104 | 104 | void onRemoveSynchronizationGroupId(QUuid synchronizationGroupId); |
|
105 | void onAddSynchronized(std::shared_ptr<Variable> variable, QUuid synchronizationGroupId); | |
|
105 | 106 | |
|
106 | 107 | void initialize(); |
|
107 | 108 | void finalize(); |
@@ -263,18 +263,16 void VariableController::onDataProvided(QUuid vIdentifier, const SqpRange &range | |||
|
263 | 263 | const SqpRange &cacheRangeRequested, |
|
264 | 264 | QVector<AcquisitionDataPacket> dataAcquired) |
|
265 | 265 | { |
|
266 | qCCritical(LOG_VariableController()) << tr("onDataProvided") << dataAcquired.isEmpty(); | |
|
267 | ||
|
268 | 266 | auto var = impl->findVariable(vIdentifier); |
|
269 | 267 | if (var != nullptr) { |
|
270 | 268 | var->setRange(rangeRequested); |
|
271 | 269 | var->setCacheRange(cacheRangeRequested); |
|
272 |
qC |
|
|
273 |
qC |
|
|
270 | qCDebug(LOG_VariableController()) << tr("1: onDataProvided") << rangeRequested; | |
|
271 | qCDebug(LOG_VariableController()) << tr("2: onDataProvided") << cacheRangeRequested; | |
|
274 | 272 | |
|
275 | 273 | auto retrievedDataSeries = impl->retrieveDataSeries(dataAcquired); |
|
276 |
qC |
|
|
277 |
|
|
|
274 | qCDebug(LOG_VariableController()) << tr("3: onDataProvided") | |
|
275 | << retrievedDataSeries->range(); | |
|
278 | 276 | var->mergeDataSeries(retrievedDataSeries); |
|
279 | 277 | emit var->updated(); |
|
280 | 278 | } |
@@ -313,6 +311,9 void VariableController::onAbortProgressRequested(std::shared_ptr<Variable> vari | |||
|
313 | 311 | |
|
314 | 312 | void VariableController::onAddSynchronizationGroupId(QUuid synchronizationGroupId) |
|
315 | 313 | { |
|
314 | qCDebug(LOG_VariableController()) << "TORM: VariableController::onAddSynchronizationGroupId" | |
|
315 | << QThread::currentThread()->objectName() | |
|
316 | << synchronizationGroupId; | |
|
316 | 317 | auto vSynchroGroup = std::make_shared<VariableSynchronizationGroup>(); |
|
317 | 318 | impl->m_GroupIdToVariableSynchronizationGroupMap.insert( |
|
318 | 319 | std::make_pair(synchronizationGroupId, vSynchroGroup)); |
@@ -323,6 +324,33 void VariableController::onRemoveSynchronizationGroupId(QUuid synchronizationGro | |||
|
323 | 324 | impl->m_GroupIdToVariableSynchronizationGroupMap.erase(synchronizationGroupId); |
|
324 | 325 | } |
|
325 | 326 | |
|
327 | void VariableController::onAddSynchronized(std::shared_ptr<Variable> variable, | |
|
328 | QUuid synchronizationGroupId) | |
|
329 | ||
|
330 | { | |
|
331 | qCDebug(LOG_VariableController()) << "TORM: VariableController::onAddSynchronized" | |
|
332 | << synchronizationGroupId; | |
|
333 |
auto vToVIdit = impl->m_VariableToIdentifierMap.find(variable);
|
|
|
334 | if (vToVIdit != impl->m_VariableToIdentifierMap.cend()) { | |
|
335 | auto itSynchroGroup | |
|
336 | = impl->m_GroupIdToVariableSynchronizationGroupMap.find(synchronizationGroupId); | |
|
337 | if (itSynchroGroup != impl->m_GroupIdToVariableSynchronizationGroupMap.cend()) { | |
|
338 | impl->m_VariableIdGroupIdMap.insert( | |
|
339 | std::make_pair(vToVIdit->second, synchronizationGroupId)); | |
|
340 | itSynchroGroup->second->addVariableId(vToVIdit->second); | |
|
341 | } | |
|
342 | else { | |
|
343 | qCCritical(LOG_VariableController()) | |
|
344 | << tr("Impossible to synchronize a variable with an unknown sycnhronization group") | |
|
345 | << variable->name(); | |
|
346 | } | |
|
347 | } | |
|
348 | else { | |
|
349 | qCCritical(LOG_VariableController()) | |
|
350 | << tr("Impossible to synchronize a variable with no identifier") << variable->name(); | |
|
351 | } | |
|
352 | } | |
|
353 | ||
|
326 | 354 | |
|
327 | 355 | void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable> > variables, |
|
328 | 356 | const SqpRange &range, const SqpRange &oldRange, |
@@ -337,24 +365,24 void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable> | |||
|
337 | 365 | // For the other, we ask the provider to give them. |
|
338 | 366 | |
|
339 | 367 | foreach (auto var, variables) { |
|
340 |
qC |
|
|
368 | qCDebug(LOG_VariableController()) << "processRequest for" << var->name(); | |
|
341 | 369 | impl->processRequest(var, range); |
|
342 | 370 | } |
|
343 | 371 | |
|
344 | 372 | if (synchronise) { |
|
345 | 373 | // Get the group ids |
|
346 |
qC |
|
|
374 | qCDebug(LOG_VariableController()) | |
|
347 | 375 | << "VariableController::onRequestDataLoading for synchro var ENABLE"; |
|
348 | 376 | auto groupIds = std::set<QUuid>(); |
|
349 | 377 | foreach (auto var, variables) { |
|
350 |
auto v |
|
|
351 |
if (v |
|
|
352 |
auto vId = v |
|
|
353 | ||
|
354 |
|
|
|
355 | if (vIdToGIdit != impl->m_VariableIdGroupIdMap.cend()) { | |
|
356 | auto gId = vToVIdit->second; | |
|
378 | auto varToVarIdIt = impl->m_VariableToIdentifierMap.find(var); | |
|
379 | if (varToVarIdIt != impl->m_VariableToIdentifierMap.cend()) { | |
|
380 | auto vId = varToVarIdIt->second; | |
|
381 | auto varIdToGroupIdIt = impl->m_VariableIdGroupIdMap.find(vId); | |
|
382 | if (varIdToGroupIdIt != impl->m_VariableIdGroupIdMap.cend()) { | |
|
383 | auto gId = varIdToGroupIdIt->second; | |
|
357 | 384 | if (groupIds.find(gId) == groupIds.cend()) { |
|
385 | qCDebug(LOG_VariableController()) << "Synchro detect group " << gId; | |
|
358 | 386 | groupIds.insert(gId); |
|
359 | 387 | } |
|
360 | 388 | } |
@@ -365,17 +393,24 void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable> | |||
|
365 | 393 | foreach (auto gId, groupIds) { |
|
366 | 394 | auto vSynchronizationGroup = impl->m_GroupIdToVariableSynchronizationGroupMap.at(gId); |
|
367 | 395 | auto vSyncIds = vSynchronizationGroup->getIds(); |
|
396 | qCDebug(LOG_VariableController()) << "Var in synchro group "; | |
|
368 | 397 | for (auto vId : vSyncIds) { |
|
369 | 398 | auto var = impl->findVariable(vId); |
|
370 | if (var != nullptr) { | |
|
371 | qCInfo(LOG_VariableController()) << "processRequest synchro for" << var->name(); | |
|
372 | auto vSyncRangeRequested | |
|
373 | = computeSynchroRangeRequested(var->range(), range, oldRange); | |
|
374 | impl->processRequest(var, vSyncRangeRequested); | |
|
375 | } | |
|
376 | else { | |
|
377 | qCCritical(LOG_VariableController()) | |
|
378 | << tr("Impossible to synchronize a null variable"); | |
|
399 | ||
|
400 | // Don't process already processed var | |
|
401 | if (!variables.contains(var)) { | |
|
402 | if (var != nullptr) { | |
|
403 | qCDebug(LOG_VariableController()) << "processRequest synchro for" | |
|
404 | << var->name(); | |
|
405 | auto vSyncRangeRequested | |
|
406 | = computeSynchroRangeRequested(var->range(), range, oldRange); | |
|
407 | impl->processRequest(var, vSyncRangeRequested); | |
|
408 | } | |
|
409 | else { | |
|
410 | qCCritical(LOG_VariableController()) | |
|
411 | ||
|
412 | << tr("Impossible to synchronize a null variable"); | |
|
413 | } | |
|
379 | 414 | } |
|
380 | 415 | } |
|
381 | 416 | } |
@@ -503,6 +538,6 void VariableController::VariableControllerPrivate::registerProvider( | |||
|
503 | 538 | &VariableAcquisitionWorker::onVariableRetrieveDataInProgress); |
|
504 | 539 | } |
|
505 | 540 | else { |
|
506 |
qC |
|
|
541 | qCDebug(LOG_VariableController()) << tr("Cannot register provider, it already exists "); | |
|
507 | 542 | } |
|
508 | 543 | } |
@@ -64,8 +64,8 void TestOneDimArrayData::testDataByComponentIndex_data() | |||
|
64 | 64 | // Test cases |
|
65 | 65 | QTest::newRow("validIndex") << QVector<double>{1., 2., 3., 4., 5.} << 0 |
|
66 | 66 | << QVector<double>{1., 2., 3., 4., 5.}; |
|
67 | QTest::newRow("invalidIndex1") | |
|
68 | << QVector<double>{1., 2., 3., 4., 5.} << -1 << QVector<double>{}; | |
|
67 | QTest::newRow("invalidIndex1") << QVector<double>{1., 2., 3., 4., 5.} << -1 | |
|
68 | << QVector<double>{}; | |
|
69 | 69 | QTest::newRow("invalidIndex2") << QVector<double>{1., 2., 3., 4., 5.} << 1 << QVector<double>{}; |
|
70 | 70 | } |
|
71 | 71 |
@@ -75,8 +75,8 void TestTwoDimArrayData::testCtor_data() | |||
|
75 | 75 | QTest::newRow("malformedInput (components of the array data haven't the same size") |
|
76 | 76 | << DataContainer{{1., 2., 3., 4., 5.}, {6., 7., 8.}, {11., 12.}} << true |
|
77 | 77 | << DataContainer{{}, {}, {}}; |
|
78 | QTest::newRow("invalidInput (less than tow components") | |
|
79 | << DataContainer{{1., 2., 3., 4., 5.}} << false << DataContainer{{}, {}, {}}; | |
|
78 | QTest::newRow("invalidInput (less than tow components") << DataContainer{{1., 2., 3., 4., 5.}} | |
|
79 | << false << DataContainer{{}, {}, {}}; | |
|
80 | 80 | } |
|
81 | 81 | |
|
82 | 82 | void TestTwoDimArrayData::testCtor() |
@@ -52,6 +52,9 signals: | |||
|
52 | 52 | const SqpRange &oldRange, bool synchronise); |
|
53 | 53 | |
|
54 | 54 | |
|
55 | void variableAdded(std::shared_ptr<Variable> var); | |
|
56 | ||
|
57 | ||
|
55 | 58 | private: |
|
56 | 59 | Ui::VisualizationGraphWidget *ui; |
|
57 | 60 |
@@ -42,6 +42,10 public: | |||
|
42 | 42 | bool contains(const Variable &variable) const override; |
|
43 | 43 | QString name() const override; |
|
44 | 44 | |
|
45 | ||
|
46 | private slots: | |
|
47 | void onVariableAdded(std::shared_ptr<Variable> variable); | |
|
48 | ||
|
45 | 49 | private: |
|
46 | 50 | Ui::VisualizationZoneWidget *ui; |
|
47 | 51 |
@@ -95,44 +95,30 void VisualizationGraphWidget::enableAcquisition(bool enable) | |||
|
95 | 95 | |
|
96 | 96 | void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable) |
|
97 | 97 | { |
|
98 | auto calibrationState = impl->m_IsCalibration; | |
|
99 | impl->m_IsCalibration = true; | |
|
98 | 100 | // Uses delegate to create the qcpplot components according to the variable |
|
99 | 101 | auto createdPlottables = VisualizationGraphHelper::create(variable, *ui->widget); |
|
102 | impl->m_IsCalibration = calibrationState; | |
|
100 | 103 | |
|
101 | 104 | for (auto createdPlottable : qAsConst(createdPlottables)) { |
|
102 | 105 | impl->m_VariableToPlotMultiMap.insert({variable, createdPlottable}); |
|
103 | 106 | } |
|
104 | 107 | |
|
105 | 108 | connect(variable.get(), SIGNAL(updated()), this, SLOT(onDataCacheVariableUpdated())); |
|
109 | ||
|
110 | emit variableAdded(variable); | |
|
106 | 111 | } |
|
107 | 112 | void VisualizationGraphWidget::addVariableUsingGraph(std::shared_ptr<Variable> variable) |
|
108 | 113 | { |
|
109 | // TODO | |
|
110 | // // when adding a variable, we need to set its time range to the current graph range | |
|
111 | // auto grapheRange = ui->widget->xAxis->range(); | |
|
112 | // auto dateTime = SqpRange{grapheRange.lower, grapheRange.upper}; | |
|
113 | // variable->setDateTime(dateTime); | |
|
114 | ||
|
115 | // auto variableDateTimeWithTolerance = dateTime; | |
|
116 | ||
|
117 | // // add tolerance for each side | |
|
118 | // auto toleranceFactor | |
|
119 | // = toleranceValue(GENERAL_TOLERANCE_AT_INIT_KEY, | |
|
120 | // GENERAL_TOLERANCE_AT_INIT_DEFAULT_VALUE); | |
|
121 | // auto tolerance = toleranceFactor * (dateTime.m_TEnd - dateTime.m_TStart); | |
|
122 | // variableDateTimeWithTolerance.m_TStart -= tolerance; | |
|
123 | // variableDateTimeWithTolerance.m_TEnd += tolerance; | |
|
124 | ||
|
125 | // // Uses delegate to create the qcpplot components according to the variable | |
|
126 | // auto createdPlottables = VisualizationGraphHelper::create(variable, *ui->widget); | |
|
127 | ||
|
128 | // for (auto createdPlottable : qAsConst(createdPlottables)) { | |
|
129 | // impl->m_VariableToPlotMultiMap.insert({variable, createdPlottable}); | |
|
130 | // } | |
|
114 | // Uses delegate to create the qcpplot components according to the variable | |
|
115 | this->addVariable(variable); | |
|
131 | 116 | |
|
132 | // connect(variable.get(), SIGNAL(updated()), this, SLOT(onDataCacheVariableUpdated())); | |
|
117 | // Request range for the variable | |
|
118 | auto graphRange = ui->widget->xAxis->range(); | |
|
133 | 119 | |
|
134 | // // CHangement detected, we need to ask controller to request data loading | |
|
135 | // emit requestDataLoading(variable, variableDateTimeWithTolerance); | |
|
120 | emit requestDataLoading(QVector<std::shared_ptr<Variable> >() << variable, | |
|
121 | SqpRange{graphRange.lower, graphRange.upper}, variable->range(), false); | |
|
136 | 122 | } |
|
137 | 123 | |
|
138 | 124 | void VisualizationGraphWidget::removeVariable(std::shared_ptr<Variable> variable) noexcept |
@@ -249,9 +235,9 void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange | |||
|
249 | 235 | !impl->m_IsCalibration); |
|
250 | 236 | |
|
251 | 237 | if (!impl->m_IsCalibration) { |
|
252 |
qC |
|
|
238 | qCInfo(LOG_VisualizationGraphWidget()) | |
|
253 | 239 | << tr("TORM: VisualizationGraphWidget::Synchronize notify !!") |
|
254 | << QThread::currentThread()->objectName(); | |
|
240 | << QThread::currentThread()->objectName() << graphRange << oldGraphRange; | |
|
255 | 241 | emit synchronize(graphRange, oldGraphRange); |
|
256 | 242 | } |
|
257 | 243 | } |
@@ -79,9 +79,6 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<V | |||
|
79 | 79 | graphWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); |
|
80 | 80 | graphWidget->setMinimumHeight(GRAPH_MINIMUM_HEIGHT); |
|
81 | 81 | |
|
82 | this->addGraph(graphWidget); | |
|
83 | ||
|
84 | graphWidget->addVariable(variable); | |
|
85 | 82 | |
|
86 | 83 | // Lambda to synchronize zone widget |
|
87 | 84 | auto synchronizeZoneWidget = [this, graphWidget](const SqpRange &grapheRange, |
@@ -168,6 +165,12 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<V | |||
|
168 | 165 | |
|
169 | 166 | // connection for synchronization |
|
170 | 167 | connect(graphWidget, &VisualizationGraphWidget::synchronize, synchronizeZoneWidget); |
|
168 | connect(graphWidget, &VisualizationGraphWidget::variableAdded, this, | |
|
169 | &VisualizationZoneWidget::onVariableAdded); | |
|
170 | ||
|
171 | this->addGraph(graphWidget); | |
|
172 | ||
|
173 | graphWidget->addVariable(variable); | |
|
171 | 174 | |
|
172 | 175 | return graphWidget; |
|
173 | 176 | } |
@@ -213,3 +216,10 QString VisualizationZoneWidget::name() const | |||
|
213 | 216 | { |
|
214 | 217 | return ui->zoneNameLabel->text(); |
|
215 | 218 | } |
|
219 | ||
|
220 | void VisualizationZoneWidget::onVariableAdded(std::shared_ptr<Variable> variable) | |
|
221 | { | |
|
222 | QMetaObject::invokeMethod(&sqpApp->variableController(), "onAddSynchronized", | |
|
223 | Qt::QueuedConnection, Q_ARG(std::shared_ptr<Variable>, variable), | |
|
224 | Q_ARG(QUuid, impl->m_SynchronisationGroupId)); | |
|
225 | } |
@@ -61,7 +61,8 void AmdaProvider::requestDataLoading(QUuid acqIdentifier, const DataProviderPar | |||
|
61 | 61 | const auto times = parameters.m_Times; |
|
62 | 62 | const auto data = parameters.m_Data; |
|
63 | 63 | for (const auto &dateTime : qAsConst(times)) { |
|
64 | retrieveData(acqIdentifier, dateTime, data); | |
|
64 | this->retrieveData(acqIdentifier, dateTime, data); | |
|
65 |
QThread::msleep(200);
ok |
|
|
65 | 66 | } |
|
66 | 67 | } |
|
67 | 68 |
General Comments 1
Auto status change to "Under Review"
You need to be logged in to leave comments.
Login now