##// END OF EJS Templates
The dataSeries of a variable is now shared istead of uniq to avoid...
perrinel -
r513:4e7b3226237d
parent child
Show More
@@ -25,7 +25,7 struct Variable::VariablePrivate {
25 25 SqpRange m_Range;
26 26 SqpRange m_CacheRange;
27 27 QVariantHash m_Metadata;
28 std::unique_ptr<IDataSeries> m_DataSeries;
28 std::shared_ptr<IDataSeries> m_DataSeries;
29 29
30 30 QReadWriteLock m_Lock;
31 31 };
@@ -75,7 +75,8 void Variable::setCacheRange(const SqpRange &cacheRange) noexcept
75 75
76 76 void Variable::setDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept
77 77 {
78 qCInfo(LOG_Variable()) << "Variable::setDataSeries" << QThread::currentThread()->objectName();
78 qCDebug(LOG_Variable()) << "TORM Variable::setDataSeries"
79 << QThread::currentThread()->objectName();
79 80 if (!dataSeries) {
80 81 /// @todo ALX : log
81 82 return;
@@ -87,7 +88,7 void Variable::setDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept
87 88
88 89 void Variable::mergeDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept
89 90 {
90 qCDebug(LOG_Variable()) << "Variable::mergeDataSeries"
91 qCDebug(LOG_Variable()) << "TORM Variable::mergeDataSeries"
91 92 << QThread::currentThread()->objectName();
92 93 if (!dataSeries) {
93 94 /// @todo ALX : log
@@ -107,16 +108,15 void Variable::mergeDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept
107 108
108 109 // sub the data
109 110 auto subData = this->dataSeries()->subData(this->cacheRange());
110 qCCritical(LOG_Variable()) << "TORM: Variable::mergeDataSeries sub" << subData->range();
111 qCDebug(LOG_Variable()) << "TORM: Variable::mergeDataSeries sub" << subData->range();
111 112 this->setDataSeries(subData);
112 qCCritical(LOG_Variable()) << "TORM: Variable::mergeDataSeries set"
113 << this->dataSeries()->range();
113 qCDebug(LOG_Variable()) << "TORM: Variable::mergeDataSeries set" << this->dataSeries()->range();
114 114 }
115 115
116 IDataSeries *Variable::dataSeries() const noexcept
116 std::shared_ptr<IDataSeries> Variable::dataSeries() const noexcept
117 117 {
118 118 impl->lockRead();
119 auto dataSeries = impl->m_DataSeries.get();
119 auto dataSeries = impl->m_DataSeries;
120 120 impl->unlock();
121 121
122 122 return dataSeries;
@@ -51,7 +51,7 void VariableAcquisitionWorker::pushVariableRequest(QUuid vIdentifier, SqpRange
51 51 DataProviderParameters parameters,
52 52 std::shared_ptr<IDataProvider> provider)
53 53 {
54 qCDebug(LOG_VariableAcquisitionWorker())
54 qCInfo(LOG_VariableAcquisitionWorker())
55 55 << tr("TORM VariableAcquisitionWorker::pushVariableRequest ") << cacheRangeRequested;
56 56
57 57 // Request creation
@@ -173,7 +173,7 void VariableAcquisitionWorker::onVariableDataAcquired(QUuid acqIdentifier,
173 173
174 174 void VariableAcquisitionWorker::onExecuteRequest(QUuid acqIdentifier)
175 175 {
176 qCDebug(LOG_VariableAcquisitionWorker()) << tr("onExecuteRequest") << QThread::currentThread();
176 qCInfo(LOG_VariableAcquisitionWorker()) << tr("onExecuteRequest") << QThread::currentThread();
177 177 impl->lockRead();
178 178 auto it = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier);
179 179 if (it != impl->m_AcqIdentifierToAcqRequestMap.cend()) {
@@ -274,6 +274,7 void VariableController::onDataProvided(QUuid vIdentifier, const SqpRange &range
274 274 qCDebug(LOG_VariableController()) << tr("3: onDataProvided")
275 275 << retrievedDataSeries->range();
276 276 var->mergeDataSeries(retrievedDataSeries);
277 qCDebug(LOG_VariableController()) << tr("4: onDataProvided");
277 278 emit var->updated();
278 279 }
279 280 else {
@@ -358,7 +359,7 void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable>
358 359 {
359 360 // NOTE: oldRange isn't really necessary since oldRange == variable->range().
360 361
361 qCDebug(LOG_VariableController()) << "VariableController::onRequestDataLoading"
362 qCInfo(LOG_VariableController()) << "VariableController::onRequestDataLoading"
362 363 << QThread::currentThread()->objectName();
363 364 // we want to load data of the variable for the dateTime.
364 365 // First we check if the cache contains some of them.
@@ -466,8 +467,6 void VariableController::VariableControllerPrivate::processRequest(std::shared_p
466 467 auto notInCacheRangeList = var->provideNotInCacheRangeList(varRangesRequested.second);
467 468
468 469 if (!notInCacheRangeList.empty()) {
469 // Display part of data which are already there
470 // Ask the provider for each data on the dateTimeListNotInCache
471 470 auto identifier = m_VariableToIdentifierMap.at(var);
472 471 auto varProvider = m_VariableToProviderMap.at(var);
473 472 if (varProvider != nullptr) {
@@ -511,7 +510,7 VariableController::VariableControllerPrivate::findVariable(QUuid vIdentifier)
511 510 std::shared_ptr<IDataSeries> VariableController::VariableControllerPrivate::retrieveDataSeries(
512 511 const QVector<AcquisitionDataPacket> acqDataPacketVector)
513 512 {
514 qCInfo(LOG_VariableController()) << tr("TORM: retrieveDataSeries acqDataPacketVector size")
513 qCDebug(LOG_VariableController()) << tr("TORM: retrieveDataSeries acqDataPacketVector size")
515 514 << acqDataPacketVector.size();
516 515 std::shared_ptr<IDataSeries> dataSeries;
517 516 if (!acqDataPacketVector.isEmpty()) {
@@ -520,7 +519,8 std::shared_ptr<IDataSeries> VariableController::VariableControllerPrivate::retr
520 519 dataSeries->merge(acqDataPacketVector[i].m_DateSeries.get());
521 520 }
522 521 }
523
522 qCDebug(LOG_VariableController()) << tr("TORM: retrieveDataSeries acqDataPacketVector size END")
523 << acqDataPacketVector.size();
524 524 return dataSeries;
525 525 }
526 526
@@ -528,7 +528,7 void VariableController::VariableControllerPrivate::registerProvider(
528 528 std::shared_ptr<IDataProvider> provider)
529 529 {
530 530 if (m_ProviderSet.find(provider) == m_ProviderSet.end()) {
531 qCInfo(LOG_VariableController()) << tr("Registering of a new provider")
531 qCDebug(LOG_VariableController()) << tr("Registering of a new provider")
532 532 << provider->objectName();
533 533 m_ProviderSet.insert(provider);
534 534 connect(provider.get(), &IDataProvider::dataProvided, m_VariableAcquisitionWorker.get(),
@@ -31,8 +31,8 struct VisualizationGraphHelper {
31 31 static QVector<QCPAbstractPlottable *> create(std::shared_ptr<Variable> variable,
32 32 QCustomPlot &plot) noexcept;
33 33
34 static void updateData(QVector<QCPAbstractPlottable *> plotableVect, IDataSeries *dataSeries,
35 const SqpRange &dateTime);
34 static void updateData(QVector<QCPAbstractPlottable *> plotableVect,
35 std::shared_ptr<IDataSeries> dataSeries, const SqpRange &dateTime);
36 36 };
37 37
38 38 #endif // SCIQLOP_VISUALIZATIONGRAPHHELPER_H
@@ -35,21 +35,21 QSharedPointer<QCPAxisTicker> axisTicker(bool isTimeAxis)
35 35 }
36 36 }
37 37
38 void updateScalarData(QCPAbstractPlottable *component, ScalarSeries &scalarSeries,
38 void updateScalarData(QCPAbstractPlottable *component, std::shared_ptr<ScalarSeries> scalarSeries,
39 39 const SqpRange &dateTime)
40 40 {
41 41 qCDebug(LOG_VisualizationGraphHelper()) << "TORM: updateScalarData"
42 42 << QThread::currentThread()->objectName();
43 43 if (auto qcpGraph = dynamic_cast<QCPGraph *>(component)) {
44 scalarSeries.lockRead();
44 scalarSeries->lockRead();
45 45 {
46 const auto &xData = scalarSeries.xAxisData()->cdata();
47 const auto &valuesData = scalarSeries.valuesData()->cdata();
46 const auto &xData = scalarSeries->xAxisData()->cdata();
47 const auto &valuesData = scalarSeries->valuesData()->cdata();
48 48
49 49 auto xDataBegin = xData.cbegin();
50 50 auto xDataEnd = xData.cend();
51 51
52 qCInfo(LOG_VisualizationGraphHelper()) << "TORM: Current points in cache"
52 qCInfo(LOG_VisualizationGraphHelper()) << "TODEBUG: Current points in cache"
53 53 << xData.count();
54 54
55 55 auto sqpDataContainer = QSharedPointer<SqpDataContainer>::create();
@@ -65,10 +65,10 void updateScalarData(QCPAbstractPlottable *component, ScalarSeries &scalarSerie
65 65 sqpDataContainer->appendGraphData(QCPGraphData(*xAxisDataIt, *valuesDataIt));
66 66 }
67 67
68 qCInfo(LOG_VisualizationGraphHelper()) << "TORM: Current points displayed"
68 qCInfo(LOG_VisualizationGraphHelper()) << "TODEBUG: Current points displayed"
69 69 << sqpDataContainer->size();
70 70 }
71 scalarSeries.unlock();
71 scalarSeries->unlock();
72 72
73 73
74 74 // Display all data
@@ -79,14 +79,14 void updateScalarData(QCPAbstractPlottable *component, ScalarSeries &scalarSerie
79 79 }
80 80 }
81 81
82 QCPAbstractPlottable *createScalarSeriesComponent(ScalarSeries &scalarSeries, QCustomPlot &plot,
83 const SqpRange &dateTime)
82 QCPAbstractPlottable *createScalarSeriesComponent(std::shared_ptr<ScalarSeries> scalarSeries,
83 QCustomPlot &plot, const SqpRange &dateTime)
84 84 {
85 85 auto component = plot.addGraph();
86 86
87 87 if (component) {
88 88 // // Graph data
89 component->setData(scalarSeries.xAxisData()->data(), scalarSeries.valuesData()->data(),
89 component->setData(scalarSeries->xAxisData()->data(), scalarSeries->valuesData()->data(),
90 90 true);
91 91
92 92 updateScalarData(component, scalarSeries, dateTime);
@@ -102,8 +102,8 QCPAbstractPlottable *createScalarSeriesComponent(ScalarSeries &scalarSeries, QC
102 102 // ticker (depending on the type of unit)
103 103 axis->setTicker(axisTicker(unit.m_TimeUnit));
104 104 };
105 setAxisProperties(plot.xAxis, scalarSeries.xAxisUnit());
106 setAxisProperties(plot.yAxis, scalarSeries.valuesUnit());
105 setAxisProperties(plot.xAxis, scalarSeries->xAxisUnit());
106 setAxisProperties(plot.yAxis, scalarSeries->valuesUnit());
107 107
108 108 // Display all data
109 109 component->rescaleAxes();
@@ -127,8 +127,8 QVector<QCPAbstractPlottable *> VisualizationGraphHelper::create(std::shared_ptr
127 127 if (variable) {
128 128 // Gets the data series of the variable to call the creation of the right components
129 129 // according to its type
130 if (auto scalarSeries = dynamic_cast<ScalarSeries *>(variable->dataSeries())) {
131 result.append(createScalarSeriesComponent(*scalarSeries, plot, variable->range()));
130 if (auto scalarSeries = std::dynamic_pointer_cast<ScalarSeries>(variable->dataSeries())) {
131 result.append(createScalarSeriesComponent(scalarSeries, plot, variable->range()));
132 132 }
133 133 else {
134 134 qCDebug(LOG_VisualizationGraphHelper())
@@ -144,11 +144,12 QVector<QCPAbstractPlottable *> VisualizationGraphHelper::create(std::shared_ptr
144 144 }
145 145
146 146 void VisualizationGraphHelper::updateData(QVector<QCPAbstractPlottable *> plotableVect,
147 IDataSeries *dataSeries, const SqpRange &dateTime)
147 std::shared_ptr<IDataSeries> dataSeries,
148 const SqpRange &dateTime)
148 149 {
149 if (auto scalarSeries = dynamic_cast<ScalarSeries *>(dataSeries)) {
150 if (auto scalarSeries = std::dynamic_pointer_cast<ScalarSeries>(dataSeries)) {
150 151 if (plotableVect.size() == 1) {
151 updateScalarData(plotableVect.at(0), *scalarSeries, dateTime);
152 updateScalarData(plotableVect.at(0), scalarSeries, dateTime);
152 153 }
153 154 else {
154 155 qCCritical(LOG_VisualizationGraphHelper()) << QObject::tr(
@@ -235,7 +235,7 void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange
235 235 !impl->m_IsCalibration);
236 236
237 237 if (!impl->m_IsCalibration) {
238 qCInfo(LOG_VisualizationGraphWidget())
238 qCDebug(LOG_VisualizationGraphWidget())
239 239 << tr("TORM: VisualizationGraphWidget::Synchronize notify !!")
240 240 << QThread::currentThread()->objectName() << graphRange << oldGraphRange;
241 241 emit synchronize(graphRange, oldGraphRange);
@@ -81,6 +81,7 void CosinusProvider::requestDataLoading(QUuid acqIdentifier,
81 81 for (const auto &dateTime : qAsConst(times)) {
82 82 if (m_VariableToEnableProvider[acqIdentifier]) {
83 83 auto scalarSeries = this->retrieveData(acqIdentifier, dateTime);
84 qCCritical(LOG_CosinusProvider()) << "CosinusProvider::dataProvided";
84 85 emit dataProvided(acqIdentifier, scalarSeries, dateTime);
85 86 }
86 87 }
General Comments 1
Under Review
author

Auto status change to "Under Review"

You need to be logged in to leave comments. Login now