This diff has been collapsed as it changes many lines, (775 lines changed) Show them Hide them | |||||
@@ -0,0 +1,775 | |||||
|
1 | #include <Variable/Variable.h> | |||
|
2 | #include <Variable/VariableAcquisitionWorker.h> | |||
|
3 | #include <Variable/VariableCacheStrategy.h> | |||
|
4 | #include <Variable/VariableController.h> | |||
|
5 | #include <Variable/VariableModel.h> | |||
|
6 | #include <Variable/VariableSynchronizationGroup.h> | |||
|
7 | ||||
|
8 | #include <Data/DataProviderParameters.h> | |||
|
9 | #include <Data/IDataProvider.h> | |||
|
10 | #include <Data/IDataSeries.h> | |||
|
11 | #include <Data/VariableRequest.h> | |||
|
12 | #include <Time/TimeController.h> | |||
|
13 | ||||
|
14 | #include <QMutex> | |||
|
15 | #include <QThread> | |||
|
16 | #include <QUuid> | |||
|
17 | #include <QtCore/QItemSelectionModel> | |||
|
18 | ||||
|
19 | #include <deque> | |||
|
20 | #include <set> | |||
|
21 | #include <unordered_map> | |||
|
22 | ||||
|
23 | Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController") | |||
|
24 | ||||
|
25 | namespace { | |||
|
26 | ||||
|
27 | SqpRange computeSynchroRangeRequested(const SqpRange &varRange, const SqpRange &graphRange, | |||
|
28 | const SqpRange &oldGraphRange) | |||
|
29 | { | |||
|
30 | auto zoomType = VariableController::getZoomType(graphRange, oldGraphRange); | |||
|
31 | ||||
|
32 | auto varRangeRequested = varRange; | |||
|
33 | switch (zoomType) { | |||
|
34 | case AcquisitionZoomType::ZoomIn: { | |||
|
35 | auto deltaLeft = graphRange.m_TStart - oldGraphRange.m_TStart; | |||
|
36 | auto deltaRight = oldGraphRange.m_TEnd - graphRange.m_TEnd; | |||
|
37 | varRangeRequested.m_TStart += deltaLeft; | |||
|
38 | varRangeRequested.m_TEnd -= deltaRight; | |||
|
39 | break; | |||
|
40 | } | |||
|
41 | ||||
|
42 | case AcquisitionZoomType::ZoomOut: { | |||
|
43 | auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart; | |||
|
44 | auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd; | |||
|
45 | varRangeRequested.m_TStart -= deltaLeft; | |||
|
46 | varRangeRequested.m_TEnd += deltaRight; | |||
|
47 | break; | |||
|
48 | } | |||
|
49 | case AcquisitionZoomType::PanRight: { | |||
|
50 | auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd; | |||
|
51 | varRangeRequested.m_TStart += deltaRight; | |||
|
52 | varRangeRequested.m_TEnd += deltaRight; | |||
|
53 | break; | |||
|
54 | } | |||
|
55 | case AcquisitionZoomType::PanLeft: { | |||
|
56 | auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart; | |||
|
57 | varRangeRequested.m_TStart -= deltaLeft; | |||
|
58 | varRangeRequested.m_TEnd -= deltaLeft; | |||
|
59 | break; | |||
|
60 | } | |||
|
61 | case AcquisitionZoomType::Unknown: { | |||
|
62 | qCCritical(LOG_VariableController()) | |||
|
63 | << VariableController::tr("Impossible to synchronize: zoom type unknown"); | |||
|
64 | break; | |||
|
65 | } | |||
|
66 | default: | |||
|
67 | qCCritical(LOG_VariableController()) << VariableController::tr( | |||
|
68 | "Impossible to synchronize: zoom type not take into account"); | |||
|
69 | // No action | |||
|
70 | break; | |||
|
71 | } | |||
|
72 | ||||
|
73 | return varRangeRequested; | |||
|
74 | } | |||
|
75 | } | |||
|
76 | ||||
|
77 | struct VariableController::VariableControllerPrivate { | |||
|
78 | explicit VariableControllerPrivate(VariableController *parent) | |||
|
79 | : m_WorkingMutex{}, | |||
|
80 | m_VariableModel{new VariableModel{parent}}, | |||
|
81 | m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}}, | |||
|
82 | m_VariableCacheStrategy{std::make_unique<VariableCacheStrategy>()}, | |||
|
83 | m_VariableAcquisitionWorker{std::make_unique<VariableAcquisitionWorker>()}, | |||
|
84 | q{parent} | |||
|
85 | { | |||
|
86 | ||||
|
87 | m_VariableAcquisitionWorker->moveToThread(&m_VariableAcquisitionWorkerThread); | |||
|
88 | m_VariableAcquisitionWorkerThread.setObjectName("VariableAcquisitionWorkerThread"); | |||
|
89 | } | |||
|
90 | ||||
|
91 | ||||
|
92 | virtual ~VariableControllerPrivate() | |||
|
93 | { | |||
|
94 | qCDebug(LOG_VariableController()) << tr("VariableControllerPrivate destruction"); | |||
|
95 | m_VariableAcquisitionWorkerThread.quit(); | |||
|
96 | m_VariableAcquisitionWorkerThread.wait(); | |||
|
97 | } | |||
|
98 | ||||
|
99 | ||||
|
100 | void processRequest(std::shared_ptr<Variable> var, const SqpRange &rangeRequested, | |||
|
101 | QUuid varRequestId); | |||
|
102 | ||||
|
103 | QVector<SqpRange> provideNotInCacheDateTimeList(std::shared_ptr<Variable> variable, | |||
|
104 | const SqpRange &dateTime); | |||
|
105 | ||||
|
106 | std::shared_ptr<Variable> findVariable(QUuid vIdentifier); | |||
|
107 | std::shared_ptr<IDataSeries> | |||
|
108 | retrieveDataSeries(const QVector<AcquisitionDataPacket> acqDataPacketVector); | |||
|
109 | ||||
|
110 | void registerProvider(std::shared_ptr<IDataProvider> provider); | |||
|
111 | ||||
|
112 | void storeVariableRequest(QUuid varId, QUuid varRequestId, const VariableRequest &varRequest); | |||
|
113 | QUuid acceptVariableRequest(QUuid varId, std::shared_ptr<IDataSeries> dataSeries); | |||
|
114 | void updateVariableRequest(QUuid varRequestId); | |||
|
115 | void cancelVariableRequest(QUuid varRequestId); | |||
|
116 | ||||
|
117 | QMutex m_WorkingMutex; | |||
|
118 | /// Variable model. The VariableController has the ownership | |||
|
119 | VariableModel *m_VariableModel; | |||
|
120 | QItemSelectionModel *m_VariableSelectionModel; | |||
|
121 | ||||
|
122 | ||||
|
123 | TimeController *m_TimeController{nullptr}; | |||
|
124 | std::unique_ptr<VariableCacheStrategy> m_VariableCacheStrategy; | |||
|
125 | std::unique_ptr<VariableAcquisitionWorker> m_VariableAcquisitionWorker; | |||
|
126 | QThread m_VariableAcquisitionWorkerThread; | |||
|
127 | ||||
|
128 | std::unordered_map<std::shared_ptr<Variable>, std::shared_ptr<IDataProvider> > | |||
|
129 | m_VariableToProviderMap; | |||
|
130 | std::unordered_map<std::shared_ptr<Variable>, QUuid> m_VariableToIdentifierMap; | |||
|
131 | std::map<QUuid, std::shared_ptr<VariableSynchronizationGroup> > | |||
|
132 | m_GroupIdToVariableSynchronizationGroupMap; | |||
|
133 | std::map<QUuid, QUuid> m_VariableIdGroupIdMap; | |||
|
134 | std::set<std::shared_ptr<IDataProvider> > m_ProviderSet; | |||
|
135 | ||||
|
136 | std::map<QUuid, std::map<QUuid, VariableRequest> > m_VarRequestIdToVarIdVarRequestMap; | |||
|
137 | ||||
|
138 | std::map<QUuid, std::deque<QUuid> > m_VarIdToVarRequestIdQueueMap; | |||
|
139 | ||||
|
140 | ||||
|
141 | VariableController *q; | |||
|
142 | }; | |||
|
143 | ||||
|
144 | ||||
|
145 | VariableController::VariableController(QObject *parent) | |||
|
146 | : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)} | |||
|
147 | { | |||
|
148 | qCDebug(LOG_VariableController()) << tr("VariableController construction") | |||
|
149 | << QThread::currentThread(); | |||
|
150 | ||||
|
151 | connect(impl->m_VariableModel, &VariableModel::abortProgessRequested, this, | |||
|
152 | &VariableController::onAbortProgressRequested); | |||
|
153 | ||||
|
154 | connect(impl->m_VariableAcquisitionWorker.get(), &VariableAcquisitionWorker::dataProvided, this, | |||
|
155 | &VariableController::onDataProvided); | |||
|
156 | connect(impl->m_VariableAcquisitionWorker.get(), | |||
|
157 | &VariableAcquisitionWorker::variableRequestInProgress, this, | |||
|
158 | &VariableController::onVariableRetrieveDataInProgress); | |||
|
159 | ||||
|
160 | connect(&impl->m_VariableAcquisitionWorkerThread, &QThread::started, | |||
|
161 | impl->m_VariableAcquisitionWorker.get(), &VariableAcquisitionWorker::initialize); | |||
|
162 | connect(&impl->m_VariableAcquisitionWorkerThread, &QThread::finished, | |||
|
163 | impl->m_VariableAcquisitionWorker.get(), &VariableAcquisitionWorker::finalize); | |||
|
164 | ||||
|
165 | ||||
|
166 | impl->m_VariableAcquisitionWorkerThread.start(); | |||
|
167 | } | |||
|
168 | ||||
|
169 | VariableController::~VariableController() | |||
|
170 | { | |||
|
171 | qCDebug(LOG_VariableController()) << tr("VariableController destruction") | |||
|
172 | << QThread::currentThread(); | |||
|
173 | this->waitForFinish(); | |||
|
174 | } | |||
|
175 | ||||
|
176 | VariableModel *VariableController::variableModel() noexcept | |||
|
177 | { | |||
|
178 | return impl->m_VariableModel; | |||
|
179 | } | |||
|
180 | ||||
|
181 | QItemSelectionModel *VariableController::variableSelectionModel() noexcept | |||
|
182 | { | |||
|
183 | return impl->m_VariableSelectionModel; | |||
|
184 | } | |||
|
185 | ||||
|
186 | void VariableController::setTimeController(TimeController *timeController) noexcept | |||
|
187 | { | |||
|
188 | impl->m_TimeController = timeController; | |||
|
189 | } | |||
|
190 | ||||
|
191 | std::shared_ptr<Variable> | |||
|
192 | VariableController::cloneVariable(std::shared_ptr<Variable> variable) noexcept | |||
|
193 | { | |||
|
194 | if (impl->m_VariableModel->containsVariable(variable)) { | |||
|
195 | // Clones variable | |||
|
196 | auto duplicate = variable->clone(); | |||
|
197 | ||||
|
198 | // Adds clone to model | |||
|
199 | impl->m_VariableModel->addVariable(duplicate); | |||
|
200 | ||||
|
201 | // Generates clone identifier | |||
|
202 | impl->m_VariableToIdentifierMap[duplicate] = QUuid::createUuid(); | |||
|
203 | ||||
|
204 | // Registers provider | |||
|
205 | auto variableProvider = impl->m_VariableToProviderMap.at(variable); | |||
|
206 | auto duplicateProvider = variableProvider != nullptr ? variableProvider->clone() : nullptr; | |||
|
207 | ||||
|
208 | impl->m_VariableToProviderMap[duplicate] = duplicateProvider; | |||
|
209 | if (duplicateProvider) { | |||
|
210 | impl->registerProvider(duplicateProvider); | |||
|
211 | } | |||
|
212 | ||||
|
213 | return duplicate; | |||
|
214 | } | |||
|
215 | else { | |||
|
216 | qCCritical(LOG_VariableController()) | |||
|
217 | << tr("Can't create duplicate of variable %1: variable not registered in the model") | |||
|
218 | .arg(variable->name()); | |||
|
219 | return nullptr; | |||
|
220 | } | |||
|
221 | } | |||
|
222 | ||||
|
223 | void VariableController::deleteVariable(std::shared_ptr<Variable> variable) noexcept | |||
|
224 | { | |||
|
225 | if (!variable) { | |||
|
226 | qCCritical(LOG_VariableController()) << "Can't delete variable: variable is null"; | |||
|
227 | return; | |||
|
228 | } | |||
|
229 | ||||
|
230 | // Spreads in SciQlop that the variable will be deleted, so that potential receivers can | |||
|
231 | // make some treatments before the deletion | |||
|
232 | emit variableAboutToBeDeleted(variable); | |||
|
233 | ||||
|
234 | // Deletes identifier | |||
|
235 | impl->m_VariableToIdentifierMap.erase(variable); | |||
|
236 | ||||
|
237 | // Deletes provider | |||
|
238 | auto nbProvidersDeleted = impl->m_VariableToProviderMap.erase(variable); | |||
|
239 | qCDebug(LOG_VariableController()) | |||
|
240 | << tr("Number of providers deleted for variable %1: %2") | |||
|
241 | .arg(variable->name(), QString::number(nbProvidersDeleted)); | |||
|
242 | ||||
|
243 | ||||
|
244 | // Deletes from model | |||
|
245 | impl->m_VariableModel->deleteVariable(variable); | |||
|
246 | } | |||
|
247 | ||||
|
248 | void VariableController::deleteVariables( | |||
|
249 | const QVector<std::shared_ptr<Variable> > &variables) noexcept | |||
|
250 | { | |||
|
251 | for (auto variable : qAsConst(variables)) { | |||
|
252 | deleteVariable(variable); | |||
|
253 | } | |||
|
254 | } | |||
|
255 | ||||
|
256 | void VariableController::abortProgress(std::shared_ptr<Variable> variable) | |||
|
257 | { | |||
|
258 | } | |||
|
259 | ||||
|
260 | std::shared_ptr<Variable> | |||
|
261 | VariableController::createVariable(const QString &name, const QVariantHash &metadata, | |||
|
262 | std::shared_ptr<IDataProvider> provider) noexcept | |||
|
263 | { | |||
|
264 | if (!impl->m_TimeController) { | |||
|
265 | qCCritical(LOG_VariableController()) | |||
|
266 | << tr("Impossible to create variable: The time controller is null"); | |||
|
267 | return nullptr; | |||
|
268 | } | |||
|
269 | ||||
|
270 | auto range = impl->m_TimeController->dateTime(); | |||
|
271 | ||||
|
272 | if (auto newVariable = impl->m_VariableModel->createVariable(name, range, metadata)) { | |||
|
273 | auto identifier = QUuid::createUuid(); | |||
|
274 | ||||
|
275 | // store the provider | |||
|
276 | impl->registerProvider(provider); | |||
|
277 | ||||
|
278 | // Associate the provider | |||
|
279 | impl->m_VariableToProviderMap[newVariable] = provider; | |||
|
280 | impl->m_VariableToIdentifierMap[newVariable] = identifier; | |||
|
281 | ||||
|
282 | ||||
|
283 | auto varRequestId = QUuid::createUuid(); | |||
|
284 | qCInfo(LOG_VariableController()) << "processRequest for" << name << varRequestId; | |||
|
285 | impl->processRequest(newVariable, range, varRequestId); | |||
|
286 | impl->updateVariableRequest(varRequestId); | |||
|
287 | ||||
|
288 | return newVariable; | |||
|
289 | } | |||
|
290 | } | |||
|
291 | ||||
|
292 | void VariableController::onDateTimeOnSelection(const SqpRange &dateTime) | |||
|
293 | { | |||
|
294 | // TODO check synchronisation and Rescale | |||
|
295 | qCDebug(LOG_VariableController()) << "VariableController::onDateTimeOnSelection" | |||
|
296 | << QThread::currentThread()->objectName(); | |||
|
297 | auto selectedRows = impl->m_VariableSelectionModel->selectedRows(); | |||
|
298 | auto varRequestId = QUuid::createUuid(); | |||
|
299 | ||||
|
300 | for (const auto &selectedRow : qAsConst(selectedRows)) { | |||
|
301 | if (auto selectedVariable = impl->m_VariableModel->variable(selectedRow.row())) { | |||
|
302 | selectedVariable->setRange(dateTime); | |||
|
303 | impl->processRequest(selectedVariable, dateTime, varRequestId); | |||
|
304 | ||||
|
305 | // notify that rescale operation has to be done | |||
|
306 | emit rangeChanged(selectedVariable, dateTime); | |||
|
307 | } | |||
|
308 | } | |||
|
309 | impl->updateVariableRequest(varRequestId); | |||
|
310 | } | |||
|
311 | ||||
|
312 | void VariableController::onDataProvided(QUuid vIdentifier, const SqpRange &rangeRequested, | |||
|
313 | const SqpRange &cacheRangeRequested, | |||
|
314 | QVector<AcquisitionDataPacket> dataAcquired) | |||
|
315 | { | |||
|
316 | auto retrievedDataSeries = impl->retrieveDataSeries(dataAcquired); | |||
|
317 | auto varRequestId = impl->acceptVariableRequest(vIdentifier, retrievedDataSeries); | |||
|
318 | if (!varRequestId.isNull()) { | |||
|
319 | impl->updateVariableRequest(varRequestId); | |||
|
320 | } | |||
|
321 | } | |||
|
322 | ||||
|
323 | void VariableController::onVariableRetrieveDataInProgress(QUuid identifier, double progress) | |||
|
324 | { | |||
|
325 | if (auto var = impl->findVariable(identifier)) { | |||
|
326 | impl->m_VariableModel->setDataProgress(var, progress); | |||
|
327 | } | |||
|
328 | else { | |||
|
329 | qCCritical(LOG_VariableController()) | |||
|
330 | << tr("Impossible to notify progression of a null variable"); | |||
|
331 | } | |||
|
332 | } | |||
|
333 | ||||
|
334 | void VariableController::onAbortProgressRequested(std::shared_ptr<Variable> variable) | |||
|
335 | { | |||
|
336 | qCDebug(LOG_VariableController()) << "TORM: VariableController::onAbortProgressRequested" | |||
|
337 | << QThread::currentThread()->objectName(); | |||
|
338 | ||||
|
339 | auto it = impl->m_VariableToIdentifierMap.find(variable); | |||
|
340 | if (it != impl->m_VariableToIdentifierMap.cend()) { | |||
|
341 | impl->m_VariableToProviderMap.at(variable)->requestDataAborting(it->second); | |||
|
342 | } | |||
|
343 | else { | |||
|
344 | qCWarning(LOG_VariableController()) | |||
|
345 | << tr("Aborting progression of inexistant variable detected !!!") | |||
|
346 | << QThread::currentThread()->objectName(); | |||
|
347 | } | |||
|
348 | } | |||
|
349 | ||||
|
350 | void VariableController::onAddSynchronizationGroupId(QUuid synchronizationGroupId) | |||
|
351 | { | |||
|
352 | qCDebug(LOG_VariableController()) << "TORM: VariableController::onAddSynchronizationGroupId" | |||
|
353 | << QThread::currentThread()->objectName() | |||
|
354 | << synchronizationGroupId; | |||
|
355 | auto vSynchroGroup = std::make_shared<VariableSynchronizationGroup>(); | |||
|
356 | impl->m_GroupIdToVariableSynchronizationGroupMap.insert( | |||
|
357 | std::make_pair(synchronizationGroupId, vSynchroGroup)); | |||
|
358 | } | |||
|
359 | ||||
|
360 | void VariableController::onRemoveSynchronizationGroupId(QUuid synchronizationGroupId) | |||
|
361 | { | |||
|
362 | impl->m_GroupIdToVariableSynchronizationGroupMap.erase(synchronizationGroupId); | |||
|
363 | } | |||
|
364 | ||||
|
365 | void VariableController::onAddSynchronized(std::shared_ptr<Variable> variable, | |||
|
366 | QUuid synchronizationGroupId) | |||
|
367 | ||||
|
368 | { | |||
|
369 | qCDebug(LOG_VariableController()) << "TORM: VariableController::onAddSynchronized" | |||
|
370 | << synchronizationGroupId; | |||
|
371 | auto varToVarIdIt = impl->m_VariableToIdentifierMap.find(variable); | |||
|
372 | if (varToVarIdIt != impl->m_VariableToIdentifierMap.cend()) { | |||
|
373 | auto groupIdToVSGIt | |||
|
374 | = impl->m_GroupIdToVariableSynchronizationGroupMap.find(synchronizationGroupId); | |||
|
375 | if (groupIdToVSGIt != impl->m_GroupIdToVariableSynchronizationGroupMap.cend()) { | |||
|
376 | impl->m_VariableIdGroupIdMap.insert( | |||
|
377 | std::make_pair(varToVarIdIt->second, synchronizationGroupId)); | |||
|
378 | groupIdToVSGIt->second->addVariableId(varToVarIdIt->second); | |||
|
379 | } | |||
|
380 | else { | |||
|
381 | qCCritical(LOG_VariableController()) | |||
|
382 | << tr("Impossible to synchronize a variable with an unknown sycnhronization group") | |||
|
383 | << variable->name(); | |||
|
384 | } | |||
|
385 | } | |||
|
386 | else { | |||
|
387 | qCCritical(LOG_VariableController()) | |||
|
388 | << tr("Impossible to synchronize a variable with no identifier") << variable->name(); | |||
|
389 | } | |||
|
390 | } | |||
|
391 | ||||
|
392 | ||||
|
393 | void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable> > variables, | |||
|
394 | const SqpRange &range, const SqpRange &oldRange, | |||
|
395 | bool synchronise) | |||
|
396 | { | |||
|
397 | // NOTE: oldRange isn't really necessary since oldRange == variable->range(). | |||
|
398 | ||||
|
399 | // we want to load data of the variable for the dateTime. | |||
|
400 | // First we check if the cache contains some of them. | |||
|
401 | // For the other, we ask the provider to give them. | |||
|
402 | ||||
|
403 | auto varRequestId = QUuid::createUuid(); | |||
|
404 | qCInfo(LOG_VariableController()) << "VariableController::onRequestDataLoading" | |||
|
405 | << QThread::currentThread()->objectName() << varRequestId; | |||
|
406 | ||||
|
407 | for (const auto &var : variables) { | |||
|
408 | qCDebug(LOG_VariableController()) << "processRequest for" << var->name() << varRequestId; | |||
|
409 | impl->processRequest(var, range, varRequestId); | |||
|
410 | } | |||
|
411 | ||||
|
412 | if (synchronise) { | |||
|
413 | // Get the group ids | |||
|
414 | qCDebug(LOG_VariableController()) | |||
|
415 | << "TORM VariableController::onRequestDataLoading for synchro var ENABLE"; | |||
|
416 | auto groupIds = std::set<QUuid>{}; | |||
|
417 | auto groupIdToOldRangeMap = std::map<QUuid, SqpRange>{}; | |||
|
418 | for (const auto &var : variables) { | |||
|
419 | auto varToVarIdIt = impl->m_VariableToIdentifierMap.find(var); | |||
|
420 | if (varToVarIdIt != impl->m_VariableToIdentifierMap.cend()) { | |||
|
421 | auto vId = varToVarIdIt->second; | |||
|
422 | auto varIdToGroupIdIt = impl->m_VariableIdGroupIdMap.find(vId); | |||
|
423 | if (varIdToGroupIdIt != impl->m_VariableIdGroupIdMap.cend()) { | |||
|
424 | auto gId = varIdToGroupIdIt->second; | |||
|
425 | groupIdToOldRangeMap.insert(std::make_pair(gId, var->range())); | |||
|
426 | if (groupIds.find(gId) == groupIds.cend()) { | |||
|
427 | qCDebug(LOG_VariableController()) << "Synchro detect group " << gId; | |||
|
428 | groupIds.insert(gId); | |||
|
429 | } | |||
|
430 | } | |||
|
431 | } | |||
|
432 | } | |||
|
433 | ||||
|
434 | // We assume here all group ids exist | |||
|
435 | for (const auto &gId : groupIds) { | |||
|
436 | auto vSynchronizationGroup = impl->m_GroupIdToVariableSynchronizationGroupMap.at(gId); | |||
|
437 | auto vSyncIds = vSynchronizationGroup->getIds(); | |||
|
438 | qCDebug(LOG_VariableController()) << "Var in synchro group "; | |||
|
439 | for (auto vId : vSyncIds) { | |||
|
440 | auto var = impl->findVariable(vId); | |||
|
441 | ||||
|
442 | // Don't process already processed var | |||
|
443 | if (!variables.contains(var)) { | |||
|
444 | if (var != nullptr) { | |||
|
445 | qCDebug(LOG_VariableController()) << "processRequest synchro for" | |||
|
446 | << var->name(); | |||
|
447 | auto vSyncRangeRequested = computeSynchroRangeRequested( | |||
|
448 | var->range(), range, groupIdToOldRangeMap.at(gId)); | |||
|
449 | qCDebug(LOG_VariableController()) << "synchro RR" << vSyncRangeRequested; | |||
|
450 | impl->processRequest(var, vSyncRangeRequested, varRequestId); | |||
|
451 | } | |||
|
452 | else { | |||
|
453 | qCCritical(LOG_VariableController()) | |||
|
454 | ||||
|
455 | << tr("Impossible to synchronize a null variable"); | |||
|
456 | } | |||
|
457 | } | |||
|
458 | } | |||
|
459 | } | |||
|
460 | } | |||
|
461 | ||||
|
462 | impl->updateVariableRequest(varRequestId); | |||
|
463 | } | |||
|
464 | ||||
|
465 | ||||
|
466 | void VariableController::initialize() | |||
|
467 | { | |||
|
468 | qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread(); | |||
|
469 | impl->m_WorkingMutex.lock(); | |||
|
470 | qCDebug(LOG_VariableController()) << tr("VariableController init END"); | |||
|
471 | } | |||
|
472 | ||||
|
473 | void VariableController::finalize() | |||
|
474 | { | |||
|
475 | impl->m_WorkingMutex.unlock(); | |||
|
476 | } | |||
|
477 | ||||
|
478 | void VariableController::waitForFinish() | |||
|
479 | { | |||
|
480 | QMutexLocker locker{&impl->m_WorkingMutex}; | |||
|
481 | } | |||
|
482 | ||||
|
483 | AcquisitionZoomType VariableController::getZoomType(const SqpRange &range, const SqpRange &oldRange) | |||
|
484 | { | |||
|
485 | // t1.m_TStart <= t2.m_TStart && t2.m_TEnd <= t1.m_TEnd | |||
|
486 | auto zoomType = AcquisitionZoomType::Unknown; | |||
|
487 | if (range.m_TStart <= oldRange.m_TStart && oldRange.m_TEnd <= range.m_TEnd) { | |||
|
488 | zoomType = AcquisitionZoomType::ZoomOut; | |||
|
489 | } | |||
|
490 | else if (range.m_TStart > oldRange.m_TStart && range.m_TEnd > oldRange.m_TEnd) { | |||
|
491 | zoomType = AcquisitionZoomType::PanRight; | |||
|
492 | } | |||
|
493 | else if (range.m_TStart < oldRange.m_TStart && range.m_TEnd < oldRange.m_TEnd) { | |||
|
494 | zoomType = AcquisitionZoomType::PanLeft; | |||
|
495 | } | |||
|
496 | else if (range.m_TStart > oldRange.m_TStart && oldRange.m_TEnd > range.m_TEnd) { | |||
|
497 | zoomType = AcquisitionZoomType::ZoomIn; | |||
|
498 | } | |||
|
499 | else { | |||
|
500 | qCCritical(LOG_VariableController()) << "getZoomType: Unknown type detected"; | |||
|
501 | } | |||
|
502 | return zoomType; | |||
|
503 | } | |||
|
504 | ||||
|
505 | void VariableController::VariableControllerPrivate::processRequest(std::shared_ptr<Variable> var, | |||
|
506 | const SqpRange &rangeRequested, | |||
|
507 | QUuid varRequestId) | |||
|
508 | { | |||
|
509 | ||||
|
510 | // TODO: protect at | |||
|
511 | auto varRequest = VariableRequest{}; | |||
|
512 | auto varId = m_VariableToIdentifierMap.at(var); | |||
|
513 | ||||
|
514 | auto varStrategyRangesRequested | |||
|
515 | = m_VariableCacheStrategy->computeStrategyRanges(var->range(), rangeRequested); | |||
|
516 | auto notInCacheRangeList = var->provideNotInCacheRangeList(varStrategyRangesRequested.second); | |||
|
517 | auto inCacheRangeList = var->provideInCacheRangeList(varStrategyRangesRequested.second); | |||
|
518 | ||||
|
519 | if (!notInCacheRangeList.empty()) { | |||
|
520 | varRequest.m_RangeRequested = varStrategyRangesRequested.first; | |||
|
521 | varRequest.m_CacheRangeRequested = varStrategyRangesRequested.second; | |||
|
522 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM processRequest RR ") << rangeRequested; | |||
|
523 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM processRequest R ") | |||
|
524 | << varStrategyRangesRequested.first; | |||
|
525 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM processRequest CR ") | |||
|
526 | << varStrategyRangesRequested.second; | |||
|
527 | // store VarRequest | |||
|
528 | storeVariableRequest(varId, varRequestId, varRequest); | |||
|
529 | ||||
|
530 | auto varProvider = m_VariableToProviderMap.at(var); | |||
|
531 | if (varProvider != nullptr) { | |||
|
532 | auto varRequestIdCanceled = m_VariableAcquisitionWorker->pushVariableRequest( | |||
|
533 | varRequestId, varId, varStrategyRangesRequested.first, | |||
|
534 | varStrategyRangesRequested.second, | |||
|
535 | DataProviderParameters{std::move(notInCacheRangeList), var->metadata()}, | |||
|
536 | varProvider); | |||
|
537 | ||||
|
538 | if (!varRequestIdCanceled.isNull()) { | |||
|
539 | qCInfo(LOG_VariableAcquisitionWorker()) << tr("varRequestIdCanceled: ") | |||
|
540 | << varRequestIdCanceled; | |||
|
541 | cancelVariableRequest(varRequestIdCanceled); | |||
|
542 | } | |||
|
543 | } | |||
|
544 | else { | |||
|
545 | qCCritical(LOG_VariableController()) | |||
|
546 | << "Impossible to provide data with a null provider"; | |||
|
547 | } | |||
|
548 | ||||
|
549 | if (!inCacheRangeList.empty()) { | |||
|
550 | emit q->updateVarDisplaying(var, inCacheRangeList.first()); | |||
|
551 | } | |||
|
552 | } | |||
|
553 | else { | |||
|
554 | ||||
|
555 | varRequest.m_RangeRequested = varStrategyRangesRequested.first; | |||
|
556 | varRequest.m_CacheRangeRequested = varStrategyRangesRequested.second; | |||
|
557 | // store VarRequest | |||
|
558 | storeVariableRequest(varId, varRequestId, varRequest); | |||
|
559 | acceptVariableRequest(varId, | |||
|
560 | var->dataSeries()->subDataSeries(varStrategyRangesRequested.second)); | |||
|
561 | } | |||
|
562 | } | |||
|
563 | ||||
|
564 | std::shared_ptr<Variable> | |||
|
565 | VariableController::VariableControllerPrivate::findVariable(QUuid vIdentifier) | |||
|
566 | { | |||
|
567 | std::shared_ptr<Variable> var; | |||
|
568 | auto findReply = [vIdentifier](const auto &entry) { return vIdentifier == entry.second; }; | |||
|
569 | ||||
|
570 | auto end = m_VariableToIdentifierMap.cend(); | |||
|
571 | auto it = std::find_if(m_VariableToIdentifierMap.cbegin(), end, findReply); | |||
|
572 | if (it != end) { | |||
|
573 | var = it->first; | |||
|
574 | } | |||
|
575 | else { | |||
|
576 | qCCritical(LOG_VariableController()) | |||
|
577 | << tr("Impossible to find the variable with the identifier: ") << vIdentifier; | |||
|
578 | } | |||
|
579 | ||||
|
580 | return var; | |||
|
581 | } | |||
|
582 | ||||
|
583 | std::shared_ptr<IDataSeries> VariableController::VariableControllerPrivate::retrieveDataSeries( | |||
|
584 | const QVector<AcquisitionDataPacket> acqDataPacketVector) | |||
|
585 | { | |||
|
586 | qCDebug(LOG_VariableController()) << tr("TORM: retrieveDataSeries acqDataPacketVector size") | |||
|
587 | << acqDataPacketVector.size(); | |||
|
588 | std::shared_ptr<IDataSeries> dataSeries; | |||
|
589 | if (!acqDataPacketVector.isEmpty()) { | |||
|
590 | dataSeries = acqDataPacketVector[0].m_DateSeries; | |||
|
591 | for (int i = 1; i < acqDataPacketVector.size(); ++i) { | |||
|
592 | dataSeries->merge(acqDataPacketVector[i].m_DateSeries.get()); | |||
|
593 | } | |||
|
594 | } | |||
|
595 | qCDebug(LOG_VariableController()) << tr("TORM: retrieveDataSeries acqDataPacketVector size END") | |||
|
596 | << acqDataPacketVector.size(); | |||
|
597 | return dataSeries; | |||
|
598 | } | |||
|
599 | ||||
|
600 | void VariableController::VariableControllerPrivate::registerProvider( | |||
|
601 | std::shared_ptr<IDataProvider> provider) | |||
|
602 | { | |||
|
603 | if (m_ProviderSet.find(provider) == m_ProviderSet.end()) { | |||
|
604 | qCDebug(LOG_VariableController()) << tr("Registering of a new provider") | |||
|
605 | << provider->objectName(); | |||
|
606 | m_ProviderSet.insert(provider); | |||
|
607 | connect(provider.get(), &IDataProvider::dataProvided, m_VariableAcquisitionWorker.get(), | |||
|
608 | &VariableAcquisitionWorker::onVariableDataAcquired); | |||
|
609 | connect(provider.get(), &IDataProvider::dataProvidedProgress, | |||
|
610 | m_VariableAcquisitionWorker.get(), | |||
|
611 | &VariableAcquisitionWorker::onVariableRetrieveDataInProgress); | |||
|
612 | } | |||
|
613 | else { | |||
|
614 | qCDebug(LOG_VariableController()) << tr("Cannot register provider, it already exists "); | |||
|
615 | } | |||
|
616 | } | |||
|
617 | ||||
|
618 | void VariableController::VariableControllerPrivate::storeVariableRequest( | |||
|
619 | QUuid varId, QUuid varRequestId, const VariableRequest &varRequest) | |||
|
620 | { | |||
|
621 | // First request for the variable. we can create an entry for it | |||
|
622 | auto varIdToVarRequestIdQueueMapIt = m_VarIdToVarRequestIdQueueMap.find(varId); | |||
|
623 | if (varIdToVarRequestIdQueueMapIt == m_VarIdToVarRequestIdQueueMap.cend()) { | |||
|
624 | auto varRequestIdQueue = std::deque<QUuid>{}; | |||
|
625 | qCDebug(LOG_VariableController()) << tr("Store REQUEST in QUEUE"); | |||
|
626 | varRequestIdQueue.push_back(varRequestId); | |||
|
627 | m_VarIdToVarRequestIdQueueMap.insert(std::make_pair(varId, std::move(varRequestIdQueue))); | |||
|
628 | } | |||
|
629 | else { | |||
|
630 | qCDebug(LOG_VariableController()) << tr("Store REQUEST in EXISTING QUEUE"); | |||
|
631 | auto &varRequestIdQueue = varIdToVarRequestIdQueueMapIt->second; | |||
|
632 | varRequestIdQueue.push_back(varRequestId); | |||
|
633 | } | |||
|
634 | ||||
|
635 | auto varRequestIdToVarIdVarRequestMapIt = m_VarRequestIdToVarIdVarRequestMap.find(varRequestId); | |||
|
636 | if (varRequestIdToVarIdVarRequestMapIt == m_VarRequestIdToVarIdVarRequestMap.cend()) { | |||
|
637 | auto varIdToVarRequestMap = std::map<QUuid, VariableRequest>{}; | |||
|
638 | varIdToVarRequestMap.insert(std::make_pair(varId, varRequest)); | |||
|
639 | qCDebug(LOG_VariableController()) << tr("Store REQUESTID in MAP"); | |||
|
640 | m_VarRequestIdToVarIdVarRequestMap.insert( | |||
|
641 | std::make_pair(varRequestId, std::move(varIdToVarRequestMap))); | |||
|
642 | } | |||
|
643 | else { | |||
|
644 | auto &varIdToVarRequestMap = varRequestIdToVarIdVarRequestMapIt->second; | |||
|
645 | qCDebug(LOG_VariableController()) << tr("Store REQUESTID in EXISTING MAP"); | |||
|
646 | varIdToVarRequestMap.insert(std::make_pair(varId, varRequest)); | |||
|
647 | } | |||
|
648 | } | |||
|
649 | ||||
|
650 | QUuid VariableController::VariableControllerPrivate::acceptVariableRequest( | |||
|
651 | QUuid varId, std::shared_ptr<IDataSeries> dataSeries) | |||
|
652 | { | |||
|
653 | QUuid varRequestId; | |||
|
654 | auto varIdToVarRequestIdQueueMapIt = m_VarIdToVarRequestIdQueueMap.find(varId); | |||
|
655 | if (varIdToVarRequestIdQueueMapIt != m_VarIdToVarRequestIdQueueMap.cend()) { | |||
|
656 | auto &varRequestIdQueue = varIdToVarRequestIdQueueMapIt->second; | |||
|
657 | varRequestId = varRequestIdQueue.front(); | |||
|
658 | auto varRequestIdToVarIdVarRequestMapIt | |||
|
659 | = m_VarRequestIdToVarIdVarRequestMap.find(varRequestId); | |||
|
660 | if (varRequestIdToVarIdVarRequestMapIt != m_VarRequestIdToVarIdVarRequestMap.cend()) { | |||
|
661 | auto &varIdToVarRequestMap = varRequestIdToVarIdVarRequestMapIt->second; | |||
|
662 | auto varIdToVarRequestMapIt = varIdToVarRequestMap.find(varId); | |||
|
663 | if (varIdToVarRequestMapIt != varIdToVarRequestMap.cend()) { | |||
|
664 | qCDebug(LOG_VariableController()) << tr("acceptVariableRequest"); | |||
|
665 | auto &varRequest = varIdToVarRequestMapIt->second; | |||
|
666 | varRequest.m_DataSeries = dataSeries; | |||
|
667 | varRequest.m_CanUpdate = true; | |||
|
668 | } | |||
|
669 | else { | |||
|
670 | qCDebug(LOG_VariableController()) | |||
|
671 | << tr("Impossible to acceptVariableRequest of a unknown variable id attached " | |||
|
672 | "to a variableRequestId") | |||
|
673 | << varRequestId << varId; | |||
|
674 | } | |||
|
675 | } | |||
|
676 | else { | |||
|
677 | qCCritical(LOG_VariableController()) | |||
|
678 | << tr("Impossible to acceptVariableRequest of a unknown variableRequestId") | |||
|
679 | << varRequestId; | |||
|
680 | } | |||
|
681 | ||||
|
682 | qCDebug(LOG_VariableController()) << tr("1: erase REQUEST in QUEUE ?") | |||
|
683 | << varRequestIdQueue.size(); | |||
|
684 | varRequestIdQueue.pop_front(); | |||
|
685 | qCDebug(LOG_VariableController()) << tr("2: erase REQUEST in QUEUE ?") | |||
|
686 | << varRequestIdQueue.size(); | |||
|
687 | if (varRequestIdQueue.empty()) { | |||
|
688 | m_VarIdToVarRequestIdQueueMap.erase(varId); | |||
|
689 | } | |||
|
690 | } | |||
|
691 | else { | |||
|
692 | qCCritical(LOG_VariableController()) | |||
|
693 | << tr("Impossible to acceptVariableRequest of a unknown variable id") << varId; | |||
|
694 | } | |||
|
695 | ||||
|
696 | return varRequestId; | |||
|
697 | } | |||
|
698 | ||||
|
699 | void VariableController::VariableControllerPrivate::updateVariableRequest(QUuid varRequestId) | |||
|
700 | { | |||
|
701 | ||||
|
702 | auto varRequestIdToVarIdVarRequestMapIt = m_VarRequestIdToVarIdVarRequestMap.find(varRequestId); | |||
|
703 | if (varRequestIdToVarIdVarRequestMapIt != m_VarRequestIdToVarIdVarRequestMap.cend()) { | |||
|
704 | bool processVariableUpdate = true; | |||
|
705 | auto &varIdToVarRequestMap = varRequestIdToVarIdVarRequestMapIt->second; | |||
|
706 | for (auto varIdToVarRequestMapIt = varIdToVarRequestMap.cbegin(); | |||
|
707 | (varIdToVarRequestMapIt != varIdToVarRequestMap.cend()) && processVariableUpdate; | |||
|
708 | ++varIdToVarRequestMapIt) { | |||
|
709 | processVariableUpdate &= varIdToVarRequestMapIt->second.m_CanUpdate; | |||
|
710 | qCDebug(LOG_VariableController()) << tr("updateVariableRequest") | |||
|
711 | << processVariableUpdate; | |||
|
712 | } | |||
|
713 | ||||
|
714 | if (processVariableUpdate) { | |||
|
715 | for (auto varIdToVarRequestMapIt = varIdToVarRequestMap.cbegin(); | |||
|
716 | varIdToVarRequestMapIt != varIdToVarRequestMap.cend(); ++varIdToVarRequestMapIt) { | |||
|
717 | if (auto var = findVariable(varIdToVarRequestMapIt->first)) { | |||
|
718 | auto &varRequest = varIdToVarRequestMapIt->second; | |||
|
719 | var->setRange(varRequest.m_RangeRequested); | |||
|
720 | var->setCacheRange(varRequest.m_CacheRangeRequested); | |||
|
721 | qCDebug(LOG_VariableController()) << tr("1: onDataProvided") | |||
|
722 | << varRequest.m_RangeRequested; | |||
|
723 | qCDebug(LOG_VariableController()) << tr("2: onDataProvided") | |||
|
724 | << varRequest.m_CacheRangeRequested; | |||
|
725 | var->mergeDataSeries(varRequest.m_DataSeries); | |||
|
726 | qCDebug(LOG_VariableController()) << tr("3: onDataProvided") | |||
|
727 | << varRequest.m_DataSeries->range(); | |||
|
728 | qCDebug(LOG_VariableController()) << tr("4: onDataProvided"); | |||
|
729 | ||||
|
730 | /// @todo MPL: confirm | |||
|
731 | // Variable update is notified only if there is no pending request for it | |||
|
732 | if (m_VarIdToVarRequestIdQueueMap.count(varIdToVarRequestMapIt->first) == 0) { | |||
|
733 | emit var->updated(); | |||
|
734 | } | |||
|
735 | } | |||
|
736 | else { | |||
|
737 | qCCritical(LOG_VariableController()) | |||
|
738 | << tr("Impossible to update data to a null variable"); | |||
|
739 | } | |||
|
740 | } | |||
|
741 | ||||
|
742 | // cleaning varRequestId | |||
|
743 | qCDebug(LOG_VariableController()) << tr("0: erase REQUEST in MAP ?") | |||
|
744 | << m_VarRequestIdToVarIdVarRequestMap.size(); | |||
|
745 | m_VarRequestIdToVarIdVarRequestMap.erase(varRequestId); | |||
|
746 | qCDebug(LOG_VariableController()) << tr("1: erase REQUEST in MAP ?") | |||
|
747 | << m_VarRequestIdToVarIdVarRequestMap.size(); | |||
|
748 | } | |||
|
749 | } | |||
|
750 | else { | |||
|
751 | qCCritical(LOG_VariableController()) | |||
|
752 | << tr("Cannot updateVariableRequest for a unknow varRequestId") << varRequestId; | |||
|
753 | } | |||
|
754 | } | |||
|
755 | ||||
|
756 | void VariableController::VariableControllerPrivate::cancelVariableRequest(QUuid varRequestId) | |||
|
757 | { | |||
|
758 | // cleaning varRequestId | |||
|
759 | m_VarRequestIdToVarIdVarRequestMap.erase(varRequestId); | |||
|
760 | ||||
|
761 | for (auto varIdToVarRequestIdQueueMapIt = m_VarIdToVarRequestIdQueueMap.begin(); | |||
|
762 | varIdToVarRequestIdQueueMapIt != m_VarIdToVarRequestIdQueueMap.end();) { | |||
|
763 | auto &varRequestIdQueue = varIdToVarRequestIdQueueMapIt->second; | |||
|
764 | varRequestIdQueue.erase( | |||
|
765 | std::remove(varRequestIdQueue.begin(), varRequestIdQueue.end(), varRequestId), | |||
|
766 | varRequestIdQueue.end()); | |||
|
767 | if (varRequestIdQueue.empty()) { | |||
|
768 | varIdToVarRequestIdQueueMapIt | |||
|
769 | = m_VarIdToVarRequestIdQueueMap.erase(varIdToVarRequestIdQueueMapIt); | |||
|
770 | } | |||
|
771 | else { | |||
|
772 | ++varIdToVarRequestIdQueueMapIt; | |||
|
773 | } | |||
|
774 | } | |||
|
775 | } |
This diff has been collapsed as it changes many lines, (636 lines changed) Show them Hide them | |||||
@@ -0,0 +1,636 | |||||
|
1 | #include "Data/DataSeries.h" | |||
|
2 | #include "Data/ScalarSeries.h" | |||
|
3 | #include "Data/VectorSeries.h" | |||
|
4 | ||||
|
5 | #include <cmath> | |||
|
6 | ||||
|
7 | #include <QObject> | |||
|
8 | #include <QtTest> | |||
|
9 | ||||
|
10 | Q_DECLARE_METATYPE(std::shared_ptr<ScalarSeries>) | |||
|
11 | Q_DECLARE_METATYPE(std::shared_ptr<VectorSeries>) | |||
|
12 | ||||
|
13 | namespace { | |||
|
14 | ||||
|
15 | using DataContainer = std::vector<double>; | |||
|
16 | ||||
|
17 | void validateRange(DataSeriesIterator first, DataSeriesIterator last, const DataContainer &xData, | |||
|
18 | const DataContainer &valuesData) | |||
|
19 | { | |||
|
20 | QVERIFY(std::equal(first, last, xData.cbegin(), xData.cend(), | |||
|
21 | [](const auto &it, const auto &expectedX) { return it.x() == expectedX; })); | |||
|
22 | QVERIFY(std::equal( | |||
|
23 | first, last, valuesData.cbegin(), valuesData.cend(), | |||
|
24 | [](const auto &it, const auto &expectedVal) { return it.value() == expectedVal; })); | |||
|
25 | } | |||
|
26 | ||||
|
27 | void validateRange(DataSeriesIterator first, DataSeriesIterator last, const DataContainer &xData, | |||
|
28 | const std::vector<DataContainer> &valuesData) | |||
|
29 | { | |||
|
30 | QVERIFY(std::equal(first, last, xData.cbegin(), xData.cend(), | |||
|
31 | [](const auto &it, const auto &expectedX) { return it.x() == expectedX; })); | |||
|
32 | for (auto i = 0; i < valuesData.size(); ++i) { | |||
|
33 | auto componentData = valuesData.at(i); | |||
|
34 | ||||
|
35 | QVERIFY(std::equal( | |||
|
36 | first, last, componentData.cbegin(), componentData.cend(), | |||
|
37 | [i](const auto &it, const auto &expectedVal) { return it.value(i) == expectedVal; })); | |||
|
38 | } | |||
|
39 | } | |||
|
40 | ||||
|
41 | } // namespace | |||
|
42 | ||||
|
43 | class TestDataSeries : public QObject { | |||
|
44 | Q_OBJECT | |||
|
45 | private: | |||
|
46 | template <typename T> | |||
|
47 | void testValuesBoundsStructure() | |||
|
48 | { | |||
|
49 | // ////////////// // | |||
|
50 | // Test structure // | |||
|
51 | // ////////////// // | |||
|
52 | ||||
|
53 | // Data series to get values bounds | |||
|
54 | QTest::addColumn<std::shared_ptr<T> >("dataSeries"); | |||
|
55 | ||||
|
56 | // x-axis range | |||
|
57 | QTest::addColumn<double>("minXAxis"); | |||
|
58 | QTest::addColumn<double>("maxXAxis"); | |||
|
59 | ||||
|
60 | // Expected results | |||
|
61 | QTest::addColumn<bool>( | |||
|
62 | "expectedOK"); // Test is expected to be ok (i.e. method doesn't return end iterators) | |||
|
63 | QTest::addColumn<double>("expectedMinValue"); | |||
|
64 | QTest::addColumn<double>("expectedMaxValue"); | |||
|
65 | } | |||
|
66 | ||||
|
67 | template <typename T> | |||
|
68 | void testValuesBounds() | |||
|
69 | { | |||
|
70 | QFETCH(std::shared_ptr<T>, dataSeries); | |||
|
71 | QFETCH(double, minXAxis); | |||
|
72 | QFETCH(double, maxXAxis); | |||
|
73 | ||||
|
74 | QFETCH(bool, expectedOK); | |||
|
75 | QFETCH(double, expectedMinValue); | |||
|
76 | QFETCH(double, expectedMaxValue); | |||
|
77 | ||||
|
78 | auto minMaxIts = dataSeries->valuesBounds(minXAxis, maxXAxis); | |||
|
79 | auto end = dataSeries->cend(); | |||
|
80 | ||||
|
81 | // Checks iterators with expected result | |||
|
82 | QCOMPARE(expectedOK, minMaxIts.first != end && minMaxIts.second != end); | |||
|
83 | ||||
|
84 | if (expectedOK) { | |||
|
85 | auto compare = [](const auto &v1, const auto &v2) { | |||
|
86 | return (std::isnan(v1) && std::isnan(v2)) || v1 == v2; | |||
|
87 | }; | |||
|
88 | ||||
|
89 | QVERIFY(compare(expectedMinValue, minMaxIts.first->minValue())); | |||
|
90 | QVERIFY(compare(expectedMaxValue, minMaxIts.second->maxValue())); | |||
|
91 | } | |||
|
92 | } | |||
|
93 | ||||
|
94 | template <typename T> | |||
|
95 | void testPurgeStructure() | |||
|
96 | { | |||
|
97 | // ////////////// // | |||
|
98 | // Test structure // | |||
|
99 | // ////////////// // | |||
|
100 | ||||
|
101 | // Data series to purge | |||
|
102 | QTest::addColumn<std::shared_ptr<T> >("dataSeries"); | |||
|
103 | QTest::addColumn<double>("min"); | |||
|
104 | QTest::addColumn<double>("max"); | |||
|
105 | ||||
|
106 | // Expected values after purge | |||
|
107 | QTest::addColumn<DataContainer>("expectedXAxisData"); | |||
|
108 | QTest::addColumn<std::vector<DataContainer> >("expectedValuesData"); | |||
|
109 | } | |||
|
110 | ||||
|
111 | template <typename T> | |||
|
112 | void testPurge() | |||
|
113 | { | |||
|
114 | QFETCH(std::shared_ptr<T>, dataSeries); | |||
|
115 | QFETCH(double, min); | |||
|
116 | QFETCH(double, max); | |||
|
117 | ||||
|
118 | dataSeries->purge(min, max); | |||
|
119 | ||||
|
120 | // Validates results | |||
|
121 | QFETCH(DataContainer, expectedXAxisData); | |||
|
122 | QFETCH(std::vector<DataContainer>, expectedValuesData); | |||
|
123 | ||||
|
124 | validateRange(dataSeries->cbegin(), dataSeries->cend(), expectedXAxisData, | |||
|
125 | expectedValuesData); | |||
|
126 | } | |||
|
127 | ||||
|
128 | private slots: | |||
|
129 | ||||
|
130 | /// Input test data | |||
|
131 | /// @sa testCtor() | |||
|
132 | void testCtor_data(); | |||
|
133 | ||||
|
134 | /// Tests construction of a data series | |||
|
135 | void testCtor(); | |||
|
136 | ||||
|
137 | /// Input test data | |||
|
138 | /// @sa testMerge() | |||
|
139 | void testMerge_data(); | |||
|
140 | ||||
|
141 | /// Tests merge of two data series | |||
|
142 | void testMerge(); | |||
|
143 | ||||
|
144 | /// Input test data | |||
|
145 | /// @sa testPurgeScalar() | |||
|
146 | void testPurgeScalar_data(); | |||
|
147 | ||||
|
148 | /// Tests purge of a scalar series | |||
|
149 | void testPurgeScalar(); | |||
|
150 | ||||
|
151 | /// Input test data | |||
|
152 | /// @sa testPurgeVector() | |||
|
153 | void testPurgeVector_data(); | |||
|
154 | ||||
|
155 | /// Tests purge of a vector series | |||
|
156 | void testPurgeVector(); | |||
|
157 | ||||
|
158 | /// Input test data | |||
|
159 | /// @sa testMinXAxisData() | |||
|
160 | void testMinXAxisData_data(); | |||
|
161 | ||||
|
162 | /// Tests get min x-axis data of a data series | |||
|
163 | void testMinXAxisData(); | |||
|
164 | ||||
|
165 | /// Input test data | |||
|
166 | /// @sa testMaxXAxisData() | |||
|
167 | void testMaxXAxisData_data(); | |||
|
168 | ||||
|
169 | /// Tests get max x-axis data of a data series | |||
|
170 | void testMaxXAxisData(); | |||
|
171 | ||||
|
172 | /// Input test data | |||
|
173 | /// @sa testXAxisRange() | |||
|
174 | void testXAxisRange_data(); | |||
|
175 | ||||
|
176 | /// Tests get x-axis range of a data series | |||
|
177 | void testXAxisRange(); | |||
|
178 | ||||
|
179 | /// Input test data | |||
|
180 | /// @sa testValuesBoundsScalar() | |||
|
181 | void testValuesBoundsScalar_data(); | |||
|
182 | ||||
|
183 | /// Tests get values bounds of a scalar series | |||
|
184 | void testValuesBoundsScalar(); | |||
|
185 | ||||
|
186 | /// Input test data | |||
|
187 | /// @sa testValuesBoundsVector() | |||
|
188 | void testValuesBoundsVector_data(); | |||
|
189 | ||||
|
190 | /// Tests get values bounds of a vector series | |||
|
191 | void testValuesBoundsVector(); | |||
|
192 | }; | |||
|
193 | ||||
|
194 | void TestDataSeries::testCtor_data() | |||
|
195 | { | |||
|
196 | // ////////////// // | |||
|
197 | // Test structure // | |||
|
198 | // ////////////// // | |||
|
199 | ||||
|
200 | // x-axis data | |||
|
201 | QTest::addColumn<DataContainer>("xAxisData"); | |||
|
202 | // values data | |||
|
203 | QTest::addColumn<DataContainer>("valuesData"); | |||
|
204 | ||||
|
205 | // expected x-axis data | |||
|
206 | QTest::addColumn<DataContainer>("expectedXAxisData"); | |||
|
207 | // expected values data | |||
|
208 | QTest::addColumn<DataContainer>("expectedValuesData"); | |||
|
209 | ||||
|
210 | // ////////// // | |||
|
211 | // Test cases // | |||
|
212 | // ////////// // | |||
|
213 | ||||
|
214 | QTest::newRow("invalidData (different sizes of vectors)") | |||
|
215 | << DataContainer{1., 2., 3., 4., 5.} << DataContainer{100., 200., 300.} << DataContainer{} | |||
|
216 | << DataContainer{}; | |||
|
217 | ||||
|
218 | QTest::newRow("sortedData") << DataContainer{1., 2., 3., 4., 5.} | |||
|
219 | << DataContainer{100., 200., 300., 400., 500.} | |||
|
220 | << DataContainer{1., 2., 3., 4., 5.} | |||
|
221 | << DataContainer{100., 200., 300., 400., 500.}; | |||
|
222 | ||||
|
223 | QTest::newRow("unsortedData") << DataContainer{5., 4., 3., 2., 1.} | |||
|
224 | << DataContainer{100., 200., 300., 400., 500.} | |||
|
225 | << DataContainer{1., 2., 3., 4., 5.} | |||
|
226 | << DataContainer{500., 400., 300., 200., 100.}; | |||
|
227 | ||||
|
228 | QTest::newRow("unsortedData2") | |||
|
229 | << DataContainer{1., 4., 3., 5., 2.} << DataContainer{100., 200., 300., 400., 500.} | |||
|
230 | << DataContainer{1., 2., 3., 4., 5.} << DataContainer{100., 500., 300., 200., 400.}; | |||
|
231 | } | |||
|
232 | ||||
|
233 | void TestDataSeries::testCtor() | |||
|
234 | { | |||
|
235 | // Creates series | |||
|
236 | QFETCH(DataContainer, xAxisData); | |||
|
237 | QFETCH(DataContainer, valuesData); | |||
|
238 | ||||
|
239 | auto series = std::make_shared<ScalarSeries>(std::move(xAxisData), std::move(valuesData), | |||
|
240 | Unit{}, Unit{}); | |||
|
241 | ||||
|
242 | // Validates results : we check that the data series is sorted on its x-axis data | |||
|
243 | QFETCH(DataContainer, expectedXAxisData); | |||
|
244 | QFETCH(DataContainer, expectedValuesData); | |||
|
245 | ||||
|
246 | validateRange(series->cbegin(), series->cend(), expectedXAxisData, expectedValuesData); | |||
|
247 | } | |||
|
248 | ||||
|
249 | namespace { | |||
|
250 | ||||
|
251 | std::shared_ptr<ScalarSeries> createScalarSeries(DataContainer xAxisData, DataContainer valuesData) | |||
|
252 | { | |||
|
253 | return std::make_shared<ScalarSeries>(std::move(xAxisData), std::move(valuesData), Unit{}, | |||
|
254 | Unit{}); | |||
|
255 | } | |||
|
256 | ||||
|
257 | std::shared_ptr<VectorSeries> createVectorSeries(DataContainer xAxisData, DataContainer xValuesData, | |||
|
258 | DataContainer yValuesData, | |||
|
259 | DataContainer zValuesData) | |||
|
260 | { | |||
|
261 | return std::make_shared<VectorSeries>(std::move(xAxisData), std::move(xValuesData), | |||
|
262 | std::move(yValuesData), std::move(zValuesData), Unit{}, | |||
|
263 | Unit{}); | |||
|
264 | } | |||
|
265 | ||||
|
266 | } // namespace | |||
|
267 | ||||
|
268 | void TestDataSeries::testMerge_data() | |||
|
269 | { | |||
|
270 | // ////////////// // | |||
|
271 | // Test structure // | |||
|
272 | // ////////////// // | |||
|
273 | ||||
|
274 | // Data series to merge | |||
|
275 | QTest::addColumn<std::shared_ptr<ScalarSeries> >("dataSeries"); | |||
|
276 | QTest::addColumn<std::shared_ptr<ScalarSeries> >("dataSeries2"); | |||
|
277 | ||||
|
278 | // Expected values in the first data series after merge | |||
|
279 | QTest::addColumn<DataContainer>("expectedXAxisData"); | |||
|
280 | QTest::addColumn<DataContainer>("expectedValuesData"); | |||
|
281 | ||||
|
282 | // ////////// // | |||
|
283 | // Test cases // | |||
|
284 | // ////////// // | |||
|
285 | ||||
|
286 | QTest::newRow("sortedMerge") | |||
|
287 | << createScalarSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.}) | |||
|
288 | << createScalarSeries({6., 7., 8., 9., 10.}, {600., 700., 800., 900., 1000.}) | |||
|
289 | << DataContainer{1., 2., 3., 4., 5., 6., 7., 8., 9., 10.} | |||
|
290 | << DataContainer{100., 200., 300., 400., 500., 600., 700., 800., 900., 1000.}; | |||
|
291 | ||||
|
292 | QTest::newRow("unsortedMerge") | |||
|
293 | << createScalarSeries({6., 7., 8., 9., 10.}, {600., 700., 800., 900., 1000.}) | |||
|
294 | << createScalarSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.}) | |||
|
295 | << DataContainer{1., 2., 3., 4., 5., 6., 7., 8., 9., 10.} | |||
|
296 | << DataContainer{100., 200., 300., 400., 500., 600., 700., 800., 900., 1000.}; | |||
|
297 | ||||
|
298 | QTest::newRow("unsortedMerge2 (merge not made because source is in the bounds of dest)") | |||
|
299 | << createScalarSeries({1., 2., 8., 9., 10}, {100., 200., 800., 900., 1000.}) | |||
|
300 | << createScalarSeries({3., 4., 5., 6., 7.}, {300., 400., 500., 600., 700.}) | |||
|
301 | << DataContainer{1., 2., 8., 9., 10.} << DataContainer{100., 200., 800., 900., 1000.}; | |||
|
302 | ||||
|
303 | QTest::newRow("unsortedMerge3") | |||
|
304 | << createScalarSeries({3., 4., 5., 7., 8}, {300., 400., 500., 700., 800.}) | |||
|
305 | << createScalarSeries({1., 2., 3., 7., 10.}, {100., 200., 333., 777., 1000.}) | |||
|
306 | << DataContainer{1., 2., 3., 4., 5., 7., 8., 10.} | |||
|
307 | << DataContainer{100., 200., 300., 400., 500., 700., 800., 1000.}; | |||
|
308 | } | |||
|
309 | ||||
|
310 | void TestDataSeries::testMerge() | |||
|
311 | { | |||
|
312 | // Merges series | |||
|
313 | QFETCH(std::shared_ptr<ScalarSeries>, dataSeries); | |||
|
314 | QFETCH(std::shared_ptr<ScalarSeries>, dataSeries2); | |||
|
315 | ||||
|
316 | dataSeries->merge(dataSeries2.get()); | |||
|
317 | ||||
|
318 | // Validates results : we check that the merge is valid and the data series is sorted on its | |||
|
319 | // x-axis data | |||
|
320 | QFETCH(DataContainer, expectedXAxisData); | |||
|
321 | QFETCH(DataContainer, expectedValuesData); | |||
|
322 | ||||
|
323 | validateRange(dataSeries->cbegin(), dataSeries->cend(), expectedXAxisData, expectedValuesData); | |||
|
324 | } | |||
|
325 | ||||
|
326 | void TestDataSeries::testPurgeScalar_data() | |||
|
327 | { | |||
|
328 | testPurgeStructure<ScalarSeries>(); | |||
|
329 | ||||
|
330 | // ////////// // | |||
|
331 | // Test cases // | |||
|
332 | // ////////// // | |||
|
333 | ||||
|
334 | QTest::newRow("purgeScalar") << createScalarSeries({1., 2., 3., 4., 5.}, | |||
|
335 | {100., 200., 300., 400., 500.}) | |||
|
336 | << 2. << 4. << DataContainer{2., 3., 4.} | |||
|
337 | << std::vector<DataContainer>{{200., 300., 400.}}; | |||
|
338 | QTest::newRow("purgeScalar2") << createScalarSeries({1., 2., 3., 4., 5.}, | |||
|
339 | {100., 200., 300., 400., 500.}) | |||
|
340 | << 0. << 2.5 << DataContainer{1., 2.} | |||
|
341 | << std::vector<DataContainer>{{100., 200.}}; | |||
|
342 | QTest::newRow("purgeScalar3") << createScalarSeries({1., 2., 3., 4., 5.}, | |||
|
343 | {100., 200., 300., 400., 500.}) | |||
|
344 | << 3.5 << 7. << DataContainer{4., 5.} | |||
|
345 | << std::vector<DataContainer>{{400., 500.}}; | |||
|
346 | QTest::newRow("purgeScalar4") << createScalarSeries({1., 2., 3., 4., 5.}, | |||
|
347 | {100., 200., 300., 400., 500.}) | |||
|
348 | << 0. << 7. << DataContainer{1., 2., 3., 4., 5.} | |||
|
349 | << std::vector<DataContainer>{{100., 200., 300., 400., 500.}}; | |||
|
350 | QTest::newRow("purgeScalar5") << createScalarSeries({1., 2., 3., 4., 5.}, | |||
|
351 | {100., 200., 300., 400., 500.}) | |||
|
352 | << 5.5 << 7. << DataContainer{} << std::vector<DataContainer>{{}}; | |||
|
353 | } | |||
|
354 | ||||
|
355 | void TestDataSeries::testPurgeScalar() | |||
|
356 | { | |||
|
357 | testPurge<ScalarSeries>(); | |||
|
358 | } | |||
|
359 | ||||
|
360 | void TestDataSeries::testPurgeVector_data() | |||
|
361 | { | |||
|
362 | testPurgeStructure<VectorSeries>(); | |||
|
363 | ||||
|
364 | // ////////// // | |||
|
365 | // Test cases // | |||
|
366 | // ////////// // | |||
|
367 | ||||
|
368 | QTest::newRow("purgeVector") << createVectorSeries({1., 2., 3., 4., 5.}, {6., 7., 8., 9., 10.}, | |||
|
369 | {11., 12., 13., 14., 15.}, | |||
|
370 | {16., 17., 18., 19., 20.}) | |||
|
371 | << 2. << 4. << DataContainer{2., 3., 4.} | |||
|
372 | << std::vector<DataContainer>{ | |||
|
373 | {7., 8., 9.}, {12., 13., 14.}, {17., 18., 19.}}; | |||
|
374 | } | |||
|
375 | ||||
|
376 | void TestDataSeries::testPurgeVector() | |||
|
377 | { | |||
|
378 | testPurge<VectorSeries>(); | |||
|
379 | } | |||
|
380 | ||||
|
381 | void TestDataSeries::testMinXAxisData_data() | |||
|
382 | { | |||
|
383 | // ////////////// // | |||
|
384 | // Test structure // | |||
|
385 | // ////////////// // | |||
|
386 | ||||
|
387 | // Data series to get min data | |||
|
388 | QTest::addColumn<std::shared_ptr<ScalarSeries> >("dataSeries"); | |||
|
389 | ||||
|
390 | // Min data | |||
|
391 | QTest::addColumn<double>("min"); | |||
|
392 | ||||
|
393 | // Expected results | |||
|
394 | QTest::addColumn<bool>( | |||
|
395 | "expectedOK"); // if true, expects to have a result (i.e. the iterator != end iterator) | |||
|
396 | QTest::addColumn<double>( | |||
|
397 | "expectedMin"); // Expected value when method doesn't return end iterator | |||
|
398 | ||||
|
399 | // ////////// // | |||
|
400 | // Test cases // | |||
|
401 | // ////////// // | |||
|
402 | ||||
|
403 | QTest::newRow("minData1") << createScalarSeries({1., 2., 3., 4., 5.}, | |||
|
404 | {100., 200., 300., 400., 500.}) | |||
|
405 | << 0. << true << 1.; | |||
|
406 | QTest::newRow("minData2") << createScalarSeries({1., 2., 3., 4., 5.}, | |||
|
407 | {100., 200., 300., 400., 500.}) | |||
|
408 | << 1. << true << 1.; | |||
|
409 | QTest::newRow("minData3") << createScalarSeries({1., 2., 3., 4., 5.}, | |||
|
410 | {100., 200., 300., 400., 500.}) | |||
|
411 | << 1.1 << true << 2.; | |||
|
412 | QTest::newRow("minData4") << createScalarSeries({1., 2., 3., 4., 5.}, | |||
|
413 | {100., 200., 300., 400., 500.}) | |||
|
414 | << 5. << true << 5.; | |||
|
415 | QTest::newRow("minData5") << createScalarSeries({1., 2., 3., 4., 5.}, | |||
|
416 | {100., 200., 300., 400., 500.}) | |||
|
417 | << 5.1 << false << std::numeric_limits<double>::quiet_NaN(); | |||
|
418 | QTest::newRow("minData6") << createScalarSeries({}, {}) << 1.1 << false | |||
|
419 | << std::numeric_limits<double>::quiet_NaN(); | |||
|
420 | } | |||
|
421 | ||||
|
422 | void TestDataSeries::testMinXAxisData() | |||
|
423 | { | |||
|
424 | QFETCH(std::shared_ptr<ScalarSeries>, dataSeries); | |||
|
425 | QFETCH(double, min); | |||
|
426 | ||||
|
427 | QFETCH(bool, expectedOK); | |||
|
428 | QFETCH(double, expectedMin); | |||
|
429 | ||||
|
430 | auto it = dataSeries->minXAxisData(min); | |||
|
431 | ||||
|
432 | QCOMPARE(expectedOK, it != dataSeries->cend()); | |||
|
433 | ||||
|
434 | // If the method doesn't return a end iterator, checks with expected value | |||
|
435 | if (expectedOK) { | |||
|
436 | QCOMPARE(expectedMin, it->x()); | |||
|
437 | } | |||
|
438 | } | |||
|
439 | ||||
|
440 | void TestDataSeries::testMaxXAxisData_data() | |||
|
441 | { | |||
|
442 | // ////////////// // | |||
|
443 | // Test structure // | |||
|
444 | // ////////////// // | |||
|
445 | ||||
|
446 | // Data series to get max data | |||
|
447 | QTest::addColumn<std::shared_ptr<ScalarSeries> >("dataSeries"); | |||
|
448 | ||||
|
449 | // Max data | |||
|
450 | QTest::addColumn<double>("max"); | |||
|
451 | ||||
|
452 | // Expected results | |||
|
453 | QTest::addColumn<bool>( | |||
|
454 | "expectedOK"); // if true, expects to have a result (i.e. the iterator != end iterator) | |||
|
455 | QTest::addColumn<double>( | |||
|
456 | "expectedMax"); // Expected value when method doesn't return end iterator | |||
|
457 | ||||
|
458 | // ////////// // | |||
|
459 | // Test cases // | |||
|
460 | // ////////// // | |||
|
461 | ||||
|
462 | QTest::newRow("maxData1") << createScalarSeries({1., 2., 3., 4., 5.}, | |||
|
463 | {100., 200., 300., 400., 500.}) | |||
|
464 | << 6. << true << 5.; | |||
|
465 | QTest::newRow("maxData2") << createScalarSeries({1., 2., 3., 4., 5.}, | |||
|
466 | {100., 200., 300., 400., 500.}) | |||
|
467 | << 5. << true << 5.; | |||
|
468 | QTest::newRow("maxData3") << createScalarSeries({1., 2., 3., 4., 5.}, | |||
|
469 | {100., 200., 300., 400., 500.}) | |||
|
470 | << 4.9 << true << 4.; | |||
|
471 | QTest::newRow("maxData4") << createScalarSeries({1., 2., 3., 4., 5.}, | |||
|
472 | {100., 200., 300., 400., 500.}) | |||
|
473 | << 1.1 << true << 1.; | |||
|
474 | QTest::newRow("maxData5") << createScalarSeries({1., 2., 3., 4., 5.}, | |||
|
475 | {100., 200., 300., 400., 500.}) | |||
|
476 | << 1. << true << 1.; | |||
|
477 | QTest::newRow("maxData6") << createScalarSeries({}, {}) << 1.1 << false | |||
|
478 | << std::numeric_limits<double>::quiet_NaN(); | |||
|
479 | } | |||
|
480 | ||||
|
481 | void TestDataSeries::testMaxXAxisData() | |||
|
482 | { | |||
|
483 | QFETCH(std::shared_ptr<ScalarSeries>, dataSeries); | |||
|
484 | QFETCH(double, max); | |||
|
485 | ||||
|
486 | QFETCH(bool, expectedOK); | |||
|
487 | QFETCH(double, expectedMax); | |||
|
488 | ||||
|
489 | auto it = dataSeries->maxXAxisData(max); | |||
|
490 | ||||
|
491 | QCOMPARE(expectedOK, it != dataSeries->cend()); | |||
|
492 | ||||
|
493 | // If the method doesn't return a end iterator, checks with expected value | |||
|
494 | if (expectedOK) { | |||
|
495 | QCOMPARE(expectedMax, it->x()); | |||
|
496 | } | |||
|
497 | } | |||
|
498 | ||||
|
499 | void TestDataSeries::testXAxisRange_data() | |||
|
500 | { | |||
|
501 | // ////////////// // | |||
|
502 | // Test structure // | |||
|
503 | // ////////////// // | |||
|
504 | ||||
|
505 | // Data series to get x-axis range | |||
|
506 | QTest::addColumn<std::shared_ptr<ScalarSeries> >("dataSeries"); | |||
|
507 | ||||
|
508 | // Min/max values | |||
|
509 | QTest::addColumn<double>("min"); | |||
|
510 | QTest::addColumn<double>("max"); | |||
|
511 | ||||
|
512 | // Expected values | |||
|
513 | QTest::addColumn<DataContainer>("expectedXAxisData"); | |||
|
514 | QTest::addColumn<DataContainer>("expectedValuesData"); | |||
|
515 | ||||
|
516 | // ////////// // | |||
|
517 | // Test cases // | |||
|
518 | // ////////// // | |||
|
519 | ||||
|
520 | QTest::newRow("xAxisRange1") << createScalarSeries({1., 2., 3., 4., 5.}, | |||
|
521 | {100., 200., 300., 400., 500.}) | |||
|
522 | << -1. << 3.2 << DataContainer{1., 2., 3.} | |||
|
523 | << DataContainer{100., 200., 300.}; | |||
|
524 | QTest::newRow("xAxisRange2") << createScalarSeries({1., 2., 3., 4., 5.}, | |||
|
525 | {100., 200., 300., 400., 500.}) | |||
|
526 | << 1. << 4. << DataContainer{1., 2., 3., 4.} | |||
|
527 | << DataContainer{100., 200., 300., 400.}; | |||
|
528 | QTest::newRow("xAxisRange3") << createScalarSeries({1., 2., 3., 4., 5.}, | |||
|
529 | {100., 200., 300., 400., 500.}) | |||
|
530 | << 1. << 3.9 << DataContainer{1., 2., 3.} | |||
|
531 | << DataContainer{100., 200., 300.}; | |||
|
532 | QTest::newRow("xAxisRange4") << createScalarSeries({1., 2., 3., 4., 5.}, | |||
|
533 | {100., 200., 300., 400., 500.}) | |||
|
534 | << 0. << 0.9 << DataContainer{} << DataContainer{}; | |||
|
535 | QTest::newRow("xAxisRange5") << createScalarSeries({1., 2., 3., 4., 5.}, | |||
|
536 | {100., 200., 300., 400., 500.}) | |||
|
537 | << 0. << 1. << DataContainer{1.} << DataContainer{100.}; | |||
|
538 | QTest::newRow("xAxisRange6") << createScalarSeries({1., 2., 3., 4., 5.}, | |||
|
539 | {100., 200., 300., 400., 500.}) | |||
|
540 | << 2.1 << 6. << DataContainer{3., 4., 5.} | |||
|
541 | << DataContainer{300., 400., 500.}; | |||
|
542 | QTest::newRow("xAxisRange7") << createScalarSeries({1., 2., 3., 4., 5.}, | |||
|
543 | {100., 200., 300., 400., 500.}) | |||
|
544 | << 6. << 9. << DataContainer{} << DataContainer{}; | |||
|
545 | QTest::newRow("xAxisRange8") << createScalarSeries({1., 2., 3., 4., 5.}, | |||
|
546 | {100., 200., 300., 400., 500.}) | |||
|
547 | << 5. << 9. << DataContainer{5.} << DataContainer{500.}; | |||
|
548 | } | |||
|
549 | ||||
|
550 | void TestDataSeries::testXAxisRange() | |||
|
551 | { | |||
|
552 | QFETCH(std::shared_ptr<ScalarSeries>, dataSeries); | |||
|
553 | QFETCH(double, min); | |||
|
554 | QFETCH(double, max); | |||
|
555 | ||||
|
556 | QFETCH(DataContainer, expectedXAxisData); | |||
|
557 | QFETCH(DataContainer, expectedValuesData); | |||
|
558 | ||||
|
559 | auto bounds = dataSeries->xAxisRange(min, max); | |||
|
560 | validateRange(bounds.first, bounds.second, expectedXAxisData, expectedValuesData); | |||
|
561 | } | |||
|
562 | ||||
|
563 | void TestDataSeries::testValuesBoundsScalar_data() | |||
|
564 | { | |||
|
565 | testValuesBoundsStructure<ScalarSeries>(); | |||
|
566 | ||||
|
567 | // ////////// // | |||
|
568 | // Test cases // | |||
|
569 | // ////////// // | |||
|
570 | auto nan = std::numeric_limits<double>::quiet_NaN(); | |||
|
571 | ||||
|
572 | QTest::newRow("scalarBounds1") | |||
|
573 | << createScalarSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.}) << 0. << 6. | |||
|
574 | << true << 100. << 500.; | |||
|
575 | QTest::newRow("scalarBounds2") | |||
|
576 | << createScalarSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.}) << 2. << 4. | |||
|
577 | << true << 200. << 400.; | |||
|
578 | QTest::newRow("scalarBounds3") | |||
|
579 | << createScalarSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.}) << 0. << 0.5 | |||
|
580 | << false << nan << nan; | |||
|
581 | QTest::newRow("scalarBounds4") | |||
|
582 | << createScalarSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.}) << 5.1 << 6. | |||
|
583 | << false << nan << nan; | |||
|
584 | QTest::newRow("scalarBounds5") << createScalarSeries({1.}, {100.}) << 0. << 2. << true << 100. | |||
|
585 | << 100.; | |||
|
586 | QTest::newRow("scalarBounds6") << createScalarSeries({}, {}) << 0. << 2. << false << nan << nan; | |||
|
587 | ||||
|
588 | // Tests with NaN values: NaN values are not included in min/max search | |||
|
589 | QTest::newRow("scalarBounds7") | |||
|
590 | << createScalarSeries({1., 2., 3., 4., 5.}, {nan, 200., 300., 400., nan}) << 0. << 6. | |||
|
591 | << true << 200. << 400.; | |||
|
592 | QTest::newRow("scalarBounds8") | |||
|
593 | << createScalarSeries({1., 2., 3., 4., 5.}, {nan, nan, nan, nan, nan}) << 0. << 6. << true | |||
|
594 | << std::numeric_limits<double>::quiet_NaN() << std::numeric_limits<double>::quiet_NaN(); | |||
|
595 | } | |||
|
596 | ||||
|
597 | void TestDataSeries::testValuesBoundsScalar() | |||
|
598 | { | |||
|
599 | testValuesBounds<ScalarSeries>(); | |||
|
600 | } | |||
|
601 | ||||
|
602 | void TestDataSeries::testValuesBoundsVector_data() | |||
|
603 | { | |||
|
604 | testValuesBoundsStructure<VectorSeries>(); | |||
|
605 | ||||
|
606 | // ////////// // | |||
|
607 | // Test cases // | |||
|
608 | // ////////// // | |||
|
609 | auto nan = std::numeric_limits<double>::quiet_NaN(); | |||
|
610 | ||||
|
611 | QTest::newRow("vectorBounds1") | |||
|
612 | << createVectorSeries({1., 2., 3., 4., 5.}, {10., 15., 20., 13., 12.}, | |||
|
613 | {35., 24., 10., 9., 0.3}, {13., 14., 12., 9., 24.}) | |||
|
614 | << 0. << 6. << true << 0.3 << 35.; // min/max in same component | |||
|
615 | QTest::newRow("vectorBounds2") | |||
|
616 | << createVectorSeries({1., 2., 3., 4., 5.}, {2.3, 15., 20., 13., 12.}, | |||
|
617 | {35., 24., 10., 9., 4.}, {13., 14., 12., 9., 24.}) | |||
|
618 | << 0. << 6. << true << 2.3 << 35.; // min/max in same entry | |||
|
619 | QTest::newRow("vectorBounds3") | |||
|
620 | << createVectorSeries({1., 2., 3., 4., 5.}, {2.3, 15., 20., 13., 12.}, | |||
|
621 | {35., 24., 10., 9., 4.}, {13., 14., 12., 9., 24.}) | |||
|
622 | << 2. << 3. << true << 10. << 24.; | |||
|
623 | ||||
|
624 | // Tests with NaN values: NaN values are not included in min/max search | |||
|
625 | QTest::newRow("vectorBounds4") | |||
|
626 | << createVectorSeries({1., 2.}, {nan, nan}, {nan, nan}, {nan, nan}) << 0. << 6. << true | |||
|
627 | << nan << nan; | |||
|
628 | } | |||
|
629 | ||||
|
630 | void TestDataSeries::testValuesBoundsVector() | |||
|
631 | { | |||
|
632 | testValuesBounds<VectorSeries>(); | |||
|
633 | } | |||
|
634 | ||||
|
635 | QTEST_MAIN(TestDataSeries) | |||
|
636 | #include "TestDataSeries.moc" |
@@ -89,8 +89,9 using default_copier_t = typename default_copier<T>::type; | |||||
89 |
|
89 | |||
90 | template <class T, class D, class C> |
|
90 | template <class T, class D, class C> | |
91 | struct is_default_manageable |
|
91 | struct is_default_manageable | |
92 |
: public std::integral_constant<bool, |
|
92 | : public std::integral_constant<bool, | |
93 |
|
|
93 | std::is_same<D, default_deleter_t<T> >::value | |
|
94 | && std::is_same<C, default_copier_t<T> >::value> { | |||
94 | }; |
|
95 | }; | |
95 | } |
|
96 | } | |
96 |
|
97 | |||
@@ -131,10 +132,11 public: | |||||
131 | } |
|
132 | } | |
132 |
|
133 | |||
133 | template <class U> |
|
134 | template <class U> | |
134 | impl_ptr(U *u, typename std::enable_if<std::is_convertible<U *, pointer>::value |
|
135 | impl_ptr(U *u, | |
135 | && is_default_manageable::value, |
|
136 | typename std::enable_if<std::is_convertible<U *, pointer>::value | |
136 |
|
|
137 | && is_default_manageable::value, | |
137 | = dummy_t_()) SPIMPL_NOEXCEPT |
|
138 | dummy_t_>::type | |
|
139 | = dummy_t_()) SPIMPL_NOEXCEPT | |||
138 | : impl_ptr(u, &details::default_delete<T>, &details::default_copy<T>) |
|
140 | : impl_ptr(u, &details::default_delete<T>, &details::default_copy<T>) | |
139 | { |
|
141 | { | |
140 | } |
|
142 | } | |
@@ -151,12 +153,12 public: | |||||
151 |
|
153 | |||
152 | #ifdef SPIMPL_HAS_AUTO_PTR |
|
154 | #ifdef SPIMPL_HAS_AUTO_PTR | |
153 | template <class U> |
|
155 | template <class U> | |
154 | impl_ptr(std::auto_ptr<U> &&u, typename std::enable_if<std::is_convertible<U *, pointer>::value |
|
156 | impl_ptr(std::auto_ptr<U> &&u, | |
155 | && is_default_manageable::value, |
|
157 | typename std::enable_if<std::is_convertible<U *, pointer>::value | |
156 |
|
|
158 | && is_default_manageable::value, | |
157 |
|
|
159 | dummy_t_>::type | |
158 | : ptr_(u.release(), &details::default_delete<T>), |
|
160 | = dummy_t_()) SPIMPL_NOEXCEPT : ptr_(u.release(), &details::default_delete<T>), | |
159 | copier_(&details::default_copy<T>) |
|
161 | copier_(&details::default_copy<T>) | |
160 | { |
|
162 | { | |
161 | } |
|
163 | } | |
162 | #endif |
|
164 | #endif |
@@ -49,14 +49,14 public: | |||||
49 | DataSourceController::DataSourceController(QObject *parent) |
|
49 | DataSourceController::DataSourceController(QObject *parent) | |
50 | : impl{spimpl::make_unique_impl<DataSourceControllerPrivate>()} |
|
50 | : impl{spimpl::make_unique_impl<DataSourceControllerPrivate>()} | |
51 | { |
|
51 | { | |
52 |
qCDebug(LOG_DataSourceController()) |
|
52 | qCDebug(LOG_DataSourceController()) | |
53 | << QThread::currentThread(); |
|
53 | << tr("DataSourceController construction") << QThread::currentThread(); | |
54 | } |
|
54 | } | |
55 |
|
55 | |||
56 | DataSourceController::~DataSourceController() |
|
56 | DataSourceController::~DataSourceController() | |
57 | { |
|
57 | { | |
58 |
qCDebug(LOG_DataSourceController()) |
|
58 | qCDebug(LOG_DataSourceController()) | |
59 | << QThread::currentThread(); |
|
59 | << tr("DataSourceController destruction") << QThread::currentThread(); | |
60 | this->waitForFinish(); |
|
60 | this->waitForFinish(); | |
61 | } |
|
61 | } | |
62 |
|
62 | |||
@@ -126,8 +126,8 void DataSourceController::loadProductItem(const QUuid &dataSourceUid, | |||||
126 |
|
126 | |||
127 | void DataSourceController::initialize() |
|
127 | void DataSourceController::initialize() | |
128 | { |
|
128 | { | |
129 |
qCDebug(LOG_DataSourceController()) |
|
129 | qCDebug(LOG_DataSourceController()) | |
130 | << QThread::currentThread(); |
|
130 | << tr("DataSourceController init") << QThread::currentThread(); | |
131 | impl->m_WorkingMutex.lock(); |
|
131 | impl->m_WorkingMutex.lock(); | |
132 | qCDebug(LOG_DataSourceController()) << tr("DataSourceController init END"); |
|
132 | qCDebug(LOG_DataSourceController()) << tr("DataSourceController init END"); | |
133 | } |
|
133 | } |
@@ -33,8 +33,8 NetworkController::NetworkController(QObject *parent) | |||||
33 | void NetworkController::onProcessRequested(const QNetworkRequest &request, QUuid identifier, |
|
33 | void NetworkController::onProcessRequested(const QNetworkRequest &request, QUuid identifier, | |
34 | std::function<void(QNetworkReply *, QUuid)> callback) |
|
34 | std::function<void(QNetworkReply *, QUuid)> callback) | |
35 | { |
|
35 | { | |
36 |
qCDebug(LOG_NetworkController()) |
|
36 | qCDebug(LOG_NetworkController()) | |
37 |
|
|
37 | << tr("NetworkController registered") << QThread::currentThread()->objectName(); | |
38 | auto reply = impl->m_AccessManager->get(request); |
|
38 | auto reply = impl->m_AccessManager->get(request); | |
39 |
|
39 | |||
40 | // Store the couple reply id |
|
40 | // Store the couple reply id | |
@@ -44,8 +44,8 void NetworkController::onProcessRequested(const QNetworkRequest &request, QUuid | |||||
44 |
|
44 | |||
45 | auto onReplyFinished = [reply, this, identifier, callback]() { |
|
45 | auto onReplyFinished = [reply, this, identifier, callback]() { | |
46 |
|
46 | |||
47 |
qCDebug(LOG_NetworkController()) |
|
47 | qCDebug(LOG_NetworkController()) | |
48 |
|
|
48 | << tr("NetworkController onReplyFinished") << QThread::currentThread() << reply; | |
49 | impl->lockRead(); |
|
49 | impl->lockRead(); | |
50 | auto it = impl->m_NetworkReplyToVariableId.find(reply); |
|
50 | auto it = impl->m_NetworkReplyToVariableId.find(reply); | |
51 | impl->unlock(); |
|
51 | impl->unlock(); | |
@@ -60,8 +60,8 void NetworkController::onProcessRequested(const QNetworkRequest &request, QUuid | |||||
60 | emit this->replyDownloadProgress(identifier, 0); |
|
60 | emit this->replyDownloadProgress(identifier, 0); | |
61 | } |
|
61 | } | |
62 |
|
62 | |||
63 |
qCDebug(LOG_NetworkController()) |
|
63 | qCDebug(LOG_NetworkController()) | |
64 |
|
|
64 | << tr("NetworkController onReplyFinished END") << QThread::currentThread() << reply; | |
65 | }; |
|
65 | }; | |
66 |
|
66 | |||
67 | auto onReplyProgress = [reply, this](qint64 bytesRead, qint64 totalBytes) { |
|
67 | auto onReplyProgress = [reply, this](qint64 bytesRead, qint64 totalBytes) { | |
@@ -75,8 +75,8 void NetworkController::onProcessRequested(const QNetworkRequest &request, QUuid | |||||
75 | if (it != impl->m_NetworkReplyToVariableId.cend()) { |
|
75 | if (it != impl->m_NetworkReplyToVariableId.cend()) { | |
76 | emit this->replyDownloadProgress(it->second, progress); |
|
76 | emit this->replyDownloadProgress(it->second, progress); | |
77 | } |
|
77 | } | |
78 |
qCDebug(LOG_NetworkController()) |
|
78 | qCDebug(LOG_NetworkController()) | |
79 |
|
|
79 | << tr("NetworkController onReplyProgress END") << QThread::currentThread() << reply; | |
80 | }; |
|
80 | }; | |
81 |
|
81 | |||
82 |
|
82 | |||
@@ -113,8 +113,8 void NetworkController::finalize() | |||||
113 | void NetworkController::onReplyCanceled(QUuid identifier) |
|
113 | void NetworkController::onReplyCanceled(QUuid identifier) | |
114 | { |
|
114 | { | |
115 | auto findReply = [identifier](const auto &entry) { return identifier == entry.second; }; |
|
115 | auto findReply = [identifier](const auto &entry) { return identifier == entry.second; }; | |
116 |
qCDebug(LOG_NetworkController()) |
|
116 | qCDebug(LOG_NetworkController()) | |
117 | << QThread::currentThread(); |
|
117 | << tr("NetworkController onReplyCanceled") << QThread::currentThread(); | |
118 |
|
118 | |||
119 |
|
119 | |||
120 | impl->lockRead(); |
|
120 | impl->lockRead(); | |
@@ -124,8 +124,8 void NetworkController::onReplyCanceled(QUuid identifier) | |||||
124 | if (it != end) { |
|
124 | if (it != end) { | |
125 | it->first->abort(); |
|
125 | it->first->abort(); | |
126 | } |
|
126 | } | |
127 |
qCDebug(LOG_NetworkController()) |
|
127 | qCDebug(LOG_NetworkController()) | |
128 | << QThread::currentThread(); |
|
128 | << tr("NetworkController onReplyCanceled END") << QThread::currentThread(); | |
129 | } |
|
129 | } | |
130 |
|
130 | |||
131 | void NetworkController::waitForFinish() |
|
131 | void NetworkController::waitForFinish() |
@@ -263,8 +263,8 QVector<SqpRange> Variable::provideNotInCacheRangeList(const SqpRange &range) co | |||||
263 | notInCache << SqpRange{impl->m_CacheRange.m_TEnd, range.m_TEnd}; |
|
263 | notInCache << SqpRange{impl->m_CacheRange.m_TEnd, range.m_TEnd}; | |
264 | } |
|
264 | } | |
265 | else { |
|
265 | else { | |
266 |
qCCritical(LOG_Variable()) |
|
266 | qCCritical(LOG_Variable()) | |
267 |
|
|
267 | << tr("Detection of unknown case.") << QThread::currentThread(); | |
268 | } |
|
268 | } | |
269 | } |
|
269 | } | |
270 |
|
270 | |||
@@ -298,8 +298,8 QVector<SqpRange> Variable::provideInCacheRangeList(const SqpRange &range) const | |||||
298 | inCache << impl->m_CacheRange; |
|
298 | inCache << impl->m_CacheRange; | |
299 | } |
|
299 | } | |
300 | else { |
|
300 | else { | |
301 |
qCCritical(LOG_Variable()) |
|
301 | qCCritical(LOG_Variable()) | |
302 |
|
|
302 | << tr("Detection of unknown case.") << QThread::currentThread(); | |
303 | } |
|
303 | } | |
304 | } |
|
304 | } | |
305 |
|
305 |
@@ -40,8 +40,8 VariableAcquisitionWorker::VariableAcquisitionWorker(QObject *parent) | |||||
40 |
|
40 | |||
41 | VariableAcquisitionWorker::~VariableAcquisitionWorker() |
|
41 | VariableAcquisitionWorker::~VariableAcquisitionWorker() | |
42 | { |
|
42 | { | |
43 |
qCInfo(LOG_VariableAcquisitionWorker()) |
|
43 | qCInfo(LOG_VariableAcquisitionWorker()) | |
44 | << QThread::currentThread(); |
|
44 | << tr("VariableAcquisitionWorker destruction") << QThread::currentThread(); | |
45 | this->waitForFinish(); |
|
45 | this->waitForFinish(); | |
46 | } |
|
46 | } | |
47 |
|
47 | |||
@@ -113,8 +113,8 void VariableAcquisitionWorker::onVariableDataAcquired(QUuid acqIdentifier, | |||||
113 | std::shared_ptr<IDataSeries> dataSeries, |
|
113 | std::shared_ptr<IDataSeries> dataSeries, | |
114 | SqpRange dataRangeAcquired) |
|
114 | SqpRange dataRangeAcquired) | |
115 | { |
|
115 | { | |
116 |
qCDebug(LOG_VariableAcquisitionWorker()) |
|
116 | qCDebug(LOG_VariableAcquisitionWorker()) | |
117 | << acqIdentifier << dataRangeAcquired; |
|
117 | << tr("onVariableDataAcquired on range ") << acqIdentifier << dataRangeAcquired; | |
118 | impl->lockWrite(); |
|
118 | impl->lockWrite(); | |
119 | auto aIdToARit = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier); |
|
119 | auto aIdToARit = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier); | |
120 | if (aIdToARit != impl->m_AcqIdentifierToAcqRequestMap.cend()) { |
|
120 | if (aIdToARit != impl->m_AcqIdentifierToAcqRequestMap.cend()) { | |
@@ -186,8 +186,8 void VariableAcquisitionWorker::onVariableDataAcquired(QUuid acqIdentifier, | |||||
186 |
|
186 | |||
187 | void VariableAcquisitionWorker::initialize() |
|
187 | void VariableAcquisitionWorker::initialize() | |
188 | { |
|
188 | { | |
189 |
qCDebug(LOG_VariableAcquisitionWorker()) |
|
189 | qCDebug(LOG_VariableAcquisitionWorker()) | |
190 | << QThread::currentThread(); |
|
190 | << tr("VariableAcquisitionWorker init") << QThread::currentThread(); | |
191 | impl->m_WorkingMutex.lock(); |
|
191 | impl->m_WorkingMutex.lock(); | |
192 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("VariableAcquisitionWorker init END"); |
|
192 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("VariableAcquisitionWorker init END"); | |
193 | } |
|
193 | } |
@@ -30,8 +30,8 VariableCacheController::VariableCacheController(QObject *parent) | |||||
30 | void VariableCacheController::addDateTime(std::shared_ptr<Variable> variable, |
|
30 | void VariableCacheController::addDateTime(std::shared_ptr<Variable> variable, | |
31 | const SqpRange &dateTime) |
|
31 | const SqpRange &dateTime) | |
32 | { |
|
32 | { | |
33 |
qCDebug(LOG_VariableCacheController()) |
|
33 | qCDebug(LOG_VariableCacheController()) | |
34 | << QThread::currentThread()->objectName(); |
|
34 | << "VariableCacheController::addDateTime" << QThread::currentThread()->objectName(); | |
35 | if (variable) { |
|
35 | if (variable) { | |
36 | auto findVariableIte = impl->m_VariableToSqpRangeListMap.find(variable); |
|
36 | auto findVariableIte = impl->m_VariableToSqpRangeListMap.find(variable); | |
37 | if (findVariableIte == impl->m_VariableToSqpRangeListMap.end()) { |
|
37 | if (findVariableIte == impl->m_VariableToSqpRangeListMap.end()) { | |
@@ -104,8 +104,8 VariableCacheController::provideNotInCacheDateTimeList(std::shared_ptr<Variable> | |||||
104 | QVector<SqpRange> |
|
104 | QVector<SqpRange> | |
105 | VariableCacheController::dateCacheList(std::shared_ptr<Variable> variable) const noexcept |
|
105 | VariableCacheController::dateCacheList(std::shared_ptr<Variable> variable) const noexcept | |
106 | { |
|
106 | { | |
107 |
qCDebug(LOG_VariableCacheController()) |
|
107 | qCDebug(LOG_VariableCacheController()) | |
108 | << QThread::currentThread()->objectName(); |
|
108 | << "VariableCacheController::dateCacheList" << QThread::currentThread()->objectName(); | |
109 | try { |
|
109 | try { | |
110 | return impl->m_VariableToSqpRangeListMap.at(variable); |
|
110 | return impl->m_VariableToSqpRangeListMap.at(variable); | |
111 | } |
|
111 | } | |
@@ -215,8 +215,8 void VariableCacheController::displayCache(std::shared_ptr<Variable> variable) c | |||||
215 | { |
|
215 | { | |
216 | auto variableDateTimeList = impl->m_VariableToSqpRangeListMap.find(variable); |
|
216 | auto variableDateTimeList = impl->m_VariableToSqpRangeListMap.find(variable); | |
217 | if (variableDateTimeList != impl->m_VariableToSqpRangeListMap.end()) { |
|
217 | if (variableDateTimeList != impl->m_VariableToSqpRangeListMap.end()) { | |
218 |
qCInfo(LOG_VariableCacheController()) |
|
218 | qCInfo(LOG_VariableCacheController()) | |
219 | << variableDateTimeList->second; |
|
219 | << tr("VariableCacheController::displayCache") << variableDateTimeList->second; | |
220 | } |
|
220 | } | |
221 | else { |
|
221 | else { | |
222 | qCWarning(LOG_VariableCacheController()) |
|
222 | qCWarning(LOG_VariableCacheController()) |
@@ -145,8 +145,8 struct VariableController::VariableControllerPrivate { | |||||
145 | VariableController::VariableController(QObject *parent) |
|
145 | VariableController::VariableController(QObject *parent) | |
146 | : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)} |
|
146 | : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)} | |
147 | { |
|
147 | { | |
148 |
qCDebug(LOG_VariableController()) |
|
148 | qCDebug(LOG_VariableController()) | |
149 | << QThread::currentThread(); |
|
149 | << tr("VariableController construction") << QThread::currentThread(); | |
150 |
|
150 | |||
151 | connect(impl->m_VariableModel, &VariableModel::abortProgessRequested, this, |
|
151 | connect(impl->m_VariableModel, &VariableModel::abortProgessRequested, this, | |
152 | &VariableController::onAbortProgressRequested); |
|
152 | &VariableController::onAbortProgressRequested); | |
@@ -168,8 +168,8 VariableController::VariableController(QObject *parent) | |||||
168 |
|
168 | |||
169 | VariableController::~VariableController() |
|
169 | VariableController::~VariableController() | |
170 | { |
|
170 | { | |
171 |
qCDebug(LOG_VariableController()) |
|
171 | qCDebug(LOG_VariableController()) | |
172 | << QThread::currentThread(); |
|
172 | << tr("VariableController destruction") << QThread::currentThread(); | |
173 | this->waitForFinish(); |
|
173 | this->waitForFinish(); | |
174 | } |
|
174 | } | |
175 |
|
175 | |||
@@ -292,8 +292,8 VariableController::createVariable(const QString &name, const QVariantHash &meta | |||||
292 | void VariableController::onDateTimeOnSelection(const SqpRange &dateTime) |
|
292 | void VariableController::onDateTimeOnSelection(const SqpRange &dateTime) | |
293 | { |
|
293 | { | |
294 | // TODO check synchronisation and Rescale |
|
294 | // TODO check synchronisation and Rescale | |
295 |
qCDebug(LOG_VariableController()) |
|
295 | qCDebug(LOG_VariableController()) | |
296 | << QThread::currentThread()->objectName(); |
|
296 | << "VariableController::onDateTimeOnSelection" << QThread::currentThread()->objectName(); | |
297 | auto selectedRows = impl->m_VariableSelectionModel->selectedRows(); |
|
297 | auto selectedRows = impl->m_VariableSelectionModel->selectedRows(); | |
298 | auto varRequestId = QUuid::createUuid(); |
|
298 | auto varRequestId = QUuid::createUuid(); | |
299 |
|
299 | |||
@@ -349,9 +349,9 void VariableController::onAbortProgressRequested(std::shared_ptr<Variable> vari | |||||
349 |
|
349 | |||
350 | void VariableController::onAddSynchronizationGroupId(QUuid synchronizationGroupId) |
|
350 | void VariableController::onAddSynchronizationGroupId(QUuid synchronizationGroupId) | |
351 | { |
|
351 | { | |
352 | qCDebug(LOG_VariableController()) << "TORM: VariableController::onAddSynchronizationGroupId" |
|
352 | qCDebug(LOG_VariableController()) | |
353 | << QThread::currentThread()->objectName() |
|
353 | << "TORM: VariableController::onAddSynchronizationGroupId" | |
354 | << synchronizationGroupId; |
|
354 | << QThread::currentThread()->objectName() << synchronizationGroupId; | |
355 | auto vSynchroGroup = std::make_shared<VariableSynchronizationGroup>(); |
|
355 | auto vSynchroGroup = std::make_shared<VariableSynchronizationGroup>(); | |
356 | impl->m_GroupIdToVariableSynchronizationGroupMap.insert( |
|
356 | impl->m_GroupIdToVariableSynchronizationGroupMap.insert( | |
357 | std::make_pair(synchronizationGroupId, vSynchroGroup)); |
|
357 | std::make_pair(synchronizationGroupId, vSynchroGroup)); | |
@@ -366,8 +366,8 void VariableController::onAddSynchronized(std::shared_ptr<Variable> variable, | |||||
366 | QUuid synchronizationGroupId) |
|
366 | QUuid synchronizationGroupId) | |
367 |
|
367 | |||
368 | { |
|
368 | { | |
369 |
qCDebug(LOG_VariableController()) |
|
369 | qCDebug(LOG_VariableController()) | |
370 | << synchronizationGroupId; |
|
370 | << "TORM: VariableController::onAddSynchronized" << synchronizationGroupId; | |
371 | auto varToVarIdIt = impl->m_VariableToIdentifierMap.find(variable); |
|
371 | auto varToVarIdIt = impl->m_VariableToIdentifierMap.find(variable); | |
372 | if (varToVarIdIt != impl->m_VariableToIdentifierMap.cend()) { |
|
372 | if (varToVarIdIt != impl->m_VariableToIdentifierMap.cend()) { | |
373 | auto groupIdToVSGIt |
|
373 | auto groupIdToVSGIt | |
@@ -472,8 +472,8 void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable> | |||||
472 | // Don't process already processed var |
|
472 | // Don't process already processed var | |
473 | if (!variables.contains(var)) { |
|
473 | if (!variables.contains(var)) { | |
474 | if (var != nullptr) { |
|
474 | if (var != nullptr) { | |
475 |
qCDebug(LOG_VariableController()) |
|
475 | qCDebug(LOG_VariableController()) | |
476 | << var->name(); |
|
476 | << "processRequest synchro for" << var->name(); | |
477 | auto vSyncRangeRequested = computeSynchroRangeRequested( |
|
477 | auto vSyncRangeRequested = computeSynchroRangeRequested( | |
478 | var->range(), range, groupIdToOldRangeMap.at(gId)); |
|
478 | var->range(), range, groupIdToOldRangeMap.at(gId)); | |
479 | qCDebug(LOG_VariableController()) << "synchro RR" << vSyncRangeRequested; |
|
479 | qCDebug(LOG_VariableController()) << "synchro RR" << vSyncRangeRequested; | |
@@ -550,10 +550,10 void VariableController::VariableControllerPrivate::processRequest(std::shared_p | |||||
550 | varRequest.m_RangeRequested = varStrategyRangesRequested.first; |
|
550 | varRequest.m_RangeRequested = varStrategyRangesRequested.first; | |
551 | varRequest.m_CacheRangeRequested = varStrategyRangesRequested.second; |
|
551 | varRequest.m_CacheRangeRequested = varStrategyRangesRequested.second; | |
552 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM processRequest RR ") << rangeRequested; |
|
552 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM processRequest RR ") << rangeRequested; | |
553 |
qCDebug(LOG_VariableAcquisitionWorker()) |
|
553 | qCDebug(LOG_VariableAcquisitionWorker()) | |
554 |
|
|
554 | << tr("TORM processRequest R ") << varStrategyRangesRequested.first; | |
555 |
qCDebug(LOG_VariableAcquisitionWorker()) |
|
555 | qCDebug(LOG_VariableAcquisitionWorker()) | |
556 |
|
|
556 | << tr("TORM processRequest CR ") << varStrategyRangesRequested.second; | |
557 | // store VarRequest |
|
557 | // store VarRequest | |
558 | storeVariableRequest(varId, varRequestId, varRequest); |
|
558 | storeVariableRequest(varId, varRequestId, varRequest); | |
559 |
|
559 | |||
@@ -566,8 +566,8 void VariableController::VariableControllerPrivate::processRequest(std::shared_p | |||||
566 | varProvider); |
|
566 | varProvider); | |
567 |
|
567 | |||
568 | if (!varRequestIdCanceled.isNull()) { |
|
568 | if (!varRequestIdCanceled.isNull()) { | |
569 |
qCInfo(LOG_VariableAcquisitionWorker()) |
|
569 | qCInfo(LOG_VariableAcquisitionWorker()) | |
570 |
|
|
570 | << tr("varRequestIdCanceled: ") << varRequestIdCanceled; | |
571 | cancelVariableRequest(varRequestIdCanceled); |
|
571 | cancelVariableRequest(varRequestIdCanceled); | |
572 | } |
|
572 | } | |
573 | } |
|
573 | } | |
@@ -613,8 +613,8 VariableController::VariableControllerPrivate::findVariable(QUuid vIdentifier) | |||||
613 | std::shared_ptr<IDataSeries> VariableController::VariableControllerPrivate::retrieveDataSeries( |
|
613 | std::shared_ptr<IDataSeries> VariableController::VariableControllerPrivate::retrieveDataSeries( | |
614 | const QVector<AcquisitionDataPacket> acqDataPacketVector) |
|
614 | const QVector<AcquisitionDataPacket> acqDataPacketVector) | |
615 | { |
|
615 | { | |
616 | qCDebug(LOG_VariableController()) << tr("TORM: retrieveDataSeries acqDataPacketVector size") |
|
616 | qCDebug(LOG_VariableController()) | |
617 | << acqDataPacketVector.size(); |
|
617 | << tr("TORM: retrieveDataSeries acqDataPacketVector size") << acqDataPacketVector.size(); | |
618 | std::shared_ptr<IDataSeries> dataSeries; |
|
618 | std::shared_ptr<IDataSeries> dataSeries; | |
619 | if (!acqDataPacketVector.isEmpty()) { |
|
619 | if (!acqDataPacketVector.isEmpty()) { | |
620 | dataSeries = acqDataPacketVector[0].m_DateSeries; |
|
620 | dataSeries = acqDataPacketVector[0].m_DateSeries; | |
@@ -631,8 +631,8 void VariableController::VariableControllerPrivate::registerProvider( | |||||
631 | std::shared_ptr<IDataProvider> provider) |
|
631 | std::shared_ptr<IDataProvider> provider) | |
632 | { |
|
632 | { | |
633 | if (m_ProviderSet.find(provider) == m_ProviderSet.end()) { |
|
633 | if (m_ProviderSet.find(provider) == m_ProviderSet.end()) { | |
634 |
qCDebug(LOG_VariableController()) |
|
634 | qCDebug(LOG_VariableController()) | |
635 |
|
|
635 | << tr("Registering of a new provider") << provider->objectName(); | |
636 | m_ProviderSet.insert(provider); |
|
636 | m_ProviderSet.insert(provider); | |
637 | connect(provider.get(), &IDataProvider::dataProvided, m_VariableAcquisitionWorker.get(), |
|
637 | connect(provider.get(), &IDataProvider::dataProvided, m_VariableAcquisitionWorker.get(), | |
638 | &VariableAcquisitionWorker::onVariableDataAcquired); |
|
638 | &VariableAcquisitionWorker::onVariableDataAcquired); | |
@@ -709,11 +709,11 QUuid VariableController::VariableControllerPrivate::acceptVariableRequest( | |||||
709 | << varRequestId; |
|
709 | << varRequestId; | |
710 | } |
|
710 | } | |
711 |
|
711 | |||
712 |
qCDebug(LOG_VariableController()) |
|
712 | qCDebug(LOG_VariableController()) | |
713 | << varRequestIdQueue.size(); |
|
713 | << tr("1: erase REQUEST in QUEUE ?") << varRequestIdQueue.size(); | |
714 | varRequestIdQueue.pop_front(); |
|
714 | varRequestIdQueue.pop_front(); | |
715 |
qCDebug(LOG_VariableController()) |
|
715 | qCDebug(LOG_VariableController()) | |
716 | << varRequestIdQueue.size(); |
|
716 | << tr("2: erase REQUEST in QUEUE ?") << varRequestIdQueue.size(); | |
717 | if (varRequestIdQueue.empty()) { |
|
717 | if (varRequestIdQueue.empty()) { | |
718 | m_VarIdToVarRequestIdQueueMap.erase(varId); |
|
718 | m_VarIdToVarRequestIdQueueMap.erase(varId); | |
719 | } |
|
719 | } | |
@@ -737,8 +737,8 void VariableController::VariableControllerPrivate::updateVariableRequest(QUuid | |||||
737 | (varIdToVarRequestMapIt != varIdToVarRequestMap.cend()) && processVariableUpdate; |
|
737 | (varIdToVarRequestMapIt != varIdToVarRequestMap.cend()) && processVariableUpdate; | |
738 | ++varIdToVarRequestMapIt) { |
|
738 | ++varIdToVarRequestMapIt) { | |
739 | processVariableUpdate &= varIdToVarRequestMapIt->second.m_CanUpdate; |
|
739 | processVariableUpdate &= varIdToVarRequestMapIt->second.m_CanUpdate; | |
740 |
qCDebug(LOG_VariableController()) |
|
740 | qCDebug(LOG_VariableController()) | |
741 |
|
|
741 | << tr("updateVariableRequest") << processVariableUpdate; | |
742 | } |
|
742 | } | |
743 |
|
743 | |||
744 | if (processVariableUpdate) { |
|
744 | if (processVariableUpdate) { | |
@@ -748,13 +748,13 void VariableController::VariableControllerPrivate::updateVariableRequest(QUuid | |||||
748 | auto &varRequest = varIdToVarRequestMapIt->second; |
|
748 | auto &varRequest = varIdToVarRequestMapIt->second; | |
749 | var->setRange(varRequest.m_RangeRequested); |
|
749 | var->setRange(varRequest.m_RangeRequested); | |
750 | var->setCacheRange(varRequest.m_CacheRangeRequested); |
|
750 | var->setCacheRange(varRequest.m_CacheRangeRequested); | |
751 |
qCDebug(LOG_VariableController()) |
|
751 | qCDebug(LOG_VariableController()) | |
752 |
|
|
752 | << tr("1: onDataProvided") << varRequest.m_RangeRequested; | |
753 |
qCDebug(LOG_VariableController()) |
|
753 | qCDebug(LOG_VariableController()) | |
754 |
|
|
754 | << tr("2: onDataProvided") << varRequest.m_CacheRangeRequested; | |
755 | var->mergeDataSeries(varRequest.m_DataSeries); |
|
755 | var->mergeDataSeries(varRequest.m_DataSeries); | |
756 |
qCDebug(LOG_VariableController()) |
|
756 | qCDebug(LOG_VariableController()) | |
757 |
|
|
757 | << tr("3: onDataProvided") << varRequest.m_DataSeries->range(); | |
758 | qCDebug(LOG_VariableController()) << tr("4: onDataProvided"); |
|
758 | qCDebug(LOG_VariableController()) << tr("4: onDataProvided"); | |
759 |
|
759 | |||
760 | /// @todo MPL: confirm |
|
760 | /// @todo MPL: confirm | |
@@ -770,11 +770,11 void VariableController::VariableControllerPrivate::updateVariableRequest(QUuid | |||||
770 | } |
|
770 | } | |
771 |
|
771 | |||
772 | // cleaning varRequestId |
|
772 | // cleaning varRequestId | |
773 |
qCDebug(LOG_VariableController()) |
|
773 | qCDebug(LOG_VariableController()) | |
774 |
|
|
774 | << tr("0: erase REQUEST in MAP ?") << m_VarRequestIdToVarIdVarRequestMap.size(); | |
775 | m_VarRequestIdToVarIdVarRequestMap.erase(varRequestId); |
|
775 | m_VarRequestIdToVarIdVarRequestMap.erase(varRequestId); | |
776 |
qCDebug(LOG_VariableController()) |
|
776 | qCDebug(LOG_VariableController()) | |
777 |
|
|
777 | << tr("1: erase REQUEST in MAP ?") << m_VarRequestIdToVarIdVarRequestMap.size(); | |
778 | } |
|
778 | } | |
779 | } |
|
779 | } | |
780 | else { |
|
780 | else { |
@@ -18,21 +18,21 public: | |||||
18 | VisualizationController::VisualizationController(QObject *parent) |
|
18 | VisualizationController::VisualizationController(QObject *parent) | |
19 | : impl{spimpl::make_unique_impl<VisualizationControllerPrivate>()} |
|
19 | : impl{spimpl::make_unique_impl<VisualizationControllerPrivate>()} | |
20 | { |
|
20 | { | |
21 |
qCDebug(LOG_VisualizationController()) |
|
21 | qCDebug(LOG_VisualizationController()) | |
22 | << QThread::currentThread(); |
|
22 | << tr("VisualizationController construction") << QThread::currentThread(); | |
23 | } |
|
23 | } | |
24 |
|
24 | |||
25 | VisualizationController::~VisualizationController() |
|
25 | VisualizationController::~VisualizationController() | |
26 | { |
|
26 | { | |
27 |
qCDebug(LOG_VisualizationController()) |
|
27 | qCDebug(LOG_VisualizationController()) | |
28 | << QThread::currentThread(); |
|
28 | << tr("VisualizationController destruction") << QThread::currentThread(); | |
29 | this->waitForFinish(); |
|
29 | this->waitForFinish(); | |
30 | } |
|
30 | } | |
31 |
|
31 | |||
32 | void VisualizationController::initialize() |
|
32 | void VisualizationController::initialize() | |
33 | { |
|
33 | { | |
34 |
qCDebug(LOG_VisualizationController()) |
|
34 | qCDebug(LOG_VisualizationController()) | |
35 | << QThread::currentThread(); |
|
35 | << tr("VisualizationController init") << QThread::currentThread(); | |
36 | impl->m_WorkingMutex.lock(); |
|
36 | impl->m_WorkingMutex.lock(); | |
37 | qCDebug(LOG_VisualizationController()) << tr("VisualizationController init END"); |
|
37 | qCDebug(LOG_VisualizationController()) << tr("VisualizationController init END"); | |
38 | } |
|
38 | } |
@@ -581,8 +581,8 void TestDataSeries::testValuesBoundsScalar_data() | |||||
581 | QTest::newRow("scalarBounds4") |
|
581 | QTest::newRow("scalarBounds4") | |
582 | << createScalarSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.}) << 5.1 << 6. |
|
582 | << createScalarSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.}) << 5.1 << 6. | |
583 | << false << nan << nan; |
|
583 | << false << nan << nan; | |
584 | QTest::newRow("scalarBounds5") << createScalarSeries({1.}, {100.}) << 0. << 2. << true << 100. |
|
584 | QTest::newRow("scalarBounds5") | |
585 | << 100.; |
|
585 | << createScalarSeries({1.}, {100.}) << 0. << 2. << true << 100. << 100.; | |
586 | QTest::newRow("scalarBounds6") << createScalarSeries({}, {}) << 0. << 2. << false << nan << nan; |
|
586 | QTest::newRow("scalarBounds6") << createScalarSeries({}, {}) << 0. << 2. << false << nan << nan; | |
587 |
|
587 | |||
588 | // Tests with NaN values: NaN values are not included in min/max search |
|
588 | // Tests with NaN values: NaN values are not included in min/max search |
@@ -267,9 +267,9 void VisualizationGraphWidget::onGraphMenuRequested(const QPoint &pos) noexcept | |||||
267 |
|
267 | |||
268 | void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange &t2) |
|
268 | void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange &t2) | |
269 | { |
|
269 | { | |
270 |
qCDebug(LOG_VisualizationGraphWidget()) |
|
270 | qCDebug(LOG_VisualizationGraphWidget()) | |
271 | << QThread::currentThread()->objectName() << "DoAcqui" |
|
271 | << tr("TORM: VisualizationGraphWidget::onRangeChanged") | |
272 | << impl->m_DoAcquisition; |
|
272 | << QThread::currentThread()->objectName() << "DoAcqui" << impl->m_DoAcquisition; | |
273 |
|
273 | |||
274 | auto graphRange = SqpRange{t1.lower, t1.upper}; |
|
274 | auto graphRange = SqpRange{t1.lower, t1.upper}; | |
275 | auto oldGraphRange = SqpRange{t2.lower, t2.upper}; |
|
275 | auto oldGraphRange = SqpRange{t2.lower, t2.upper}; |
@@ -127,10 +127,10 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<V | |||||
127 | graphChildRange.m_TStart += deltaLeft; |
|
127 | graphChildRange.m_TStart += deltaLeft; | |
128 | graphChildRange.m_TEnd -= deltaRight; |
|
128 | graphChildRange.m_TEnd -= deltaRight; | |
129 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: ZoomIn"); |
|
129 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: ZoomIn"); | |
130 |
qCDebug(LOG_VisualizationZoneWidget()) |
|
130 | qCDebug(LOG_VisualizationZoneWidget()) | |
131 | << deltaLeft; |
|
131 | << tr("TORM: deltaLeft") << deltaLeft; | |
132 |
qCDebug(LOG_VisualizationZoneWidget()) |
|
132 | qCDebug(LOG_VisualizationZoneWidget()) | |
133 | << deltaRight; |
|
133 | << tr("TORM: deltaRight") << deltaRight; | |
134 | qCDebug(LOG_VisualizationZoneWidget()) |
|
134 | qCDebug(LOG_VisualizationZoneWidget()) | |
135 | << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart; |
|
135 | << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart; | |
136 |
|
136 | |||
@@ -141,10 +141,10 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<V | |||||
141 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: ZoomOut"); |
|
141 | qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: ZoomOut"); | |
142 | auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart; |
|
142 | auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart; | |
143 | auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd; |
|
143 | auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd; | |
144 |
qCDebug(LOG_VisualizationZoneWidget()) |
|
144 | qCDebug(LOG_VisualizationZoneWidget()) | |
145 | << deltaLeft; |
|
145 | << tr("TORM: deltaLeft") << deltaLeft; | |
146 |
qCDebug(LOG_VisualizationZoneWidget()) |
|
146 | qCDebug(LOG_VisualizationZoneWidget()) | |
147 | << deltaRight; |
|
147 | << tr("TORM: deltaRight") << deltaRight; | |
148 | qCDebug(LOG_VisualizationZoneWidget()) |
|
148 | qCDebug(LOG_VisualizationZoneWidget()) | |
149 | << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart; |
|
149 | << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart; | |
150 | graphChildRange.m_TStart -= deltaLeft; |
|
150 | graphChildRange.m_TStart -= deltaLeft; | |
@@ -179,10 +179,10 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<V | |||||
179 | break; |
|
179 | break; | |
180 | } |
|
180 | } | |
181 | graphChild->enableAcquisition(false); |
|
181 | graphChild->enableAcquisition(false); | |
182 |
qCDebug(LOG_VisualizationZoneWidget()) |
|
182 | qCDebug(LOG_VisualizationZoneWidget()) | |
183 |
|
|
183 | << tr("TORM: Range before: ") << graphChild->graphRange(); | |
184 |
qCDebug(LOG_VisualizationZoneWidget()) |
|
184 | qCDebug(LOG_VisualizationZoneWidget()) | |
185 | << graphChildRange; |
|
185 | << tr("TORM: Range after : ") << graphChildRange; | |
186 | qCDebug(LOG_VisualizationZoneWidget()) |
|
186 | qCDebug(LOG_VisualizationZoneWidget()) | |
187 | << tr("TORM: child dt") << graphChildRange.m_TEnd - graphChildRange.m_TStart; |
|
187 | << tr("TORM: child dt") << graphChildRange.m_TEnd - graphChildRange.m_TStart; | |
188 | graphChild->setGraphRange(graphChildRange); |
|
188 | graphChild->setGraphRange(graphChildRange); |
@@ -142,14 +142,14 void TestAmdaParser::testReadJson_data() | |||||
142 | QTest::newRow("Valid file") << QStringLiteral("ValidFile1.json") << validResults1(); |
|
142 | QTest::newRow("Valid file") << QStringLiteral("ValidFile1.json") << validResults1(); | |
143 |
|
143 | |||
144 | // Invalid files |
|
144 | // Invalid files | |
145 |
QTest::newRow("Invalid file (unexisting file)") |
|
145 | QTest::newRow("Invalid file (unexisting file)") | |
146 | << invalidResults(); |
|
146 | << QStringLiteral("UnexistingFile.json") << invalidResults(); | |
147 |
QTest::newRow("Invalid file (two root objects)") |
|
147 | QTest::newRow("Invalid file (two root objects)") | |
148 | << invalidResults(); |
|
148 | << QStringLiteral("TwoRootsFile.json") << invalidResults(); | |
149 |
QTest::newRow("Invalid file (wrong root key)") |
|
149 | QTest::newRow("Invalid file (wrong root key)") | |
150 | << invalidResults(); |
|
150 | << QStringLiteral("WrongRootKey.json") << invalidResults(); | |
151 |
QTest::newRow("Invalid file (wrong root type)") |
|
151 | QTest::newRow("Invalid file (wrong root type)") | |
152 | << invalidResults(); |
|
152 | << QStringLiteral("WrongRootType.json") << invalidResults(); | |
153 | } |
|
153 | } | |
154 |
|
154 | |||
155 | void TestAmdaParser::testReadJson() |
|
155 | void TestAmdaParser::testReadJson() |
@@ -229,11 +229,11 void TestAmdaResultParser::testReadScalarTxt_data() | |||||
229 | QVector<QDateTime>{}, QVector<double>{}}; |
|
229 | QVector<QDateTime>{}, QVector<double>{}}; | |
230 |
|
230 | |||
231 | // Invalid files |
|
231 | // Invalid files | |
232 |
QTest::newRow("Invalid file (unexisting file)") |
|
232 | QTest::newRow("Invalid file (unexisting file)") | |
233 | << ExpectedResults<ScalarSeries>{}; |
|
233 | << QStringLiteral("UnexistingFile.txt") << ExpectedResults<ScalarSeries>{}; | |
234 |
|
234 | |||
235 |
QTest::newRow("Invalid file (file not found on server)") |
|
235 | QTest::newRow("Invalid file (file not found on server)") | |
236 | << ExpectedResults<ScalarSeries>{}; |
|
236 | << QStringLiteral("FileNotFound.txt") << ExpectedResults<ScalarSeries>{}; | |
237 | } |
|
237 | } | |
238 |
|
238 | |||
239 | void TestAmdaResultParser::testReadScalarTxt() |
|
239 | void TestAmdaResultParser::testReadScalarTxt() |
@@ -24,7 +24,7 std::shared_ptr<IDataSeries> CosinusProvider::retrieveData(QUuid acqIdentifier, | |||||
24 | auto dataIndex = 0; |
|
24 | auto dataIndex = 0; | |
25 |
|
25 | |||
26 | // Gets the timerange from the parameters |
|
26 | // Gets the timerange from the parameters | |
27 |
double freq = 1 |
|
27 | double freq = 1.0; | |
28 | double start = std::ceil(dataRangeRequested.m_TStart * freq); // 100 htz |
|
28 | double start = std::ceil(dataRangeRequested.m_TStart * freq); // 100 htz | |
29 | double end = std::floor(dataRangeRequested.m_TEnd * freq); // 100 htz |
|
29 | double end = std::floor(dataRangeRequested.m_TEnd * freq); // 100 htz | |
30 |
|
30 | |||
@@ -79,8 +79,8 void CosinusProvider::requestDataLoading(QUuid acqIdentifier, | |||||
79 | { |
|
79 | { | |
80 | // TODO: Add Mutex |
|
80 | // TODO: Add Mutex | |
81 | m_VariableToEnableProvider[acqIdentifier] = true; |
|
81 | m_VariableToEnableProvider[acqIdentifier] = true; | |
82 | qCDebug(LOG_CosinusProvider()) << "TORM: CosinusProvider::requestDataLoading" |
|
82 | qCDebug(LOG_CosinusProvider()) | |
83 |
|
|
83 | << "TORM: CosinusProvider::requestDataLoading" << QThread::currentThread()->objectName(); | |
84 | // NOTE: Try to use multithread if possible |
|
84 | // NOTE: Try to use multithread if possible | |
85 | const auto times = parameters.m_Times; |
|
85 | const auto times = parameters.m_Times; | |
86 |
|
86 |
General Comments 0
You need to be logged in to leave comments.
Login now