@@ -65,7 +65,7 signals: | |||
|
65 | 65 | * @brief requestConstructed send a request for the data identified by acqIdentifier |
|
66 | 66 | * @callback is the methode call by the reply of the request when it is finished. |
|
67 | 67 | */ |
|
68 |
void requestConstructed( |
|
|
68 | void requestConstructed(std::shared_ptr<QNetworkRequest> request, QUuid acqIdentifier, | |
|
69 | 69 | std::function<void(QNetworkReply *, QUuid)> callback); |
|
70 | 70 | }; |
|
71 | 71 |
@@ -7,6 +7,7 | |||
|
7 | 7 | #include <QObject> |
|
8 | 8 | #include <QUuid> |
|
9 | 9 | |
|
10 | #include <Common/MetaTypes.h> | |
|
10 | 11 | #include <Common/spimpl.h> |
|
11 | 12 | #include <functional> |
|
12 | 13 | |
@@ -29,14 +30,14 public: | |||
|
29 | 30 | public slots: |
|
30 | 31 | /// Execute request and call callback when the reply is finished. Identifier is attached to the |
|
31 | 32 | /// callback |
|
32 |
void onProcessRequested( |
|
|
33 | void onProcessRequested(std::shared_ptr<QNetworkRequest> request, QUuid identifier, | |
|
33 | 34 | std::function<void(QNetworkReply *, QUuid)> callback); |
|
34 | 35 | /// Cancel the request of identifier |
|
35 | 36 | void onReplyCanceled(QUuid identifier); |
|
36 | 37 | |
|
37 | 38 | signals: |
|
38 | 39 | void replyFinished(QNetworkReply *reply, QUuid identifier); |
|
39 |
void replyDownloadProgress(QUuid identifier, |
|
|
40 | void replyDownloadProgress(QUuid identifier, std::shared_ptr<QNetworkRequest> networkRequest, | |
|
40 | 41 | double progress); |
|
41 | 42 | |
|
42 | 43 | private: |
@@ -46,4 +47,7 private: | |||
|
46 | 47 | spimpl::unique_impl_ptr<NetworkControllerPrivate> impl; |
|
47 | 48 | }; |
|
48 | 49 | |
|
50 | SCIQLOP_REGISTER_META_TYPE(NETWORKREQUEST_REGISTRY, std::shared_ptr<QNetworkRequest>) | |
|
51 | ||
|
52 | ||
|
49 | 53 | #endif // SCIQLOP_NETWORKCONTROLLER_H |
@@ -30,12 +30,13 NetworkController::NetworkController(QObject *parent) | |||
|
30 | 30 | { |
|
31 | 31 | } |
|
32 | 32 | |
|
33 |
void NetworkController::onProcessRequested( |
|
|
33 | void NetworkController::onProcessRequested(std::shared_ptr<QNetworkRequest> request, | |
|
34 | QUuid identifier, | |
|
34 | 35 | std::function<void(QNetworkReply *, QUuid)> callback) |
|
35 | 36 | { |
|
36 |
qCDebug(LOG_NetworkController()) << tr("NetworkController |
|
|
37 | << QThread::currentThread()->objectName(); | |
|
38 | auto reply = impl->m_AccessManager->get(request); | |
|
37 | qCDebug(LOG_NetworkController()) << tr("NetworkController onProcessRequested") | |
|
38 | << QThread::currentThread()->objectName() << &request; | |
|
39 | auto reply = impl->m_AccessManager->get(*request); | |
|
39 | 40 | |
|
40 | 41 | // Store the couple reply id |
|
41 | 42 | impl->lockWrite(); |
@@ -45,7 +46,7 void NetworkController::onProcessRequested(const QNetworkRequest &request, QUuid | |||
|
45 | 46 | auto onReplyFinished = [request, reply, this, identifier, callback]() { |
|
46 | 47 | |
|
47 | 48 | qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyFinished") |
|
48 | << QThread::currentThread() << reply; | |
|
49 | << QThread::currentThread() << request.get() << reply; | |
|
49 | 50 | impl->lockRead(); |
|
50 | 51 | auto it = impl->m_NetworkReplyToVariableId.find(reply); |
|
51 | 52 | impl->unlock(); |
@@ -56,8 +57,6 void NetworkController::onProcessRequested(const QNetworkRequest &request, QUuid | |||
|
56 | 57 | // Deletes reply |
|
57 | 58 | callback(reply, identifier); |
|
58 | 59 | reply->deleteLater(); |
|
59 | ||
|
60 | emit this->replyDownloadProgress(identifier, request, 0); | |
|
61 | 60 | } |
|
62 | 61 | |
|
63 | 62 | qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyFinished END") |
@@ -68,7 +67,7 void NetworkController::onProcessRequested(const QNetworkRequest &request, QUuid | |||
|
68 | 67 | |
|
69 | 68 | double progress = (bytesRead * 100.0) / totalBytes; |
|
70 | 69 | qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyProgress") << progress |
|
71 | << QThread::currentThread() << reply; | |
|
70 | << QThread::currentThread() << request.get() << reply; | |
|
72 | 71 | impl->lockRead(); |
|
73 | 72 | auto it = impl->m_NetworkReplyToVariableId.find(reply); |
|
74 | 73 | impl->unlock(); |
@@ -117,20 +117,6 void VariableAcquisitionWorker::onVariableRetrieveDataInProgress(QUuid acqIdenti | |||
|
117 | 117 | = std::isnan(progress) ? 0.0 : (progress * currentPartSize) / 100.0; |
|
118 | 118 | auto currentAlreadyProgress = aIdToARit->second.m_Progression * currentPartSize; |
|
119 | 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 | 120 | auto finalProgression = currentAlreadyProgress + currentPartProgress; |
|
135 | 121 | emit variableRequestInProgress(aIdToARit->second.m_vIdentifier, finalProgression); |
|
136 | 122 | |
@@ -145,7 +131,7 void VariableAcquisitionWorker::onVariableDataAcquired(QUuid acqIdentifier, | |||
|
145 | 131 | std::shared_ptr<IDataSeries> dataSeries, |
|
146 | 132 | SqpRange dataRangeAcquired) |
|
147 | 133 | { |
|
148 |
qC |
|
|
134 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM: onVariableDataAcquired on range ") | |
|
149 | 135 | << acqIdentifier << dataRangeAcquired; |
|
150 | 136 | impl->lockWrite(); |
|
151 | 137 | auto aIdToARit = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier); |
@@ -269,19 +255,3 void VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate::removeVariable | |||
|
269 | 255 | m_VIdentifierToCurrrentAcqIdNextIdPairMap.erase(vIdentifier); |
|
270 | 256 | unlock(); |
|
271 | 257 | } |
|
272 | ||
|
273 | //void VariableAcquisitionWorker::onExecuteRequest(QUuid acqIdentifier) | |
|
274 | //{ | |
|
275 | // qCDebug(LOG_VariableAcquisitionWorker()) << tr("onExecuteRequest") << QThread::currentThread(); | |
|
276 | // impl->lockRead(); | |
|
277 | // auto it = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier); | |
|
278 | // if (it != impl->m_AcqIdentifierToAcqRequestMap.cend()) { | |
|
279 | // auto request = it->second; | |
|
280 | // impl->unlock(); | |
|
281 | // request.m_Provider->requestDataLoading(acqIdentifier, request.m_DataProviderParameters); | |
|
282 | // } | |
|
283 | // else { | |
|
284 | // impl->unlock(); | |
|
285 | // // TODO log no acqIdentifier recognized | |
|
286 | // } | |
|
287 | //} |
@@ -322,7 +322,8 void VariableController::onDataProvided(QUuid vIdentifier, const SqpRange &range | |||
|
322 | 322 | |
|
323 | 323 | void VariableController::onVariableRetrieveDataInProgress(QUuid identifier, double progress) |
|
324 | 324 | { |
|
325 | qCInfo(LOG_VariableController()) << "TORM: ariableController::onVariableRetrieveDataInProgress" | |
|
325 | qCDebug(LOG_VariableController()) | |
|
326 | << "TORM: variableController::onVariableRetrieveDataInProgress" | |
|
326 | 327 |
|
|
327 | 328 | if (auto var = impl->findVariable(identifier)) { |
|
328 | 329 | impl->m_VariableModel->setDataProgress(var, progress); |
General Comments 0
You need to be logged in to leave comments.
Login now