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