@@ -25,8 +25,7 class SCIQLOP_CORE_EXPORT Variable : public QObject { | |||
|
25 | 25 | Q_OBJECT |
|
26 | 26 | |
|
27 | 27 | public: |
|
28 |
explicit Variable(const QString &name, const |
|
|
29 | const QVariantHash &metadata = {}); | |
|
28 | explicit Variable(const QString &name, const QVariantHash &metadata = {}); | |
|
30 | 29 | |
|
31 | 30 | /// Copy ctor |
|
32 | 31 | explicit Variable(const Variable &other); |
@@ -45,11 +45,10 public: | |||
|
45 | 45 | /** |
|
46 | 46 | * Creates a new variable in the model |
|
47 | 47 | * @param name the name of the new variable |
|
48 | * @param dateTime the dateTime of the new variable | |
|
49 | 48 | * @param metadata the metadata associated to the new variable |
|
50 | 49 | * @return the pointer to the new variable |
|
51 | 50 | */ |
|
52 |
std::shared_ptr<Variable> createVariable(const QString &name, |
|
|
51 | std::shared_ptr<Variable> createVariable(const QString &name, | |
|
53 | 52 | const QVariantHash &metadata) noexcept; |
|
54 | 53 | |
|
55 | 54 | /** |
@@ -10,10 +10,10 | |||
|
10 | 10 | Q_LOGGING_CATEGORY(LOG_Variable, "Variable") |
|
11 | 11 | |
|
12 | 12 | struct Variable::VariablePrivate { |
|
13 |
explicit VariablePrivate(const QString &name, const |
|
|
14 | const QVariantHash &metadata) | |
|
13 | explicit VariablePrivate(const QString &name, const QVariantHash &metadata) | |
|
15 | 14 | : m_Name{name}, |
|
16 |
m_Range{ |
|
|
15 | m_Range{INVALID_RANGE}, | |
|
16 | m_CacheRange{INVALID_RANGE}, | |
|
17 | 17 | m_Metadata{metadata}, |
|
18 | 18 | m_DataSeries{nullptr}, |
|
19 | 19 | m_RealRange{INVALID_RANGE}, |
@@ -24,6 +24,7 struct Variable::VariablePrivate { | |||
|
24 | 24 | VariablePrivate(const VariablePrivate &other) |
|
25 | 25 | : m_Name{other.m_Name}, |
|
26 | 26 | m_Range{other.m_Range}, |
|
27 | m_CacheRange{other.m_CacheRange}, | |
|
27 | 28 | m_Metadata{other.m_Metadata}, |
|
28 | 29 | m_DataSeries{other.m_DataSeries != nullptr ? other.m_DataSeries->clone() : nullptr}, |
|
29 | 30 | m_RealRange{other.m_RealRange}, |
@@ -55,7 +56,8 struct Variable::VariablePrivate { | |||
|
55 | 56 | auto minXAxisIt = m_DataSeries->minXAxisData(m_Range.m_TStart); |
|
56 | 57 | auto maxXAxisIt = m_DataSeries->maxXAxisData(m_Range.m_TEnd); |
|
57 | 58 | |
|
58 | m_RealRange = (minXAxisIt != end && maxXAxisIt != end) | |
|
59 | m_RealRange | |
|
60 | = (minXAxisIt != end && maxXAxisIt != end && minXAxisIt->x() <= maxXAxisIt->x()) | |
|
59 | 61 |
|
|
60 | 62 |
|
|
61 | 63 | m_DataSeries->unlock(); |
@@ -77,8 +79,8 struct Variable::VariablePrivate { | |||
|
77 | 79 | QReadWriteLock m_Lock; |
|
78 | 80 | }; |
|
79 | 81 | |
|
80 |
Variable::Variable(const QString &name, const |
|
|
81 |
: impl{spimpl::make_unique_impl<VariablePrivate>(name, |
|
|
82 | Variable::Variable(const QString &name, const QVariantHash &metadata) | |
|
83 | : impl{spimpl::make_unique_impl<VariablePrivate>(name, metadata)} | |
|
82 | 84 | { |
|
83 | 85 | } |
|
84 | 86 | |
@@ -242,8 +244,8 bool Variable::cacheIsInside(const SqpRange &range) const noexcept | |||
|
242 | 244 | QVector<SqpRange> Variable::provideNotInCacheRangeList(const SqpRange &range) const noexcept |
|
243 | 245 | { |
|
244 | 246 | // This code assume that cach in contigue. Can return 0, 1 or 2 SqpRange |
|
245 | ||
|
246 | 247 | auto notInCache = QVector<SqpRange>{}; |
|
248 | if (impl->m_CacheRange != INVALID_RANGE) { | |
|
247 | 249 | |
|
248 | 250 | if (!this->cacheContains(range)) { |
|
249 | 251 | if (range.m_TEnd <= impl->m_CacheRange.m_TStart |
@@ -267,6 +269,10 QVector<SqpRange> Variable::provideNotInCacheRangeList(const SqpRange &range) co | |||
|
267 | 269 | << QThread::currentThread(); |
|
268 | 270 | } |
|
269 | 271 | } |
|
272 | } | |
|
273 | else { | |
|
274 | notInCache << range; | |
|
275 | } | |
|
270 | 276 | |
|
271 | 277 | return notInCache; |
|
272 | 278 | } |
@@ -277,6 +283,7 QVector<SqpRange> Variable::provideInCacheRangeList(const SqpRange &range) const | |||
|
277 | 283 | |
|
278 | 284 | auto inCache = QVector<SqpRange>{}; |
|
279 | 285 | |
|
286 | if (impl->m_CacheRange != INVALID_RANGE) { | |
|
280 | 287 | |
|
281 | 288 | if (this->intersect(range)) { |
|
282 | 289 | if (range.m_TStart <= impl->m_CacheRange.m_TStart |
@@ -302,6 +309,7 QVector<SqpRange> Variable::provideInCacheRangeList(const SqpRange &range) const | |||
|
302 | 309 | << QThread::currentThread(); |
|
303 | 310 | } |
|
304 | 311 | } |
|
312 | } | |
|
305 | 313 | |
|
306 | 314 | return inCache; |
|
307 | 315 | } |
@@ -265,7 +265,7 VariableController::createVariable(const QString &name, const QVariantHash &meta | |||
|
265 | 265 | |
|
266 | 266 | auto range = impl->m_TimeController->dateTime(); |
|
267 | 267 | |
|
268 |
if (auto newVariable = impl->m_VariableModel->createVariable(name, |
|
|
268 | if (auto newVariable = impl->m_VariableModel->createVariable(name, metadata)) { | |
|
269 | 269 | auto identifier = QUuid::createUuid(); |
|
270 | 270 | |
|
271 | 271 | // store the provider |
@@ -573,7 +573,7 void VariableController::VariableControllerPrivate::processRequest(std::shared_p | |||
|
573 | 573 | varProvider); |
|
574 | 574 | |
|
575 | 575 | if (!varRequestIdCanceled.isNull()) { |
|
576 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("varRequestIdCanceled: ") | |
|
576 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("vsarRequestIdCanceled: ") | |
|
577 | 577 | << varRequestIdCanceled; |
|
578 | 578 | cancelVariableRequest(varRequestIdCanceled); |
|
579 | 579 | } |
@@ -588,7 +588,6 void VariableController::VariableControllerPrivate::processRequest(std::shared_p | |||
|
588 | 588 | } |
|
589 | 589 | } |
|
590 | 590 | else { |
|
591 | ||
|
592 | 591 | varRequest.m_RangeRequested = varStrategyRangesRequested.first; |
|
593 | 592 | varRequest.m_CacheRangeRequested = varStrategyRangesRequested.second; |
|
594 | 593 | // store VarRequest |
@@ -97,10 +97,9 bool VariableModel::containsVariable(std::shared_ptr<Variable> variable) const n | |||
|
97 | 97 | } |
|
98 | 98 | |
|
99 | 99 | std::shared_ptr<Variable> VariableModel::createVariable(const QString &name, |
|
100 | const SqpRange &dateTime, | |
|
101 | 100 | const QVariantHash &metadata) noexcept |
|
102 | 101 | { |
|
103 |
auto variable = std::make_shared<Variable>(name, |
|
|
102 | auto variable = std::make_shared<Variable>(name, metadata); | |
|
104 | 103 | addVariable(variable); |
|
105 | 104 | |
|
106 | 105 | return variable; |
@@ -24,10 +24,12 void TestVariable::testNotInCacheRangeList() | |||
|
24 | 24 | |
|
25 | 25 | auto varCRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}}; |
|
26 | 26 | auto varCRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; |
|
27 | ||
|
27 | 28 | auto sqpCR |
|
28 | 29 | = SqpRange{DateUtils::secondsSinceEpoch(varCRS), DateUtils::secondsSinceEpoch(varCRE)}; |
|
29 | 30 | |
|
30 |
Variable var{"Var test" |
|
|
31 | Variable var{"Var test"}; | |
|
32 | var.setRange(sqpR); | |
|
31 | 33 | var.setCacheRange(sqpCR); |
|
32 | 34 | |
|
33 | 35 | // 1: [ts,te] < varTS |
@@ -109,7 +111,8 void TestVariable::testInCacheRangeList() | |||
|
109 | 111 | auto sqpCR |
|
110 | 112 | = SqpRange{DateUtils::secondsSinceEpoch(varCRS), DateUtils::secondsSinceEpoch(varCRE)}; |
|
111 | 113 | |
|
112 |
Variable var{"Var test" |
|
|
114 | Variable var{"Var test"}; | |
|
115 | var.setRange(sqpR); | |
|
113 | 116 | var.setCacheRange(sqpCR); |
|
114 | 117 | |
|
115 | 118 | // 1: [ts,te] < varTS |
@@ -32,7 +32,8 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||
|
32 | 32 | auto te2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 20, 0, 0}}; |
|
33 | 33 | auto sqp2 = SqpRange{DateUtils::secondsSinceEpoch(ts2), DateUtils::secondsSinceEpoch(te2)}; |
|
34 | 34 | |
|
35 |
auto var0 = std::make_shared<Variable>("" |
|
|
35 | auto var0 = std::make_shared<Variable>(""); | |
|
36 | var0->setRange(sqp0); | |
|
36 | 37 | |
|
37 | 38 | variableCacheController.addDateTime(var0, sqp0); |
|
38 | 39 | variableCacheController.addDateTime(var0, sqp1); |
@@ -267,7 +268,8 void TestVariableCacheController::testAddDateTime() | |||
|
267 | 268 | auto sqp03 = SqpRange{DateUtils::secondsSinceEpoch(ts03), DateUtils::secondsSinceEpoch(te03)}; |
|
268 | 269 | |
|
269 | 270 | |
|
270 |
auto var0 = std::make_shared<Variable>("" |
|
|
271 | auto var0 = std::make_shared<Variable>(""); | |
|
272 | var0->setRange(sqp0); | |
|
271 | 273 | |
|
272 | 274 | |
|
273 | 275 | // First case: add the first interval to the variable :sqp0 |
@@ -107,7 +107,6 void AmdaProvider::onReplyDownloadProgress(QUuid acqIdentifier, | |||
|
107 | 107 | auto acqIdToRequestProgressMapIt = m_AcqIdToRequestProgressMap.find(acqIdentifier); |
|
108 | 108 | if (acqIdToRequestProgressMapIt != m_AcqIdToRequestProgressMap.end()) { |
|
109 | 109 | |
|
110 | qCDebug(LOG_AmdaProvider()) << tr("1 onReplyDownloadProgress found") << progress; | |
|
111 | 110 | auto requestPtr = networkRequest; |
|
112 | 111 | auto findRequest = [requestPtr](const auto &entry) { return requestPtr == entry.first; }; |
|
113 | 112 | |
@@ -159,7 +158,6 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa | |||
|
159 | 158 | qCCritical(LOG_AmdaProvider()) << tr("Can't retrieve data: unknown product id"); |
|
160 | 159 | return; |
|
161 | 160 | } |
|
162 | qCDebug(LOG_AmdaProvider()) << tr("AmdaProvider::retrieveData") << dateTime; | |
|
163 | 161 | |
|
164 | 162 | // Retrieves the data type that determines whether the expected format for the result file is |
|
165 | 163 | // scalar, vector... |
@@ -210,7 +208,7 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa | |||
|
210 | 208 | if (reply->error() != QNetworkReply::OperationCanceledError) { |
|
211 | 209 | auto downloadFileUrl = QUrl{QString{reply->readAll()}}; |
|
212 | 210 | |
|
213 |
qC |
|
|
211 | qCDebug(LOG_AmdaProvider()) | |
|
214 | 212 | << tr("TORM AmdaProvider::retrieveData downloadFileUrl:") << downloadFileUrl; |
|
215 | 213 | // Executes request for downloading file // |
|
216 | 214 |
@@ -100,8 +100,6 void TestAmdaAcquisition::testAcquisition() | |||
|
100 | 100 | auto var = vc.createVariable("bx_gse", metaData, provider); |
|
101 | 101 | |
|
102 | 102 | // 1 : Variable creation |
|
103 | QCOMPARE(var->range().m_TStart, sqpR.m_TStart); | |
|
104 | QCOMPARE(var->range().m_TEnd, sqpR.m_TEnd); | |
|
105 | 103 | |
|
106 | 104 | qDebug() << " 1: TIMECONTROLLER" << timeController->dateTime(); |
|
107 | 105 | qDebug() << " 1: RANGE " << var->range(); |
General Comments 0
You need to be logged in to leave comments.
Login now