|
@@
-4,6
+4,7
|
|
4
|
#include <Variable/VariableController.h>
|
|
4
|
#include <Variable/VariableController.h>
|
|
5
|
#include <Variable/VariableModel.h>
|
|
5
|
#include <Variable/VariableModel.h>
|
|
6
|
#include <Variable/VariableSynchronizationGroup.h>
|
|
6
|
#include <Variable/VariableSynchronizationGroup.h>
|
|
|
|
|
7
|
#include <Variable/cachestrategyfactory.h>
|
|
7
|
|
|
8
|
|
|
8
|
#include <Data/DataProviderParameters.h>
|
|
9
|
#include <Data/DataProviderParameters.h>
|
|
9
|
#include <Data/IDataProvider.h>
|
|
10
|
#include <Data/IDataProvider.h>
|
|
@@
-79,7
+80,9
struct VariableController::VariableControllerPrivate {
|
|
79
|
: m_WorkingMutex{},
|
|
80
|
: m_WorkingMutex{},
|
|
80
|
m_VariableModel{new VariableModel{parent}},
|
|
81
|
m_VariableModel{new VariableModel{parent}},
|
|
81
|
m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}},
|
|
82
|
m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}},
|
|
82
|
m_VariableCacheStrategy{std::make_unique<VariableCacheStrategy>()},
|
|
83
|
// m_VariableCacheStrategy{std::make_unique<VariableCacheStrategy>()},
|
|
|
|
|
84
|
m_VariableCacheStrategy{
|
|
|
|
|
85
|
CacheStrategyFactory::createCacheStrategy(CacheStrategy::SingleThreshold)},
|
|
83
|
m_VariableAcquisitionWorker{std::make_unique<VariableAcquisitionWorker>()},
|
|
86
|
m_VariableAcquisitionWorker{std::make_unique<VariableAcquisitionWorker>()},
|
|
84
|
q{parent}
|
|
87
|
q{parent}
|
|
85
|
{
|
|
88
|
{
|
|
@@
-145,8
+148,8
struct VariableController::VariableControllerPrivate {
|
|
145
|
VariableController::VariableController(QObject *parent)
|
|
148
|
VariableController::VariableController(QObject *parent)
|
|
146
|
: QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)}
|
|
149
|
: QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)}
|
|
147
|
{
|
|
150
|
{
|
|
148
|
qCDebug(LOG_VariableController()) << tr("VariableController construction")
|
|
151
|
qCDebug(LOG_VariableController())
|
|
149
|
<< QThread::currentThread();
|
|
152
|
<< tr("VariableController construction") << QThread::currentThread();
|
|
150
|
|
|
153
|
|
|
151
|
connect(impl->m_VariableModel, &VariableModel::abortProgessRequested, this,
|
|
154
|
connect(impl->m_VariableModel, &VariableModel::abortProgessRequested, this,
|
|
152
|
&VariableController::onAbortProgressRequested);
|
|
155
|
&VariableController::onAbortProgressRequested);
|
|
@@
-173,8
+176,8
VariableController::VariableController(QObject *parent)
|
|
173
|
|
|
176
|
|
|
174
|
VariableController::~VariableController()
|
|
177
|
VariableController::~VariableController()
|
|
175
|
{
|
|
178
|
{
|
|
176
|
qCDebug(LOG_VariableController()) << tr("VariableController destruction")
|
|
179
|
qCDebug(LOG_VariableController())
|
|
177
|
<< QThread::currentThread();
|
|
180
|
<< tr("VariableController destruction") << QThread::currentThread();
|
|
178
|
this->waitForFinish();
|
|
181
|
this->waitForFinish();
|
|
179
|
}
|
|
182
|
}
|
|
180
|
|
|
183
|
|
|
@@
-293,8
+296,8
VariableController::createVariable(const QString &name, const QVariantHash &meta
|
|
293
|
void VariableController::onDateTimeOnSelection(const SqpRange &dateTime)
|
|
296
|
void VariableController::onDateTimeOnSelection(const SqpRange &dateTime)
|
|
294
|
{
|
|
297
|
{
|
|
295
|
// TODO check synchronisation and Rescale
|
|
298
|
// TODO check synchronisation and Rescale
|
|
296
|
qCDebug(LOG_VariableController()) << "VariableController::onDateTimeOnSelection"
|
|
299
|
qCDebug(LOG_VariableController())
|
|
297
|
<< QThread::currentThread()->objectName();
|
|
300
|
<< "VariableController::onDateTimeOnSelection" << QThread::currentThread()->objectName();
|
|
298
|
auto selectedRows = impl->m_VariableSelectionModel->selectedRows();
|
|
301
|
auto selectedRows = impl->m_VariableSelectionModel->selectedRows();
|
|
299
|
auto varRequestId = QUuid::createUuid();
|
|
302
|
auto varRequestId = QUuid::createUuid();
|
|
300
|
|
|
303
|
|
|
@@
-380,9
+383,9
void VariableController::onAbortAcquisitionRequested(QUuid vIdentifier)
|
|
380
|
|
|
383
|
|
|
381
|
void VariableController::onAddSynchronizationGroupId(QUuid synchronizationGroupId)
|
|
384
|
void VariableController::onAddSynchronizationGroupId(QUuid synchronizationGroupId)
|
|
382
|
{
|
|
385
|
{
|
|
383
|
qCDebug(LOG_VariableController()) << "TORM: VariableController::onAddSynchronizationGroupId"
|
|
386
|
qCDebug(LOG_VariableController())
|
|
384
|
<< QThread::currentThread()->objectName()
|
|
387
|
<< "TORM: VariableController::onAddSynchronizationGroupId"
|
|
385
|
<< synchronizationGroupId;
|
|
388
|
<< QThread::currentThread()->objectName() << synchronizationGroupId;
|
|
386
|
auto vSynchroGroup = std::make_shared<VariableSynchronizationGroup>();
|
|
389
|
auto vSynchroGroup = std::make_shared<VariableSynchronizationGroup>();
|
|
387
|
impl->m_GroupIdToVariableSynchronizationGroupMap.insert(
|
|
390
|
impl->m_GroupIdToVariableSynchronizationGroupMap.insert(
|
|
388
|
std::make_pair(synchronizationGroupId, vSynchroGroup));
|
|
391
|
std::make_pair(synchronizationGroupId, vSynchroGroup));
|
|
@@
-397,8
+400,8
void VariableController::onAddSynchronized(std::shared_ptr<Variable> variable,
|
|
397
|
QUuid synchronizationGroupId)
|
|
400
|
QUuid synchronizationGroupId)
|
|
398
|
|
|
401
|
|
|
399
|
{
|
|
402
|
{
|
|
400
|
qCDebug(LOG_VariableController()) << "TORM: VariableController::onAddSynchronized"
|
|
403
|
qCDebug(LOG_VariableController())
|
|
401
|
<< synchronizationGroupId;
|
|
404
|
<< "TORM: VariableController::onAddSynchronized" << synchronizationGroupId;
|
|
402
|
auto varToVarIdIt = impl->m_VariableToIdentifierMap.find(variable);
|
|
405
|
auto varToVarIdIt = impl->m_VariableToIdentifierMap.find(variable);
|
|
403
|
if (varToVarIdIt != impl->m_VariableToIdentifierMap.cend()) {
|
|
406
|
if (varToVarIdIt != impl->m_VariableToIdentifierMap.cend()) {
|
|
404
|
auto groupIdToVSGIt
|
|
407
|
auto groupIdToVSGIt
|
|
@@
-503,8
+506,8
void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable>
|
|
503
|
// Don't process already processed var
|
|
506
|
// Don't process already processed var
|
|
504
|
if (!variables.contains(var)) {
|
|
507
|
if (!variables.contains(var)) {
|
|
505
|
if (var != nullptr) {
|
|
508
|
if (var != nullptr) {
|
|
506
|
qCDebug(LOG_VariableController()) << "processRequest synchro for"
|
|
509
|
qCDebug(LOG_VariableController())
|
|
507
|
<< var->name();
|
|
510
|
<< "processRequest synchro for" << var->name();
|
|
508
|
auto vSyncRangeRequested = computeSynchroRangeRequested(
|
|
511
|
auto vSyncRangeRequested = computeSynchroRangeRequested(
|
|
509
|
var->range(), range, groupIdToOldRangeMap.at(gId));
|
|
512
|
var->range(), range, groupIdToOldRangeMap.at(gId));
|
|
510
|
qCDebug(LOG_VariableController()) << "synchro RR" << vSyncRangeRequested;
|
|
513
|
qCDebug(LOG_VariableController()) << "synchro RR" << vSyncRangeRequested;
|
|
@@
-573,7
+576,7
void VariableController::VariableControllerPrivate::processRequest(std::shared_p
|
|
573
|
auto varId = m_VariableToIdentifierMap.at(var);
|
|
576
|
auto varId = m_VariableToIdentifierMap.at(var);
|
|
574
|
|
|
577
|
|
|
575
|
auto varStrategyRangesRequested
|
|
578
|
auto varStrategyRangesRequested
|
|
576
|
= m_VariableCacheStrategy->computeStrategyRanges(var->range(), rangeRequested);
|
|
579
|
= m_VariableCacheStrategy->computeRange(var->range(), rangeRequested);
|
|
577
|
|
|
580
|
|
|
578
|
auto notInCacheRangeList = QVector<SqpRange>{varStrategyRangesRequested.second};
|
|
581
|
auto notInCacheRangeList = QVector<SqpRange>{varStrategyRangesRequested.second};
|
|
579
|
auto inCacheRangeList = QVector<SqpRange>{};
|
|
582
|
auto inCacheRangeList = QVector<SqpRange>{};
|
|
@@
-598,8
+601,8
void VariableController::VariableControllerPrivate::processRequest(std::shared_p
|
|
598
|
varProvider);
|
|
601
|
varProvider);
|
|
599
|
|
|
602
|
|
|
600
|
if (!varRequestIdCanceled.isNull()) {
|
|
603
|
if (!varRequestIdCanceled.isNull()) {
|
|
601
|
qCDebug(LOG_VariableAcquisitionWorker()) << tr("vsarRequestIdCanceled: ")
|
|
604
|
qCDebug(LOG_VariableAcquisitionWorker())
|
|
602
|
<< varRequestIdCanceled;
|
|
605
|
<< tr("vsarRequestIdCanceled: ") << varRequestIdCanceled;
|
|
603
|
cancelVariableRequest(varRequestIdCanceled);
|
|
606
|
cancelVariableRequest(varRequestIdCanceled);
|
|
604
|
}
|
|
607
|
}
|
|
605
|
}
|
|
608
|
}
|
|
@@
-644,8
+647,8
VariableController::VariableControllerPrivate::findVariable(QUuid vIdentifier)
|
|
644
|
std::shared_ptr<IDataSeries> VariableController::VariableControllerPrivate::retrieveDataSeries(
|
|
647
|
std::shared_ptr<IDataSeries> VariableController::VariableControllerPrivate::retrieveDataSeries(
|
|
645
|
const QVector<AcquisitionDataPacket> acqDataPacketVector)
|
|
648
|
const QVector<AcquisitionDataPacket> acqDataPacketVector)
|
|
646
|
{
|
|
649
|
{
|
|
647
|
qCDebug(LOG_VariableController()) << tr("TORM: retrieveDataSeries acqDataPacketVector size")
|
|
650
|
qCDebug(LOG_VariableController())
|
|
648
|
<< acqDataPacketVector.size();
|
|
651
|
<< tr("TORM: retrieveDataSeries acqDataPacketVector size") << acqDataPacketVector.size();
|
|
649
|
std::shared_ptr<IDataSeries> dataSeries;
|
|
652
|
std::shared_ptr<IDataSeries> dataSeries;
|
|
650
|
if (!acqDataPacketVector.isEmpty()) {
|
|
653
|
if (!acqDataPacketVector.isEmpty()) {
|
|
651
|
dataSeries = acqDataPacketVector[0].m_DateSeries;
|
|
654
|
dataSeries = acqDataPacketVector[0].m_DateSeries;
|
|
@@
-662,8
+665,8
void VariableController::VariableControllerPrivate::registerProvider(
|
|
662
|
std::shared_ptr<IDataProvider> provider)
|
|
665
|
std::shared_ptr<IDataProvider> provider)
|
|
663
|
{
|
|
666
|
{
|
|
664
|
if (m_ProviderSet.find(provider) == m_ProviderSet.end()) {
|
|
667
|
if (m_ProviderSet.find(provider) == m_ProviderSet.end()) {
|
|
665
|
qCDebug(LOG_VariableController()) << tr("Registering of a new provider")
|
|
668
|
qCDebug(LOG_VariableController())
|
|
666
|
<< provider->objectName();
|
|
669
|
<< tr("Registering of a new provider") << provider->objectName();
|
|
667
|
m_ProviderSet.insert(provider);
|
|
670
|
m_ProviderSet.insert(provider);
|
|
668
|
connect(provider.get(), &IDataProvider::dataProvided, m_VariableAcquisitionWorker.get(),
|
|
671
|
connect(provider.get(), &IDataProvider::dataProvided, m_VariableAcquisitionWorker.get(),
|
|
669
|
&VariableAcquisitionWorker::onVariableDataAcquired);
|
|
672
|
&VariableAcquisitionWorker::onVariableDataAcquired);
|
|
@@
-769,8
+772,8
void VariableController::VariableControllerPrivate::updateVariableRequest(QUuid
|
|
769
|
(varIdToVarRequestMapIt != varIdToVarRequestMap.cend()) && processVariableUpdate;
|
|
772
|
(varIdToVarRequestMapIt != varIdToVarRequestMap.cend()) && processVariableUpdate;
|
|
770
|
++varIdToVarRequestMapIt) {
|
|
773
|
++varIdToVarRequestMapIt) {
|
|
771
|
processVariableUpdate &= varIdToVarRequestMapIt->second.m_CanUpdate;
|
|
774
|
processVariableUpdate &= varIdToVarRequestMapIt->second.m_CanUpdate;
|
|
772
|
qCDebug(LOG_VariableController()) << tr("updateVariableRequest")
|
|
775
|
qCDebug(LOG_VariableController())
|
|
773
|
<< processVariableUpdate;
|
|
776
|
<< tr("updateVariableRequest") << processVariableUpdate;
|
|
774
|
}
|
|
777
|
}
|
|
775
|
|
|
778
|
|
|
776
|
if (processVariableUpdate) {
|
|
779
|
if (processVariableUpdate) {
|
|
@@
-780,13
+783,13
void VariableController::VariableControllerPrivate::updateVariableRequest(QUuid
|
|
780
|
auto &varRequest = varIdToVarRequestMapIt->second;
|
|
783
|
auto &varRequest = varIdToVarRequestMapIt->second;
|
|
781
|
var->setRange(varRequest.m_RangeRequested);
|
|
784
|
var->setRange(varRequest.m_RangeRequested);
|
|
782
|
var->setCacheRange(varRequest.m_CacheRangeRequested);
|
|
785
|
var->setCacheRange(varRequest.m_CacheRangeRequested);
|
|
783
|
qCDebug(LOG_VariableController()) << tr("1: onDataProvided")
|
|
786
|
qCDebug(LOG_VariableController())
|
|
784
|
<< varRequest.m_RangeRequested;
|
|
787
|
<< tr("1: onDataProvided") << varRequest.m_RangeRequested;
|
|
785
|
qCDebug(LOG_VariableController()) << tr("2: onDataProvided")
|
|
788
|
qCDebug(LOG_VariableController())
|
|
786
|
<< varRequest.m_CacheRangeRequested;
|
|
789
|
<< tr("2: onDataProvided") << varRequest.m_CacheRangeRequested;
|
|
787
|
var->mergeDataSeries(varRequest.m_DataSeries);
|
|
790
|
var->mergeDataSeries(varRequest.m_DataSeries);
|
|
788
|
qCDebug(LOG_VariableController()) << tr("3: onDataProvided")
|
|
791
|
qCDebug(LOG_VariableController())
|
|
789
|
<< varRequest.m_DataSeries->range();
|
|
792
|
<< tr("3: onDataProvided") << varRequest.m_DataSeries->range();
|
|
790
|
qCDebug(LOG_VariableController()) << tr("4: onDataProvided");
|
|
793
|
qCDebug(LOG_VariableController()) << tr("4: onDataProvided");
|
|
791
|
|
|
794
|
|
|
792
|
/// @todo MPL: confirm
|
|
795
|
/// @todo MPL: confirm
|
|
@@
-804,11
+807,11
void VariableController::VariableControllerPrivate::updateVariableRequest(QUuid
|
|
804
|
}
|
|
807
|
}
|
|
805
|
|
|
808
|
|
|
806
|
// cleaning varRequestId
|
|
809
|
// cleaning varRequestId
|
|
807
|
qCDebug(LOG_VariableController()) << tr("0: erase REQUEST in MAP ?")
|
|
810
|
qCDebug(LOG_VariableController())
|
|
808
|
<< m_VarRequestIdToVarIdVarRequestMap.size();
|
|
811
|
<< tr("0: erase REQUEST in MAP ?") << m_VarRequestIdToVarIdVarRequestMap.size();
|
|
809
|
m_VarRequestIdToVarIdVarRequestMap.erase(varRequestId);
|
|
812
|
m_VarRequestIdToVarIdVarRequestMap.erase(varRequestId);
|
|
810
|
qCDebug(LOG_VariableController()) << tr("1: erase REQUEST in MAP ?")
|
|
813
|
qCDebug(LOG_VariableController())
|
|
811
|
<< m_VarRequestIdToVarIdVarRequestMap.size();
|
|
814
|
<< tr("1: erase REQUEST in MAP ?") << m_VarRequestIdToVarIdVarRequestMap.size();
|
|
812
|
}
|
|
815
|
}
|
|
813
|
}
|
|
816
|
}
|
|
814
|
else {
|
|
817
|
else {
|