##// END OF EJS Templates
Correction for MR
perrinel -
r760:ba0e6f7d7791
parent child
Show More
@@ -50,17 +50,19 void NetworkController::onProcessRequested(std::shared_ptr<QNetworkRequest> requ
50 50 << QThread::currentThread() << request.get() << reply;
51 51 impl->lockRead();
52 52 auto it = impl->m_NetworkReplyToId.find(reply);
53 impl->unlock();
54 53 if (it != impl->m_NetworkReplyToId.cend()) {
54 qCDebug(LOG_NetworkController()) << tr("Remove for reply: ") << it->second;
55 impl->unlock();
55 56 impl->lockWrite();
56 qCDebug(LOG_NetworkController()) << tr("Remove for reply: ")
57 << impl->m_NetworkReplyToId[reply];
58 57 impl->m_NetworkReplyToId.erase(reply);
59 58 impl->unlock();
60 59 // Deletes reply
61 60 callback(reply, identifier);
62 61 reply->deleteLater();
63 62 }
63 else {
64 impl->unlock();
65 }
64 66
65 67 qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyFinished END")
66 68 << QThread::currentThread() << reply;
@@ -76,10 +78,15 void NetworkController::onProcessRequested(std::shared_ptr<QNetworkRequest> requ
76 78 << bytesRead << totalBytes;
77 79 impl->lockRead();
78 80 auto it = impl->m_NetworkReplyToId.find(reply);
79 impl->unlock();
80 81 if (it != impl->m_NetworkReplyToId.cend()) {
81 emit this->replyDownloadProgress(it->second, request, progress);
82 auto id = it->second;
83 impl->unlock();
84 emit this->replyDownloadProgress(id, request, progress);
85 }
86 else {
87 impl->unlock();
82 88 }
89
83 90 qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyProgress END")
84 91 << QThread::currentThread() << reply;
85 92 }
@@ -82,6 +82,8 void AmdaProvider::requestDataLoading(QUuid acqIdentifier, const DataProviderPar
82 82 const auto times = parameters.m_Times;
83 83 const auto data = parameters.m_Data;
84 84 for (const auto &dateTime : qAsConst(times)) {
85 qCInfo(LOG_AmdaProvider()) << tr("TORM AmdaProvider::requestDataLoading ") << acqIdentifier
86 << dateTime;
85 87 this->retrieveData(acqIdentifier, dateTime, data);
86 88
87 89
@@ -102,11 +104,12 void AmdaProvider::onReplyDownloadProgress(QUuid acqIdentifier,
102 104 std::shared_ptr<QNetworkRequest> networkRequest,
103 105 double progress)
104 106 {
105 qCInfo(LOG_AmdaProvider()) << tr("onReplyDownloadProgress") << acqIdentifier
106 << networkRequest.get() << progress;
107 qCDebug(LOG_AmdaProvider()) << tr("onReplyDownloadProgress") << acqIdentifier
108 << networkRequest.get() << progress;
107 109 auto acqIdToRequestProgressMapIt = m_AcqIdToRequestProgressMap.find(acqIdentifier);
108 110 if (acqIdToRequestProgressMapIt != m_AcqIdToRequestProgressMap.end()) {
109 111
112 // Update the progression for the current request
110 113 auto requestPtr = networkRequest;
111 114 auto findRequest = [requestPtr](const auto &entry) { return requestPtr == entry.first; };
112 115
@@ -125,18 +128,15 void AmdaProvider::onReplyDownloadProgress(QUuid acqIdentifier,
125 128 qCWarning(LOG_AmdaProvider()) << tr("Can't retrieve Request in progress")
126 129 << acqIdentifier << networkRequest.get() << progress;
127 130 }
128 }
129 131
130 acqIdToRequestProgressMapIt = m_AcqIdToRequestProgressMap.find(acqIdentifier);
131 if (acqIdToRequestProgressMapIt != m_AcqIdToRequestProgressMap.end()) {
132 // Compute the current final progress and notify it
132 133 double finalProgress = 0.0;
133 134
134 auto &requestProgressMap = acqIdToRequestProgressMapIt->second;
135 135 auto fraq = requestProgressMap.size();
136 136
137 137 for (auto requestProgress : requestProgressMap) {
138 138 finalProgress += requestProgress.second;
139 qCDebug(LOG_AmdaProvider()) << tr("current final progress without freq:")
139 qCDebug(LOG_AmdaProvider()) << tr("Current final progress without fraq:")
140 140 << finalProgress << requestProgress.second;
141 141 }
142 142
@@ -144,8 +144,7 void AmdaProvider::onReplyDownloadProgress(QUuid acqIdentifier,
144 144 finalProgress = finalProgress / fraq;
145 145 }
146 146
147 qCDebug(LOG_AmdaProvider()) << tr("2 onReplyDownloadProgress final progress") << fraq
148 << finalProgress;
147 qCDebug(LOG_AmdaProvider()) << tr("Current final progress: ") << fraq << finalProgress;
149 148 emit dataProvidedProgress(acqIdentifier, finalProgress);
150 149 }
151 150 else {
@@ -176,7 +175,7 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa
176 175 auto endDate = dateFormat(dateTime.m_TEnd);
177 176
178 177 auto url = QUrl{QString{AMDA_URL_FORMAT}.arg(startDate, endDate, productId)};
179 qCDebug(LOG_AmdaProvider()) << tr("TORM AmdaProvider::retrieveData url:") << url;
178 qCInfo(LOG_AmdaProvider()) << tr("TORM AmdaProvider::retrieveData url:") << url;
180 179 auto tempFile = std::make_shared<QTemporaryFile>();
181 180
182 181 // LAMBDA
@@ -184,7 +183,7 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa
184 183 productValueType](QNetworkReply *reply, QUuid dataId) noexcept {
185 184
186 185 // Don't do anything if the reply was abort
187 if (reply->error() != QNetworkReply::OperationCanceledError) {
186 if (reply->error() == QNetworkReply::NoError) {
188 187
189 188 if (tempFile) {
190 189 auto replyReadAll = reply->readAll();
@@ -206,16 +205,19 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa
206 205 << dataId;
207 206 m_AcqIdToRequestProgressMap.erase(dataId);
208 207 }
208 else {
209 qCCritical(LOG_AmdaProvider()) << tr("httpDownloadFinished ERROR");
210 }
209 211
210 212 };
211 213 auto httpFinishedLambda
212 214 = [this, httpDownloadFinished, tempFile](QNetworkReply *reply, QUuid dataId) noexcept {
213 215
214 216 // Don't do anything if the reply was abort
215 if (reply->error() != QNetworkReply::OperationCanceledError) {
217 if (reply->error() == QNetworkReply::NoError) {
216 218 auto downloadFileUrl = QUrl{QString{reply->readAll()}};
217 219
218 qCDebug(LOG_AmdaProvider())
220 qCInfo(LOG_AmdaProvider())
219 221 << tr("TORM AmdaProvider::retrieveData downloadFileUrl:") << downloadFileUrl;
220 222 // Executes request for downloading file //
221 223
@@ -230,6 +232,7 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa
230 232 else {
231 233 qCDebug(LOG_AmdaProvider())
232 234 << tr("acquisition requests erase because of aborting") << dataId;
235 qCCritical(LOG_AmdaProvider()) << tr("httpFinishedLambda ERROR");
233 236 m_AcqIdToRequestProgressMap.erase(dataId);
234 237 }
235 238 };
General Comments 0
You need to be logged in to leave comments. Login now