Auto status change to "Under Review"
@@ -15,12 +15,10 | |||||
15 | * @brief The VariableRequest struct holds the information of an acquisition request |
|
15 | * @brief The VariableRequest struct holds the information of an acquisition request | |
16 | */ |
|
16 | */ | |
17 | struct VariableRequest { |
|
17 | struct VariableRequest { | |
18 | VariableRequest() { m_CanUpdate = false; } |
|
18 | QUuid m_VariableGroupId; | |
19 |
|
||||
20 | SqpRange m_RangeRequested; |
|
19 | SqpRange m_RangeRequested; | |
21 | SqpRange m_CacheRangeRequested; |
|
20 | SqpRange m_CacheRangeRequested; | |
22 | std::shared_ptr<IDataSeries> m_DataSeries; |
|
21 | std::shared_ptr<IDataSeries> m_DataSeries; | |
23 | bool m_CanUpdate; |
|
|||
24 | }; |
|
22 | }; | |
25 |
|
23 | |||
26 | SCIQLOP_REGISTER_META_TYPE(VARIABLEREQUEST_REGISTRY, VariableRequest) |
|
24 | SCIQLOP_REGISTER_META_TYPE(VARIABLEREQUEST_REGISTRY, VariableRequest) |
This diff has been collapsed as it changes many lines, (629 lines changed) Show them Hide them | |||||
@@ -77,6 +77,23 SqpRange computeSynchroRangeRequested(const SqpRange &varRange, const SqpRange & | |||||
77 | } |
|
77 | } | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
|
80 | enum class VariableRequestHandlerState { OFF, RUNNING, PENDING }; | |||
|
81 | ||||
|
82 | struct VariableRequestHandler { | |||
|
83 | ||||
|
84 | VariableRequestHandler() | |||
|
85 | { | |||
|
86 | m_CanUpdate = false; | |||
|
87 | m_State = VariableRequestHandlerState::OFF; | |||
|
88 | } | |||
|
89 | ||||
|
90 | QUuid m_VarId; | |||
|
91 | VariableRequest m_RunningVarRequest; | |||
|
92 | VariableRequest m_PendingVarRequest; | |||
|
93 | VariableRequestHandlerState m_State; | |||
|
94 | bool m_CanUpdate; | |||
|
95 | }; | |||
|
96 | ||||
80 | struct VariableController::VariableControllerPrivate { |
|
97 | struct VariableController::VariableControllerPrivate { | |
81 | explicit VariableControllerPrivate(VariableController *parent) |
|
98 | explicit VariableControllerPrivate(VariableController *parent) | |
82 | : m_WorkingMutex{}, |
|
99 | : m_WorkingMutex{}, | |
@@ -113,10 +130,10 struct VariableController::VariableControllerPrivate { | |||||
113 |
|
130 | |||
114 | void storeVariableRequest(QUuid varId, QUuid varRequestId, const VariableRequest &varRequest); |
|
131 | void storeVariableRequest(QUuid varId, QUuid varRequestId, const VariableRequest &varRequest); | |
115 | QUuid acceptVariableRequest(QUuid varId, std::shared_ptr<IDataSeries> dataSeries); |
|
132 | QUuid acceptVariableRequest(QUuid varId, std::shared_ptr<IDataSeries> dataSeries); | |
|
133 | void updateVariables(QUuid varRequestId); | |||
116 | void updateVariableRequest(QUuid varRequestId); |
|
134 | void updateVariableRequest(QUuid varRequestId); | |
117 | void cancelVariableRequest(QUuid varRequestId); |
|
135 | void cancelVariableRequest(QUuid varRequestId); | |
118 | void abortVariableRequest(QUuid varRequestId); |
|
136 | void executeVarRequest(std::shared_ptr<Variable> var, VariableRequest &varRequest); | |
119 | SqpRange getLastRequestedRange(QUuid varId); |
|
|||
120 |
|
137 | |||
121 | QMutex m_WorkingMutex; |
|
138 | QMutex m_WorkingMutex; | |
122 | /// Variable model. The VariableController has the ownership |
|
139 | /// Variable model. The VariableController has the ownership | |
@@ -137,9 +154,8 struct VariableController::VariableControllerPrivate { | |||||
137 | std::map<QUuid, QUuid> m_VariableIdGroupIdMap; |
|
154 | std::map<QUuid, QUuid> m_VariableIdGroupIdMap; | |
138 | std::set<std::shared_ptr<IDataProvider> > m_ProviderSet; |
|
155 | std::set<std::shared_ptr<IDataProvider> > m_ProviderSet; | |
139 |
|
156 | |||
140 |
std::map<QUuid, std:: |
|
157 | std::map<QUuid, std::list<QUuid> > m_VarGroupIdToVarIds; | |
141 |
|
158 | std::map<QUuid, std::unique_ptr<VariableRequestHandler> > m_VarIdToVarRequestHandler; | ||
142 | std::map<QUuid, std::deque<QUuid> > m_VarIdToVarRequestIdQueueMap; |
|
|||
143 |
|
159 | |||
144 | VariableController *q; |
|
160 | VariableController *q; | |
145 | }; |
|
161 | }; | |
@@ -274,20 +290,28 VariableController::createVariable(const QString &name, const QVariantHash &meta | |||||
274 | auto range = impl->m_TimeController->dateTime(); |
|
290 | auto range = impl->m_TimeController->dateTime(); | |
275 |
|
291 | |||
276 | if (auto newVariable = impl->m_VariableModel->createVariable(name, metadata)) { |
|
292 | if (auto newVariable = impl->m_VariableModel->createVariable(name, metadata)) { | |
277 |
auto |
|
293 | auto varId = QUuid::createUuid(); | |
|
294 | ||||
|
295 | // Create the handler | |||
|
296 | auto varRequestHandler = std::make_unique<VariableRequestHandler>(); | |||
|
297 | varRequestHandler->m_VarId = varId; | |||
|
298 | ||||
|
299 | impl->m_VarIdToVarRequestHandler.insert( | |||
|
300 | std::make_pair(varId, std::move(varRequestHandler))); | |||
278 |
|
301 | |||
279 | // store the provider |
|
302 | // store the provider | |
280 | impl->registerProvider(provider); |
|
303 | impl->registerProvider(provider); | |
281 |
|
304 | |||
282 | // Associate the provider |
|
305 | // Associate the provider | |
283 | impl->m_VariableToProviderMap[newVariable] = provider; |
|
306 | impl->m_VariableToProviderMap[newVariable] = provider; | |
284 |
impl->m_VariableToIdentifierMap[newVariable] = |
|
307 | impl->m_VariableToIdentifierMap[newVariable] = varId; | |
285 |
|
308 | |||
|
309 | this->onRequestDataLoading(QVector<std::shared_ptr<Variable> >{newVariable}, range, false); | |||
286 |
|
310 | |||
287 | auto varRequestId = QUuid::createUuid(); |
|
311 | // auto varRequestId = QUuid::createUuid(); | |
288 |
qCInfo(LOG_VariableController()) << "createVariable: " << |
|
312 | // qCInfo(LOG_VariableController()) << "createVariable: " << varId << varRequestId; | |
289 | impl->processRequest(newVariable, range, varRequestId); |
|
313 | // impl->processRequest(newVariable, range, varRequestId); | |
290 | impl->updateVariableRequest(varRequestId); |
|
314 | // impl->updateVariableRequest(varRequestId); | |
291 |
|
315 | |||
292 | return newVariable; |
|
316 | return newVariable; | |
293 | } |
|
317 | } | |
@@ -319,10 +343,11 void VariableController::onDataProvided(QUuid vIdentifier, const SqpRange &range | |||||
319 | const SqpRange &cacheRangeRequested, |
|
343 | const SqpRange &cacheRangeRequested, | |
320 | QVector<AcquisitionDataPacket> dataAcquired) |
|
344 | QVector<AcquisitionDataPacket> dataAcquired) | |
321 | { |
|
345 | { | |
|
346 | qCInfo(LOG_VariableController()) << tr("onDataProvided") << QThread::currentThread(); | |||
322 | auto retrievedDataSeries = impl->retrieveDataSeries(dataAcquired); |
|
347 | auto retrievedDataSeries = impl->retrieveDataSeries(dataAcquired); | |
323 | auto varRequestId = impl->acceptVariableRequest(vIdentifier, retrievedDataSeries); |
|
348 | auto varRequestId = impl->acceptVariableRequest(vIdentifier, retrievedDataSeries); | |
324 | if (!varRequestId.isNull()) { |
|
349 | if (!varRequestId.isNull()) { | |
325 |
impl->updateVariable |
|
350 | impl->updateVariables(varRequestId); | |
326 | } |
|
351 | } | |
327 | } |
|
352 | } | |
328 |
|
353 | |||
@@ -342,31 +367,32 void VariableController::onVariableRetrieveDataInProgress(QUuid identifier, doub | |||||
342 |
|
367 | |||
343 | void VariableController::onAbortProgressRequested(std::shared_ptr<Variable> variable) |
|
368 | void VariableController::onAbortProgressRequested(std::shared_ptr<Variable> variable) | |
344 | { |
|
369 | { | |
345 | auto it = impl->m_VariableToIdentifierMap.find(variable); |
|
370 | // auto it = impl->m_VariableToIdentifierMap.find(variable); | |
346 | if (it != impl->m_VariableToIdentifierMap.cend()) { |
|
371 | // if (it != impl->m_VariableToIdentifierMap.cend()) { | |
347 | impl->m_VariableAcquisitionWorker->abortProgressRequested(it->second); |
|
372 | // impl->m_VariableAcquisitionWorker->abortProgressRequested(it->second); | |
348 |
|
373 | |||
349 | QUuid varRequestId; |
|
374 | // QUuid varRequestId; | |
350 | auto varIdToVarRequestIdQueueMapIt = impl->m_VarIdToVarRequestIdQueueMap.find(it->second); |
|
375 | // auto varIdToVarRequestIdQueueMapIt = | |
351 |
|
|
376 | // impl->m_VarIdToVarRequestIdQueueMap.find(it->second); | |
352 | auto &varRequestIdQueue = varIdToVarRequestIdQueueMapIt->second; |
|
377 | // if (varIdToVarRequestIdQueueMapIt != impl->m_VarIdToVarRequestIdQueueMap.cend()) { | |
353 | varRequestId = varRequestIdQueue.front(); |
|
378 | // auto &varRequestIdQueue = varIdToVarRequestIdQueueMapIt->second; | |
354 | impl->cancelVariableRequest(varRequestId); |
|
379 | // varRequestId = varRequestIdQueue.front(); | |
355 |
|
380 | // impl->cancelVariableRequest(varRequestId); | ||
356 | // Finish the progression for the request |
|
381 | ||
357 | impl->m_VariableModel->setDataProgress(variable, 0.0); |
|
382 | // // Finish the progression for the request | |
358 | } |
|
383 | // impl->m_VariableModel->setDataProgress(variable, 0.0); | |
359 | else { |
|
384 | // } | |
360 | qCWarning(LOG_VariableController()) |
|
385 | // else { | |
361 | << tr("Aborting progression of inexistant variable request detected !!!") |
|
386 | // qCWarning(LOG_VariableController()) | |
362 | << QThread::currentThread()->objectName(); |
|
387 | // << tr("Aborting progression of inexistant variable request detected !!!") | |
363 | } |
|
388 | // << QThread::currentThread()->objectName(); | |
364 | } |
|
389 | // } | |
365 | else { |
|
390 | // } | |
366 | qCWarning(LOG_VariableController()) |
|
391 | // else { | |
367 | << tr("Aborting progression of inexistant variable detected !!!") |
|
392 | // qCWarning(LOG_VariableController()) | |
368 | << QThread::currentThread()->objectName(); |
|
393 | // << tr("Aborting progression of inexistant variable detected !!!") | |
369 | } |
|
394 | // << QThread::currentThread()->objectName(); | |
|
395 | // } | |||
370 | } |
|
396 | } | |
371 |
|
397 | |||
372 | void VariableController::onAbortAcquisitionRequested(QUuid vIdentifier) |
|
398 | void VariableController::onAbortAcquisitionRequested(QUuid vIdentifier) | |
@@ -459,58 +485,62 void VariableController::desynchronize(std::shared_ptr<Variable> variable, | |||||
459 | void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable> > variables, |
|
485 | void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable> > variables, | |
460 | const SqpRange &range, bool synchronise) |
|
486 | const SqpRange &range, bool synchronise) | |
461 | { |
|
487 | { | |
462 | // NOTE: oldRange isn't really necessary since oldRange == variable->range(). |
|
488 | // variables is assumed synchronized | |
463 |
|
489 | // TODO: Asser variables synchronization | ||
464 | // we want to load data of the variable for the dateTime. |
|
490 | // we want to load data of the variable for the dateTime. | |
465 | // First we check if the cache contains some of them. |
|
491 | if (variables.isEmpty()) { | |
466 | // For the other, we ask the provider to give them. |
|
492 | return; | |
|
493 | } | |||
467 |
|
494 | |||
468 | auto varRequestId = QUuid::createUuid(); |
|
495 | auto varRequestId = QUuid::createUuid(); | |
469 |
qC |
|
496 | qCCritical(LOG_VariableController()) << "VariableController::onRequestDataLoading" | |
470 |
<< QThread::currentThread()->objectName() << varRequestId |
|
497 | << QThread::currentThread()->objectName() << varRequestId | |
|
498 | << range; | |||
471 |
|
499 | |||
|
500 | if (!synchronise) { | |||
|
501 | auto varIds = std::list<QUuid>{}; | |||
472 | for (const auto &var : variables) { |
|
502 | for (const auto &var : variables) { | |
473 | qCInfo(LOG_VariableController()) << "processRequest for" << var->name() << varRequestId; |
|
503 | auto vId = impl->m_VariableToIdentifierMap.at(var); | |
474 | impl->processRequest(var, range, varRequestId); |
|
504 | varIds.push_back(vId); | |
475 | } |
|
505 | } | |
476 |
|
506 | impl->m_VarGroupIdToVarIds.insert(std::make_pair(varRequestId, varIds)); | ||
477 | if (synchronise) { |
|
|||
478 | // Get the group ids |
|
|||
479 | qCDebug(LOG_VariableController()) |
|
|||
480 | << "TORM VariableController::onRequestDataLoading for synchro var ENABLE"; |
|
|||
481 | auto groupIds = std::set<QUuid>{}; |
|
|||
482 | auto groupIdToOldRangeMap = std::map<QUuid, SqpRange>{}; |
|
|||
483 | for (const auto &var : variables) { |
|
507 | for (const auto &var : variables) { | |
484 | auto varToVarIdIt = impl->m_VariableToIdentifierMap.find(var); |
|
508 | qCInfo(LOG_VariableController()) << "processRequest for" << var->name() << varRequestId | |
485 | if (varToVarIdIt != impl->m_VariableToIdentifierMap.cend()) { |
|
509 | << varIds.size(); | |
486 | auto vId = varToVarIdIt->second; |
|
510 | impl->processRequest(var, range, varRequestId); | |
487 | auto varIdToGroupIdIt = impl->m_VariableIdGroupIdMap.find(vId); |
|
|||
488 | if (varIdToGroupIdIt != impl->m_VariableIdGroupIdMap.cend()) { |
|
|||
489 | auto gId = varIdToGroupIdIt->second; |
|
|||
490 | groupIdToOldRangeMap.insert(std::make_pair(gId, var->range())); |
|
|||
491 | if (groupIds.find(gId) == groupIds.cend()) { |
|
|||
492 | qCDebug(LOG_VariableController()) << "Synchro detect group " << gId; |
|
|||
493 | groupIds.insert(gId); |
|
|||
494 | } |
|
|||
495 | } |
|
|||
496 |
|
|
511 | } | |
497 |
|
|
512 | } | |
|
513 | else { | |||
|
514 | auto vId = impl->m_VariableToIdentifierMap.at(variables.first()); | |||
|
515 | qCInfo(LOG_VariableController()) << "Var in synchro group 0" << vId; | |||
|
516 | auto varIdToGroupIdIt = impl->m_VariableIdGroupIdMap.find(vId); | |||
|
517 | if (varIdToGroupIdIt != impl->m_VariableIdGroupIdMap.cend()) { | |||
|
518 | auto groupId = varIdToGroupIdIt->second; | |||
498 |
|
519 | |||
499 | // We assume here all group ids exist |
|
520 | auto vSynchronizationGroup | |
500 | for (const auto &gId : groupIds) { |
|
521 | = impl->m_GroupIdToVariableSynchronizationGroupMap.at(groupId); | |
501 | auto vSynchronizationGroup = impl->m_GroupIdToVariableSynchronizationGroupMap.at(gId); |
|
|||
502 | auto vSyncIds = vSynchronizationGroup->getIds(); |
|
522 | auto vSyncIds = vSynchronizationGroup->getIds(); | |
503 | qCDebug(LOG_VariableController()) << "Var in synchro group "; |
|
523 | ||
|
524 | qCInfo(LOG_VariableController()) << "Var in synchro group 1" << groupId; | |||
|
525 | ||||
|
526 | auto varIds = std::list<QUuid>{}; | |||
|
527 | for (auto vId : vSyncIds) { | |||
|
528 | varIds.push_back(vId); | |||
|
529 | } | |||
|
530 | impl->m_VarGroupIdToVarIds.insert(std::make_pair(varRequestId, varIds)); | |||
|
531 | ||||
504 | for (auto vId : vSyncIds) { |
|
532 | for (auto vId : vSyncIds) { | |
505 | auto var = impl->findVariable(vId); |
|
533 | auto var = impl->findVariable(vId); | |
506 |
|
534 | |||
507 | // Don't process already processed var |
|
535 | // Don't process already processed var | |
508 | if (!variables.contains(var)) { |
|
|||
509 |
|
|
536 | if (var != nullptr) { | |
510 |
|
|
537 | qCInfo(LOG_VariableController()) << "processRequest synchro for" << var->name() | |
511 |
|
|
538 | << varRequestId; | |
512 |
|
|
539 | auto vSyncRangeRequested | |
513 | var->range(), range, groupIdToOldRangeMap.at(gId)); |
|
540 | = variables.contains(var) | |
|
541 | ? range | |||
|
542 | : computeSynchroRangeRequested(var->range(), range, | |||
|
543 | variables.first()->range()); | |||
514 |
|
|
544 | qCDebug(LOG_VariableController()) << "synchro RR" << vSyncRangeRequested; | |
515 |
|
|
545 | impl->processRequest(var, vSyncRangeRequested, varRequestId); | |
516 |
|
|
546 | } | |
@@ -522,9 +552,8 void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable> | |||||
522 |
|
|
552 | } | |
523 |
|
|
553 | } | |
524 |
|
|
554 | } | |
525 | } |
|
|||
526 |
|
555 | |||
527 |
impl->updateVariable |
|
556 | impl->updateVariables(varRequestId); | |
528 | } |
|
557 | } | |
529 |
|
558 | |||
530 |
|
559 | |||
@@ -575,64 +604,68 void VariableController::VariableControllerPrivate::processRequest(std::shared_p | |||||
575 | const SqpRange &rangeRequested, |
|
604 | const SqpRange &rangeRequested, | |
576 | QUuid varRequestId) |
|
605 | QUuid varRequestId) | |
577 | { |
|
606 | { | |
578 | auto varRequest = VariableRequest{}; |
|
607 | auto itVar = m_VariableToIdentifierMap.find(var); | |
|
608 | if (itVar == m_VariableToIdentifierMap.cend()) { | |||
|
609 | qCCritical(LOG_VariableController()) | |||
|
610 | << tr("Impossible to process request for unknown variable"); | |||
|
611 | return; | |||
|
612 | } | |||
|
613 | ||||
|
614 | auto varId = itVar->second; | |||
579 |
|
615 | |||
580 |
auto it = m_Var |
|
616 | auto itVarHandler = m_VarIdToVarRequestHandler.find(varId); | |
581 | if (it != m_VariableToIdentifierMap.cend()) { |
|
617 | if (itVarHandler == m_VarIdToVarRequestHandler.cend()) { | |
|
618 | qCCritical(LOG_VariableController()) | |||
|
619 | << tr("Impossible to process request for variable with unknown handler"); | |||
|
620 | return; | |||
|
621 | } | |||
582 |
|
622 | |||
583 | auto varId = it->second; |
|
623 | auto oldRange = var->range(); | |
584 |
|
624 | |||
585 | auto oldRange = getLastRequestedRange(varId); |
|
625 | auto varHandler = itVarHandler->second.get(); | |
586 |
|
626 | |||
587 | // check for update oldRange to the last request range. |
|
627 | if (varHandler->m_State != VariableRequestHandlerState::OFF) { | |
588 | if (oldRange == INVALID_RANGE) { |
|
628 | oldRange = varHandler->m_RunningVarRequest.m_RangeRequested; | |
589 | oldRange = var->range(); |
|
|||
590 |
|
|
629 | } | |
591 |
|
630 | |||
|
631 | auto varRequest = VariableRequest{}; | |||
|
632 | varRequest.m_VariableGroupId = varRequestId; | |||
592 |
|
|
633 | auto varStrategyRangesRequested | |
593 |
|
|
634 | = m_VariableCacheStrategy->computeRange(oldRange, rangeRequested); | |
594 |
|
||||
595 | // Use commented lines to remove the cache (run time) |
|
|||
596 | // auto notInCacheRangeList = QVector<SqpRange>{varStrategyRangesRequested.second}; |
|
|||
597 | // auto inCacheRangeList = QVector<SqpRange>{}; |
|
|||
598 | auto notInCacheRangeList |
|
|||
599 | = Variable::provideNotInCacheRangeList(oldRange, varStrategyRangesRequested.second); |
|
|||
600 | auto inCacheRangeList |
|
|||
601 | = Variable::provideInCacheRangeList(oldRange, varStrategyRangesRequested.second); |
|
|||
602 |
|
||||
603 | if (!notInCacheRangeList.empty()) { |
|
|||
604 |
|
|
635 | varRequest.m_RangeRequested = varStrategyRangesRequested.first; | |
605 |
|
|
636 | varRequest.m_CacheRangeRequested = varStrategyRangesRequested.second; | |
606 |
|
637 | |||
607 | // store VarRequest |
|
638 | switch (varHandler->m_State) { | |
608 | storeVariableRequest(varId, varRequestId, varRequest); |
|
639 | case VariableRequestHandlerState::OFF: { | |
609 |
|
640 | qCCritical(LOG_VariableController()) << tr("Process Request OFF") | ||
610 | auto varProvider = m_VariableToProviderMap.at(var); |
|
641 | << varRequest.m_RangeRequested | |
611 | if (varProvider != nullptr) { |
|
642 | << varRequest.m_CacheRangeRequested; | |
612 | auto varRequestIdCanceled = m_VariableAcquisitionWorker->pushVariableRequest( |
|
643 | varHandler->m_RunningVarRequest = varRequest; | |
613 | varRequestId, varId, varStrategyRangesRequested.first, |
|
644 | varHandler->m_State = VariableRequestHandlerState::RUNNING; | |
614 | varStrategyRangesRequested.second, |
|
645 | executeVarRequest(var, varRequest); | |
615 | DataProviderParameters{std::move(notInCacheRangeList), var->metadata()}, |
|
646 | break; | |
616 | varProvider); |
|
|||
617 |
|
||||
618 |
|
|
647 | } | |
619 | else { |
|
648 | case VariableRequestHandlerState::RUNNING: { | |
620 |
|
|
649 | qCCritical(LOG_VariableController()) << tr("Process Request RUNNING") | |
621 | << "Impossible to provide data with a null provider"; |
|
650 | << varRequest.m_RangeRequested | |
|
651 | << varRequest.m_CacheRangeRequested; | |||
|
652 | varHandler->m_State = VariableRequestHandlerState::PENDING; | |||
|
653 | varHandler->m_PendingVarRequest = varRequest; | |||
|
654 | break; | |||
622 |
|
|
655 | } | |
|
656 | case VariableRequestHandlerState::PENDING: { | |||
|
657 | qCCritical(LOG_VariableController()) << tr("Process Request PENDING") | |||
|
658 | << varRequest.m_RangeRequested | |||
|
659 | << varRequest.m_CacheRangeRequested; | |||
|
660 | auto variableGroupIdToCancel = varHandler->m_PendingVarRequest.m_VariableGroupId; | |||
|
661 | varHandler->m_PendingVarRequest = varRequest; | |||
|
662 | cancelVariableRequest(variableGroupIdToCancel); | |||
623 |
|
663 | |||
624 | if (!inCacheRangeList.empty()) { |
|
664 | break; | |
625 | emit q->updateVarDisplaying(var, inCacheRangeList.first()); |
|
|||
626 | } |
|
|||
627 | } |
|
|||
628 | else { |
|
|||
629 | varRequest.m_RangeRequested = varStrategyRangesRequested.first; |
|
|||
630 | varRequest.m_CacheRangeRequested = varStrategyRangesRequested.second; |
|
|||
631 | // store VarRequest |
|
|||
632 | storeVariableRequest(varId, varRequestId, varRequest); |
|
|||
633 | acceptVariableRequest( |
|
|||
634 | varId, var->dataSeries()->subDataSeries(varStrategyRangesRequested.second)); |
|
|||
635 | } |
|
665 | } | |
|
666 | default: | |||
|
667 | qCCritical(LOG_VariableController()) | |||
|
668 | << QObject::tr("Unknown VariableRequestHandlerState"); | |||
636 | } |
|
669 | } | |
637 | } |
|
670 | } | |
638 |
|
671 | |||
@@ -693,266 +726,244 void VariableController::VariableControllerPrivate::registerProvider( | |||||
693 | } |
|
726 | } | |
694 | } |
|
727 | } | |
695 |
|
728 | |||
696 | void VariableController::VariableControllerPrivate::storeVariableRequest( |
|
|||
697 | QUuid varId, QUuid varRequestId, const VariableRequest &varRequest) |
|
|||
698 | { |
|
|||
699 | // First request for the variable. we can create an entry for it |
|
|||
700 | auto varIdToVarRequestIdQueueMapIt = m_VarIdToVarRequestIdQueueMap.find(varId); |
|
|||
701 | if (varIdToVarRequestIdQueueMapIt == m_VarIdToVarRequestIdQueueMap.cend()) { |
|
|||
702 | auto varRequestIdQueue = std::deque<QUuid>{}; |
|
|||
703 | qCDebug(LOG_VariableController()) << tr("Store REQUEST in QUEUE"); |
|
|||
704 | varRequestIdQueue.push_back(varRequestId); |
|
|||
705 | m_VarIdToVarRequestIdQueueMap.insert(std::make_pair(varId, std::move(varRequestIdQueue))); |
|
|||
706 | } |
|
|||
707 | else { |
|
|||
708 | qCDebug(LOG_VariableController()) << tr("Store REQUEST in EXISTING QUEUE"); |
|
|||
709 | auto &varRequestIdQueue = varIdToVarRequestIdQueueMapIt->second; |
|
|||
710 | varRequestIdQueue.push_back(varRequestId); |
|
|||
711 | } |
|
|||
712 |
|
||||
713 | auto varRequestIdToVarIdVarRequestMapIt = m_VarRequestIdToVarIdVarRequestMap.find(varRequestId); |
|
|||
714 | if (varRequestIdToVarIdVarRequestMapIt == m_VarRequestIdToVarIdVarRequestMap.cend()) { |
|
|||
715 | auto varIdToVarRequestMap = std::map<QUuid, VariableRequest>{}; |
|
|||
716 | varIdToVarRequestMap.insert(std::make_pair(varId, varRequest)); |
|
|||
717 | qCDebug(LOG_VariableController()) << tr("Store REQUESTID in MAP"); |
|
|||
718 | m_VarRequestIdToVarIdVarRequestMap.insert( |
|
|||
719 | std::make_pair(varRequestId, std::move(varIdToVarRequestMap))); |
|
|||
720 | } |
|
|||
721 | else { |
|
|||
722 | auto &varIdToVarRequestMap = varRequestIdToVarIdVarRequestMapIt->second; |
|
|||
723 | qCDebug(LOG_VariableController()) << tr("Store REQUESTID in EXISTING MAP"); |
|
|||
724 | varIdToVarRequestMap.insert(std::make_pair(varId, varRequest)); |
|
|||
725 | } |
|
|||
726 | } |
|
|||
727 |
|
||||
728 | QUuid VariableController::VariableControllerPrivate::acceptVariableRequest( |
|
729 | QUuid VariableController::VariableControllerPrivate::acceptVariableRequest( | |
729 | QUuid varId, std::shared_ptr<IDataSeries> dataSeries) |
|
730 | QUuid varId, std::shared_ptr<IDataSeries> dataSeries) | |
730 | { |
|
731 | { | |
731 | QUuid varRequestId; |
|
732 | auto itVarHandler = m_VarIdToVarRequestHandler.find(varId); | |
732 | auto varIdToVarRequestIdQueueMapIt = m_VarIdToVarRequestIdQueueMap.find(varId); |
|
733 | if (itVarHandler == m_VarIdToVarRequestHandler.cend()) { | |
733 | if (varIdToVarRequestIdQueueMapIt != m_VarIdToVarRequestIdQueueMap.cend()) { |
|
734 | return QUuid(); | |
734 | auto &varRequestIdQueue = varIdToVarRequestIdQueueMapIt->second; |
|
|||
735 | varRequestId = varRequestIdQueue.front(); |
|
|||
736 | auto varRequestIdToVarIdVarRequestMapIt |
|
|||
737 | = m_VarRequestIdToVarIdVarRequestMap.find(varRequestId); |
|
|||
738 | if (varRequestIdToVarIdVarRequestMapIt != m_VarRequestIdToVarIdVarRequestMap.cend()) { |
|
|||
739 | auto &varIdToVarRequestMap = varRequestIdToVarIdVarRequestMapIt->second; |
|
|||
740 | auto varIdToVarRequestMapIt = varIdToVarRequestMap.find(varId); |
|
|||
741 | if (varIdToVarRequestMapIt != varIdToVarRequestMap.cend()) { |
|
|||
742 | qCDebug(LOG_VariableController()) << tr("acceptVariableRequest"); |
|
|||
743 | auto &varRequest = varIdToVarRequestMapIt->second; |
|
|||
744 | varRequest.m_DataSeries = dataSeries; |
|
|||
745 | varRequest.m_CanUpdate = true; |
|
|||
746 | } |
|
|||
747 | else { |
|
|||
748 | qCDebug(LOG_VariableController()) |
|
|||
749 | << tr("Impossible to acceptVariableRequest of a unknown variable id attached " |
|
|||
750 | "to a variableRequestId") |
|
|||
751 | << varRequestId << varId; |
|
|||
752 | } |
|
|||
753 | } |
|
|||
754 | else { |
|
|||
755 | qCCritical(LOG_VariableController()) |
|
|||
756 | << tr("Impossible to acceptVariableRequest of a unknown variableRequestId") |
|
|||
757 | << varRequestId; |
|
|||
758 |
|
|
735 | } | |
759 |
|
736 | |||
760 | varRequestIdQueue.pop_front(); |
|
737 | auto varHandler = itVarHandler->second.get(); | |
761 | if (varRequestIdQueue.empty()) { |
|
738 | if (varHandler->m_State == VariableRequestHandlerState::OFF) { | |
762 | qCDebug(LOG_VariableController()) |
|
739 | // TODO log impossible case !!! | |
763 | << tr("TORM Erase REQUEST because it has been accepted") << varId; |
|
|||
764 | m_VarIdToVarRequestIdQueueMap.erase(varId); |
|
|||
765 | } |
|
|||
766 | } |
|
|||
767 | else { |
|
|||
768 | qCCritical(LOG_VariableController()) |
|
|||
769 | << tr("Impossible to acceptVariableRequest of a unknown variable id") << varId; |
|
|||
770 | } |
|
740 | } | |
771 |
|
741 | |||
772 | return varRequestId; |
|
742 | varHandler->m_RunningVarRequest.m_DataSeries = dataSeries; | |
|
743 | varHandler->m_CanUpdate = true; | |||
|
744 | ||||
|
745 | // Element traitΓ©, on a dΓ©jΓ toutes les donnΓ©es necessaires | |||
|
746 | auto varGroupId = varHandler->m_RunningVarRequest.m_VariableGroupId; | |||
|
747 | qCInfo(LOG_VariableController()) << "Variable::acceptVariableRequest" << varGroupId | |||
|
748 | << m_VarGroupIdToVarIds.size(); | |||
|
749 | ||||
|
750 | return varHandler->m_RunningVarRequest.m_VariableGroupId; | |||
773 | } |
|
751 | } | |
774 |
|
752 | |||
775 |
void VariableController::VariableControllerPrivate::updateVariable |
|
753 | void VariableController::VariableControllerPrivate::updateVariables(QUuid varRequestId) | |
776 | { |
|
754 | { | |
|
755 | qCInfo(LOG_VariableController()) << "VariableControllerPrivate::updateVariables" | |||
|
756 | << QThread::currentThread()->objectName() << varRequestId; | |||
777 |
|
757 | |||
778 |
auto var |
|
758 | auto varGroupIdToVarIdsIt = m_VarGroupIdToVarIds.find(varRequestId); | |
779 |
if (var |
|
759 | if (varGroupIdToVarIdsIt == m_VarGroupIdToVarIds.end()) { | |
|
760 | // TODO LOG cannot update since varGroupdId isn't here anymore | |||
|
761 | qCInfo(LOG_VariableController()) << "Impossible to updateVariables of unknown variables" | |||
|
762 | << varRequestId; | |||
|
763 | return; | |||
|
764 | } | |||
|
765 | ||||
|
766 | auto &varIds = varGroupIdToVarIdsIt->second; | |||
|
767 | auto varIdsEnd = varIds.end(); | |||
780 |
|
|
768 | bool processVariableUpdate = true; | |
781 | auto &varIdToVarRequestMap = varRequestIdToVarIdVarRequestMapIt->second; |
|
769 | qCInfo(LOG_VariableController()) | |
782 | for (auto varIdToVarRequestMapIt = varIdToVarRequestMap.cbegin(); |
|
770 | << "VariableControllerPrivate::compute procss for group of size" << varIds.size(); | |
783 |
|
|
771 | for (auto varIdsIt = varIds.begin(); (varIdsIt != varIdsEnd) && processVariableUpdate; | |
784 |
|
|
772 | ++varIdsIt) { | |
785 | processVariableUpdate &= varIdToVarRequestMapIt->second.m_CanUpdate; |
|
773 | auto itVarHandler = m_VarIdToVarRequestHandler.find(*varIdsIt); | |
786 | qCDebug(LOG_VariableController()) << tr("updateVariableRequest") |
|
774 | if (itVarHandler != m_VarIdToVarRequestHandler.cend()) { | |
787 | << processVariableUpdate; |
|
775 | processVariableUpdate &= itVarHandler->second->m_CanUpdate; | |
|
776 | } | |||
788 |
|
|
777 | } | |
789 |
|
778 | |||
790 |
|
|
779 | if (processVariableUpdate) { | |
791 | for (auto varIdToVarRequestMapIt = varIdToVarRequestMap.cbegin(); |
|
780 | qCInfo(LOG_VariableController()) << "Final update OK for the var request" << varIds.size(); | |
792 | varIdToVarRequestMapIt != varIdToVarRequestMap.cend(); ++varIdToVarRequestMapIt) { |
|
781 | for (auto varIdsIt = varIds.begin(); varIdsIt != varIdsEnd; ++varIdsIt) { | |
793 | if (auto var = findVariable(varIdToVarRequestMapIt->first)) { |
|
782 | auto itVarHandler = m_VarIdToVarRequestHandler.find(*varIdsIt); | |
794 | auto &varRequest = varIdToVarRequestMapIt->second; |
|
783 | if (itVarHandler != m_VarIdToVarRequestHandler.cend()) { | |
|
784 | if (auto var = findVariable(*varIdsIt)) { | |||
|
785 | auto &varRequest = itVarHandler->second->m_RunningVarRequest; | |||
795 | var->setRange(varRequest.m_RangeRequested); |
|
786 | var->setRange(varRequest.m_RangeRequested); | |
796 | var->setCacheRange(varRequest.m_CacheRangeRequested); |
|
787 | var->setCacheRange(varRequest.m_CacheRangeRequested); | |
797 |
qC |
|
788 | qCInfo(LOG_VariableController()) << tr("1: onDataProvided") | |
798 |
|
|
789 | << varRequest.m_RangeRequested | |
799 |
|
|
790 | << varRequest.m_CacheRangeRequested; | |
800 |
qC |
|
791 | qCInfo(LOG_VariableController()) << tr("2: onDataProvided var points before") | |
801 |
|
|
792 | << var->nbPoints() | |
802 |
|
|
793 | << varRequest.m_DataSeries->nbPoints(); | |
803 | var->mergeDataSeries(varRequest.m_DataSeries); |
|
794 | var->mergeDataSeries(varRequest.m_DataSeries); | |
804 |
qC |
|
795 | qCInfo(LOG_VariableController()) << tr("3: onDataProvided var points after") | |
805 |
|
|
796 | << var->nbPoints(); | |
806 |
|
797 | |||
807 | emit var->updated(); |
|
798 | emit var->updated(); | |
|
799 | qCCritical(LOG_VariableController()) << tr("Update OK"); | |||
808 | } |
|
800 | } | |
809 | else { |
|
801 | else { | |
810 | qCCritical(LOG_VariableController()) |
|
802 | qCCritical(LOG_VariableController()) | |
811 | << tr("Impossible to update data to a null variable"); |
|
803 | << tr("Impossible to update data to a null variable"); | |
812 | } |
|
804 | } | |
813 | } |
|
805 | } | |
814 | // cleaning varRequestId |
|
|||
815 | qCDebug(LOG_VariableController()) << tr("0: erase REQUEST in MAP ?") |
|
|||
816 | << m_VarRequestIdToVarIdVarRequestMap.size(); |
|
|||
817 | m_VarRequestIdToVarIdVarRequestMap.erase(varRequestId); |
|
|||
818 | qCDebug(LOG_VariableController()) << tr("1: erase REQUEST in MAP ?") |
|
|||
819 | << m_VarRequestIdToVarIdVarRequestMap.size(); |
|
|||
820 | } |
|
|||
821 | } |
|
806 | } | |
822 | else { |
|
807 | updateVariableRequest(varRequestId); | |
823 | qCCritical(LOG_VariableController()) |
|
808 | ||
824 | << tr("Cannot updateVariableRequest for a unknow varRequestId") << varRequestId; |
|
809 | // cleaning varRequestId | |
|
810 | qCInfo(LOG_VariableController()) << tr("m_VarGroupIdToVarIds erase") << varRequestId; | |||
|
811 | m_VarGroupIdToVarIds.erase(varRequestId); | |||
825 | } |
|
812 | } | |
826 | } |
|
813 | } | |
827 |
|
814 | |||
828 | void VariableController::VariableControllerPrivate::cancelVariableRequest(QUuid varRequestId) |
|
815 | ||
|
816 | void VariableController::VariableControllerPrivate::updateVariableRequest(QUuid varRequestId) | |||
829 | { |
|
817 | { | |
830 | // cleaning varRequestId |
|
818 | auto varGroupIdToVarIdsIt = m_VarGroupIdToVarIds.find(varRequestId); | |
831 | m_VarRequestIdToVarIdVarRequestMap.erase(varRequestId); |
|
819 | if (varGroupIdToVarIdsIt == m_VarGroupIdToVarIds.end()) { | |
|
820 | // TODO LOG cannot update variable request since varGroupdId isn't here anymore | |||
|
821 | return; | |||
|
822 | } | |||
832 |
|
823 | |||
833 | for (auto varIdToVarRequestIdQueueMapIt = m_VarIdToVarRequestIdQueueMap.begin(); |
|
824 | auto &varIds = varGroupIdToVarIdsIt->second; | |
834 | varIdToVarRequestIdQueueMapIt != m_VarIdToVarRequestIdQueueMap.end();) { |
|
825 | auto varIdsEnd = varIds.end(); | |
835 | auto &varRequestIdQueue = varIdToVarRequestIdQueueMapIt->second; |
|
826 | for (auto varIdsIt = varIds.begin(); (varIdsIt != varIdsEnd); ++varIdsIt) { | |
836 | varRequestIdQueue.erase( |
|
827 | auto itVarHandler = m_VarIdToVarRequestHandler.find(*varIdsIt); | |
837 | std::remove(varRequestIdQueue.begin(), varRequestIdQueue.end(), varRequestId), |
|
828 | if (itVarHandler != m_VarIdToVarRequestHandler.cend()) { | |
838 | varRequestIdQueue.end()); |
|
|||
839 | if (varRequestIdQueue.empty()) { |
|
|||
840 | varIdToVarRequestIdQueueMapIt |
|
|||
841 | = m_VarIdToVarRequestIdQueueMap.erase(varIdToVarRequestIdQueueMapIt); |
|
|||
842 |
|
829 | |||
843 | // Recompute if there is any next request based on the removed request. |
|
830 | auto varHandler = itVarHandler->second.get(); | |
|
831 | varHandler->m_CanUpdate = false; | |||
|
832 | ||||
|
833 | ||||
|
834 | switch (varHandler->m_State) { | |||
|
835 | case VariableRequestHandlerState::OFF: { | |||
|
836 | qCCritical(LOG_VariableController()) | |||
|
837 | << QObject::tr("Impossible to update a variable with handler in OFF state"); | |||
|
838 | } break; | |||
|
839 | case VariableRequestHandlerState::RUNNING: { | |||
|
840 | varHandler->m_State = VariableRequestHandlerState::OFF; | |||
|
841 | varHandler->m_RunningVarRequest = VariableRequest{}; | |||
|
842 | break; | |||
|
843 | } | |||
|
844 | case VariableRequestHandlerState::PENDING: { | |||
|
845 | varHandler->m_State = VariableRequestHandlerState::RUNNING; | |||
|
846 | varHandler->m_RunningVarRequest = varHandler->m_PendingVarRequest; | |||
|
847 | varHandler->m_PendingVarRequest = VariableRequest{}; | |||
|
848 | auto var = findVariable(itVarHandler->first); | |||
|
849 | executeVarRequest(var, varHandler->m_RunningVarRequest); | |||
|
850 | break; | |||
|
851 | } | |||
|
852 | default: | |||
|
853 | qCCritical(LOG_VariableController()) | |||
|
854 | << QObject::tr("Unknown VariableRequestHandlerState"); | |||
844 | } |
|
855 | } | |
845 | else { |
|
|||
846 | ++varIdToVarRequestIdQueueMapIt; |
|
|||
847 | } |
|
856 | } | |
848 | } |
|
857 | } | |
849 | } |
|
858 | } | |
850 |
|
859 | |||
851 | void VariableController::VariableControllerPrivate::abortVariableRequest(QUuid varRequestId) |
|
860 | ||
|
861 | void VariableController::VariableControllerPrivate::cancelVariableRequest(QUuid varRequestId) | |||
852 | { |
|
862 | { | |
853 | auto varRequestIdsMap = std::map<QUuid, VariableRequest>{}; |
|
863 | auto varGroupIdToVarIdsIt = m_VarGroupIdToVarIds.find(varRequestId); | |
854 | auto varRequestIdToVarIdVarRequestMapIt = m_VarRequestIdToVarIdVarRequestMap.find(varRequestId); |
|
864 | if (varGroupIdToVarIdsIt == m_VarGroupIdToVarIds.end()) { | |
855 | if (varRequestIdToVarIdVarRequestMapIt != m_VarRequestIdToVarIdVarRequestMap.cend()) { |
|
865 | // TODO LOG cannot cancel variable request since varGroupdId isn't here anymore | |
856 | varRequestIdsMap = varRequestIdToVarIdVarRequestMapIt->second; |
|
866 | return; | |
857 | } |
|
867 | } | |
858 | qCCritical(LOG_VariableController()) |
|
|||
859 | << tr("abortVariableRequest : varRequestId and count of aborting") << varRequestId |
|
|||
860 | << varRequestIdsMap.size(); |
|
|||
861 |
|
868 | |||
862 | auto nextUuidToRemove = QSet<QUuid>{}; |
|
869 | auto &varIds = varGroupIdToVarIdsIt->second; | |
863 |
auto varIdEnd = var |
|
870 | auto varIdsEnd = varIds.end(); | |
864 |
for (auto varIdIt = var |
|
871 | for (auto varIdsIt = varIds.begin(); (varIdsIt != varIdsEnd); ++varIdsIt) { | |
865 | auto currentVarId = varIdIt->first; |
|
872 | auto itVarHandler = m_VarIdToVarRequestHandler.find(*varIdsIt); | |
866 | auto varIdToVarRequestIdQueueMapIt = m_VarIdToVarRequestIdQueueMap.find(currentVarId); |
|
873 | if (itVarHandler == m_VarIdToVarRequestHandler.cend()) { | |
867 | if (varIdToVarRequestIdQueueMapIt != m_VarIdToVarRequestIdQueueMap.cend()) { |
|
|||
868 |
|
874 | |||
869 | auto &varRequestIdQueue = varIdToVarRequestIdQueueMapIt->second; |
|
875 | auto varHandler = itVarHandler->second.get(); | |
870 |
|
876 | varHandler->m_CanUpdate = false; | ||
871 | auto varReqIdQueueEnd = varRequestIdQueue.end(); |
|
877 | varHandler->m_VarId = QUuid{}; | |
872 | for (auto varReqIdQueueIt = varRequestIdQueue.begin(); |
|
878 | switch (varHandler->m_State) { | |
873 | varReqIdQueueIt != varRequestIdQueue.end(); ++varReqIdQueueIt) { |
|
879 | case VariableRequestHandlerState::OFF: { | |
874 | if (*varReqIdQueueIt == varRequestId) { |
|
880 | qCWarning(LOG_VariableController()) | |
875 | auto nextVarRequestIdToRm = varReqIdQueueIt; |
|
881 | << QObject::tr("Impossible to cancel a variable with no running request"); | |
876 |
|
|
882 | break; | |
|
883 | } | |||
|
884 | case VariableRequestHandlerState::RUNNING: { | |||
877 |
|
885 | |||
878 | if (nextVarRequestIdToRm == varReqIdQueueEnd) { |
|
886 | if (varHandler->m_RunningVarRequest.m_VariableGroupId == varRequestId) { | |
879 | // The varRequestId is in progress for the current var, let's aborting it. |
|
887 | auto var = findVariable(itVarHandler->first); | |
880 | m_VariableAcquisitionWorker->abortProgressRequested(currentVarId); |
|
888 | auto varProvider = m_VariableToProviderMap.at(var); | |
|
889 | if (varProvider != nullptr) { | |||
|
890 | m_VariableAcquisitionWorker->abortProgressRequested( | |||
|
891 | itVarHandler->first); | |||
881 | } |
|
892 | } | |
882 | else { |
|
893 | varHandler->m_RunningVarRequest = VariableRequest{}; | |
883 | // There is at least one Request after |
|
|||
884 | // let's add only new id to remove |
|
|||
885 | if (!nextUuidToRemove.contains(*nextVarRequestIdToRm)) { |
|
|||
886 | nextUuidToRemove << *nextVarRequestIdToRm; |
|
|||
887 |
|
|
894 | } | |
|
895 | else { | |||
|
896 | // TODO: log Impossible to cancel the running variable request beacause its | |||
|
897 | // varRequestId isn't not the canceled one | |||
888 | } |
|
898 | } | |
889 |
|
||||
890 | qCCritical(LOG_VariableController()) << tr("remove the request : aborting") |
|
|||
891 | << currentVarId; |
|
|||
892 |
|
||||
893 | varReqIdQueueIt = varRequestIdQueue.erase(varReqIdQueueIt); |
|
|||
894 | // break is necessary here, we don"t need to iterate on the dequeue anymore and |
|
|||
895 | // the iteration is broken because of the erase |
|
|||
896 | break; |
|
899 | break; | |
897 | } |
|
900 | } | |
|
901 | case VariableRequestHandlerState::PENDING: { | |||
|
902 | if (varHandler->m_RunningVarRequest.m_VariableGroupId == varRequestId) { | |||
|
903 | auto var = findVariable(itVarHandler->first); | |||
|
904 | auto varProvider = m_VariableToProviderMap.at(var); | |||
|
905 | if (varProvider != nullptr) { | |||
|
906 | m_VariableAcquisitionWorker->abortProgressRequested( | |||
|
907 | itVarHandler->first); | |||
898 | } |
|
908 | } | |
899 |
|
909 | varHandler->m_RunningVarRequest = varHandler->m_PendingVarRequest; | ||
900 | // beacause the process can modify the map under the iteration, we need to update the |
|
910 | executeVarRequest(var, varHandler->m_RunningVarRequest); | |
901 | // iterator only if no erase has been done |
|
911 | } | |
902 | if (varRequestIdQueue.empty()) { |
|
912 | else if (varHandler->m_PendingVarRequest.m_VariableGroupId == varRequestId) { | |
903 | varIdIt = varRequestIdsMap.erase(varIdIt); |
|
913 | varHandler->m_PendingVarRequest = VariableRequest{}; | |
904 | } |
|
914 | } | |
905 | else { |
|
915 | else { | |
906 | ++varIdIt; |
|
916 | // TODO: log Impossible to cancel the variable request beacause its | |
|
917 | // varRequestId isn't not the canceled one | |||
907 | } |
|
918 | } | |
|
919 | break; | |||
908 | } |
|
920 | } | |
|
921 | default: | |||
|
922 | qCCritical(LOG_VariableController()) | |||
|
923 | << QObject::tr("Unknown VariableRequestHandlerState"); | |||
909 | } |
|
924 | } | |
910 |
|
||||
911 | if (varRequestIdToVarIdVarRequestMapIt != m_VarRequestIdToVarIdVarRequestMap.cend()) { |
|
|||
912 | qCCritical(LOG_VariableController()) << tr("remove the varRequestId"); |
|
|||
913 | m_VarRequestIdToVarIdVarRequestMap.erase(varRequestIdToVarIdVarRequestMapIt); |
|
|||
914 | } |
|
925 | } | |
915 |
|
||||
916 | for (auto nextVarRequestIdToRm : nextUuidToRemove) { |
|
|||
917 | qCCritical(LOG_VariableController()) << tr("Cancel automaticaly the next request:") |
|
|||
918 | << nextVarRequestIdToRm; |
|
|||
919 | abortVariableRequest(nextVarRequestIdToRm); |
|
|||
920 | } |
|
926 | } | |
921 | } |
|
927 | } | |
922 |
|
928 | |||
923 |
|
|
929 | void VariableController::VariableControllerPrivate::executeVarRequest(std::shared_ptr<Variable> var, | |
|
930 | VariableRequest &varRequest) | |||
924 | { |
|
931 | { | |
925 | auto lastRangeRequested = SqpRange{INVALID_RANGE}; |
|
932 | qCCritical(LOG_VariableController()) << tr("TORM: executeVarRequest"); | |
926 | auto varIdToVarRequestIdQueueMapIt = m_VarIdToVarRequestIdQueueMap.find(varId); |
|
933 | ||
927 | if (varIdToVarRequestIdQueueMapIt != m_VarIdToVarRequestIdQueueMap.cend()) { |
|
934 | auto varId = m_VariableToIdentifierMap.at(var); | |
928 | auto &varRequestIdQueue = varIdToVarRequestIdQueueMapIt->second; |
|
935 | ||
929 | auto varRequestId = varRequestIdQueue.back(); |
|
936 | auto varCacheRange = var->cacheRange(); | |
930 | auto varRequestIdToVarIdVarRequestMapIt |
|
937 | auto varCacheRangeRequested = varRequest.m_CacheRangeRequested; | |
931 | = m_VarRequestIdToVarIdVarRequestMap.find(varRequestId); |
|
938 | auto notInCacheRangeList | |
932 | if (varRequestIdToVarIdVarRequestMapIt != m_VarRequestIdToVarIdVarRequestMap.cend()) { |
|
939 | = Variable::provideNotInCacheRangeList(varCacheRange, varCacheRangeRequested); | |
933 | auto &varIdToVarRequestMap = varRequestIdToVarIdVarRequestMapIt->second; |
|
940 | // auto inCacheRangeList | |
934 | auto varIdToVarRequestMapIt = varIdToVarRequestMap.find(varId); |
|
941 | // = Variable::provideInCacheRangeList(varCacheRange, varCacheRangeRequested); | |
935 | if (varIdToVarRequestMapIt != varIdToVarRequestMap.cend()) { |
|
942 | ||
936 | auto &varRequest = varIdToVarRequestMapIt->second; |
|
943 | if (!notInCacheRangeList.empty()) { | |
937 | lastRangeRequested = varRequest.m_RangeRequested; |
|
944 | ||
938 | } |
|
945 | auto varProvider = m_VariableToProviderMap.at(var); | |
939 | else { |
|
946 | if (varProvider != nullptr) { | |
940 |
|
|
947 | qCCritical(LOG_VariableController()) << "executeVarRequest " | |
941 | << tr("Impossible to getLastRequestedRange of a unknown variable id attached " |
|
948 | << varRequest.m_RangeRequested | |
942 |
|
|
949 | << varRequest.m_CacheRangeRequested; | |
943 | << varRequestId << varId; |
|
950 | m_VariableAcquisitionWorker->pushVariableRequest( | |
944 | } |
|
951 | varRequest.m_VariableGroupId, varId, varRequest.m_RangeRequested, | |
|
952 | varRequest.m_CacheRangeRequested, | |||
|
953 | DataProviderParameters{std::move(notInCacheRangeList), var->metadata()}, | |||
|
954 | varProvider); | |||
945 | } |
|
955 | } | |
946 | else { |
|
956 | else { | |
947 | qCCritical(LOG_VariableController()) |
|
957 | qCCritical(LOG_VariableController()) | |
948 | << tr("Impossible to getLastRequestedRange of a unknown variableRequestId") |
|
958 | << "Impossible to provide data with a null provider"; | |
949 | << varRequestId; |
|
|||
950 | } |
|
959 | } | |
|
960 | ||||
|
961 | // if (!inCacheRangeList.empty()) { | |||
|
962 | // emit q->updateVarDisplaying(var, inCacheRangeList.first()); | |||
|
963 | // } | |||
951 | } |
|
964 | } | |
952 | else { |
|
965 | else { | |
953 | qDebug(LOG_VariableController()) |
|
966 | acceptVariableRequest(varId, | |
954 | << tr("Impossible to getLastRequestedRange of a unknown variable id") << varId; |
|
967 | var->dataSeries()->subDataSeries(varRequest.m_CacheRangeRequested)); | |
955 | } |
|
968 | } | |
956 |
|
||||
957 | return lastRangeRequested; |
|
|||
958 | } |
|
969 | } |
General Comments 3
Merge lasted acquisition developpement on main Sciqlop branch
You need to be logged in to leave comments.
Login now