##// END OF EJS Templates
Correction for pull request
perrinel -
r227:e94f13bbc48f
parent child
Show More
@@ -4,8 +4,15
4 #include <Data/ArrayData.h>
4 #include <Data/ArrayData.h>
5 #include <Data/IDataSeries.h>
5 #include <Data/IDataSeries.h>
6
6
7 #include <QLoggingCategory>
8
7 #include <memory>
9 #include <memory>
8
10
11
12 Q_DECLARE_LOGGING_CATEGORY(LOG_DataSeries)
13 Q_LOGGING_CATEGORY(LOG_DataSeries, "DataSeries")
14
15
9 /**
16 /**
10 * @brief The DataSeries class is the base (abstract) implementation of IDataSeries.
17 * @brief The DataSeries class is the base (abstract) implementation of IDataSeries.
11 *
18 *
@@ -36,6 +43,10 public:
36 m_XAxisData->merge(dimDataSeries->xAxisData().get());
43 m_XAxisData->merge(dimDataSeries->xAxisData().get());
37 m_ValuesData->merge(dimDataSeries->valuesData().get());
44 m_ValuesData->merge(dimDataSeries->valuesData().get());
38 }
45 }
46 else {
47 qCWarning(LOG_DataSeries())
48 << QObject::tr("Dection of a type of IDataSeries we cannot merge with !");
49 }
39 }
50 }
40
51
41 protected:
52 protected:
@@ -31,7 +31,7 public:
31 virtual void requestDataLoading(const QVector<SqpDateTime> &dateTimeList) = 0;
31 virtual void requestDataLoading(const QVector<SqpDateTime> &dateTimeList) = 0;
32
32
33 signals:
33 signals:
34 void dataProvided(std::shared_ptr<IDataSeries> dateSerie, SqpDateTime dateTime);
34 void dataProvided(std::shared_ptr<IDataSeries> dateSerie, const SqpDateTime &dateTime);
35 };
35 };
36 // Required for using shared_ptr in signals/slots
36 // Required for using shared_ptr in signals/slots
37 Q_DECLARE_METATYPE(std::shared_ptr<IDataProvider>)
37 Q_DECLARE_METATYPE(std::shared_ptr<IDataProvider>)
@@ -33,7 +33,7 public:
33 /// @return the data of the variable, nullptr if there is no data
33 /// @return the data of the variable, nullptr if there is no data
34 IDataSeries *dataSeries() const noexcept;
34 IDataSeries *dataSeries() const noexcept;
35
35
36 bool contains(SqpDateTime dateTime);
36 bool contains(const SqpDateTime &dateTime);
37 void setDataSeries(std::unique_ptr<IDataSeries> dataSeries) noexcept;
37 void setDataSeries(std::unique_ptr<IDataSeries> dataSeries) noexcept;
38
38
39 public slots:
39 public slots:
@@ -9,7 +9,7
9
9
10 class Variable;
10 class Variable;
11
11
12 /// This class aims to store in the cash all of the dateTime already requested to the variable.
12 /// This class aims to store in the cache all of the dateTime already requested to the variable.
13 class VariableCacheController : public QObject {
13 class VariableCacheController : public QObject {
14 Q_OBJECT
14 Q_OBJECT
15 public:
15 public:
@@ -71,7 +71,7 IDataSeries *Variable::dataSeries() const noexcept
71 return impl->m_DataSeries.get();
71 return impl->m_DataSeries.get();
72 }
72 }
73
73
74 bool Variable::contains(SqpDateTime dateTime)
74 bool Variable::contains(const SqpDateTime &dateTime)
75 {
75 {
76 if (!impl->m_DateTime.contains(dateTime)) {
76 if (!impl->m_DateTime.contains(dateTime)) {
77 // The current variable dateTime isn't enough to display the dateTime requested.
77 // The current variable dateTime isn't enough to display the dateTime requested.
@@ -23,7 +23,7 struct VariableCacheController::VariableCacheControllerPrivate {
23
23
24
24
25 VariableCacheController::VariableCacheController(QObject *parent)
25 VariableCacheController::VariableCacheController(QObject *parent)
26 : QObject(parent), impl{spimpl::make_unique_impl<VariableCacheControllerPrivate>()}
26 : QObject{parent}, impl{spimpl::make_unique_impl<VariableCacheControllerPrivate>()}
27 {
27 {
28 }
28 }
29
29
@@ -48,9 +48,8 void VariableCacheController::addDateTime(std::shared_ptr<Variable> variable,
48 // will be compared to the next interval. The old one is remove from the list
48 // will be compared to the next interval. The old one is remove from the list
49 // C: if it is superior, we do the same with the next interval of the list
49 // C: if it is superior, we do the same with the next interval of the list
50
50
51 int cacheIndex = 0;
52 impl->addDateTimeRecurse(dateTime, impl->m_VariableToSqpDateTimeListMap.at(variable),
51 impl->addDateTimeRecurse(dateTime, impl->m_VariableToSqpDateTimeListMap.at(variable),
53 cacheIndex);
52 0);
54 }
53 }
55 }
54 }
56 }
55 }
@@ -94,7 +93,6 void VariableCacheController::VariableCacheControllerPrivate::addDateTimeRecurse
94 // The compared one is < to current one compared, we can insert it
93 // The compared one is < to current one compared, we can insert it
95 dateTimeList.insert(cacheIndex, dateTime);
94 dateTimeList.insert(cacheIndex, dateTime);
96 }
95 }
97
98 else if (dateTime.m_TStart > currentDateTime.m_TEnd) {
96 else if (dateTime.m_TStart > currentDateTime.m_TEnd) {
99 // The compared one is > to current one compared we can comparet if to the next one
97 // The compared one is > to current one compared we can comparet if to the next one
100 addDateTimeRecurse(dateTime, dateTimeList, ++cacheIndex);
98 addDateTimeRecurse(dateTime, dateTimeList, ++cacheIndex);
@@ -153,11 +151,10 void VariableCacheController::VariableCacheControllerPrivate::addInCacheDataBySt
153 }
151 }
154
152
155 auto currentDateTimeI = dateTimeList[cacheIndex];
153 auto currentDateTimeI = dateTimeList[cacheIndex];
156 auto cacheIndexJ = cacheIndex;
157 if (currentTStart < currentDateTimeI.m_TStart) {
154 if (currentTStart < currentDateTimeI.m_TStart) {
158
155
159 // ts localised between to interval: let's localized te
156 // ts localised between to interval: let's localized te
160 addInCacheDataByEnd(dateTime, dateTimeList, notInCache, cacheIndexJ, currentTStart);
157 addInCacheDataByEnd(dateTime, dateTimeList, notInCache, cacheIndex, currentTStart);
161 }
158 }
162 else if (dateTime.m_TStart < currentDateTimeI.m_TEnd) {
159 else if (dateTime.m_TStart < currentDateTimeI.m_TEnd) {
163 // ts not localised before the current interval: we need to look at the next interval
160 // ts not localised before the current interval: we need to look at the next interval
@@ -122,22 +122,22 void VariableController::requestDataLoading(std::shared_ptr<Variable> variable,
122
122
123 QElapsedTimer timer;
123 QElapsedTimer timer;
124 timer.start();
124 timer.start();
125 qCInfo(LOG_VariableController()) << "The slow s0 operation took" << timer.elapsed()
125 qCInfo(LOG_VariableController()) << "TORM: The slow s0 operation took" << timer.elapsed()
126 << "milliseconds";
126 << "milliseconds";
127 auto dateTimeListNotInCache
127 auto dateTimeListNotInCache
128 = impl->m_VariableCacheController->provideNotInCacheDateTimeList(variable, dateTime);
128 = impl->m_VariableCacheController->provideNotInCacheDateTimeList(variable, dateTime);
129 qCInfo(LOG_VariableController()) << "The slow s1 operation took" << timer.elapsed()
129 qCInfo(LOG_VariableController()) << "TORM: The slow s1 operation took" << timer.elapsed()
130 << "milliseconds";
130 << "milliseconds";
131
131
132 // Ask the provider for each data on the dateTimeListNotInCache
132 // Ask the provider for each data on the dateTimeListNotInCache
133 impl->m_VariableToProviderMap.at(variable)->requestDataLoading(dateTimeListNotInCache);
133 impl->m_VariableToProviderMap.at(variable)->requestDataLoading(dateTimeListNotInCache);
134
134
135 qCInfo(LOG_VariableController()) << "The slow s2 operation took" << timer.elapsed()
135 qCInfo(LOG_VariableController()) << "TORM: The slow s2 operation took" << timer.elapsed()
136 << "milliseconds";
136 << "milliseconds";
137
137
138 // store in cache
138 // store in cache
139 impl->m_VariableCacheController->addDateTime(variable, dateTime);
139 impl->m_VariableCacheController->addDateTime(variable, dateTime);
140 qCInfo(LOG_VariableController()) << "The slow s3 operation took" << timer.elapsed()
140 qCInfo(LOG_VariableController()) << "TORM: The slow s3 operation took" << timer.elapsed()
141 << "milliseconds";
141 << "milliseconds";
142 }
142 }
143 else {
143 else {
@@ -51,9 +51,9 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
51 auto notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
51 auto notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
52
52
53 QCOMPARE(notInCach.size(), 1);
53 QCOMPARE(notInCach.size(), 1);
54 auto notInCashSqp = notInCach.first();
54 auto notInCacheSqp = notInCach.first();
55 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
55 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
56 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
56 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
57
57
58
58
59 // second case ts < ts0 && ts0 < te <= te0
59 // second case ts < ts0 && ts0 < te <= te0
@@ -66,9 +66,9 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
66 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
66 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
67
67
68 QCOMPARE(notInCach.size(), 1);
68 QCOMPARE(notInCach.size(), 1);
69 notInCashSqp = notInCach.first();
69 notInCacheSqp = notInCach.first();
70 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
70 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
71 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch()));
71 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch()));
72
72
73 // 3th case ts < ts0 && te0 < te <= ts1
73 // 3th case ts < ts0 && te0 < te <= ts1
74 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
74 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
@@ -80,13 +80,13 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
80 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
80 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
81
81
82 QCOMPARE(notInCach.size(), 2);
82 QCOMPARE(notInCach.size(), 2);
83 notInCashSqp = notInCach.first();
83 notInCacheSqp = notInCach.first();
84 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
84 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
85 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch()));
85 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch()));
86
86
87 notInCashSqp = notInCach.at(1);
87 notInCacheSqp = notInCach.at(1);
88 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
88 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
89 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
89 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
90
90
91 // 4th case ts < ts0 && ts1 < te <= te1
91 // 4th case ts < ts0 && ts1 < te <= te1
92 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
92 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
@@ -98,13 +98,13 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
98 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
98 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
99
99
100 QCOMPARE(notInCach.size(), 2);
100 QCOMPARE(notInCach.size(), 2);
101 notInCashSqp = notInCach.first();
101 notInCacheSqp = notInCach.first();
102 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
102 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
103 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch()));
103 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch()));
104
104
105 notInCashSqp = notInCach.at(1);
105 notInCacheSqp = notInCach.at(1);
106 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
106 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
107 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
107 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
108
108
109 // 5th case ts < ts0 && te3 < te
109 // 5th case ts < ts0 && te3 < te
110 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
110 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
@@ -116,21 +116,21 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
116 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
116 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
117
117
118 QCOMPARE(notInCach.size(), 4);
118 QCOMPARE(notInCach.size(), 4);
119 notInCashSqp = notInCach.first();
119 notInCacheSqp = notInCach.first();
120 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
120 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
121 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch()));
121 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch()));
122
122
123 notInCashSqp = notInCach.at(1);
123 notInCacheSqp = notInCach.at(1);
124 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
124 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
125 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
125 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
126
126
127 notInCashSqp = notInCach.at(2);
127 notInCacheSqp = notInCach.at(2);
128 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(te1.toMSecsSinceEpoch()));
128 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te1.toMSecsSinceEpoch()));
129 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(ts2.toMSecsSinceEpoch()));
129 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts2.toMSecsSinceEpoch()));
130
130
131 notInCashSqp = notInCach.at(3);
131 notInCacheSqp = notInCach.at(3);
132 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(te2.toMSecsSinceEpoch()));
132 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te2.toMSecsSinceEpoch()));
133 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
133 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
134
134
135
135
136 // 6th case ts2 < ts
136 // 6th case ts2 < ts
@@ -143,9 +143,9 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
143 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
143 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
144
144
145 QCOMPARE(notInCach.size(), 1);
145 QCOMPARE(notInCach.size(), 1);
146 notInCashSqp = notInCach.first();
146 notInCacheSqp = notInCach.first();
147 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
147 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
148 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
148 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
149
149
150 // 7th case ts = te0 && te < ts1
150 // 7th case ts = te0 && te < ts1
151 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}};
151 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}};
@@ -157,9 +157,9 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
157 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
157 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
158
158
159 QCOMPARE(notInCach.size(), 1);
159 QCOMPARE(notInCach.size(), 1);
160 notInCashSqp = notInCach.first();
160 notInCacheSqp = notInCach.first();
161 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
161 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
162 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
162 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
163
163
164 // 8th case ts0 < ts < te0 && te < ts1
164 // 8th case ts0 < ts < te0 && te < ts1
165 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}};
165 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}};
@@ -171,9 +171,9 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
171 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
171 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
172
172
173 QCOMPARE(notInCach.size(), 1);
173 QCOMPARE(notInCach.size(), 1);
174 notInCashSqp = notInCach.first();
174 notInCacheSqp = notInCach.first();
175 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
175 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
176 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
176 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
177
177
178 // 9th case ts0 < ts < te0 && ts1 < te < te1
178 // 9th case ts0 < ts < te0 && ts1 < te < te1
179 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}};
179 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}};
@@ -185,9 +185,9 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
185 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
185 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
186
186
187 QCOMPARE(notInCach.size(), 1);
187 QCOMPARE(notInCach.size(), 1);
188 notInCashSqp = notInCach.first();
188 notInCacheSqp = notInCach.first();
189 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
189 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
190 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
190 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
191
191
192 // 10th case te1 < ts < te < ts2
192 // 10th case te1 < ts < te < ts2
193 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 9, 0, 0}};
193 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 9, 0, 0}};
@@ -199,9 +199,9 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
199 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
199 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
200
200
201 QCOMPARE(notInCach.size(), 1);
201 QCOMPARE(notInCach.size(), 1);
202 notInCashSqp = notInCach.first();
202 notInCacheSqp = notInCach.first();
203 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
203 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
204 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
204 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
205
205
206 // 11th case te0 < ts < ts1 && te3 < te
206 // 11th case te0 < ts < ts1 && te3 < te
207 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
207 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
@@ -213,17 +213,17 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
213 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
213 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
214
214
215 QCOMPARE(notInCach.size(), 3);
215 QCOMPARE(notInCach.size(), 3);
216 notInCashSqp = notInCach.first();
216 notInCacheSqp = notInCach.first();
217 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
217 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
218 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
218 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
219
219
220 notInCashSqp = notInCach.at(1);
220 notInCacheSqp = notInCach.at(1);
221 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(te1.toMSecsSinceEpoch()));
221 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te1.toMSecsSinceEpoch()));
222 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(ts2.toMSecsSinceEpoch()));
222 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts2.toMSecsSinceEpoch()));
223
223
224 notInCashSqp = notInCach.at(2);
224 notInCacheSqp = notInCach.at(2);
225 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(te2.toMSecsSinceEpoch()));
225 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te2.toMSecsSinceEpoch()));
226 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
226 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
227
227
228 // 12th case te0 < ts < ts1 && te3 < te
228 // 12th case te0 < ts < ts1 && te3 < te
229 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
229 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
@@ -234,13 +234,13 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
234 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
234 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
235
235
236 QCOMPARE(notInCach.size(), 2);
236 QCOMPARE(notInCach.size(), 2);
237 notInCashSqp = notInCach.first();
237 notInCacheSqp = notInCach.first();
238 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
238 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
239 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
239 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
240
240
241 notInCashSqp = notInCach.at(1);
241 notInCacheSqp = notInCach.at(1);
242 QCOMPARE(notInCashSqp.m_TStart, static_cast<double>(te1.toMSecsSinceEpoch()));
242 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te1.toMSecsSinceEpoch()));
243 QCOMPARE(notInCashSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
243 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
244 }
244 }
245
245
246
246
@@ -1,5 +1,5
1 #ifndef SCIQLOP_GRAPHPLOTTABLESFACTORY_H
1 #ifndef SCIQLOP_VISUALIZATIONGRAPHHELPER_H
2 #define SCIQLOP_GRAPHPLOTTABLESFACTORY_H
2 #define SCIQLOP_VISUALIZATIONGRAPHHELPER_H
3
3
4 #include <Data/SqpDateTime.h>
4 #include <Data/SqpDateTime.h>
5
5
@@ -8,7 +8,7
8
8
9 #include <memory>
9 #include <memory>
10
10
11 Q_DECLARE_LOGGING_CATEGORY(LOG_GraphPlottablesFactory)
11 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationGraphHelper)
12
12
13 class IDataSeries;
13 class IDataSeries;
14 class QCPAbstractPlottable;
14 class QCPAbstractPlottable;
@@ -16,10 +16,10 class QCustomPlot;
16 class Variable;
16 class Variable;
17
17
18 /**
18 /**
19 * @brief The GraphPlottablesFactory class aims to create the QCustomPlot components relative to a
19 * @brief The VisualizationGraphHelper class aims to create the QCustomPlot components relative to a
20 * variable, depending on the data series of this variable
20 * variable, depending on the data series of this variable
21 */
21 */
22 struct GraphPlottablesFactory {
22 struct VisualizationGraphHelper {
23 /**
23 /**
24 * Creates (if possible) the QCustomPlot components relative to the variable passed in
24 * Creates (if possible) the QCustomPlot components relative to the variable passed in
25 * parameter, and adds these to the plot passed in parameter.
25 * parameter, and adds these to the plot passed in parameter.
@@ -35,4 +35,4 struct GraphPlottablesFactory {
35 const SqpDateTime &dateTime);
35 const SqpDateTime &dateTime);
36 };
36 };
37
37
38 #endif // SCIQLOP_GRAPHPLOTTABLESFACTORY_H
38 #endif // SCIQLOP_VISUALIZATIONGRAPHHELPER_H
@@ -1,4 +1,4
1 #include "Visualization/GraphPlottablesFactory.h"
1 #include "Visualization/VisualizationGraphHelper.h"
2 #include "Visualization/qcustomplot.h"
2 #include "Visualization/qcustomplot.h"
3
3
4 #include <Data/ScalarSeries.h>
4 #include <Data/ScalarSeries.h>
@@ -7,7 +7,7
7
7
8 #include <QElapsedTimer>
8 #include <QElapsedTimer>
9
9
10 Q_LOGGING_CATEGORY(LOG_GraphPlottablesFactory, "GraphPlottablesFactory")
10 Q_LOGGING_CATEGORY(LOG_VisualizationGraphHelper, "VisualizationGraphHelper")
11
11
12 namespace {
12 namespace {
13
13
@@ -37,8 +37,8 void updateScalarData(QCPAbstractPlottable *component, ScalarSeries &scalarSerie
37 timer.start();
37 timer.start();
38 if (auto qcpGraph = dynamic_cast<QCPGraph *>(component)) {
38 if (auto qcpGraph = dynamic_cast<QCPGraph *>(component)) {
39 // Clean the graph
39 // Clean the graph
40 qCDebug(LOG_GraphPlottablesFactory()) << "The slow s1 operation took" << timer.elapsed()
40 qCDebug(LOG_VisualizationGraphHelper()) << "The slow s1 operation took" << timer.elapsed()
41 << "milliseconds";
41 << "milliseconds";
42 // NAIVE approch
42 // NAIVE approch
43 const auto &xData = scalarSeries.xAxisData()->data();
43 const auto &xData = scalarSeries.xAxisData()->data();
44 const auto &valuesData = scalarSeries.valuesData()->data();
44 const auto &valuesData = scalarSeries.valuesData()->data();
@@ -59,8 +59,8 void updateScalarData(QCPAbstractPlottable *component, ScalarSeries &scalarSerie
59
59
60 qcpGraph->setData(xValue, vValue);
60 qcpGraph->setData(xValue, vValue);
61
61
62 qCDebug(LOG_GraphPlottablesFactory()) << "The slow s2 operation took" << timer.elapsed()
62 qCDebug(LOG_VisualizationGraphHelper()) << "The slow s2 operation took" << timer.elapsed()
63 << "milliseconds";
63 << "milliseconds";
64 }
64 }
65 else {
65 else {
66 /// @todo DEBUG
66 /// @todo DEBUG
@@ -99,7 +99,7 QCPAbstractPlottable *createScalarSeriesComponent(ScalarSeries &scalarSeries, QC
99 plot.replot();
99 plot.replot();
100 }
100 }
101 else {
101 else {
102 qCDebug(LOG_GraphPlottablesFactory())
102 qCDebug(LOG_VisualizationGraphHelper())
103 << QObject::tr("Can't create graph for the scalar series");
103 << QObject::tr("Can't create graph for the scalar series");
104 }
104 }
105
105
@@ -108,8 +108,8 QCPAbstractPlottable *createScalarSeriesComponent(ScalarSeries &scalarSeries, QC
108
108
109 } // namespace
109 } // namespace
110
110
111 QVector<QCPAbstractPlottable *> GraphPlottablesFactory::create(std::shared_ptr<Variable> variable,
111 QVector<QCPAbstractPlottable *> VisualizationGraphHelper::create(std::shared_ptr<Variable> variable,
112 QCustomPlot &plot) noexcept
112 QCustomPlot &plot) noexcept
113 {
113 {
114 auto result = QVector<QCPAbstractPlottable *>{};
114 auto result = QVector<QCPAbstractPlottable *>{};
115
115
@@ -120,27 +120,27 QVector<QCPAbstractPlottable *> GraphPlottablesFactory::create(std::shared_ptr<V
120 result.append(createScalarSeriesComponent(*scalarSeries, plot, variable->dateTime()));
120 result.append(createScalarSeriesComponent(*scalarSeries, plot, variable->dateTime()));
121 }
121 }
122 else {
122 else {
123 qCDebug(LOG_GraphPlottablesFactory())
123 qCDebug(LOG_VisualizationGraphHelper())
124 << QObject::tr("Can't create graph plottables : unmanaged data series type");
124 << QObject::tr("Can't create graph plottables : unmanaged data series type");
125 }
125 }
126 }
126 }
127 else {
127 else {
128 qCDebug(LOG_GraphPlottablesFactory())
128 qCDebug(LOG_VisualizationGraphHelper())
129 << QObject::tr("Can't create graph plottables : the variable is null");
129 << QObject::tr("Can't create graph plottables : the variable is null");
130 }
130 }
131
131
132 return result;
132 return result;
133 }
133 }
134
134
135 void GraphPlottablesFactory::updateData(QVector<QCPAbstractPlottable *> plotableVect,
135 void VisualizationGraphHelper::updateData(QVector<QCPAbstractPlottable *> plotableVect,
136 IDataSeries *dataSeries, const SqpDateTime &dateTime)
136 IDataSeries *dataSeries, const SqpDateTime &dateTime)
137 {
137 {
138 if (auto scalarSeries = dynamic_cast<ScalarSeries *>(dataSeries)) {
138 if (auto scalarSeries = dynamic_cast<ScalarSeries *>(dataSeries)) {
139 if (plotableVect.size() == 1) {
139 if (plotableVect.size() == 1) {
140 updateScalarData(plotableVect.at(0), *scalarSeries, dateTime);
140 updateScalarData(plotableVect.at(0), *scalarSeries, dateTime);
141 }
141 }
142 else {
142 else {
143 qCCritical(LOG_GraphPlottablesFactory()) << QObject::tr(
143 qCCritical(LOG_VisualizationGraphHelper()) << QObject::tr(
144 "Can't update Data of a scalarSeries because there is not only one component "
144 "Can't update Data of a scalarSeries because there is not only one component "
145 "associated");
145 "associated");
146 }
146 }
@@ -1,6 +1,6
1 #include "Visualization/VisualizationGraphWidget.h"
1 #include "Visualization/VisualizationGraphWidget.h"
2 #include "Visualization/GraphPlottablesFactory.h"
3 #include "Visualization/IVisualizationWidgetVisitor.h"
2 #include "Visualization/IVisualizationWidgetVisitor.h"
3 #include "Visualization/VisualizationGraphHelper.h"
4 #include "ui_VisualizationGraphWidget.h"
4 #include "ui_VisualizationGraphWidget.h"
5
5
6 #include <Data/ArrayData.h>
6 #include <Data/ArrayData.h>
@@ -61,7 +61,7 VisualizationGraphWidget::~VisualizationGraphWidget()
61 void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable)
61 void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable)
62 {
62 {
63 // Uses delegate to create the qcpplot components according to the variable
63 // Uses delegate to create the qcpplot components according to the variable
64 auto createdPlottables = GraphPlottablesFactory::create(variable, *ui->widget);
64 auto createdPlottables = VisualizationGraphHelper::create(variable, *ui->widget);
65
65
66 for (auto createdPlottable : qAsConst(createdPlottables)) {
66 for (auto createdPlottable : qAsConst(createdPlottables)) {
67 impl->m_VariableToPlotMultiMap.insert({variable, createdPlottable});
67 impl->m_VariableToPlotMultiMap.insert({variable, createdPlottable});
@@ -142,11 +142,19 void VisualizationGraphWidget::onMouseWheel(QWheelEvent *event) noexcept
142
142
143 void VisualizationGraphWidget::onDataCacheVariableUpdated()
143 void VisualizationGraphWidget::onDataCacheVariableUpdated()
144 {
144 {
145 // NOTE:
146 // We don't want to call the method for each component of a variable unitarily, but for all
147 // its components at once (eg its three components in the case of a vector).
148
149 // The unordered_multimap does not do this easily, so the question is whether to:
150 // - use an ordered_multimap and the algos of std to group the values by key
151 // - use a map (unique keys) and store as values directly the list of components
152
145 for (auto it = impl->m_VariableToPlotMultiMap.cbegin();
153 for (auto it = impl->m_VariableToPlotMultiMap.cbegin();
146 it != impl->m_VariableToPlotMultiMap.cend(); ++it) {
154 it != impl->m_VariableToPlotMultiMap.cend(); ++it) {
147 auto variable = it->first;
155 auto variable = it->first;
148 GraphPlottablesFactory::updateData(QVector<QCPAbstractPlottable *>{} << it->second,
156 VisualizationGraphHelper::updateData(QVector<QCPAbstractPlottable *>{} << it->second,
149 variable->dataSeries(), variable->dateTime());
157 variable->dataSeries(), variable->dateTime());
150 }
158 }
151 }
159 }
152
160
@@ -160,6 +168,6 void VisualizationGraphWidget::updateDisplay(std::shared_ptr<Variable> variable)
160 abstractPlotableVect.push_back(it->second);
168 abstractPlotableVect.push_back(it->second);
161 }
169 }
162
170
163 GraphPlottablesFactory::updateData(abstractPlotableVect, variable->dataSeries(),
171 VisualizationGraphHelper::updateData(abstractPlotableVect, variable->dataSeries(),
164 variable->dateTime());
172 variable->dateTime());
165 }
173 }
@@ -36,7 +36,7 CosinusProvider::retrieveData(const DataProviderParameters &parameters) const
36 void CosinusProvider::requestDataLoading(const QVector<SqpDateTime> &dateTimeList)
36 void CosinusProvider::requestDataLoading(const QVector<SqpDateTime> &dateTimeList)
37 {
37 {
38 // NOTE: Try to use multithread if possible
38 // NOTE: Try to use multithread if possible
39 foreach (const auto &dateTime, dateTimeList) {
39 for (const auto &dateTime : dateTimeList) {
40
40
41 auto scalarSeries = this->retrieveDataSeries(dateTime);
41 auto scalarSeries = this->retrieveDataSeries(dateTime);
42
42
General Comments 0
You need to be logged in to leave comments. Login now