@@ -21,6 +21,7 struct AcquisitionRequest { | |||||
21 | { |
|
21 | { | |
22 | m_AcqIdentifier = QUuid::createUuid(); |
|
22 | m_AcqIdentifier = QUuid::createUuid(); | |
23 | m_Size = 0; |
|
23 | m_Size = 0; | |
|
24 | m_Progression = 0; | |||
24 | } |
|
25 | } | |
25 |
|
26 | |||
26 | QUuid m_VarRequestId; |
|
27 | QUuid m_VarRequestId; | |
@@ -30,6 +31,7 struct AcquisitionRequest { | |||||
30 | SqpRange m_RangeRequested; |
|
31 | SqpRange m_RangeRequested; | |
31 | SqpRange m_CacheRangeRequested; |
|
32 | SqpRange m_CacheRangeRequested; | |
32 | int m_Size; |
|
33 | int m_Size; | |
|
34 | int m_Progression; | |||
33 | std::shared_ptr<IDataProvider> m_Provider; |
|
35 | std::shared_ptr<IDataProvider> m_Provider; | |
34 | }; |
|
36 | }; | |
35 |
|
37 |
@@ -36,7 +36,8 public slots: | |||||
36 |
|
36 | |||
37 | signals: |
|
37 | signals: | |
38 | void replyFinished(QNetworkReply *reply, QUuid identifier); |
|
38 | void replyFinished(QNetworkReply *reply, QUuid identifier); | |
39 |
void replyDownloadProgress(QUuid identifier, |
|
39 | void replyDownloadProgress(QUuid identifier, const QNetworkRequest &networkRequest, | |
|
40 | double progress); | |||
40 |
|
41 | |||
41 | private: |
|
42 | private: | |
42 | void waitForFinish(); |
|
43 | void waitForFinish(); |
@@ -42,7 +42,7 void NetworkController::onProcessRequested(const QNetworkRequest &request, QUuid | |||||
42 | impl->m_NetworkReplyToVariableId[reply] = identifier; |
|
42 | impl->m_NetworkReplyToVariableId[reply] = identifier; | |
43 | impl->unlock(); |
|
43 | impl->unlock(); | |
44 |
|
44 | |||
45 | auto onReplyFinished = [reply, this, identifier, callback]() { |
|
45 | auto onReplyFinished = [request, reply, this, identifier, callback]() { | |
46 |
|
46 | |||
47 | qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyFinished") |
|
47 | qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyFinished") | |
48 | << QThread::currentThread() << reply; |
|
48 | << QThread::currentThread() << reply; | |
@@ -57,14 +57,14 void NetworkController::onProcessRequested(const QNetworkRequest &request, QUuid | |||||
57 | callback(reply, identifier); |
|
57 | callback(reply, identifier); | |
58 | reply->deleteLater(); |
|
58 | reply->deleteLater(); | |
59 |
|
59 | |||
60 | emit this->replyDownloadProgress(identifier, 0); |
|
60 | emit this->replyDownloadProgress(identifier, request, 0); | |
61 | } |
|
61 | } | |
62 |
|
62 | |||
63 | qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyFinished END") |
|
63 | qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyFinished END") | |
64 | << QThread::currentThread() << reply; |
|
64 | << QThread::currentThread() << reply; | |
65 | }; |
|
65 | }; | |
66 |
|
66 | |||
67 | auto onReplyProgress = [reply, this](qint64 bytesRead, qint64 totalBytes) { |
|
67 | auto onReplyProgress = [reply, request, this](qint64 bytesRead, qint64 totalBytes) { | |
68 |
|
68 | |||
69 | double progress = (bytesRead * 100.0) / totalBytes; |
|
69 | double progress = (bytesRead * 100.0) / totalBytes; | |
70 | qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyProgress") << progress |
|
70 | qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyProgress") << progress | |
@@ -73,7 +73,7 void NetworkController::onProcessRequested(const QNetworkRequest &request, QUuid | |||||
73 | auto it = impl->m_NetworkReplyToVariableId.find(reply); |
|
73 | auto it = impl->m_NetworkReplyToVariableId.find(reply); | |
74 | impl->unlock(); |
|
74 | impl->unlock(); | |
75 | if (it != impl->m_NetworkReplyToVariableId.cend()) { |
|
75 | if (it != impl->m_NetworkReplyToVariableId.cend()) { | |
76 | emit this->replyDownloadProgress(it->second, progress); |
|
76 | emit this->replyDownloadProgress(it->second, request, progress); | |
77 | } |
|
77 | } | |
78 | qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyProgress END") |
|
78 | qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyProgress END") | |
79 | << QThread::currentThread() << reply; |
|
79 | << QThread::currentThread() << reply; |
@@ -12,6 +12,8 | |||||
12 | #include <QReadWriteLock> |
|
12 | #include <QReadWriteLock> | |
13 | #include <QThread> |
|
13 | #include <QThread> | |
14 |
|
14 | |||
|
15 | #include <cmath> | |||
|
16 | ||||
15 | Q_LOGGING_CATEGORY(LOG_VariableAcquisitionWorker, "VariableAcquisitionWorker") |
|
17 | Q_LOGGING_CATEGORY(LOG_VariableAcquisitionWorker, "VariableAcquisitionWorker") | |
16 |
|
18 | |||
17 | struct VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate { |
|
19 | struct VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate { | |
@@ -106,15 +108,45 void VariableAcquisitionWorker::abortProgressRequested(QUuid vIdentifier) | |||||
106 | void VariableAcquisitionWorker::onVariableRetrieveDataInProgress(QUuid acqIdentifier, |
|
108 | void VariableAcquisitionWorker::onVariableRetrieveDataInProgress(QUuid acqIdentifier, | |
107 | double progress) |
|
109 | double progress) | |
108 | { |
|
110 | { | |
109 | // TODO |
|
111 | impl->lockRead(); | |
|
112 | auto aIdToARit = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier); | |||
|
113 | if (aIdToARit != impl->m_AcqIdentifierToAcqRequestMap.cend()) { | |||
|
114 | auto currentPartSize = (aIdToARit->second.m_Size != 0) ? 100 / aIdToARit->second.m_Size : 0; | |||
|
115 | ||||
|
116 | auto currentPartProgress | |||
|
117 | = std::isnan(progress) ? 0.0 : (progress * currentPartSize) / 100.0; | |||
|
118 | auto currentAlreadyProgress = aIdToARit->second.m_Progression * currentPartSize; | |||
|
119 | ||||
|
120 | qCInfo(LOG_VariableAcquisitionWorker()) << tr("TORM: progress :") << progress; | |||
|
121 | qCInfo(LOG_VariableAcquisitionWorker()) << tr("TORM: onVariableRetrieveDataInProgress A:") | |||
|
122 | << aIdToARit->second.m_Progression | |||
|
123 | << aIdToARit->second.m_Size; | |||
|
124 | qCInfo(LOG_VariableAcquisitionWorker()) << tr("TORM: onVariableRetrieveDataInProgress B:") | |||
|
125 | << currentPartSize; | |||
|
126 | qCInfo(LOG_VariableAcquisitionWorker()) << tr("TORM: onVariableRetrieveDataInProgress C:") | |||
|
127 | << currentPartProgress; | |||
|
128 | qCInfo(LOG_VariableAcquisitionWorker()) << tr("TORM: onVariableRetrieveDataInProgress D:") | |||
|
129 | << currentAlreadyProgress; | |||
|
130 | qCInfo(LOG_VariableAcquisitionWorker()) << tr("TORM: onVariableRetrieveDataInProgress E:") | |||
|
131 | << currentAlreadyProgress + currentPartProgress | |||
|
132 | << "\n"; | |||
|
133 | ||||
|
134 | auto finalProgression = currentAlreadyProgress + currentPartProgress; | |||
|
135 | emit variableRequestInProgress(aIdToARit->second.m_vIdentifier, finalProgression); | |||
|
136 | ||||
|
137 | if (finalProgression == 100.0) { | |||
|
138 | emit variableRequestInProgress(aIdToARit->second.m_vIdentifier, 0.0); | |||
|
139 | } | |||
|
140 | } | |||
|
141 | impl->unlock(); | |||
110 | } |
|
142 | } | |
111 |
|
143 | |||
112 | void VariableAcquisitionWorker::onVariableDataAcquired(QUuid acqIdentifier, |
|
144 | void VariableAcquisitionWorker::onVariableDataAcquired(QUuid acqIdentifier, | |
113 | std::shared_ptr<IDataSeries> dataSeries, |
|
145 | std::shared_ptr<IDataSeries> dataSeries, | |
114 | SqpRange dataRangeAcquired) |
|
146 | SqpRange dataRangeAcquired) | |
115 | { |
|
147 | { | |
116 |
qC |
|
148 | qCInfo(LOG_VariableAcquisitionWorker()) << tr("TORM: onVariableDataAcquired on range ") | |
117 |
|
|
149 | << acqIdentifier << dataRangeAcquired; | |
118 | impl->lockWrite(); |
|
150 | impl->lockWrite(); | |
119 | auto aIdToARit = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier); |
|
151 | auto aIdToARit = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier); | |
120 | if (aIdToARit != impl->m_AcqIdentifierToAcqRequestMap.cend()) { |
|
152 | if (aIdToARit != impl->m_AcqIdentifierToAcqRequestMap.cend()) { | |
@@ -137,11 +169,11 void VariableAcquisitionWorker::onVariableDataAcquired(QUuid acqIdentifier, | |||||
137 |
|
169 | |||
138 | // Decrement the counter of the request |
|
170 | // Decrement the counter of the request | |
139 | auto &acqRequest = aIdToARit->second; |
|
171 | auto &acqRequest = aIdToARit->second; | |
140 |
acqRequest.m_ |
|
172 | acqRequest.m_Progression = acqRequest.m_Progression + 1; | |
141 |
|
173 | |||
142 | // if the counter is 0, we can return data then run the next request if it exists and |
|
174 | // if the counter is 0, we can return data then run the next request if it exists and | |
143 | // removed the finished request |
|
175 | // removed the finished request | |
144 |
if (acqRequest.m_Size == |
|
176 | if (acqRequest.m_Size == acqRequest.m_Progression) { | |
145 | // Return the data |
|
177 | // Return the data | |
146 | aIdToADPVit = impl->m_AcqIdentifierToAcqDataPacketVectorMap.find(acqIdentifier); |
|
178 | aIdToADPVit = impl->m_AcqIdentifierToAcqDataPacketVectorMap.find(acqIdentifier); | |
147 | if (aIdToADPVit != impl->m_AcqIdentifierToAcqDataPacketVectorMap.cend()) { |
|
179 | if (aIdToADPVit != impl->m_AcqIdentifierToAcqDataPacketVectorMap.cend()) { | |
@@ -192,6 +224,7 void VariableAcquisitionWorker::onExecuteRequest(QUuid acqIdentifier) | |||||
192 | if (it != impl->m_AcqIdentifierToAcqRequestMap.cend()) { |
|
224 | if (it != impl->m_AcqIdentifierToAcqRequestMap.cend()) { | |
193 | auto request = it->second; |
|
225 | auto request = it->second; | |
194 | impl->unlock(); |
|
226 | impl->unlock(); | |
|
227 | emit variableRequestInProgress(request.m_vIdentifier, 0.1); | |||
195 | request.m_Provider->requestDataLoading(acqIdentifier, request.m_DataProviderParameters); |
|
228 | request.m_Provider->requestDataLoading(acqIdentifier, request.m_DataProviderParameters); | |
196 | } |
|
229 | } | |
197 | else { |
|
230 | else { |
@@ -290,6 +290,8 void VariableController::onDataProvided(QUuid vIdentifier, const SqpRange &range | |||||
290 |
|
290 | |||
291 | void VariableController::onVariableRetrieveDataInProgress(QUuid identifier, double progress) |
|
291 | void VariableController::onVariableRetrieveDataInProgress(QUuid identifier, double progress) | |
292 | { |
|
292 | { | |
|
293 | qCInfo(LOG_VariableController()) << "TORM: ariableController::onVariableRetrieveDataInProgress" | |||
|
294 | << QThread::currentThread()->objectName() << progress; | |||
293 | if (auto var = impl->findVariable(identifier)) { |
|
295 | if (auto var = impl->findVariable(identifier)) { | |
294 | impl->m_VariableModel->setDataProgress(var, progress); |
|
296 | impl->m_VariableModel->setDataProgress(var, progress); | |
295 | } |
|
297 | } |
@@ -86,8 +86,8 void TestTwoDimArrayData::testCtor_data() | |||||
86 | << true << Container{{1., 2., 3., 4., 5.}, |
|
86 | << true << Container{{1., 2., 3., 4., 5.}, | |
87 | {6., 7., 8., 9., 10.}, |
|
87 | {6., 7., 8., 9., 10.}, | |
88 | {11., 12., 13., 14., 15.}}; |
|
88 | {11., 12., 13., 14., 15.}}; | |
89 | QTest::newRow("invalidInput (invalid data size") |
|
89 | QTest::newRow("invalidInput (invalid data size") << InputData{{1., 2., 3., 4., 5., 6., 7.}, 3} | |
90 | << InputData{{1., 2., 3., 4., 5., 6., 7.}, 3} << false << Container{{}, {}, {}}; |
|
90 | << false << Container{{}, {}, {}}; | |
91 | QTest::newRow("invalidInput (less than two components") |
|
91 | QTest::newRow("invalidInput (less than two components") | |
92 | << flatten(Container{{1., 2., 3., 4., 5.}}) << false << Container{{}, {}, {}}; |
|
92 | << flatten(Container{{1., 2., 3., 4., 5.}}) << false << Container{{}, {}, {}}; | |
93 | } |
|
93 | } |
@@ -7,10 +7,12 | |||||
7 |
|
7 | |||
8 | #include <QLoggingCategory> |
|
8 | #include <QLoggingCategory> | |
9 |
|
9 | |||
|
10 | #include <map> | |||
10 |
|
11 | |||
11 | Q_DECLARE_LOGGING_CATEGORY(LOG_AmdaProvider) |
|
12 | Q_DECLARE_LOGGING_CATEGORY(LOG_AmdaProvider) | |
12 |
|
13 | |||
13 | class QNetworkReply; |
|
14 | class QNetworkReply; | |
|
15 | class QNetworkRequest; | |||
14 |
|
16 | |||
15 | /** |
|
17 | /** | |
16 | * @brief The AmdaProvider class is an example of how a data provider can generate data |
|
18 | * @brief The AmdaProvider class is an example of how a data provider can generate data | |
@@ -23,8 +25,17 public: | |||||
23 |
|
25 | |||
24 | void requestDataAborting(QUuid acqIdentifier) override; |
|
26 | void requestDataAborting(QUuid acqIdentifier) override; | |
25 |
|
27 | |||
|
28 | private slots: | |||
|
29 | void onReplyDownloadProgress(QUuid, const QNetworkRequest &, double progress); | |||
|
30 | ||||
26 | private: |
|
31 | private: | |
27 | void retrieveData(QUuid token, const SqpRange &dateTime, const QVariantHash &data); |
|
32 | void retrieveData(QUuid token, const SqpRange &dateTime, const QVariantHash &data); | |
|
33 | ||||
|
34 | void updateRequestProgress(QUuid acqIdentifier, std::shared_ptr<QNetworkRequest> request, | |||
|
35 | double progress); | |||
|
36 | ||||
|
37 | std::map<QUuid, std::map<std::shared_ptr<QNetworkRequest>, double> > | |||
|
38 | m_AcqIdToRequestProgressMap; | |||
28 | }; |
|
39 | }; | |
29 |
|
40 | |||
30 | #endif // SCIQLOP_AMDAPROVIDER_H |
|
41 | #endif // SCIQLOP_AMDAPROVIDER_H |
@@ -29,6 +29,11 const auto AMDA_URL_FORMAT = QStringLiteral( | |||||
29 | /// Dates format passed in the URL (e.g 2013-09-23T09:00) |
|
29 | /// Dates format passed in the URL (e.g 2013-09-23T09:00) | |
30 | const auto AMDA_TIME_FORMAT = QStringLiteral("yyyy-MM-ddThh:mm:ss"); |
|
30 | const auto AMDA_TIME_FORMAT = QStringLiteral("yyyy-MM-ddThh:mm:ss"); | |
31 |
|
31 | |||
|
32 | // struct AmdaProgression { | |||
|
33 | // QUuid acqIdentifier; | |||
|
34 | // std::map<QNetworkRequest, double> m_RequestId; | |||
|
35 | //}; | |||
|
36 | ||||
32 | /// Formats a time to a date that can be passed in URL |
|
37 | /// Formats a time to a date that can be passed in URL | |
33 | QString dateFormat(double sqpRange) noexcept |
|
38 | QString dateFormat(double sqpRange) noexcept | |
34 | { |
|
39 | { | |
@@ -63,8 +68,9 AmdaProvider::AmdaProvider() | |||||
63 | std::function<void(QNetworkReply *, QUuid)>))); |
|
68 | std::function<void(QNetworkReply *, QUuid)>))); | |
64 |
|
69 | |||
65 |
|
70 | |||
66 |
connect(&sqpApp->networkController(), |
|
71 | connect(&sqpApp->networkController(), | |
67 |
SIGNAL( |
|
72 | SIGNAL(replyDownloadProgress(QUuid, const QNetworkRequest &, double)), this, | |
|
73 | SLOT(onReplyDownloadProgress(QUuid, const QNetworkRequest &, double))); | |||
68 | } |
|
74 | } | |
69 | } |
|
75 | } | |
70 |
|
76 | |||
@@ -76,6 +82,7 void AmdaProvider::requestDataLoading(QUuid acqIdentifier, const DataProviderPar | |||||
76 | for (const auto &dateTime : qAsConst(times)) { |
|
82 | for (const auto &dateTime : qAsConst(times)) { | |
77 | this->retrieveData(acqIdentifier, dateTime, data); |
|
83 | this->retrieveData(acqIdentifier, dateTime, data); | |
78 |
|
84 | |||
|
85 | ||||
79 | // TORM when AMDA will support quick asynchrone request |
|
86 | // TORM when AMDA will support quick asynchrone request | |
80 | QThread::msleep(1000); |
|
87 | QThread::msleep(1000); | |
81 | } |
|
88 | } | |
@@ -89,6 +96,55 void AmdaProvider::requestDataAborting(QUuid acqIdentifier) | |||||
89 | } |
|
96 | } | |
90 | } |
|
97 | } | |
91 |
|
98 | |||
|
99 | void AmdaProvider::onReplyDownloadProgress(QUuid acqIdentifier, | |||
|
100 | const QNetworkRequest &networkRequest, double progress) | |||
|
101 | { | |||
|
102 | qCCritical(LOG_AmdaProvider()) << tr("onReplyDownloadProgress") << progress; | |||
|
103 | auto acqIdToRequestProgressMapIt = m_AcqIdToRequestProgressMap.find(acqIdentifier); | |||
|
104 | if (acqIdToRequestProgressMapIt != m_AcqIdToRequestProgressMap.end()) { | |||
|
105 | ||||
|
106 | qCCritical(LOG_AmdaProvider()) << tr("1 onReplyDownloadProgress") << progress; | |||
|
107 | auto requestPtr = &networkRequest; | |||
|
108 | auto findRequest | |||
|
109 | = [requestPtr](const auto &entry) { return requestPtr == entry.first.get(); }; | |||
|
110 | ||||
|
111 | auto &requestProgressMap = acqIdToRequestProgressMapIt->second; | |||
|
112 | auto requestProgressMapEnd = requestProgressMap.end(); | |||
|
113 | auto requestProgressMapIt | |||
|
114 | = std::find_if(requestProgressMap.begin(), requestProgressMapEnd, findRequest); | |||
|
115 | ||||
|
116 | if (requestProgressMapIt != requestProgressMapEnd) { | |||
|
117 | requestProgressMapIt->second = progress; | |||
|
118 | } | |||
|
119 | else { | |||
|
120 | qCCritical(LOG_AmdaProvider()) << tr("Can't retrieve Request in progress"); | |||
|
121 | } | |||
|
122 | } | |||
|
123 | ||||
|
124 | acqIdToRequestProgressMapIt = m_AcqIdToRequestProgressMap.find(acqIdentifier); | |||
|
125 | if (acqIdToRequestProgressMapIt != m_AcqIdToRequestProgressMap.end()) { | |||
|
126 | qCCritical(LOG_AmdaProvider()) << tr("2 onReplyDownloadProgress") << progress; | |||
|
127 | double finalProgress = 0.0; | |||
|
128 | ||||
|
129 | auto &requestProgressMap = acqIdToRequestProgressMapIt->second; | |||
|
130 | auto fraq = requestProgressMap.size(); | |||
|
131 | ||||
|
132 | for (auto requestProgress : requestProgressMap) { | |||
|
133 | finalProgress += requestProgress.second; | |||
|
134 | } | |||
|
135 | ||||
|
136 | if (fraq > 0) { | |||
|
137 | finalProgress = finalProgress / fraq; | |||
|
138 | } | |||
|
139 | ||||
|
140 | qCCritical(LOG_AmdaProvider()) << tr("2 onReplyDownloadProgress") << finalProgress; | |||
|
141 | emit dataProvidedProgress(acqIdentifier, finalProgress); | |||
|
142 | } | |||
|
143 | else { | |||
|
144 | emit dataProvidedProgress(acqIdentifier, 0.0); | |||
|
145 | } | |||
|
146 | } | |||
|
147 | ||||
92 | void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVariantHash &data) |
|
148 | void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVariantHash &data) | |
93 | { |
|
149 | { | |
94 | // Retrieves product ID from data: if the value is invalid, no request is made |
|
150 | // Retrieves product ID from data: if the value is invalid, no request is made | |
@@ -137,6 +193,7 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa | |||||
137 | /// @todo ALX : debug |
|
193 | /// @todo ALX : debug | |
138 | } |
|
194 | } | |
139 | } |
|
195 | } | |
|
196 | m_AcqIdToRequestProgressMap.erase(dataId); | |||
140 | } |
|
197 | } | |
141 |
|
198 | |||
142 | }; |
|
199 | }; | |
@@ -147,7 +204,6 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa | |||||
147 | if (reply->error() != QNetworkReply::OperationCanceledError) { |
|
204 | if (reply->error() != QNetworkReply::OperationCanceledError) { | |
148 | auto downloadFileUrl = QUrl{QString{reply->readAll()}}; |
|
205 | auto downloadFileUrl = QUrl{QString{reply->readAll()}}; | |
149 |
|
206 | |||
150 |
|
||||
151 | qCInfo(LOG_AmdaProvider()) |
|
207 | qCInfo(LOG_AmdaProvider()) | |
152 | << tr("TORM AmdaProvider::retrieveData downloadFileUrl:") << downloadFileUrl; |
|
208 | << tr("TORM AmdaProvider::retrieveData downloadFileUrl:") << downloadFileUrl; | |
153 | // Executes request for downloading file // |
|
209 | // Executes request for downloading file // | |
@@ -155,14 +211,44 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa | |||||
155 | // Creates destination file |
|
211 | // Creates destination file | |
156 | if (tempFile->open()) { |
|
212 | if (tempFile->open()) { | |
157 | // Executes request |
|
213 | // Executes request | |
158 |
|
|
214 | auto request = std::make_shared<QNetworkRequest>(downloadFileUrl); | |
159 | httpDownloadFinished); |
|
215 | updateRequestProgress(dataId, request, 0.0); | |
|
216 | emit requestConstructed(*request.get(), dataId, httpDownloadFinished); | |||
160 | } |
|
217 | } | |
161 | } |
|
218 | } | |
|
219 | else { | |||
|
220 | m_AcqIdToRequestProgressMap.erase(dataId); | |||
|
221 | } | |||
162 | }; |
|
222 | }; | |
163 |
|
223 | |||
164 | // //////////////// // |
|
224 | // //////////////// // | |
165 | // Executes request // |
|
225 | // Executes request // | |
166 | // //////////////// // |
|
226 | // //////////////// // | |
167 | emit requestConstructed(QNetworkRequest{url}, token, httpFinishedLambda); |
|
227 | ||
|
228 | auto request = std::make_shared<QNetworkRequest>(url); | |||
|
229 | updateRequestProgress(token, request, 0.0); | |||
|
230 | ||||
|
231 | emit requestConstructed(*request.get(), token, httpFinishedLambda); | |||
|
232 | } | |||
|
233 | ||||
|
234 | void AmdaProvider::updateRequestProgress(QUuid acqIdentifier, | |||
|
235 | std::shared_ptr<QNetworkRequest> request, double progress) | |||
|
236 | { | |||
|
237 | auto acqIdToRequestProgressMapIt = m_AcqIdToRequestProgressMap.find(acqIdentifier); | |||
|
238 | if (acqIdToRequestProgressMapIt != m_AcqIdToRequestProgressMap.end()) { | |||
|
239 | auto &requestProgressMap = acqIdToRequestProgressMapIt->second; | |||
|
240 | auto requestProgressMapIt = requestProgressMap.find(request); | |||
|
241 | if (requestProgressMapIt != requestProgressMap.end()) { | |||
|
242 | requestProgressMapIt->second = progress; | |||
|
243 | } | |||
|
244 | else { | |||
|
245 | acqIdToRequestProgressMapIt->second.insert(std::make_pair(request, progress)); | |||
|
246 | } | |||
|
247 | } | |||
|
248 | else { | |||
|
249 | auto requestProgressMap = std::map<std::shared_ptr<QNetworkRequest>, double>{}; | |||
|
250 | requestProgressMap.insert(std::make_pair(request, progress)); | |||
|
251 | m_AcqIdToRequestProgressMap.insert( | |||
|
252 | std::make_pair(acqIdentifier, std::move(requestProgressMap))); | |||
|
253 | } | |||
168 | } |
|
254 | } |
@@ -52,6 +52,9 std::shared_ptr<IDataSeries> CosinusProvider::retrieveData(QUuid acqIdentifier, | |||||
52 | progress = currentProgress; |
|
52 | progress = currentProgress; | |
53 |
|
53 | |||
54 | emit dataProvidedProgress(acqIdentifier, progress); |
|
54 | emit dataProvidedProgress(acqIdentifier, progress); | |
|
55 | qCInfo(LOG_CosinusProvider()) << "TORM: CosinusProvider::retrieveData" | |||
|
56 | << QThread::currentThread()->objectName() << progress; | |||
|
57 | // NOTE: Try to use multithread if possible | |||
55 | } |
|
58 | } | |
56 | } |
|
59 | } | |
57 | else { |
|
60 | else { | |
@@ -62,8 +65,10 std::shared_ptr<IDataSeries> CosinusProvider::retrieveData(QUuid acqIdentifier, | |||||
62 | } |
|
65 | } | |
63 | } |
|
66 | } | |
64 | } |
|
67 | } | |
65 | emit dataProvidedProgress(acqIdentifier, 0.0); |
|
68 | if (progress != 100) { | |
66 |
|
69 | // We can close progression beacause all data has been retrieved | ||
|
70 | emit dataProvidedProgress(acqIdentifier, 100); | |||
|
71 | } | |||
67 | return std::make_shared<ScalarSeries>(std::move(xAxisData), std::move(valuesData), |
|
72 | return std::make_shared<ScalarSeries>(std::move(xAxisData), std::move(valuesData), | |
68 | Unit{QStringLiteral("t"), true}, Unit{}); |
|
73 | Unit{QStringLiteral("t"), true}, Unit{}); | |
69 | } |
|
74 | } |
General Comments 0
You need to be logged in to leave comments.
Login now