@@ -9,6 +9,7 | |||||
9 |
|
9 | |||
10 | // Relevant keys in JSON file |
|
10 | // Relevant keys in JSON file | |
11 | extern const QString AMDA_COMPONENT_KEY; |
|
11 | extern const QString AMDA_COMPONENT_KEY; | |
|
12 | extern const QString AMDA_DATA_TYPE_KEY; | |||
12 | extern const QString AMDA_PRODUCT_KEY; |
|
13 | extern const QString AMDA_PRODUCT_KEY; | |
13 | extern const QString AMDA_ROOT_KEY; |
|
14 | extern const QString AMDA_ROOT_KEY; | |
14 | extern const QString AMDA_XML_ID_KEY; |
|
15 | extern const QString AMDA_XML_ID_KEY; |
@@ -1,6 +1,7 | |||||
1 | #include "AmdaDefs.h" |
|
1 | #include "AmdaDefs.h" | |
2 |
|
2 | |||
3 | const QString AMDA_COMPONENT_KEY = QStringLiteral("component"); |
|
3 | const QString AMDA_COMPONENT_KEY = QStringLiteral("component"); | |
|
4 | const QString AMDA_DATA_TYPE_KEY = QStringLiteral("dataType"); | |||
4 | const QString AMDA_PRODUCT_KEY = QStringLiteral("parameter"); |
|
5 | const QString AMDA_PRODUCT_KEY = QStringLiteral("parameter"); | |
5 | const QString AMDA_ROOT_KEY = QStringLiteral("dataCenter"); |
|
6 | const QString AMDA_ROOT_KEY = QStringLiteral("dataCenter"); | |
6 | const QString AMDA_XML_ID_KEY = QStringLiteral("xml:id"); |
|
7 | const QString AMDA_XML_ID_KEY = QStringLiteral("xml:id"); |
@@ -36,6 +36,19 QString dateFormat(double sqpRange) noexcept | |||||
36 | return dateTime.toString(AMDA_TIME_FORMAT); |
|
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 | } // namespace |
|
52 | } // namespace | |
40 |
|
53 | |||
41 | AmdaProvider::AmdaProvider() |
|
54 | AmdaProvider::AmdaProvider() | |
@@ -86,6 +99,10 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa | |||||
86 | } |
|
99 | } | |
87 | qCDebug(LOG_AmdaProvider()) << tr("AmdaProvider::retrieveData") << dateTime; |
|
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 | // Creates URL // |
|
107 | // Creates URL // | |
91 | // /////////// // |
|
108 | // /////////// // | |
@@ -98,30 +115,31 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa | |||||
98 | auto tempFile = std::make_shared<QTemporaryFile>(); |
|
115 | auto tempFile = std::make_shared<QTemporaryFile>(); | |
99 |
|
116 | |||
100 | // LAMBDA |
|
117 | // LAMBDA | |
101 | auto httpDownloadFinished |
|
118 | auto httpDownloadFinished = [this, dateTime, tempFile, | |
102 |
|
|
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) { | |
106 |
|
123 | |||
107 |
|
|
124 | if (tempFile) { | |
108 |
|
|
125 | auto replyReadAll = reply->readAll(); | |
109 |
|
|
126 | if (!replyReadAll.isEmpty()) { | |
110 |
|
|
127 | tempFile->write(replyReadAll); | |
111 |
|
|
128 | } | |
112 |
|
|
129 | tempFile->close(); | |
113 |
|
130 | |||
114 |
|
|
131 | // Parse results file | |
115 | if (auto dataSeries = AmdaResultParser::readTxt(tempFile->fileName())) { |
|
132 | if (auto dataSeries | |
116 | emit dataProvided(dataId, dataSeries, dateTime); |
|
133 | = AmdaResultParser::readTxt(tempFile->fileName(), productValueType)) { | |
117 | } |
|
134 | emit dataProvided(dataId, dataSeries, dateTime); | |
118 |
|
|
135 | } | |
119 | /// @todo ALX : debug |
|
136 | else { | |
120 |
|
|
137 | /// @todo ALX : debug | |
121 |
|
|
138 | } | |
122 |
|
|
139 | } | |
123 |
|
140 | } | ||
124 | }; |
|
141 | ||
|
142 | }; | |||
125 | auto httpFinishedLambda |
|
143 | auto httpFinishedLambda | |
126 | = [this, httpDownloadFinished, tempFile](QNetworkReply *reply, QUuid dataId) noexcept { |
|
144 | = [this, httpDownloadFinished, tempFile](QNetworkReply *reply, QUuid dataId) noexcept { | |
127 |
|
145 |
General Comments 0
You need to be logged in to leave comments.
Login now