Auto status change to "Under Review"
@@ -48,15 +48,17 SqpRange computeSynchroRangeRequested(const SqpRange &varRange, const SqpRange & | |||||
48 | break; |
|
48 | break; | |
49 | } |
|
49 | } | |
50 | case AcquisitionZoomType::PanRight: { |
|
50 | case AcquisitionZoomType::PanRight: { | |
|
51 | auto deltaLeft = graphRange.m_TStart - oldGraphRange.m_TStart; | |||
51 | auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd; |
|
52 | auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd; | |
52 |
varRangeRequested.m_TStart += delta |
|
53 | varRangeRequested.m_TStart += deltaLeft; | |
53 | varRangeRequested.m_TEnd += deltaRight; |
|
54 | varRangeRequested.m_TEnd += deltaRight; | |
54 | break; |
|
55 | break; | |
55 | } |
|
56 | } | |
56 | case AcquisitionZoomType::PanLeft: { |
|
57 | case AcquisitionZoomType::PanLeft: { | |
57 | auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart; |
|
58 | auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart; | |
|
59 | auto deltaRight = oldGraphRange.m_TEnd - graphRange.m_TEnd; | |||
58 | varRangeRequested.m_TStart -= deltaLeft; |
|
60 | varRangeRequested.m_TStart -= deltaLeft; | |
59 |
varRangeRequested.m_TEnd -= delta |
|
61 | varRangeRequested.m_TEnd -= deltaRight; | |
60 | break; |
|
62 | break; | |
61 | } |
|
63 | } | |
62 | case AcquisitionZoomType::Unknown: { |
|
64 | case AcquisitionZoomType::Unknown: { | |
@@ -551,15 +553,19 AcquisitionZoomType VariableController::getZoomType(const SqpRange &range, const | |||||
551 | // t1.m_TStart <= t2.m_TStart && t2.m_TEnd <= t1.m_TEnd |
|
553 | // t1.m_TStart <= t2.m_TStart && t2.m_TEnd <= t1.m_TEnd | |
552 | auto zoomType = AcquisitionZoomType::Unknown; |
|
554 | auto zoomType = AcquisitionZoomType::Unknown; | |
553 | if (range.m_TStart <= oldRange.m_TStart && oldRange.m_TEnd <= range.m_TEnd) { |
|
555 | if (range.m_TStart <= oldRange.m_TStart && oldRange.m_TEnd <= range.m_TEnd) { | |
|
556 | qCCritical(LOG_VariableController()) << "zoomtype: ZoomOut"; | |||
554 | zoomType = AcquisitionZoomType::ZoomOut; |
|
557 | zoomType = AcquisitionZoomType::ZoomOut; | |
555 | } |
|
558 | } | |
556 | else if (range.m_TStart > oldRange.m_TStart && range.m_TEnd > oldRange.m_TEnd) { |
|
559 | else if (range.m_TStart > oldRange.m_TStart && range.m_TEnd > oldRange.m_TEnd) { | |
|
560 | qCCritical(LOG_VariableController()) << "zoomtype: PanRight"; | |||
557 | zoomType = AcquisitionZoomType::PanRight; |
|
561 | zoomType = AcquisitionZoomType::PanRight; | |
558 | } |
|
562 | } | |
559 | else if (range.m_TStart < oldRange.m_TStart && range.m_TEnd < oldRange.m_TEnd) { |
|
563 | else if (range.m_TStart < oldRange.m_TStart && range.m_TEnd < oldRange.m_TEnd) { | |
|
564 | qCCritical(LOG_VariableController()) << "zoomtype: PanLeft"; | |||
560 | zoomType = AcquisitionZoomType::PanLeft; |
|
565 | zoomType = AcquisitionZoomType::PanLeft; | |
561 | } |
|
566 | } | |
562 | else if (range.m_TStart > oldRange.m_TStart && oldRange.m_TEnd > range.m_TEnd) { |
|
567 | else if (range.m_TStart > oldRange.m_TStart && oldRange.m_TEnd > range.m_TEnd) { | |
|
568 | qCCritical(LOG_VariableController()) << "zoomtype: ZoomIn"; | |||
563 | zoomType = AcquisitionZoomType::ZoomIn; |
|
569 | zoomType = AcquisitionZoomType::ZoomIn; | |
564 | } |
|
570 | } | |
565 | else { |
|
571 | else { |
@@ -171,20 +171,10 private slots: | |||||
171 | void testSync(); |
|
171 | void testSync(); | |
172 | }; |
|
172 | }; | |
173 |
|
173 | |||
174 | void TestVariableSync::testSync_data() |
|
174 | namespace { | |
175 | { |
|
|||
176 | // ////////////// // |
|
|||
177 | // Test structure // |
|
|||
178 | // ////////////// // |
|
|||
179 |
|
||||
180 | QTest::addColumn<QUuid>("syncId"); |
|
|||
181 | QTest::addColumn<SqpRange>("initialRange"); |
|
|||
182 | QTest::addColumn<Iterations>("iterations"); |
|
|||
183 |
|
||||
184 | // ////////// // |
|
|||
185 | // Test cases // |
|
|||
186 | // ////////// // |
|
|||
187 |
|
175 | |||
|
176 | void testSyncCase1() | |||
|
177 | { | |||
188 | // Id used to synchronize variables in the controller |
|
178 | // Id used to synchronize variables in the controller | |
189 | auto syncId = QUuid::createUuid(); |
|
179 | auto syncId = QUuid::createUuid(); | |
190 |
|
180 | |||
@@ -254,7 +244,86 void TestVariableSync::testSync_data() | |||||
254 | // Zoom out |
|
244 | // Zoom out | |
255 | moveVar0(range({12, 0}, {18, 0}), range({11, 0}, {17, 0})); |
|
245 | moveVar0(range({12, 0}, {18, 0}), range({11, 0}, {17, 0})); | |
256 |
|
246 | |||
257 | QTest::newRow("sync1") << syncId << initialRange << std::move(iterations); |
|
247 | QTest::newRow("sync1") << syncId << initialRange << std::move(iterations) << 200; | |
|
248 | } | |||
|
249 | ||||
|
250 | void testSyncCase2() | |||
|
251 | { | |||
|
252 | // Id used to synchronize variables in the controller | |||
|
253 | auto syncId = QUuid::createUuid(); | |||
|
254 | ||||
|
255 | /// Generates a range according to a start time and a end time (the date is the same) | |||
|
256 | auto dateTime = [](int year, int month, int day, int hours, int minutes, int seconds) { | |||
|
257 | return DateUtils::secondsSinceEpoch( | |||
|
258 | QDateTime{{year, month, day}, QTime{hours, minutes, seconds}, Qt::UTC}); | |||
|
259 | }; | |||
|
260 | ||||
|
261 | auto initialRange = SqpRange{dateTime(2017, 1, 1, 12, 0, 0), dateTime(2017, 1, 1, 13, 0, 0)}; | |||
|
262 | ||||
|
263 | Iterations iterations{}; | |||
|
264 | // Creates variables var0 and var1 | |||
|
265 | iterations.push_back({std::make_shared<Create>(0), {{0, initialRange}}}); | |||
|
266 | iterations.push_back({std::make_shared<Create>(1), {{0, initialRange}, {1, initialRange}}}); | |||
|
267 | ||||
|
268 | // Adds variables into the sync group (ranges don't need to be tested here) | |||
|
269 | iterations.push_back({std::make_shared<Synchronize>(0, syncId)}); | |||
|
270 | iterations.push_back({std::make_shared<Synchronize>(1, syncId)}); | |||
|
271 | ||||
|
272 | ||||
|
273 | // Moves var0 through several operations: | |||
|
274 | // - range of var0 changes | |||
|
275 | // - range or var1 changes according to the previous shift (one hour) | |||
|
276 | auto moveVar0 = [&iterations](const auto &var0NewRange) { | |||
|
277 | iterations.push_back( | |||
|
278 | {std::make_shared<Move>(0, var0NewRange), {{0, var0NewRange}, {1, var0NewRange}}}); | |||
|
279 | }; | |||
|
280 | moveVar0(SqpRange{dateTime(2017, 1, 1, 12, 0, 0), dateTime(2017, 1, 1, 13, 0, 0)}); | |||
|
281 | moveVar0(SqpRange{dateTime(2017, 1, 1, 14, 0, 0), dateTime(2017, 1, 1, 15, 0, 0)}); | |||
|
282 | moveVar0(SqpRange{dateTime(2017, 1, 1, 8, 0, 0), dateTime(2017, 1, 1, 9, 0, 0)}); | |||
|
283 | // moveVar0(SqpRange{dateTime(2017, 1, 1, 7, 30, 0), dateTime(2017, 1, 1, 9, 30, 0)}); | |||
|
284 | moveVar0(SqpRange{dateTime(2017, 1, 1, 2, 0, 0), dateTime(2017, 1, 1, 4, 0, 0)}); | |||
|
285 | moveVar0(SqpRange{dateTime(2017, 1, 1, 6, 0, 0), dateTime(2017, 1, 1, 8, 0, 0)}); | |||
|
286 | ||||
|
287 | moveVar0(SqpRange{dateTime(2017, 1, 10, 6, 0, 0), dateTime(2017, 1, 15, 8, 0, 0)}); | |||
|
288 | moveVar0(SqpRange{dateTime(2017, 1, 17, 6, 0, 0), dateTime(2017, 1, 25, 8, 0, 0)}); | |||
|
289 | moveVar0(SqpRange{dateTime(2017, 1, 2, 6, 0, 0), dateTime(2017, 1, 8, 8, 0, 0)}); | |||
|
290 | ||||
|
291 | moveVar0(SqpRange{dateTime(2017, 4, 10, 6, 0, 0), dateTime(2017, 6, 15, 8, 0, 0)}); | |||
|
292 | moveVar0(SqpRange{dateTime(2017, 1, 17, 6, 0, 0), dateTime(2017, 2, 25, 8, 0, 0)}); | |||
|
293 | moveVar0(SqpRange{dateTime(2017, 7, 2, 6, 0, 0), dateTime(2017, 10, 8, 8, 0, 0)}); | |||
|
294 | moveVar0(SqpRange{dateTime(2017, 4, 10, 6, 0, 0), dateTime(2017, 6, 15, 8, 0, 0)}); | |||
|
295 | moveVar0(SqpRange{dateTime(2017, 1, 17, 6, 0, 0), dateTime(2017, 2, 25, 8, 0, 0)}); | |||
|
296 | moveVar0(SqpRange{dateTime(2017, 7, 2, 6, 0, 0), dateTime(2017, 10, 8, 8, 0, 0)}); | |||
|
297 | moveVar0(SqpRange{dateTime(2017, 4, 10, 6, 0, 0), dateTime(2017, 6, 15, 8, 0, 0)}); | |||
|
298 | moveVar0(SqpRange{dateTime(2017, 1, 17, 6, 0, 0), dateTime(2017, 2, 25, 8, 0, 0)}); | |||
|
299 | moveVar0(SqpRange{dateTime(2017, 7, 2, 6, 0, 0), dateTime(2017, 10, 8, 8, 0, 0)}); | |||
|
300 | moveVar0(SqpRange{dateTime(2017, 4, 10, 6, 0, 0), dateTime(2017, 6, 15, 8, 0, 0)}); | |||
|
301 | moveVar0(SqpRange{dateTime(2017, 1, 17, 6, 0, 0), dateTime(2017, 2, 25, 8, 0, 0)}); | |||
|
302 | moveVar0(SqpRange{dateTime(2017, 7, 2, 6, 0, 0), dateTime(2017, 10, 8, 8, 0, 0)}); | |||
|
303 | ||||
|
304 | ||||
|
305 | QTest::newRow("sync2") << syncId << initialRange << iterations << 4000; | |||
|
306 | // QTest::newRow("sync3") << syncId << initialRange << iterations << 5000; | |||
|
307 | } | |||
|
308 | } | |||
|
309 | ||||
|
310 | void TestVariableSync::testSync_data() | |||
|
311 | { | |||
|
312 | // ////////////// // | |||
|
313 | // Test structure // | |||
|
314 | // ////////////// // | |||
|
315 | ||||
|
316 | QTest::addColumn<QUuid>("syncId"); | |||
|
317 | QTest::addColumn<SqpRange>("initialRange"); | |||
|
318 | QTest::addColumn<Iterations>("iterations"); | |||
|
319 | QTest::addColumn<int>("operationDelay"); | |||
|
320 | ||||
|
321 | // ////////// // | |||
|
322 | // Test cases // | |||
|
323 | // ////////// // | |||
|
324 | ||||
|
325 | testSyncCase1(); | |||
|
326 | testSyncCase2(); | |||
258 | } |
|
327 | } | |
259 |
|
328 | |||
260 | void TestVariableSync::testSync() |
|
329 | void TestVariableSync::testSync() | |
@@ -271,15 +340,8 void TestVariableSync::testSync() | |||||
271 | // Synchronization group used |
|
340 | // Synchronization group used | |
272 | variableController.onAddSynchronizationGroupId(syncId); |
|
341 | variableController.onAddSynchronizationGroupId(syncId); | |
273 |
|
342 | |||
274 | // For each iteration: |
|
343 | auto validateRanges = [&variableController](const auto &expectedRanges) { | |
275 | // - execute operation |
|
344 | for (const auto &expectedRangeEntry : expectedRanges) { | |
276 | // - compare the variables' state to the expected states |
|
|||
277 | QFETCH(Iterations, iterations); |
|
|||
278 | for (const auto &iteration : iterations) { |
|
|||
279 | iteration.m_Operation->exec(variableController); |
|
|||
280 | QTest::qWait(OPERATION_DELAY); |
|
|||
281 |
|
||||
282 | for (const auto &expectedRangeEntry : iteration.m_ExpectedRanges) { |
|
|||
283 | auto variableIndex = expectedRangeEntry.first; |
|
345 | auto variableIndex = expectedRangeEntry.first; | |
284 | auto expectedRange = expectedRangeEntry.second; |
|
346 | auto expectedRange = expectedRangeEntry.second; | |
285 |
|
347 | |||
@@ -297,12 +359,31 void TestVariableSync::testSync() | |||||
297 |
|
359 | |||
298 | auto it = dataSeries->xAxisRange(range.m_TStart, range.m_TEnd); |
|
360 | auto it = dataSeries->xAxisRange(range.m_TStart, range.m_TEnd); | |
299 | auto expectedValues = values(range); |
|
361 | auto expectedValues = values(range); | |
|
362 | qInfo() << std::distance(it.first, it.second) << expectedValues.size(); | |||
300 | QVERIFY(std::equal(it.first, it.second, expectedValues.cbegin(), expectedValues.cend(), |
|
363 | QVERIFY(std::equal(it.first, it.second, expectedValues.cbegin(), expectedValues.cend(), | |
301 | [](const auto &dataSeriesIt, const auto &expectedValue) { |
|
364 | [](const auto &dataSeriesIt, const auto &expectedValue) { | |
302 | return dataSeriesIt.value() == expectedValue; |
|
365 | return dataSeriesIt.value() == expectedValue; | |
303 | })); |
|
366 | })); | |
304 | } |
|
367 | } | |
|
368 | }; | |||
|
369 | ||||
|
370 | // For each iteration: | |||
|
371 | // - execute operation | |||
|
372 | // - compare the variables' state to the expected states | |||
|
373 | QFETCH(Iterations, iterations); | |||
|
374 | QFETCH(int, operationDelay); | |||
|
375 | for (const auto &iteration : iterations) { | |||
|
376 | iteration.m_Operation->exec(variableController); | |||
|
377 | QTest::qWait(operationDelay); | |||
|
378 | ||||
|
379 | validateRanges(iteration.m_ExpectedRanges); | |||
|
380 | } | |||
|
381 | ||||
|
382 | for (const auto &iteration : iterations) { | |||
|
383 | iteration.m_Operation->exec(variableController); | |||
305 | } |
|
384 | } | |
|
385 | QTest::qWait(operationDelay); | |||
|
386 | validateRanges(iterations.back().m_ExpectedRanges); | |||
306 | } |
|
387 | } | |
307 |
|
388 | |||
308 | QTEST_MAIN(TestVariableSync) |
|
389 | QTEST_MAIN(TestVariableSync) |
@@ -153,8 +153,9 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<V | |||||
153 | } |
|
153 | } | |
154 | case AcquisitionZoomType::PanRight: { |
|
154 | case AcquisitionZoomType::PanRight: { | |
155 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: PanRight"); |
|
155 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: PanRight"); | |
|
156 | auto deltaLeft = graphRange.m_TStart - oldGraphRange.m_TStart; | |||
156 | auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd; |
|
157 | auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd; | |
157 |
graphChildRange.m_TStart += delta |
|
158 | graphChildRange.m_TStart += deltaLeft; | |
158 | graphChildRange.m_TEnd += deltaRight; |
|
159 | graphChildRange.m_TEnd += deltaRight; | |
159 | qCDebug(LOG_VisualizationZoneWidget()) |
|
160 | qCDebug(LOG_VisualizationZoneWidget()) | |
160 | << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart; |
|
161 | << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart; | |
@@ -163,8 +164,9 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<V | |||||
163 | case AcquisitionZoomType::PanLeft: { |
|
164 | case AcquisitionZoomType::PanLeft: { | |
164 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: PanLeft"); |
|
165 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: PanLeft"); | |
165 | auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart; |
|
166 | auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart; | |
|
167 | auto deltaRight = oldGraphRange.m_TEnd - graphRange.m_TEnd; | |||
166 | graphChildRange.m_TStart -= deltaLeft; |
|
168 | graphChildRange.m_TStart -= deltaLeft; | |
167 |
graphChildRange.m_TEnd -= delta |
|
169 | graphChildRange.m_TEnd -= deltaRight; | |
168 | break; |
|
170 | break; | |
169 | } |
|
171 | } | |
170 | case AcquisitionZoomType::Unknown: { |
|
172 | case AcquisitionZoomType::Unknown: { |
General Comments 3
Status change > Approved
You need to be logged in to leave comments.
Login now