@@ -28,8 +28,6 struct AcquisitionRequest { | |||
|
28 | 28 | QUuid m_AcqIdentifier; |
|
29 | 29 | QUuid m_vIdentifier; |
|
30 | 30 | DataProviderParameters m_DataProviderParameters; |
|
31 | SqpRange m_RangeRequested; | |
|
32 | SqpRange m_CacheRangeRequested; | |
|
33 | 31 | int m_Size; |
|
34 | 32 | int m_Progression; |
|
35 | 33 | std::shared_ptr<IDataProvider> m_Provider; |
@@ -28,8 +28,8 public: | |||
|
28 | 28 | explicit VariableAcquisitionWorker(QObject *parent = 0); |
|
29 | 29 | virtual ~VariableAcquisitionWorker(); |
|
30 | 30 | |
|
31 |
QUuid pushVariableRequest(QUuid varRequestId, QUuid vIdentifier, |
|
|
32 |
|
|
|
31 | QUuid pushVariableRequest(QUuid varRequestId, QUuid vIdentifier, | |
|
32 | DataProviderParameters parameters, | |
|
33 | 33 | std::shared_ptr<IDataProvider> provider); |
|
34 | 34 | |
|
35 | 35 | void abortProgressRequested(QUuid vIdentifier); |
@@ -37,9 +37,7 public: | |||
|
37 | 37 | void initialize(); |
|
38 | 38 | void finalize(); |
|
39 | 39 | signals: |
|
40 |
void dataProvided(QUuid vIdentifier, |
|
|
41 | const SqpRange &cacheRangeRequested, | |
|
42 | QVector<AcquisitionDataPacket> dataAcquired); | |
|
40 | void dataProvided(QUuid vIdentifier, QVector<AcquisitionDataPacket> dataAcquired); | |
|
43 | 41 | |
|
44 | 42 | void variableRequestInProgress(QUuid vIdentifier, double progress); |
|
45 | 43 |
@@ -112,9 +112,7 public slots: | |||
|
112 | 112 | void onUpdateDateTime(std::shared_ptr<Variable> variable, const SqpRange &dateTime); |
|
113 | 113 | |
|
114 | 114 | |
|
115 |
void onDataProvided(QUuid vIdentifier, |
|
|
116 | const SqpRange &cacheRangeRequested, | |
|
117 | QVector<AcquisitionDataPacket> dataAcquired); | |
|
115 | void onDataProvided(QUuid vIdentifier, QVector<AcquisitionDataPacket> dataAcquired); | |
|
118 | 116 | |
|
119 | 117 | void onVariableRetrieveDataInProgress(QUuid identifier, double progress); |
|
120 | 118 |
@@ -29,9 +29,6 struct VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate { | |||
|
29 | 29 | |
|
30 | 30 | void removeVariableRequest(QUuid vIdentifier); |
|
31 | 31 | |
|
32 | /// Remove the current request and execute the next one if exist | |
|
33 | void updateToNextRequest(QUuid vIdentifier); | |
|
34 | ||
|
35 | 32 | /// Remove and/or abort all AcqRequest in link with varRequestId |
|
36 | 33 | void cancelVarRequest(QUuid varRequestId); |
|
37 | 34 | void removeAcqRequest(QUuid acqRequestId); |
@@ -41,7 +38,7 struct VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate { | |||
|
41 | 38 | |
|
42 | 39 | std::map<QUuid, QVector<AcquisitionDataPacket> > m_AcqIdentifierToAcqDataPacketVectorMap; |
|
43 | 40 | std::map<QUuid, AcquisitionRequest> m_AcqIdentifierToAcqRequestMap; |
|
44 |
std::map<QUuid, |
|
|
41 | std::map<QUuid, QUuid> m_VIdentifierToCurrrentAcqIdMap; | |
|
45 | 42 | VariableAcquisitionWorker *q; |
|
46 | 43 | }; |
|
47 | 44 | |
@@ -60,26 +57,23 VariableAcquisitionWorker::~VariableAcquisitionWorker() | |||
|
60 | 57 | |
|
61 | 58 | |
|
62 | 59 | QUuid VariableAcquisitionWorker::pushVariableRequest(QUuid varRequestId, QUuid vIdentifier, |
|
63 | SqpRange rangeRequested, | |
|
64 | SqpRange cacheRangeRequested, | |
|
65 | 60 | DataProviderParameters parameters, |
|
66 | 61 | std::shared_ptr<IDataProvider> provider) |
|
67 | 62 | { |
|
68 | 63 | qCDebug(LOG_VariableAcquisitionWorker()) |
|
69 |
<< tr("TORM VariableAcquisitionWorker::pushVariableRequest ") << |
|
|
64 | << tr("TORM VariableAcquisitionWorker::pushVariableRequest varRequestId: ") << varRequestId | |
|
65 | << "vId: " << vIdentifier; | |
|
70 | 66 | auto varRequestIdCanceled = QUuid(); |
|
71 | 67 | |
|
72 | 68 | // Request creation |
|
73 | 69 | auto acqRequest = AcquisitionRequest{}; |
|
74 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("PushVariableRequest ") << vIdentifier | |
|
75 | << varRequestId; | |
|
76 | 70 | acqRequest.m_VarRequestId = varRequestId; |
|
77 | 71 | acqRequest.m_vIdentifier = vIdentifier; |
|
78 | 72 | acqRequest.m_DataProviderParameters = parameters; |
|
79 | acqRequest.m_RangeRequested = rangeRequested; | |
|
80 | acqRequest.m_CacheRangeRequested = cacheRangeRequested; | |
|
81 | 73 | acqRequest.m_Size = parameters.m_Times.size(); |
|
82 | 74 | acqRequest.m_Provider = provider; |
|
75 | qCInfo(LOG_VariableAcquisitionWorker()) << tr("Add acqRequest ") << acqRequest.m_AcqIdentifier | |
|
76 | << acqRequest.m_Size; | |
|
83 | 77 | |
|
84 | 78 | |
|
85 | 79 | // Register request |
@@ -87,32 +81,31 QUuid VariableAcquisitionWorker::pushVariableRequest(QUuid varRequestId, QUuid v | |||
|
87 | 81 | impl->m_AcqIdentifierToAcqRequestMap.insert( |
|
88 | 82 | std::make_pair(acqRequest.m_AcqIdentifier, acqRequest)); |
|
89 | 83 | |
|
90 |
auto it = impl->m_VIdentifierToCurrrentAcqId |
|
|
91 |
if (it != impl->m_VIdentifierToCurrrentAcqId |
|
|
92 |
// A current request already exists, we can |
|
|
93 | auto oldAcqId = it->second.second; | |
|
84 | auto it = impl->m_VIdentifierToCurrrentAcqIdMap.find(vIdentifier); | |
|
85 | if (it != impl->m_VIdentifierToCurrrentAcqIdMap.cend()) { | |
|
86 | // A current request already exists, we can cancel it | |
|
87 | // remove old acqIdentifier from the worker | |
|
88 | auto oldAcqId = it->second; | |
|
94 | 89 | auto acqIdentifierToAcqRequestMapIt = impl->m_AcqIdentifierToAcqRequestMap.find(oldAcqId); |
|
95 | 90 | if (acqIdentifierToAcqRequestMapIt != impl->m_AcqIdentifierToAcqRequestMap.cend()) { |
|
96 | 91 | auto oldAcqRequest = acqIdentifierToAcqRequestMapIt->second; |
|
97 | 92 | varRequestIdCanceled = oldAcqRequest.m_VarRequestId; |
|
98 | 93 | } |
|
99 | ||
|
100 | it->second.second = acqRequest.m_AcqIdentifier; | |
|
101 | 94 | impl->unlock(); |
|
102 | ||
|
103 | // remove old acqIdentifier from the worker | |
|
104 | 95 | impl->cancelVarRequest(varRequestIdCanceled); |
|
105 | // impl->m_AcqIdentifierToAcqRequestMap.erase(oldAcqId); | |
|
106 | 96 | } |
|
107 | 97 | else { |
|
108 | // First request for the variable, it must be stored and executed | |
|
109 | impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.insert( | |
|
110 | std::make_pair(vIdentifier, std::make_pair(acqRequest.m_AcqIdentifier, QUuid()))); | |
|
98 | impl->unlock(); | |
|
99 | } | |
|
100 | ||
|
101 | // Request for the variable, it must be stored and executed | |
|
102 | impl->lockWrite(); | |
|
103 | impl->m_VIdentifierToCurrrentAcqIdMap.insert( | |
|
104 | std::make_pair(vIdentifier, acqRequest.m_AcqIdentifier)); | |
|
111 | 105 |
|
|
112 | 106 | |
|
113 | 107 |
|
|
114 | 108 |
|
|
115 | } | |
|
116 | 109 | |
|
117 | 110 | return varRequestIdCanceled; |
|
118 | 111 | } |
@@ -121,18 +114,15 void VariableAcquisitionWorker::abortProgressRequested(QUuid vIdentifier) | |||
|
121 | 114 | { |
|
122 | 115 | impl->lockRead(); |
|
123 | 116 | |
|
124 |
auto it = impl->m_VIdentifierToCurrrentAcqId |
|
|
125 |
if (it != impl->m_VIdentifierToCurrrentAcqId |
|
|
126 |
auto currentAcqId = it->second |
|
|
117 | auto it = impl->m_VIdentifierToCurrrentAcqIdMap.find(vIdentifier); | |
|
118 | if (it != impl->m_VIdentifierToCurrrentAcqIdMap.cend()) { | |
|
119 | auto currentAcqId = it->second; | |
|
127 | 120 | |
|
128 | 121 | auto it = impl->m_AcqIdentifierToAcqRequestMap.find(currentAcqId); |
|
129 | 122 | if (it != impl->m_AcqIdentifierToAcqRequestMap.cend()) { |
|
130 | 123 | auto request = it->second; |
|
131 | 124 | impl->unlock(); |
|
132 | 125 | |
|
133 | // Remove the current request from the worker | |
|
134 | impl->updateToNextRequest(vIdentifier); | |
|
135 | ||
|
136 | 126 | // notify the request aborting to the provider |
|
137 | 127 | request.m_Provider->requestDataAborting(currentAcqId); |
|
138 | 128 | } |
@@ -151,22 +141,29 void VariableAcquisitionWorker::onVariableRetrieveDataInProgress(QUuid acqIdenti | |||
|
151 | 141 | double progress) |
|
152 | 142 | { |
|
153 | 143 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM: onVariableRetrieveDataInProgress ") |
|
144 | << QThread::currentThread()->objectName() | |
|
154 | 145 | << acqIdentifier << progress; |
|
155 | 146 | impl->lockRead(); |
|
156 | 147 | auto aIdToARit = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier); |
|
157 | 148 | if (aIdToARit != impl->m_AcqIdentifierToAcqRequestMap.cend()) { |
|
158 | auto currentPartSize = (aIdToARit->second.m_Size != 0) ? 100 / aIdToARit->second.m_Size : 0; | |
|
149 | auto progressPartSize | |
|
150 | = (aIdToARit->second.m_Size != 0) ? 100 / aIdToARit->second.m_Size : 0; | |
|
159 | 151 | |
|
160 | 152 | auto currentPartProgress |
|
161 |
= std::isnan(progress) ? 0.0 : (progress * |
|
|
162 | auto currentAlreadyProgress = aIdToARit->second.m_Progression * currentPartSize; | |
|
153 | = std::isnan(progress) ? 0.0 : (progress * progressPartSize) / 100.0; | |
|
154 | ||
|
155 | // We can only give an approximation of the currentProgression since its upgrade is async. | |
|
156 | auto currentProgression = aIdToARit->second.m_Progression; | |
|
157 | if (currentProgression == aIdToARit->second.m_Size) { | |
|
158 | currentProgression = aIdToARit->second.m_Size - 1; | |
|
159 | } | |
|
160 | ||
|
161 | auto currentAlreadyProgress = progressPartSize * currentProgression; | |
|
162 | ||
|
163 | 163 | |
|
164 | 164 | auto finalProgression = currentAlreadyProgress + currentPartProgress; |
|
165 | 165 | emit variableRequestInProgress(aIdToARit->second.m_vIdentifier, finalProgression); |
|
166 | qCDebug(LOG_VariableAcquisitionWorker()) | |
|
167 | << tr("TORM: onVariableRetrieveDataInProgress ") | |
|
168 | << QThread::currentThread()->objectName() << aIdToARit->second.m_vIdentifier | |
|
169 | << currentPartSize << currentAlreadyProgress << currentPartProgress << finalProgression; | |
|
166 | ||
|
170 | 167 | if (finalProgression == 100.0) { |
|
171 | 168 | emit variableRequestInProgress(aIdToARit->second.m_vIdentifier, 0.0); |
|
172 | 169 | } |
@@ -183,14 +180,10 void VariableAcquisitionWorker::onVariableAcquisitionFailed(QUuid acqIdentifier) | |||
|
183 | 180 | if (it != impl->m_AcqIdentifierToAcqRequestMap.cend()) { |
|
184 | 181 | auto request = it->second; |
|
185 | 182 | impl->unlock(); |
|
186 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("onVariableAcquisitionFailed") | |
|
187 | << acqIdentifier << request.m_vIdentifier | |
|
188 | << QThread::currentThread(); | |
|
189 | 183 | emit variableCanceledRequested(request.m_vIdentifier); |
|
190 | 184 | } |
|
191 | 185 | else { |
|
192 | 186 | impl->unlock(); |
|
193 | // TODO log no acqIdentifier recognized | |
|
194 | 187 | } |
|
195 | 188 | } |
|
196 | 189 | |
@@ -228,17 +221,12 void VariableAcquisitionWorker::onVariableDataAcquired(QUuid acqIdentifier, | |||
|
228 | 221 | // removed the finished request |
|
229 | 222 | if (acqRequest.m_Size == acqRequest.m_Progression) { |
|
230 | 223 | auto varId = acqRequest.m_vIdentifier; |
|
231 | auto rangeRequested = acqRequest.m_RangeRequested; | |
|
232 | auto cacheRangeRequested = acqRequest.m_CacheRangeRequested; | |
|
233 | 224 | // Return the data |
|
234 | 225 | aIdToADPVit = impl->m_AcqIdentifierToAcqDataPacketVectorMap.find(acqIdentifier); |
|
235 | 226 | if (aIdToADPVit != impl->m_AcqIdentifierToAcqDataPacketVectorMap.cend()) { |
|
236 |
emit dataProvided(varId, |
|
|
227 | emit dataProvided(varId, aIdToADPVit->second); | |
|
237 | 228 | } |
|
238 | 229 | impl->unlock(); |
|
239 | ||
|
240 | // Update to the next request | |
|
241 | impl->updateToNextRequest(acqRequest.m_vIdentifier); | |
|
242 | 230 | } |
|
243 | 231 | else { |
|
244 | 232 | impl->unlock(); |
@@ -260,6 +248,8 void VariableAcquisitionWorker::onExecuteRequest(QUuid acqIdentifier) | |||
|
260 | 248 | auto request = it->second; |
|
261 | 249 | impl->unlock(); |
|
262 | 250 | emit variableRequestInProgress(request.m_vIdentifier, 0.1); |
|
251 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("Start request 10%") << acqIdentifier | |
|
252 | << QThread::currentThread(); | |
|
263 | 253 | request.m_Provider->requestDataLoading(acqIdentifier, request.m_DataProviderParameters); |
|
264 | 254 | } |
|
265 | 255 | else { |
@@ -290,61 +280,30 void VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate::removeVariable | |||
|
290 | 280 | QUuid vIdentifier) |
|
291 | 281 | { |
|
292 | 282 | lockWrite(); |
|
293 |
auto it = m_VIdentifierToCurrrentAcqId |
|
|
283 | auto it = m_VIdentifierToCurrrentAcqIdMap.find(vIdentifier); | |
|
294 | 284 | |
|
295 |
if (it != m_VIdentifierToCurrrentAcqId |
|
|
285 | if (it != m_VIdentifierToCurrrentAcqIdMap.cend()) { | |
|
296 | 286 | // A current request already exists, we can replace the next one |
|
297 | 287 | |
|
298 | m_AcqIdentifierToAcqRequestMap.erase(it->second.first); | |
|
299 | m_AcqIdentifierToAcqDataPacketVectorMap.erase(it->second.first); | |
|
300 | ||
|
301 |
m_AcqIdentifierToAcqRequestMap.erase(it->second |
|
|
302 |
m_AcqIdentifierToAcqDataPacketVectorMap.erase(it->second |
|
|
303 | } | |
|
304 | m_VIdentifierToCurrrentAcqIdNextIdPairMap.erase(vIdentifier); | |
|
305 | unlock(); | |
|
288 | qCDebug(LOG_VariableAcquisitionWorker()) | |
|
289 | << "VariableAcquisitionWorkerPrivate::removeVariableRequest " | |
|
290 | << QThread::currentThread()->objectName() << it->second; | |
|
291 | m_AcqIdentifierToAcqRequestMap.erase(it->second); | |
|
292 | m_AcqIdentifierToAcqDataPacketVectorMap.erase(it->second); | |
|
306 | 293 | } |
|
307 | 294 | |
|
308 | void VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate::updateToNextRequest( | |
|
309 | QUuid vIdentifier) | |
|
310 | { | |
|
311 | lockRead(); | |
|
312 | auto it = m_VIdentifierToCurrrentAcqIdNextIdPairMap.find(vIdentifier); | |
|
313 | if (it != m_VIdentifierToCurrrentAcqIdNextIdPairMap.cend()) { | |
|
314 | if (it->second.second.isNull()) { | |
|
315 | unlock(); | |
|
316 | // There is no next request, we can remove the variable request | |
|
317 | removeVariableRequest(vIdentifier); | |
|
318 | } | |
|
319 | else { | |
|
320 | auto acqIdentifierToRemove = it->second.first; | |
|
321 | // Move the next request to the current request | |
|
322 | auto nextRequestId = it->second.second; | |
|
323 | it->second.first = nextRequestId; | |
|
324 | it->second.second = QUuid(); | |
|
325 | unlock(); | |
|
326 | // Remove AcquisitionRequest and results; | |
|
327 | lockWrite(); | |
|
328 | m_AcqIdentifierToAcqRequestMap.erase(acqIdentifierToRemove); | |
|
329 | m_AcqIdentifierToAcqDataPacketVectorMap.erase(acqIdentifierToRemove); | |
|
330 | unlock(); | |
|
331 | // Execute the current request | |
|
332 | QMetaObject::invokeMethod(q, "onExecuteRequest", Qt::QueuedConnection, | |
|
333 | Q_ARG(QUuid, nextRequestId)); | |
|
334 | } | |
|
335 | } | |
|
336 | else { | |
|
295 | // stop any progression | |
|
296 | emit q->variableRequestInProgress(vIdentifier, 0.0); | |
|
297 | ||
|
298 | m_VIdentifierToCurrrentAcqIdMap.erase(vIdentifier); | |
|
337 | 299 |
|
|
338 | qCCritical(LOG_VariableAcquisitionWorker()) | |
|
339 | << tr("Impossible to execute the acquisition on an unfound variable "); | |
|
340 | } | |
|
341 | 300 | } |
|
342 | 301 | |
|
343 | 302 | void VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate::cancelVarRequest( |
|
344 | 303 | QUuid varRequestId) |
|
345 | 304 | { |
|
346 | 305 | qCDebug(LOG_VariableAcquisitionWorker()) |
|
347 |
<< "VariableAcquisitionWorkerPrivate::cancelVarRequest |
|
|
306 | << "VariableAcquisitionWorkerPrivate::cancelVarRequest start"; | |
|
348 | 307 | lockRead(); |
|
349 | 308 | // get all AcqIdentifier in link with varRequestId |
|
350 | 309 | QVector<QUuid> acqIdsToRm; |
@@ -377,22 +336,15 void VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate::removeAcqReque | |||
|
377 | 336 | vIdentifier = acqIt->second.m_vIdentifier; |
|
378 | 337 | provider = acqIt->second.m_Provider; |
|
379 | 338 | |
|
380 |
auto it = m_VIdentifierToCurrrentAcqId |
|
|
381 |
if (it != m_VIdentifierToCurrrentAcqId |
|
|
382 |
if (it->second |
|
|
339 | auto it = m_VIdentifierToCurrrentAcqIdMap.find(vIdentifier); | |
|
340 | if (it != m_VIdentifierToCurrrentAcqIdMap.cend()) { | |
|
341 | if (it->second == acqRequestId) { | |
|
383 | 342 | // acqRequest is currently running -> let's aborting it |
|
384 | 343 | unlock(); |
|
385 | 344 | |
|
386 | // Remove the current request from the worker | |
|
387 | updateToNextRequest(vIdentifier); | |
|
388 | ||
|
389 | 345 | // notify the request aborting to the provider |
|
390 | 346 | provider->requestDataAborting(acqRequestId); |
|
391 | 347 | } |
|
392 | else if (it->second.second == acqRequestId) { | |
|
393 | it->second.second = QUuid(); | |
|
394 | unlock(); | |
|
395 | } | |
|
396 | 348 | else { |
|
397 | 349 | unlock(); |
|
398 | 350 | } |
@@ -409,6 +361,7 void VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate::removeAcqReque | |||
|
409 | 361 | |
|
410 | 362 | m_AcqIdentifierToAcqDataPacketVectorMap.erase(acqRequestId); |
|
411 | 363 | m_AcqIdentifierToAcqRequestMap.erase(acqRequestId); |
|
364 | m_VIdentifierToCurrrentAcqIdMap.erase(vIdentifier); | |
|
412 | 365 | |
|
413 | 366 | unlock(); |
|
414 | 367 | qCDebug(LOG_VariableAcquisitionWorker()) |
@@ -368,11 +368,6 VariableController::createVariable(const QString &name, const QVariantHash &meta | |||
|
368 | 368 | |
|
369 | 369 | this->onRequestDataLoading(QVector<std::shared_ptr<Variable> >{newVariable}, range, false); |
|
370 | 370 | |
|
371 | // auto varRequestId = QUuid::createUuid(); | |
|
372 | // qCInfo(LOG_VariableController()) << "createVariable: " << varId << varRequestId; | |
|
373 | // impl->processRequest(newVariable, range, varRequestId); | |
|
374 | // impl->updateVariableRequest(varRequestId); | |
|
375 | ||
|
376 | 371 | emit variableAdded(newVariable); |
|
377 | 372 | |
|
378 | 373 | return newVariable; |
@@ -390,20 +385,6 void VariableController::onDateTimeOnSelection(const SqpRange &dateTime) | |||
|
390 | 385 | auto selectedRows = impl->m_VariableSelectionModel->selectedRows(); |
|
391 | 386 | |
|
392 | 387 | // NOTE we only permit the time modification for one variable |
|
393 | // DEPRECATED | |
|
394 | // auto variables = QVector<std::shared_ptr<Variable> >{}; | |
|
395 | // for (const auto &selectedRow : qAsConst(selectedRows)) { | |
|
396 | // if (auto selectedVariable = | |
|
397 | // impl->m_VariableModel->variable(selectedRow.row())) { | |
|
398 | // variables << selectedVariable; | |
|
399 | ||
|
400 | // // notify that rescale operation has to be done | |
|
401 | // emit rangeChanged(selectedVariable, dateTime); | |
|
402 | // } | |
|
403 | // } | |
|
404 | // if (!variables.isEmpty()) { | |
|
405 | // this->onRequestDataLoading(variables, dateTime, synchro); | |
|
406 | // } | |
|
407 | 388 | if (selectedRows.size() == 1) { |
|
408 | 389 | |
|
409 | 390 | if (auto selectedVariable |
@@ -441,8 +422,7 void VariableController::onUpdateDateTime(std::shared_ptr<Variable> variable, | |||
|
441 | 422 | this->onRequestDataLoading(QVector<std::shared_ptr<Variable> >{variable}, dateTime, synchro); |
|
442 | 423 | } |
|
443 | 424 | |
|
444 |
void VariableController::onDataProvided(QUuid vIdentifier, |
|
|
445 | const SqpRange &cacheRangeRequested, | |
|
425 | void VariableController::onDataProvided(QUuid vIdentifier, | |
|
446 | 426 | QVector<AcquisitionDataPacket> dataAcquired) |
|
447 | 427 | { |
|
448 | 428 | qCDebug(LOG_VariableController()) << tr("onDataProvided") << QThread::currentThread(); |
@@ -459,6 +439,8 void VariableController::onVariableRetrieveDataInProgress(QUuid identifier, doub | |||
|
459 | 439 | << "TORM: variableController::onVariableRetrieveDataInProgress" |
|
460 | 440 | << QThread::currentThread()->objectName() << progress; |
|
461 | 441 | if (auto var = impl->findVariable(identifier)) { |
|
442 | qCDebug(LOG_VariableController()) | |
|
443 | << "TORM: variableController::onVariableRetrieveDataInProgress FOUND"; | |
|
462 | 444 | impl->m_VariableModel->setDataProgress(var, progress); |
|
463 | 445 | } |
|
464 | 446 | else { |
@@ -590,7 +572,7 void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable> | |||
|
590 | 572 | } |
|
591 | 573 | impl->m_VarGroupIdToVarIds.insert(std::make_pair(varRequestId, varIds)); |
|
592 | 574 | for (const auto &var : variables) { |
|
593 |
qCDebug(LOG_VariableController()) << " |
|
|
575 | qCDebug(LOG_VariableController()) << "onRequestDataLoading: for" << varRequestId | |
|
594 | 576 | << varIds.size(); |
|
595 | 577 | impl->processRequest(var, range, varRequestId); |
|
596 | 578 | } |
@@ -609,6 +591,8 void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable> | |||
|
609 | 591 | for (auto vId : vSyncIds) { |
|
610 | 592 | varIds.push_back(vId); |
|
611 | 593 | } |
|
594 | qCDebug(LOG_VariableController()) << "onRequestDataLoading sync: for" << varRequestId | |
|
595 | << varIds.size(); | |
|
612 | 596 | impl->m_VarGroupIdToVarIds.insert(std::make_pair(varRequestId, varIds)); |
|
613 | 597 | |
|
614 | 598 | for (auto vId : vSyncIds) { |
@@ -850,8 +834,6 void VariableController::VariableControllerPrivate::updateVariables(QUuid varReq | |||
|
850 | 834 | auto &varIds = varGroupIdToVarIdsIt->second; |
|
851 | 835 | auto varIdsEnd = varIds.end(); |
|
852 | 836 | bool processVariableUpdate = true; |
|
853 | qCDebug(LOG_VariableController()) << "VariableControllerPrivate::updateVariables" | |
|
854 | << varRequestId << varIds.size(); | |
|
855 | 837 | for (auto varIdsIt = varIds.begin(); (varIdsIt != varIdsEnd) && processVariableUpdate; |
|
856 | 838 | ++varIdsIt) { |
|
857 | 839 | auto itVarHandler = m_VarIdToVarRequestHandler.find(*varIdsIt); |
@@ -861,7 +843,6 void VariableController::VariableControllerPrivate::updateVariables(QUuid varReq | |||
|
861 | 843 | } |
|
862 | 844 | |
|
863 | 845 | if (processVariableUpdate) { |
|
864 | qCDebug(LOG_VariableController()) << "Final update OK for the var request" << varIds.size(); | |
|
865 | 846 | for (auto varIdsIt = varIds.begin(); varIdsIt != varIdsEnd; ++varIdsIt) { |
|
866 | 847 | auto itVarHandler = m_VarIdToVarRequestHandler.find(*varIdsIt); |
|
867 | 848 | if (itVarHandler != m_VarIdToVarRequestHandler.cend()) { |
@@ -880,7 +861,6 void VariableController::VariableControllerPrivate::updateVariables(QUuid varReq | |||
|
880 | 861 | << var->nbPoints(); |
|
881 | 862 | |
|
882 | 863 | emit var->updated(); |
|
883 | qCDebug(LOG_VariableController()) << tr("Update OK"); | |
|
884 | 864 | } |
|
885 | 865 | else { |
|
886 | 866 | qCCritical(LOG_VariableController()) |
@@ -912,13 +892,22 void VariableController::VariableControllerPrivate::updateVariableRequest(QUuid | |||
|
912 | 892 | |
|
913 | 893 | auto &varIds = varGroupIdToVarIdsIt->second; |
|
914 | 894 | auto varIdsEnd = varIds.end(); |
|
895 | ||
|
896 | // First pass all canUpdate of handler to false | |
|
915 | 897 | for (auto varIdsIt = varIds.begin(); (varIdsIt != varIdsEnd); ++varIdsIt) { |
|
916 | 898 | auto itVarHandler = m_VarIdToVarRequestHandler.find(*varIdsIt); |
|
917 | 899 | if (itVarHandler != m_VarIdToVarRequestHandler.cend()) { |
|
918 | 900 | |
|
919 | 901 | auto varHandler = itVarHandler->second.get(); |
|
920 | 902 | varHandler->m_CanUpdate = false; |
|
903 | } | |
|
904 | } | |
|
905 | // Second update requests of handler | |
|
906 | for (auto varIdsIt = varIds.begin(); (varIdsIt != varIdsEnd); ++varIdsIt) { | |
|
907 | auto itVarHandler = m_VarIdToVarRequestHandler.find(*varIdsIt); | |
|
908 | if (itVarHandler != m_VarIdToVarRequestHandler.cend()) { | |
|
921 | 909 | |
|
910 | auto varHandler = itVarHandler->second.get(); | |
|
922 | 911 | |
|
923 | 912 | switch (varHandler->m_State) { |
|
924 | 913 | case VariableRequestHandlerState::OFF: { |
@@ -961,6 +950,17 void VariableController::VariableControllerPrivate::cancelVariableRequest(QUuid | |||
|
961 | 950 | |
|
962 | 951 | auto &varIds = varGroupIdToVarIdsIt->second; |
|
963 | 952 | auto varIdsEnd = varIds.end(); |
|
953 | ||
|
954 | // First pass all canUpdate of handler to false | |
|
955 | for (auto varIdsIt = varIds.begin(); (varIdsIt != varIdsEnd); ++varIdsIt) { | |
|
956 | auto itVarHandler = m_VarIdToVarRequestHandler.find(*varIdsIt); | |
|
957 | if (itVarHandler != m_VarIdToVarRequestHandler.cend()) { | |
|
958 | ||
|
959 | auto varHandler = itVarHandler->second.get(); | |
|
960 | varHandler->m_CanUpdate = false; | |
|
961 | } | |
|
962 | } | |
|
963 | ||
|
964 | 964 | for (auto varIdsIt = varIds.begin(); (varIdsIt != varIdsEnd); ++varIdsIt) { |
|
965 | 965 | auto itVarHandler = m_VarIdToVarRequestHandler.find(*varIdsIt); |
|
966 | 966 | if (itVarHandler != m_VarIdToVarRequestHandler.cend()) { |
@@ -983,7 +983,6 void VariableController::VariableControllerPrivate::cancelVariableRequest(QUuid | |||
|
983 | 983 | itVarHandler->first); |
|
984 | 984 | } |
|
985 | 985 | m_VariableModel->setDataProgress(var, 0.0); |
|
986 | varHandler->m_CanUpdate = false; | |
|
987 | 986 | varHandler->m_State = VariableRequestHandlerState::OFF; |
|
988 | 987 | varHandler->m_RunningVarRequest = VariableRequest{}; |
|
989 | 988 | } |
@@ -1002,7 +1001,6 void VariableController::VariableControllerPrivate::cancelVariableRequest(QUuid | |||
|
1002 | 1001 | itVarHandler->first); |
|
1003 | 1002 | } |
|
1004 | 1003 | m_VariableModel->setDataProgress(var, 0.0); |
|
1005 | varHandler->m_CanUpdate = false; | |
|
1006 | 1004 | varHandler->m_State = VariableRequestHandlerState::RUNNING; |
|
1007 | 1005 | varHandler->m_RunningVarRequest = varHandler->m_PendingVarRequest; |
|
1008 | 1006 | varHandler->m_PendingVarRequest = VariableRequest{}; |
@@ -1034,8 +1032,6 void VariableController::VariableControllerPrivate::cancelVariableRequest(QUuid | |||
|
1034 | 1032 | void VariableController::VariableControllerPrivate::executeVarRequest(std::shared_ptr<Variable> var, |
|
1035 | 1033 | VariableRequest &varRequest) |
|
1036 | 1034 | { |
|
1037 | qCDebug(LOG_VariableController()) << tr("TORM: executeVarRequest"); | |
|
1038 | ||
|
1039 | 1035 | auto varIdIt = m_VariableToIdentifierMap.find(var); |
|
1040 | 1036 | if (varIdIt == m_VariableToIdentifierMap.cend()) { |
|
1041 | 1037 | qCWarning(LOG_VariableController()) << tr( |
@@ -1059,8 +1055,7 void VariableController::VariableControllerPrivate::executeVarRequest(std::share | |||
|
1059 | 1055 | qCDebug(LOG_VariableController()) << "executeVarRequest " << varRequest.m_RangeRequested |
|
1060 | 1056 | << varRequest.m_CacheRangeRequested; |
|
1061 | 1057 | m_VariableAcquisitionWorker->pushVariableRequest( |
|
1062 |
varRequest.m_VariableGroupId, varId, |
|
|
1063 | varRequest.m_CacheRangeRequested, | |
|
1058 | varRequest.m_VariableGroupId, varId, | |
|
1064 | 1059 | DataProviderParameters{std::move(notInCacheRangeList), var->metadata()}, |
|
1065 | 1060 | varProvider); |
|
1066 | 1061 | } |
@@ -1074,6 +1069,8 void VariableController::VariableControllerPrivate::executeVarRequest(std::share | |||
|
1074 | 1069 | } |
|
1075 | 1070 | } |
|
1076 | 1071 | else { |
|
1072 | qCDebug(LOG_VariableController()) << "All already in the cache " | |
|
1073 | << varRequest.m_RangeRequested; | |
|
1077 | 1074 | acceptVariableRequest(varId, |
|
1078 | 1075 | var->dataSeries()->subDataSeries(varRequest.m_CacheRangeRequested)); |
|
1079 | 1076 | } |
|
1 | NO CONTENT: modified file |
@@ -135,12 +135,16 void AmdaProvider::onReplyDownloadProgress(QUuid acqIdentifier, | |||
|
135 | 135 | finalProgress = finalProgress / fraq; |
|
136 | 136 | } |
|
137 | 137 | |
|
138 |
qCDebug(LOG_AmdaProvider()) << tr(" |
|
|
138 | qCDebug(LOG_AmdaProvider()) << tr("final progress: ") | |
|
139 | << QThread::currentThread()->objectName() << acqIdentifier | |
|
140 | << fraq << finalProgress; | |
|
139 | 141 | emit dataProvidedProgress(acqIdentifier, finalProgress); |
|
140 | 142 | } |
|
141 | 143 | else { |
|
142 | 144 | // This case can happened when a progression is send after the request has been finished. |
|
143 | 145 | // Generaly the case when aborting a request |
|
146 | qCDebug(LOG_AmdaProvider()) << tr("Acquisition request not found: final progress: 100 : ") | |
|
147 | << QThread::currentThread()->objectName() << acqIdentifier; | |
|
144 | 148 | emit dataProvidedProgress(acqIdentifier, 100.0); |
|
145 | 149 | } |
|
146 | 150 | } |
@@ -169,7 +173,6 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa | |||
|
169 | 173 | QVariantHash urlProperties{{AMDA_SERVER_KEY, data.value(AMDA_SERVER_KEY)}}; |
|
170 | 174 | auto url = QUrl{QString{AMDA_URL_FORMAT}.arg(AmdaServer::instance().url(urlProperties), |
|
171 | 175 | startDate, endDate, productId)}; |
|
172 | qCInfo(LOG_AmdaProvider()) << tr("TORM AmdaProvider::retrieveData url:") << url; | |
|
173 | 176 | auto tempFile = std::make_shared<QTemporaryFile>(); |
|
174 | 177 | |
|
175 | 178 | // LAMBDA |
@@ -211,8 +214,8 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa | |||
|
211 | 214 | if (reply->error() == QNetworkReply::NoError) { |
|
212 | 215 | auto downloadFileUrl = QUrl{QString{reply->readAll()}.trimmed()}; |
|
213 | 216 | |
|
214 | qCInfo(LOG_AmdaProvider()) | |
|
215 | << tr("TORM AmdaProvider::retrieveData downloadFileUrl:") << downloadFileUrl; | |
|
217 | qCDebug(LOG_AmdaProvider()) << tr("AmdaProvider::retrieveData downloadFileUrl:") | |
|
218 | << downloadFileUrl; | |
|
216 | 219 | // Executes request for downloading file // |
|
217 | 220 | |
|
218 | 221 | // Creates destination file |
@@ -238,7 +241,6 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa | |||
|
238 | 241 | // //////////////// // |
|
239 | 242 | |
|
240 | 243 | auto request = std::make_shared<QNetworkRequest>(url); |
|
241 | qCDebug(LOG_AmdaProvider()) << tr("First Request creation") << request.get(); | |
|
242 | 244 | updateRequestProgress(token, request, 0.0); |
|
243 | 245 | |
|
244 | 246 | emit requestConstructed(request, token, httpFinishedLambda); |
@@ -247,7 +249,6 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa | |||
|
247 | 249 | void AmdaProvider::updateRequestProgress(QUuid acqIdentifier, |
|
248 | 250 | std::shared_ptr<QNetworkRequest> request, double progress) |
|
249 | 251 | { |
|
250 | qCDebug(LOG_AmdaProvider()) << tr("updateRequestProgress request") << request.get(); | |
|
251 | 252 | auto acqIdToRequestProgressMapIt = m_AcqIdToRequestProgressMap.find(acqIdentifier); |
|
252 | 253 | if (acqIdToRequestProgressMapIt != m_AcqIdToRequestProgressMap.end()) { |
|
253 | 254 | auto &requestProgressMap = acqIdToRequestProgressMapIt->second; |
@@ -13,6 +13,7 const QString PROVIDER_PROPERTY = QStringLiteral("provider"); | |||
|
13 | 13 | const QString OPERATION_DELAY_BOUNDS_PROPERTY = QStringLiteral("operationDelays"); |
|
14 | 14 | const QString VALIDATORS_PROPERTY = QStringLiteral("validators"); |
|
15 | 15 | const QString VALIDATION_FREQUENCY_BOUNDS_PROPERTY = QStringLiteral("validationFrequencyBounds"); |
|
16 | const QString CUSTOM_OPERATIONS_PROPERTY = QStringLiteral("customOperations"); | |
|
16 | 17 | |
|
17 | 18 | // //////////// // |
|
18 | 19 | // FuzzingState // |
@@ -62,6 +62,9 extern const QString VALIDATORS_PROPERTY; | |||
|
62 | 62 | /// Min/max number of operations to execute before calling validation of the current test's state |
|
63 | 63 | extern const QString VALIDATION_FREQUENCY_BOUNDS_PROPERTY; |
|
64 | 64 | |
|
65 | /// Custom operations to execute instead of random operations | |
|
66 | extern const QString CUSTOM_OPERATIONS_PROPERTY; | |
|
67 | ||
|
65 | 68 | // /////// // |
|
66 | 69 | // Structs // |
|
67 | 70 | // /////// // |
@@ -178,7 +178,7 struct SynchronizeOperation : public IFuzzingOperation { | |||
|
178 | 178 | fuzzingState.synchronizeVariable(variableId, syncGroupId); |
|
179 | 179 | |
|
180 | 180 | variableController.onRequestDataLoading({variableState.m_Variable}, variableState.m_Range, |
|
181 |
|
|
|
181 | true); | |
|
182 | 182 | } |
|
183 | 183 | }; |
|
184 | 184 |
@@ -57,6 +57,12 struct OperationProperty { | |||
|
57 | 57 | using VariableOperation = std::pair<VariableId, std::shared_ptr<IFuzzingOperation> >; |
|
58 | 58 | using VariablesOperations = std::vector<VariableOperation>; |
|
59 | 59 | |
|
60 | struct CustomVariableOperation { | |
|
61 | VariableOperation m_VariableOperation{}; | |
|
62 | bool m_WaitAcquisition{false}; | |
|
63 | }; | |
|
64 | using CustomVariablesOperations = std::vector<CustomVariableOperation>; | |
|
65 | ||
|
60 | 66 | using OperationsTypes = std::map<FuzzingOperationType, OperationProperty>; |
|
61 | 67 | using OperationsPool = std::map<std::shared_ptr<IFuzzingOperation>, OperationProperty>; |
|
62 | 68 | |
@@ -67,30 +73,150 using Validators = std::vector<std::shared_ptr<IFuzzingValidator> >; | |||
|
67 | 73 | // ///////// // |
|
68 | 74 | |
|
69 | 75 | // Defaults values used when the associated properties have not been set for the test |
|
70 |
const auto ACQUISITION_TIMEOUT_DEFAULT_VALUE = |
|
|
71 |
const auto NB_MAX_OPERATIONS_DEFAULT_VALUE = 1 |
|
|
72 |
const auto NB_MAX_SYNC_GROUPS_DEFAULT_VALUE = |
|
|
73 |
const auto NB_MAX_VARIABLES_DEFAULT_VALUE = |
|
|
76 | const auto ACQUISITION_TIMEOUT_DEFAULT_VALUE = 100000; | |
|
77 | const auto NB_MAX_OPERATIONS_DEFAULT_VALUE = 160; | |
|
78 | const auto NB_MAX_SYNC_GROUPS_DEFAULT_VALUE = 8; | |
|
79 | const auto NB_MAX_VARIABLES_DEFAULT_VALUE = 30; | |
|
74 | 80 | const auto AVAILABLE_OPERATIONS_DEFAULT_VALUE = QVariant::fromValue( |
|
75 |
OperationsTypes{{FuzzingOperationType::CREATE, { |
|
|
76 |
{FuzzingOperationType::DELETE, {0. |
|
|
81 | OperationsTypes{{FuzzingOperationType::CREATE, {40000., true}}, | |
|
82 | {FuzzingOperationType::DELETE, {0.0}}, // Delete operation is less frequent | |
|
77 | 83 | {FuzzingOperationType::PAN_LEFT, {1.}}, |
|
78 | 84 | {FuzzingOperationType::PAN_RIGHT, {1.}}, |
|
79 | 85 | {FuzzingOperationType::ZOOM_IN, {1.}}, |
|
80 | 86 | {FuzzingOperationType::ZOOM_OUT, {1.}}, |
|
81 |
{FuzzingOperationType::SYNCHRONIZE, { |
|
|
82 |
{FuzzingOperationType::DESYNCHRONIZE, {0. |
|
|
87 | {FuzzingOperationType::SYNCHRONIZE, {500.0}}, | |
|
88 | {FuzzingOperationType::DESYNCHRONIZE, {0.0}}}); | |
|
83 | 89 | const auto CACHE_TOLERANCE_DEFAULT_VALUE = 0.2; |
|
84 | 90 | |
|
85 | 91 | /// Min/max delays between each operation (in ms) |
|
86 |
const auto OPERATION_DELAY_BOUNDS_DEFAULT_VALUE = QVariant::fromValue(std::make_pair( |
|
|
92 | const auto OPERATION_DELAY_BOUNDS_DEFAULT_VALUE = QVariant::fromValue(std::make_pair(20, 3000)); | |
|
87 | 93 | |
|
88 | 94 | /// Validators for the tests (executed in the order in which they're defined) |
|
89 | 95 | const auto VALIDATORS_DEFAULT_VALUE = QVariant::fromValue( |
|
90 | 96 | ValidatorsTypes{{FuzzingValidatorType::RANGE, FuzzingValidatorType::DATA}}); |
|
91 | 97 | |
|
92 | 98 | /// Min/max number of operations to execute before calling validation |
|
93 |
const auto VALIDATION_FREQUENCY_BOUNDS_DEFAULT_VALUE = QVariant::fromValue(std::make_pair( |
|
|
99 | const auto VALIDATION_FREQUENCY_BOUNDS_DEFAULT_VALUE = QVariant::fromValue(std::make_pair(2, 10)); | |
|
100 | ||
|
101 | ||
|
102 | // /////// ////// | |
|
103 | // CUSTOM CASE // | |
|
104 | // /////// ////// | |
|
105 | ||
|
106 | auto op = [](auto type){ | |
|
107 | return FuzzingOperationFactory::create(type); | |
|
108 | }; | |
|
109 | ||
|
110 | ||
|
111 | const QVariant CUSTOM_CASE_ONE =QVariant::fromValue(CustomVariablesOperations{{{0, op(FuzzingOperationType::CREATE)}, true}, | |
|
112 | {{0, op(FuzzingOperationType::SYNCHRONIZE)}}, | |
|
113 | {{1, op(FuzzingOperationType::CREATE)}, true}, | |
|
114 | {{1, op(FuzzingOperationType::SYNCHRONIZE)}}, | |
|
115 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
116 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
117 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
118 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
119 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
120 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
121 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
122 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
123 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
124 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
125 | {{0, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
126 | {{1, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
127 | {{0, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
128 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
129 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
130 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
131 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
132 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
133 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
134 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
135 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
136 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
137 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
138 | {{1, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
139 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
140 | {{1, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
141 | {{0, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
142 | {{1, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
143 | {{0, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
144 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
145 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
146 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
147 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
148 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
149 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
150 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
151 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
152 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
153 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
154 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
155 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
156 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
157 | {{0, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
158 | {{1, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
159 | {{0, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
160 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
161 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
162 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
163 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
164 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
165 | {{0, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
166 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
167 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
168 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
169 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
170 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
171 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
172 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
173 | {{0, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
174 | {{1, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
175 | {{0, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
176 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
177 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
178 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
179 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
180 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
181 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
182 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
183 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
184 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
185 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
186 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
187 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
188 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
189 | {{0, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
190 | {{1, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
191 | {{0, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
192 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
193 | {{0, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
194 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
195 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
196 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
197 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
198 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
199 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
200 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
201 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
202 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
203 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
204 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
205 | {{0, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
206 | {{1, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
207 | {{0, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
208 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
209 | {{0, op(FuzzingOperationType::PAN_LEFT)}}, | |
|
210 | {{1, op(FuzzingOperationType::PAN_RIGHT)}}, | |
|
211 | }); | |
|
212 | ||
|
213 | const QVariant CUSTOM_CASE_TWO =QVariant::fromValue(CustomVariablesOperations{{{0, op(FuzzingOperationType::CREATE)}, true}, | |
|
214 | {{0, op(FuzzingOperationType::SYNCHRONIZE)}}, | |
|
215 | {{1, op(FuzzingOperationType::CREATE)}, true}, | |
|
216 | {{1, op(FuzzingOperationType::SYNCHRONIZE)}}, | |
|
217 | {{1, op(FuzzingOperationType::ZOOM_OUT)}}, | |
|
218 | {{1, op(FuzzingOperationType::ZOOM_IN)}}, | |
|
219 | }); | |
|
94 | 220 | |
|
95 | 221 | // /////// // |
|
96 | 222 | // Methods // |
@@ -193,9 +319,6 public: | |||
|
193 | 319 | |
|
194 | 320 | void execute() |
|
195 | 321 | { |
|
196 | qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Running" << nbMaxOperations() << "operations on" | |
|
197 | << nbMaxVariables() << "variable(s)..."; | |
|
198 | ||
|
199 | 322 | |
|
200 | 323 | // Inits the count of the number of operations before the next validation |
|
201 | 324 | int nextValidationCounter = 0; |
@@ -207,28 +330,52 public: | |||
|
207 | 330 | }; |
|
208 | 331 | updateValidationCounter(); |
|
209 | 332 | |
|
333 | // Get custom operations | |
|
334 | auto customOperations = m_Properties.value(CUSTOM_OPERATIONS_PROPERTY).value<CustomVariablesOperations>(); | |
|
335 | auto isCustomTest = !customOperations.empty(); | |
|
336 | ||
|
337 | auto nbOperations = isCustomTest ? customOperations.size() : nbMaxOperations(); | |
|
338 | ||
|
339 | qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Running" << nbOperations << "operations on" | |
|
340 | << nbMaxVariables() << "variable(s)..."; | |
|
341 | ||
|
210 | 342 | auto canExecute = true; |
|
211 |
for (auto i = 0; i < nb |
|
|
343 | for (auto i = 0; i < nbOperations && canExecute; ++i) { | |
|
344 | VariableOperation variableOperation{}; | |
|
345 | auto forceWait = false; | |
|
346 | ||
|
347 | if(isCustomTest){ | |
|
348 | auto customOperation = customOperations.front(); | |
|
349 | variableOperation = customOperation.m_VariableOperation; | |
|
350 | customOperations.erase(customOperations.begin()); | |
|
351 | ||
|
352 | canExecute = variableOperation.second->canExecute(variableOperation.first, m_FuzzingState); | |
|
353 | forceWait = customOperation.m_WaitAcquisition; | |
|
354 | } else { | |
|
212 | 355 | // Retrieves all operations that can be executed in the current context |
|
213 | 356 | VariablesOperations variableOperations{}; |
|
214 | 357 | Weights weights{}; |
|
215 | 358 | std::tie(variableOperations, weights) |
|
216 | 359 | = availableOperations(m_FuzzingState, operationsPool()); |
|
217 | 360 | |
|
361 | // Of the operations available, chooses a random operation and executes it | |
|
362 | variableOperation | |
|
363 | = RandomGenerator::instance().randomChoice(variableOperations, weights); | |
|
218 | 364 | canExecute = !variableOperations.empty(); |
|
365 | forceWait = operationsPool().at(variableOperation.second).m_WaitAcquisition; | |
|
366 | } | |
|
367 | ||
|
219 | 368 | if (canExecute) { |
|
220 | 369 | --nextValidationCounter; |
|
221 | 370 | |
|
222 | // Of the operations available, chooses a random operation and executes it | |
|
223 | auto variableOperation | |
|
224 | = RandomGenerator::instance().randomChoice(variableOperations, weights); | |
|
225 | ||
|
226 | 371 | auto variableId = variableOperation.first; |
|
227 | 372 | auto fuzzingOperation = variableOperation.second; |
|
228 | 373 | |
|
229 | 374 | auto waitAcquisition = nextValidationCounter == 0 |
|
230 |
|| |
|
|
375 | || forceWait; | |
|
231 | 376 | |
|
377 | qCInfo(LOG_TestAmdaFuzzing()).noquote() << "Operation :" << i +1 << " on" | |
|
378 | << nbOperations; | |
|
232 | 379 | fuzzingOperation->execute(variableId, m_FuzzingState, m_VariableController, |
|
233 | 380 | m_Properties); |
|
234 | 381 | |
@@ -293,6 +440,7 private: | |||
|
293 | 440 | } // namespace |
|
294 | 441 | |
|
295 | 442 | Q_DECLARE_METATYPE(OperationsTypes) |
|
443 | Q_DECLARE_METATYPE(CustomVariablesOperations) | |
|
296 | 444 | |
|
297 | 445 | class TestAmdaFuzzing : public QObject { |
|
298 | 446 | Q_OBJECT |
@@ -306,7 +454,7 private slots: | |||
|
306 | 454 | void TestAmdaFuzzing::testFuzzing_data() |
|
307 | 455 | { |
|
308 | 456 | // Note: Comment this line to run fuzzing tests |
|
309 | QSKIP("Fuzzing tests are disabled by default"); | |
|
457 | // QSKIP("Fuzzing tests are disabled by default"); | |
|
310 | 458 | |
|
311 | 459 | // ////////////// // |
|
312 | 460 | // Test structure // |
@@ -318,17 +466,34 void TestAmdaFuzzing::testFuzzing_data() | |||
|
318 | 466 | // Test cases // |
|
319 | 467 | // ////////// // |
|
320 | 468 | |
|
321 |
auto maxRange = SqpRange::fromDateTime({2017, 1, |
|
|
322 |
MetadataPool metadataPool{{{"dataType", "vector"}, {"xml:id", " |
|
|
469 | auto maxRange = SqpRange::fromDateTime({2017, 1, 5}, {8, 0}, {2017, 1, 5}, {16, 0}); | |
|
470 | MetadataPool metadataPool{{{"dataType", "vector"}, {"xml:id", "c1_b"}}}; | |
|
323 | 471 | |
|
324 | 472 | // Note: we don't use auto here as we want to pass std::shared_ptr<IDataProvider> as is in the |
|
325 | 473 | // QVariant |
|
326 | 474 | std::shared_ptr<IDataProvider> provider = std::make_shared<AmdaProvider>(); |
|
327 | 475 | |
|
476 | ||
|
477 | // Case Custom one : Only lot of pan on two variables synchronized | |
|
478 | // QTest::newRow("fuzzingTestPan") << Properties{ | |
|
479 | // {MAX_RANGE_PROPERTY, QVariant::fromValue(maxRange)}, | |
|
480 | // {METADATA_POOL_PROPERTY, QVariant::fromValue(metadataPool)}, | |
|
481 | // {PROVIDER_PROPERTY, QVariant::fromValue(provider)}, | |
|
482 | // {CUSTOM_OPERATIONS_PROPERTY, CUSTOM_CASE_ONE}}; | |
|
483 | ||
|
484 | // QTest::newRow("fuzzingTestZoom") << Properties{ | |
|
485 | // {MAX_RANGE_PROPERTY, QVariant::fromValue(maxRange)}, | |
|
486 | // {METADATA_POOL_PROPERTY, QVariant::fromValue(metadataPool)}, | |
|
487 | // {PROVIDER_PROPERTY, QVariant::fromValue(provider)}, | |
|
488 | // {CUSTOM_OPERATIONS_PROPERTY, CUSTOM_CASE_TWO}}; | |
|
489 | ||
|
490 | ||
|
491 | //// Fuzzing | |
|
328 | 492 | QTest::newRow("fuzzingTest") << Properties{ |
|
329 | 493 |
|
|
330 | 494 |
|
|
331 | 495 |
|
|
496 | ||
|
332 | 497 | } |
|
333 | 498 | |
|
334 | 499 | void TestAmdaFuzzing::testFuzzing() |
General Comments 0
You need to be logged in to leave comments.
Login now