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