##// END OF EJS Templates
Reads variable metadata to get the data type...
Alexandre Leroux -
r566:a6f250cc335f
parent child
Show More
@@ -9,6 +9,7
9 9
10 10 // Relevant keys in JSON file
11 11 extern const QString AMDA_COMPONENT_KEY;
12 extern const QString AMDA_DATA_TYPE_KEY;
12 13 extern const QString AMDA_PRODUCT_KEY;
13 14 extern const QString AMDA_ROOT_KEY;
14 15 extern const QString AMDA_XML_ID_KEY;
@@ -1,6 +1,7
1 1 #include "AmdaDefs.h"
2 2
3 3 const QString AMDA_COMPONENT_KEY = QStringLiteral("component");
4 const QString AMDA_DATA_TYPE_KEY = QStringLiteral("dataType");
4 5 const QString AMDA_PRODUCT_KEY = QStringLiteral("parameter");
5 6 const QString AMDA_ROOT_KEY = QStringLiteral("dataCenter");
6 7 const QString AMDA_XML_ID_KEY = QStringLiteral("xml:id");
@@ -36,6 +36,19 QString dateFormat(double sqpRange) noexcept
36 36 return dateTime.toString(AMDA_TIME_FORMAT);
37 37 }
38 38
39 AmdaResultParser::ValueType valueType(const QString &valueType)
40 {
41 if (valueType == QStringLiteral("scalar")) {
42 return AmdaResultParser::ValueType::SCALAR;
43 }
44 else if (valueType == QStringLiteral("vector")) {
45 return AmdaResultParser::ValueType::VECTOR;
46 }
47 else {
48 return AmdaResultParser::ValueType::UNKNOWN;
49 }
50 }
51
39 52 } // namespace
40 53
41 54 AmdaProvider::AmdaProvider()
@@ -86,6 +99,10 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa
86 99 }
87 100 qCDebug(LOG_AmdaProvider()) << tr("AmdaProvider::retrieveData") << dateTime;
88 101
102 // Retrieves the data type that determines whether the expected format for the result file is
103 // scalar, vector...
104 auto productValueType = valueType(data.value(AMDA_DATA_TYPE_KEY).toString());
105
89 106 // /////////// //
90 107 // Creates URL //
91 108 // /////////// //
@@ -98,8 +115,8 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa
98 115 auto tempFile = std::make_shared<QTemporaryFile>();
99 116
100 117 // LAMBDA
101 auto httpDownloadFinished
102 = [this, dateTime, tempFile](QNetworkReply *reply, QUuid dataId) noexcept {
118 auto httpDownloadFinished = [this, dateTime, tempFile,
119 productValueType](QNetworkReply *reply, QUuid dataId) noexcept {
103 120
104 121 // Don't do anything if the reply was abort
105 122 if (reply->error() != QNetworkReply::OperationCanceledError) {
@@ -112,7 +129,8 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa
112 129 tempFile->close();
113 130
114 131 // Parse results file
115 if (auto dataSeries = AmdaResultParser::readTxt(tempFile->fileName())) {
132 if (auto dataSeries
133 = AmdaResultParser::readTxt(tempFile->fileName(), productValueType)) {
116 134 emit dataProvided(dataId, dataSeries, dateTime);
117 135 }
118 136 else {
General Comments 0
You need to be logged in to leave comments. Login now