@@ -21,6 +21,7 struct AcquisitionRequest { | |||
|
21 | 21 | { |
|
22 | 22 | m_AcqIdentifier = QUuid::createUuid(); |
|
23 | 23 | m_Size = 0; |
|
24 | m_Progression = 0; | |
|
24 | 25 | } |
|
25 | 26 | |
|
26 | 27 | QUuid m_VarRequestId; |
@@ -30,6 +31,7 struct AcquisitionRequest { | |||
|
30 | 31 | SqpRange m_RangeRequested; |
|
31 | 32 | SqpRange m_CacheRangeRequested; |
|
32 | 33 | int m_Size; |
|
34 | int m_Progression; | |
|
33 | 35 | std::shared_ptr<IDataProvider> m_Provider; |
|
34 | 36 | }; |
|
35 | 37 |
@@ -55,17 +55,21 signals: | |||
|
55 | 55 | const SqpRange &dataRangeAcquired); |
|
56 | 56 | |
|
57 | 57 | /** |
|
58 | * @brief dataProvided send dataSeries under dateTime and that corresponds of the data | |
|
59 | * identified by identifier | |
|
60 | */ | |
|
58 | * @brief dataProvidedProgress notify the progression of the data identifier by acqIdentifier | |
|
59 | */ | |
|
61 | 60 | void dataProvidedProgress(QUuid acqIdentifier, double progress); |
|
62 | 61 | |
|
62 | /** | |
|
63 | * @brief dataProvidedFailed notify that data acquisition has failed | |
|
64 | */ | |
|
65 | void dataProvidedFailed(QUuid acqIdentifier); | |
|
66 | ||
|
63 | 67 | |
|
64 | 68 | /** |
|
65 | 69 | * @brief requestConstructed send a request for the data identified by acqIdentifier |
|
66 | 70 | * @callback is the methode call by the reply of the request when it is finished. |
|
67 | 71 | */ |
|
68 |
void requestConstructed( |
|
|
72 | void requestConstructed(std::shared_ptr<QNetworkRequest> request, QUuid acqIdentifier, | |
|
69 | 73 | std::function<void(QNetworkReply *, QUuid)> callback); |
|
70 | 74 | }; |
|
71 | 75 |
@@ -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,15 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, dou |
|
|
40 | void replyDownloadProgress(QUuid identifier, std::shared_ptr<QNetworkRequest> networkRequest, | |
|
41 | double progress); | |
|
40 | 42 | |
|
41 | 43 | private: |
|
42 | 44 | void waitForFinish(); |
@@ -45,4 +47,7 private: | |||
|
45 | 47 | spimpl::unique_impl_ptr<NetworkControllerPrivate> impl; |
|
46 | 48 | }; |
|
47 | 49 | |
|
50 | SCIQLOP_REGISTER_META_TYPE(NETWORKREQUEST_REGISTRY, std::shared_ptr<QNetworkRequest>) | |
|
51 | ||
|
52 | ||
|
48 | 53 | #endif // SCIQLOP_NETWORKCONTROLLER_H |
@@ -25,8 +25,7 class SCIQLOP_CORE_EXPORT Variable : public QObject { | |||
|
25 | 25 | Q_OBJECT |
|
26 | 26 | |
|
27 | 27 | public: |
|
28 |
explicit Variable(const QString &name, const |
|
|
29 | const QVariantHash &metadata = {}); | |
|
28 | explicit Variable(const QString &name, const QVariantHash &metadata = {}); | |
|
30 | 29 | |
|
31 | 30 | /// Copy ctor |
|
32 | 31 | explicit Variable(const Variable &other); |
@@ -43,10 +43,15 signals: | |||
|
43 | 43 | |
|
44 | 44 | void variableRequestInProgress(QUuid vIdentifier, double progress); |
|
45 | 45 | |
|
46 | ||
|
47 | void variableCanceledRequested(QUuid vIdentifier); | |
|
48 | ||
|
49 | ||
|
46 | 50 | public slots: |
|
47 | 51 | void onVariableDataAcquired(QUuid acqIdentifier, std::shared_ptr<IDataSeries> dataSeries, |
|
48 | 52 | SqpRange dataRangeAcquired); |
|
49 | 53 | void onVariableRetrieveDataInProgress(QUuid acqIdentifier, double progress); |
|
54 | void onVariableAcquisitionFailed(QUuid acqIdentifier); | |
|
50 | 55 | |
|
51 | 56 | private: |
|
52 | 57 | void waitForFinish(); |
@@ -68,10 +68,6 public: | |||
|
68 | 68 | */ |
|
69 | 69 | void deleteVariables(const QVector<std::shared_ptr<Variable> > &variables) noexcept; |
|
70 | 70 | |
|
71 | /** | |
|
72 | * @brief abort the variable retrieve data progression | |
|
73 | */ | |
|
74 | void abortProgress(std::shared_ptr<Variable> variable); | |
|
75 | 71 | |
|
76 | 72 | static AcquisitionZoomType getZoomType(const SqpRange &range, const SqpRange &oldRange); |
|
77 | 73 | signals: |
@@ -110,6 +106,7 public slots: | |||
|
110 | 106 | |
|
111 | 107 | /// Cancel the current request for the variable |
|
112 | 108 | void onAbortProgressRequested(std::shared_ptr<Variable> variable); |
|
109 | void onAbortAcquisitionRequested(QUuid vIdentifier); | |
|
113 | 110 | |
|
114 | 111 | // synchronization group methods |
|
115 | 112 | void onAddSynchronizationGroupId(QUuid synchronizationGroupId); |
@@ -45,11 +45,10 public: | |||
|
45 | 45 | /** |
|
46 | 46 | * Creates a new variable in the model |
|
47 | 47 | * @param name the name of the new variable |
|
48 | * @param dateTime the dateTime of the new variable | |
|
49 | 48 | * @param metadata the metadata associated to the new variable |
|
50 | 49 | * @return the pointer to the new variable |
|
51 | 50 | */ |
|
52 |
std::shared_ptr<Variable> createVariable(const QString &name, |
|
|
51 | std::shared_ptr<Variable> createVariable(const QString &name, | |
|
53 | 52 | const QVariantHash &metadata) noexcept; |
|
54 | 53 | |
|
55 | 54 | /** |
@@ -21,7 +21,7 struct NetworkController::NetworkControllerPrivate { | |||
|
21 | 21 | QMutex m_WorkingMutex; |
|
22 | 22 | |
|
23 | 23 | QReadWriteLock m_Lock; |
|
24 |
std::unordered_map<QNetworkReply *, QUuid> m_NetworkReplyTo |
|
|
24 | std::unordered_map<QNetworkReply *, QUuid> m_NetworkReplyToId; | |
|
25 | 25 | std::unique_ptr<QNetworkAccessManager> m_AccessManager{nullptr}; |
|
26 | 26 | }; |
|
27 | 27 | |
@@ -30,53 +30,66 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(); |
|
42 |
impl->m_NetworkReplyTo |
|
|
43 | impl->m_NetworkReplyToId[reply] = identifier; | |
|
44 | qCDebug(LOG_NetworkController()) << tr("Store for reply: ") << identifier; | |
|
43 | 45 | impl->unlock(); |
|
44 | 46 | |
|
45 | auto onReplyFinished = [reply, this, identifier, callback]() { | |
|
47 | auto onReplyFinished = [request, reply, this, identifier, callback]() { | |
|
46 | 48 | |
|
47 | 49 | qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyFinished") |
|
48 | << QThread::currentThread() << reply; | |
|
50 | << QThread::currentThread() << request.get() << reply; | |
|
49 | 51 | impl->lockRead(); |
|
50 |
auto it = impl->m_NetworkReplyTo |
|
|
51 | impl->unlock(); | |
|
52 | if (it != impl->m_NetworkReplyToVariableId.cend()) { | |
|
52 | auto it = impl->m_NetworkReplyToId.find(reply); | |
|
53 | if (it != impl->m_NetworkReplyToId.cend()) { | |
|
54 | qCDebug(LOG_NetworkController()) << tr("Remove for reply: ") << it->second; | |
|
55 | impl->unlock(); | |
|
53 | 56 | impl->lockWrite(); |
|
54 |
impl->m_NetworkReplyTo |
|
|
57 | impl->m_NetworkReplyToId.erase(reply); | |
|
55 | 58 | impl->unlock(); |
|
56 | 59 | // Deletes reply |
|
57 | 60 | callback(reply, identifier); |
|
58 | 61 | reply->deleteLater(); |
|
59 | ||
|
60 | emit this->replyDownloadProgress(identifier, 0); | |
|
62 | } | |
|
63 | else { | |
|
64 | impl->unlock(); | |
|
61 | 65 | } |
|
62 | 66 | |
|
63 | 67 | qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyFinished END") |
|
64 | 68 | << QThread::currentThread() << reply; |
|
65 | 69 | }; |
|
66 | 70 | |
|
67 | auto onReplyProgress = [reply, this](qint64 bytesRead, qint64 totalBytes) { | |
|
68 | ||
|
69 | double progress = (bytesRead * 100.0) / totalBytes; | |
|
70 | qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyProgress") << progress | |
|
71 | << QThread::currentThread() << reply; | |
|
72 | impl->lockRead(); | |
|
73 | auto it = impl->m_NetworkReplyToVariableId.find(reply); | |
|
74 | impl->unlock(); | |
|
75 | if (it != impl->m_NetworkReplyToVariableId.cend()) { | |
|
76 | emit this->replyDownloadProgress(it->second, progress); | |
|
71 | auto onReplyProgress = [reply, request, this](qint64 bytesRead, qint64 totalBytes) { | |
|
72 | ||
|
73 | // NOTE: a totalbytes of 0 can happened when a request has been aborted | |
|
74 | if (totalBytes > 0) { | |
|
75 | double progress = (bytesRead * 100.0) / totalBytes; | |
|
76 | qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyProgress") << progress | |
|
77 | << QThread::currentThread() << request.get() << reply | |
|
78 | << bytesRead << totalBytes; | |
|
79 | impl->lockRead(); | |
|
80 | auto it = impl->m_NetworkReplyToId.find(reply); | |
|
81 | if (it != impl->m_NetworkReplyToId.cend()) { | |
|
82 | auto id = it->second; | |
|
83 | impl->unlock(); | |
|
84 | emit this->replyDownloadProgress(id, request, progress); | |
|
85 | } | |
|
86 | else { | |
|
87 | impl->unlock(); | |
|
88 | } | |
|
89 | ||
|
90 | qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyProgress END") | |
|
91 | << QThread::currentThread() << reply; | |
|
77 | 92 | } |
|
78 | qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyProgress END") | |
|
79 | << QThread::currentThread() << reply; | |
|
80 | 93 | }; |
|
81 | 94 | |
|
82 | 95 | |
@@ -94,7 +107,6 void NetworkController::initialize() | |||
|
94 | 107 | |
|
95 | 108 | |
|
96 | 109 | auto onReplyErrors = [this](QNetworkReply *reply, const QList<QSslError> &errors) { |
|
97 | ||
|
98 | 110 | qCCritical(LOG_NetworkController()) << tr("NetworkAcessManager errors: ") << errors; |
|
99 | 111 | |
|
100 | 112 | }; |
@@ -114,14 +126,16 void NetworkController::onReplyCanceled(QUuid identifier) | |||
|
114 | 126 | { |
|
115 | 127 | auto findReply = [identifier](const auto &entry) { return identifier == entry.second; }; |
|
116 | 128 | qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyCanceled") |
|
117 | << QThread::currentThread(); | |
|
129 | << QThread::currentThread() << identifier; | |
|
118 | 130 | |
|
119 | 131 | |
|
120 | 132 | impl->lockRead(); |
|
121 |
auto end = impl->m_NetworkReplyTo |
|
|
122 |
auto it = std::find_if(impl->m_NetworkReplyTo |
|
|
133 | auto end = impl->m_NetworkReplyToId.cend(); | |
|
134 | auto it = std::find_if(impl->m_NetworkReplyToId.cbegin(), end, findReply); | |
|
123 | 135 | impl->unlock(); |
|
124 | 136 | if (it != end) { |
|
137 | qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyCanceled ABORT DONE") | |
|
138 | << QThread::currentThread() << identifier; | |
|
125 | 139 | it->first->abort(); |
|
126 | 140 | } |
|
127 | 141 | qCDebug(LOG_NetworkController()) << tr("NetworkController onReplyCanceled END") |
@@ -10,10 +10,10 | |||
|
10 | 10 | Q_LOGGING_CATEGORY(LOG_Variable, "Variable") |
|
11 | 11 | |
|
12 | 12 | struct Variable::VariablePrivate { |
|
13 |
explicit VariablePrivate(const QString &name, const |
|
|
14 | const QVariantHash &metadata) | |
|
13 | explicit VariablePrivate(const QString &name, const QVariantHash &metadata) | |
|
15 | 14 | : m_Name{name}, |
|
16 |
m_Range{ |
|
|
15 | m_Range{INVALID_RANGE}, | |
|
16 | m_CacheRange{INVALID_RANGE}, | |
|
17 | 17 | m_Metadata{metadata}, |
|
18 | 18 | m_DataSeries{nullptr}, |
|
19 | 19 | m_RealRange{INVALID_RANGE}, |
@@ -24,6 +24,7 struct Variable::VariablePrivate { | |||
|
24 | 24 | VariablePrivate(const VariablePrivate &other) |
|
25 | 25 | : m_Name{other.m_Name}, |
|
26 | 26 | m_Range{other.m_Range}, |
|
27 | m_CacheRange{other.m_CacheRange}, | |
|
27 | 28 | m_Metadata{other.m_Metadata}, |
|
28 | 29 | m_DataSeries{other.m_DataSeries != nullptr ? other.m_DataSeries->clone() : nullptr}, |
|
29 | 30 | m_RealRange{other.m_RealRange}, |
@@ -55,9 +56,10 struct Variable::VariablePrivate { | |||
|
55 | 56 | auto minXAxisIt = m_DataSeries->minXAxisData(m_Range.m_TStart); |
|
56 | 57 | auto maxXAxisIt = m_DataSeries->maxXAxisData(m_Range.m_TEnd); |
|
57 | 58 | |
|
58 | m_RealRange = (minXAxisIt != end && maxXAxisIt != end) | |
|
59 |
|
|
|
60 | : INVALID_RANGE; | |
|
59 | m_RealRange | |
|
60 | = (minXAxisIt != end && maxXAxisIt != end && minXAxisIt->x() <= maxXAxisIt->x()) | |
|
61 | ? SqpRange{minXAxisIt->x(), maxXAxisIt->x()} | |
|
62 | : INVALID_RANGE; | |
|
61 | 63 | m_DataSeries->unlock(); |
|
62 | 64 | } |
|
63 | 65 | else { |
@@ -77,8 +79,8 struct Variable::VariablePrivate { | |||
|
77 | 79 | QReadWriteLock m_Lock; |
|
78 | 80 | }; |
|
79 | 81 | |
|
80 |
Variable::Variable(const QString &name, const |
|
|
81 |
: impl{spimpl::make_unique_impl<VariablePrivate>(name, |
|
|
82 | Variable::Variable(const QString &name, const QVariantHash &metadata) | |
|
83 | : impl{spimpl::make_unique_impl<VariablePrivate>(name, metadata)} | |
|
82 | 84 | { |
|
83 | 85 | } |
|
84 | 86 | |
@@ -242,31 +244,35 bool Variable::cacheIsInside(const SqpRange &range) const noexcept | |||
|
242 | 244 | QVector<SqpRange> Variable::provideNotInCacheRangeList(const SqpRange &range) const noexcept |
|
243 | 245 | { |
|
244 | 246 | // This code assume that cach in contigue. Can return 0, 1 or 2 SqpRange |
|
245 | ||
|
246 | 247 | auto notInCache = QVector<SqpRange>{}; |
|
247 | ||
|
248 | if (!this->cacheContains(range)) { | |
|
249 | if (range.m_TEnd <= impl->m_CacheRange.m_TStart | |
|
250 |
|
|
|
251 | notInCache << range; | |
|
252 | } | |
|
253 | else if (range.m_TStart < impl->m_CacheRange.m_TStart | |
|
254 |
|
|
|
255 |
|
|
|
256 | } | |
|
257 | else if (range.m_TStart < impl->m_CacheRange.m_TStart | |
|
258 |
|
|
|
259 |
|
|
|
260 |
|
|
|
261 | } | |
|
262 | else if (range.m_TStart < impl->m_CacheRange.m_TEnd) { | |
|
263 |
|
|
|
264 | } | |
|
265 |
|
|
|
266 | qCCritical(LOG_Variable()) << tr("Detection of unknown case.") | |
|
267 | << QThread::currentThread(); | |
|
248 | if (impl->m_CacheRange != INVALID_RANGE) { | |
|
249 | ||
|
250 | if (!this->cacheContains(range)) { | |
|
251 | if (range.m_TEnd <= impl->m_CacheRange.m_TStart | |
|
252 | || range.m_TStart >= impl->m_CacheRange.m_TEnd) { | |
|
253 | notInCache << range; | |
|
254 | } | |
|
255 | else if (range.m_TStart < impl->m_CacheRange.m_TStart | |
|
256 | && range.m_TEnd <= impl->m_CacheRange.m_TEnd) { | |
|
257 | notInCache << SqpRange{range.m_TStart, impl->m_CacheRange.m_TStart}; | |
|
258 | } | |
|
259 | else if (range.m_TStart < impl->m_CacheRange.m_TStart | |
|
260 | && range.m_TEnd > impl->m_CacheRange.m_TEnd) { | |
|
261 | notInCache << SqpRange{range.m_TStart, impl->m_CacheRange.m_TStart} | |
|
262 | << SqpRange{impl->m_CacheRange.m_TEnd, range.m_TEnd}; | |
|
263 | } | |
|
264 | else if (range.m_TStart < impl->m_CacheRange.m_TEnd) { | |
|
265 | notInCache << SqpRange{impl->m_CacheRange.m_TEnd, range.m_TEnd}; | |
|
266 | } | |
|
267 | else { | |
|
268 | qCCritical(LOG_Variable()) << tr("Detection of unknown case.") | |
|
269 | << QThread::currentThread(); | |
|
270 | } | |
|
268 | 271 | } |
|
269 | 272 | } |
|
273 | else { | |
|
274 | notInCache << range; | |
|
275 | } | |
|
270 | 276 | |
|
271 | 277 | return notInCache; |
|
272 | 278 | } |
@@ -277,29 +283,31 QVector<SqpRange> Variable::provideInCacheRangeList(const SqpRange &range) const | |||
|
277 | 283 | |
|
278 | 284 | auto inCache = QVector<SqpRange>{}; |
|
279 | 285 | |
|
280 | ||
|
281 | if (this->intersect(range)) { | |
|
282 | if (range.m_TStart <= impl->m_CacheRange.m_TStart | |
|
283 |
|
|
|
284 |
&& range.m_TEnd |
|
|
285 |
|
|
|
286 | } | |
|
287 | ||
|
288 | else if (range.m_TStart >= impl->m_CacheRange.m_TStart | |
|
289 |
|
|
|
290 | inCache << range; | |
|
291 | } | |
|
292 | else if (range.m_TStart > impl->m_CacheRange.m_TStart | |
|
293 |
|
|
|
294 |
|
|
|
295 | } | |
|
296 | else if (range.m_TStart <= impl->m_CacheRange.m_TStart | |
|
297 |
|
|
|
298 |
|
|
|
299 | } | |
|
300 |
|
|
|
301 | qCCritical(LOG_Variable()) << tr("Detection of unknown case.") | |
|
302 | << QThread::currentThread(); | |
|
286 | if (impl->m_CacheRange != INVALID_RANGE) { | |
|
287 | ||
|
288 | if (this->intersect(range)) { | |
|
289 | if (range.m_TStart <= impl->m_CacheRange.m_TStart | |
|
290 | && range.m_TEnd >= impl->m_CacheRange.m_TStart | |
|
291 | && range.m_TEnd < impl->m_CacheRange.m_TEnd) { | |
|
292 | inCache << SqpRange{impl->m_CacheRange.m_TStart, range.m_TEnd}; | |
|
293 | } | |
|
294 | ||
|
295 | else if (range.m_TStart >= impl->m_CacheRange.m_TStart | |
|
296 | && range.m_TEnd <= impl->m_CacheRange.m_TEnd) { | |
|
297 | inCache << range; | |
|
298 | } | |
|
299 | else if (range.m_TStart > impl->m_CacheRange.m_TStart | |
|
300 | && range.m_TEnd > impl->m_CacheRange.m_TEnd) { | |
|
301 | inCache << SqpRange{range.m_TStart, impl->m_CacheRange.m_TEnd}; | |
|
302 | } | |
|
303 | else if (range.m_TStart <= impl->m_CacheRange.m_TStart | |
|
304 | && range.m_TEnd >= impl->m_CacheRange.m_TEnd) { | |
|
305 | inCache << impl->m_CacheRange; | |
|
306 | } | |
|
307 | else { | |
|
308 | qCCritical(LOG_Variable()) << tr("Detection of unknown case.") | |
|
309 | << QThread::currentThread(); | |
|
310 | } | |
|
303 | 311 | } |
|
304 | 312 | } |
|
305 | 313 |
@@ -12,11 +12,16 | |||
|
12 | 12 | #include <QReadWriteLock> |
|
13 | 13 | #include <QThread> |
|
14 | 14 | |
|
15 | #include <cmath> | |
|
16 | ||
|
15 | 17 | Q_LOGGING_CATEGORY(LOG_VariableAcquisitionWorker, "VariableAcquisitionWorker") |
|
16 | 18 | |
|
17 | 19 | struct VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate { |
|
18 | 20 | |
|
19 |
explicit VariableAcquisitionWorkerPrivate() |
|
|
21 | explicit VariableAcquisitionWorkerPrivate(VariableAcquisitionWorker *parent) | |
|
22 | : m_Lock{QReadWriteLock::Recursive}, q{parent} | |
|
23 | { | |
|
24 | } | |
|
20 | 25 | |
|
21 | 26 | void lockRead() { m_Lock.lockForRead(); } |
|
22 | 27 | void lockWrite() { m_Lock.lockForWrite(); } |
@@ -24,17 +29,21 struct VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate { | |||
|
24 | 29 | |
|
25 | 30 | void removeVariableRequest(QUuid vIdentifier); |
|
26 | 31 | |
|
32 | /// Remove the current request and execute the next one if exist | |
|
33 | void updateToNextRequest(QUuid vIdentifier); | |
|
34 | ||
|
27 | 35 | QMutex m_WorkingMutex; |
|
28 | 36 | QReadWriteLock m_Lock; |
|
29 | 37 | |
|
30 | 38 | std::map<QUuid, QVector<AcquisitionDataPacket> > m_AcqIdentifierToAcqDataPacketVectorMap; |
|
31 | 39 | std::map<QUuid, AcquisitionRequest> m_AcqIdentifierToAcqRequestMap; |
|
32 | 40 | std::map<QUuid, std::pair<QUuid, QUuid> > m_VIdentifierToCurrrentAcqIdNextIdPairMap; |
|
41 | VariableAcquisitionWorker *q; | |
|
33 | 42 | }; |
|
34 | 43 | |
|
35 | 44 | |
|
36 | 45 | VariableAcquisitionWorker::VariableAcquisitionWorker(QObject *parent) |
|
37 | : QObject{parent}, impl{spimpl::make_unique_impl<VariableAcquisitionWorkerPrivate>()} | |
|
46 | : QObject{parent}, impl{spimpl::make_unique_impl<VariableAcquisitionWorkerPrivate>(this)} | |
|
38 | 47 | { |
|
39 | 48 | } |
|
40 | 49 | |
@@ -58,6 +67,7 QUuid VariableAcquisitionWorker::pushVariableRequest(QUuid varRequestId, QUuid v | |||
|
58 | 67 | |
|
59 | 68 | // Request creation |
|
60 | 69 | auto acqRequest = AcquisitionRequest{}; |
|
70 | qCInfo(LOG_VariableAcquisitionWorker()) << tr("TpushVariableRequest ") << vIdentifier; | |
|
61 | 71 | acqRequest.m_VarRequestId = varRequestId; |
|
62 | 72 | acqRequest.m_vIdentifier = vIdentifier; |
|
63 | 73 | acqRequest.m_DataProviderParameters = parameters; |
@@ -100,20 +110,89 QUuid VariableAcquisitionWorker::pushVariableRequest(QUuid varRequestId, QUuid v | |||
|
100 | 110 | |
|
101 | 111 | void VariableAcquisitionWorker::abortProgressRequested(QUuid vIdentifier) |
|
102 | 112 | { |
|
103 | // TODO | |
|
113 | impl->lockRead(); | |
|
114 | ||
|
115 | auto it = impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.find(vIdentifier); | |
|
116 | if (it != impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.cend()) { | |
|
117 | auto currentAcqId = it->second.first; | |
|
118 | ||
|
119 | auto it = impl->m_AcqIdentifierToAcqRequestMap.find(currentAcqId); | |
|
120 | if (it != impl->m_AcqIdentifierToAcqRequestMap.cend()) { | |
|
121 | auto request = it->second; | |
|
122 | impl->unlock(); | |
|
123 | ||
|
124 | // Remove the current request from the worker | |
|
125 | ||
|
126 | impl->lockWrite(); | |
|
127 | impl->updateToNextRequest(vIdentifier); | |
|
128 | impl->unlock(); | |
|
129 | ||
|
130 | // notify the request aborting to the provider | |
|
131 | request.m_Provider->requestDataAborting(currentAcqId); | |
|
132 | } | |
|
133 | else { | |
|
134 | impl->unlock(); | |
|
135 | qCWarning(LOG_VariableAcquisitionWorker()) | |
|
136 | << tr("Impossible to abort an unknown acquisition request") << currentAcqId; | |
|
137 | } | |
|
138 | } | |
|
139 | else { | |
|
140 | impl->unlock(); | |
|
141 | } | |
|
104 | 142 | } |
|
105 | 143 | |
|
106 | 144 | void VariableAcquisitionWorker::onVariableRetrieveDataInProgress(QUuid acqIdentifier, |
|
107 | 145 | double progress) |
|
108 | 146 | { |
|
109 | // TODO | |
|
147 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM: onVariableRetrieveDataInProgress ") | |
|
148 | << acqIdentifier << progress; | |
|
149 | impl->lockRead(); | |
|
150 | auto aIdToARit = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier); | |
|
151 | if (aIdToARit != impl->m_AcqIdentifierToAcqRequestMap.cend()) { | |
|
152 | auto currentPartSize = (aIdToARit->second.m_Size != 0) ? 100 / aIdToARit->second.m_Size : 0; | |
|
153 | ||
|
154 | auto currentPartProgress | |
|
155 | = std::isnan(progress) ? 0.0 : (progress * currentPartSize) / 100.0; | |
|
156 | auto currentAlreadyProgress = aIdToARit->second.m_Progression * currentPartSize; | |
|
157 | ||
|
158 | auto finalProgression = currentAlreadyProgress + currentPartProgress; | |
|
159 | emit variableRequestInProgress(aIdToARit->second.m_vIdentifier, finalProgression); | |
|
160 | qCDebug(LOG_VariableAcquisitionWorker()) | |
|
161 | << tr("TORM: onVariableRetrieveDataInProgress ") | |
|
162 | << QThread::currentThread()->objectName() << aIdToARit->second.m_vIdentifier | |
|
163 | << currentPartSize << currentAlreadyProgress << currentPartProgress << finalProgression; | |
|
164 | if (finalProgression == 100.0) { | |
|
165 | emit variableRequestInProgress(aIdToARit->second.m_vIdentifier, 0.0); | |
|
166 | } | |
|
167 | } | |
|
168 | impl->unlock(); | |
|
169 | } | |
|
170 | ||
|
171 | void VariableAcquisitionWorker::onVariableAcquisitionFailed(QUuid acqIdentifier) | |
|
172 | { | |
|
173 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("onVariableAcquisitionFailed") | |
|
174 | << QThread::currentThread(); | |
|
175 | impl->lockRead(); | |
|
176 | auto it = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier); | |
|
177 | if (it != impl->m_AcqIdentifierToAcqRequestMap.cend()) { | |
|
178 | auto request = it->second; | |
|
179 | impl->unlock(); | |
|
180 | qCInfo(LOG_VariableAcquisitionWorker()) << tr("onVariableAcquisitionFailed") | |
|
181 | << acqIdentifier << request.m_vIdentifier | |
|
182 | << QThread::currentThread(); | |
|
183 | emit variableCanceledRequested(request.m_vIdentifier); | |
|
184 | } | |
|
185 | else { | |
|
186 | impl->unlock(); | |
|
187 | // TODO log no acqIdentifier recognized | |
|
188 | } | |
|
110 | 189 | } |
|
111 | 190 | |
|
112 | 191 | void VariableAcquisitionWorker::onVariableDataAcquired(QUuid acqIdentifier, |
|
113 | 192 | std::shared_ptr<IDataSeries> dataSeries, |
|
114 | 193 | SqpRange dataRangeAcquired) |
|
115 | 194 | { |
|
116 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("onVariableDataAcquired on range ") | |
|
195 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM: onVariableDataAcquired on range ") | |
|
117 | 196 | << acqIdentifier << dataRangeAcquired; |
|
118 | 197 | impl->lockWrite(); |
|
119 | 198 | auto aIdToARit = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier); |
@@ -137,11 +216,11 void VariableAcquisitionWorker::onVariableDataAcquired(QUuid acqIdentifier, | |||
|
137 | 216 | |
|
138 | 217 | // Decrement the counter of the request |
|
139 | 218 | auto &acqRequest = aIdToARit->second; |
|
140 |
acqRequest.m_ |
|
|
219 | acqRequest.m_Progression = acqRequest.m_Progression + 1; | |
|
141 | 220 | |
|
142 | 221 | // if the counter is 0, we can return data then run the next request if it exists and |
|
143 | 222 | // removed the finished request |
|
144 |
if (acqRequest.m_Size == |
|
|
223 | if (acqRequest.m_Size == acqRequest.m_Progression) { | |
|
145 | 224 | // Return the data |
|
146 | 225 | aIdToADPVit = impl->m_AcqIdentifierToAcqDataPacketVectorMap.find(acqIdentifier); |
|
147 | 226 | if (aIdToADPVit != impl->m_AcqIdentifierToAcqDataPacketVectorMap.cend()) { |
@@ -149,41 +228,34 void VariableAcquisitionWorker::onVariableDataAcquired(QUuid acqIdentifier, | |||
|
149 | 228 | acqRequest.m_CacheRangeRequested, aIdToADPVit->second); |
|
150 | 229 | } |
|
151 | 230 | |
|
152 |
// |
|
|
153 | auto it | |
|
154 | = impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.find(acqRequest.m_vIdentifier); | |
|
155 | ||
|
156 | if (it != impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.cend()) { | |
|
157 | if (it->second.second.isNull()) { | |
|
158 | // There is no next request, we can remove the variable request | |
|
159 | impl->removeVariableRequest(acqRequest.m_vIdentifier); | |
|
160 | } | |
|
161 | else { | |
|
162 | auto acqIdentifierToRemove = it->second.first; | |
|
163 | // Move the next request to the current request | |
|
164 | it->second.first = it->second.second; | |
|
165 | it->second.second = QUuid(); | |
|
166 | // Remove AcquisitionRequest and results; | |
|
167 | impl->m_AcqIdentifierToAcqRequestMap.erase(acqIdentifierToRemove); | |
|
168 | impl->m_AcqIdentifierToAcqDataPacketVectorMap.erase(acqIdentifierToRemove); | |
|
169 | // Execute the current request | |
|
170 | QMetaObject::invokeMethod(this, "onExecuteRequest", Qt::QueuedConnection, | |
|
171 | Q_ARG(QUuid, it->second.first)); | |
|
172 | } | |
|
173 | } | |
|
174 | else { | |
|
175 | qCCritical(LOG_VariableAcquisitionWorker()) | |
|
176 | << tr("Impossible to execute the acquisition on an unfound variable "); | |
|
177 | } | |
|
231 | // Update to the next request | |
|
232 | impl->updateToNextRequest(acqRequest.m_vIdentifier); | |
|
178 | 233 | } |
|
179 | 234 | } |
|
180 | 235 | else { |
|
181 |
qC |
|
|
182 | << tr("Impossible to retrieve AcquisitionRequest for the incoming data"); | |
|
236 | qCWarning(LOG_VariableAcquisitionWorker()) | |
|
237 | << tr("Impossible to retrieve AcquisitionRequest for the incoming data."); | |
|
183 | 238 | } |
|
184 | 239 | impl->unlock(); |
|
185 | 240 | } |
|
186 | 241 | |
|
242 | void VariableAcquisitionWorker::onExecuteRequest(QUuid acqIdentifier) | |
|
243 | { | |
|
244 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("onExecuteRequest") << QThread::currentThread(); | |
|
245 | impl->lockRead(); | |
|
246 | auto it = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier); | |
|
247 | if (it != impl->m_AcqIdentifierToAcqRequestMap.cend()) { | |
|
248 | auto request = it->second; | |
|
249 | impl->unlock(); | |
|
250 | emit variableRequestInProgress(request.m_vIdentifier, 0.1); | |
|
251 | request.m_Provider->requestDataLoading(acqIdentifier, request.m_DataProviderParameters); | |
|
252 | } | |
|
253 | else { | |
|
254 | impl->unlock(); | |
|
255 | // TODO log no acqIdentifier recognized | |
|
256 | } | |
|
257 | } | |
|
258 | ||
|
187 | 259 | void VariableAcquisitionWorker::initialize() |
|
188 | 260 | { |
|
189 | 261 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("VariableAcquisitionWorker init") |
@@ -221,18 +293,30 void VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate::removeVariable | |||
|
221 | 293 | unlock(); |
|
222 | 294 | } |
|
223 | 295 | |
|
224 | void VariableAcquisitionWorker::onExecuteRequest(QUuid acqIdentifier) | |
|
296 | void VariableAcquisitionWorker::VariableAcquisitionWorkerPrivate::updateToNextRequest( | |
|
297 | QUuid vIdentifier) | |
|
225 | 298 | { |
|
226 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("onExecuteRequest") << QThread::currentThread(); | |
|
227 | impl->lockRead(); | |
|
228 | auto it = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier); | |
|
229 | if (it != impl->m_AcqIdentifierToAcqRequestMap.cend()) { | |
|
230 | auto request = it->second; | |
|
231 | impl->unlock(); | |
|
232 | request.m_Provider->requestDataLoading(acqIdentifier, request.m_DataProviderParameters); | |
|
299 | auto it = m_VIdentifierToCurrrentAcqIdNextIdPairMap.find(vIdentifier); | |
|
300 | if (it != m_VIdentifierToCurrrentAcqIdNextIdPairMap.cend()) { | |
|
301 | if (it->second.second.isNull()) { | |
|
302 | // There is no next request, we can remove the variable request | |
|
303 | removeVariableRequest(vIdentifier); | |
|
304 | } | |
|
305 | else { | |
|
306 | auto acqIdentifierToRemove = it->second.first; | |
|
307 | // Move the next request to the current request | |
|
308 | it->second.first = it->second.second; | |
|
309 | it->second.second = QUuid(); | |
|
310 | // Remove AcquisitionRequest and results; | |
|
311 | m_AcqIdentifierToAcqRequestMap.erase(acqIdentifierToRemove); | |
|
312 | m_AcqIdentifierToAcqDataPacketVectorMap.erase(acqIdentifierToRemove); | |
|
313 | // Execute the current request | |
|
314 | QMetaObject::invokeMethod(q, "onExecuteRequest", Qt::QueuedConnection, | |
|
315 | Q_ARG(QUuid, it->second.first)); | |
|
316 | } | |
|
233 | 317 | } |
|
234 | 318 | else { |
|
235 | impl->unlock(); | |
|
236 | // TODO log no acqIdentifier recognized | |
|
319 | qCCritical(LOG_VariableAcquisitionWorker()) | |
|
320 | << tr("Impossible to execute the acquisition on an unfound variable "); | |
|
237 | 321 | } |
|
238 | 322 | } |
@@ -151,12 +151,17 VariableController::VariableController(QObject *parent) | |||
|
151 | 151 | connect(impl->m_VariableModel, &VariableModel::abortProgessRequested, this, |
|
152 | 152 | &VariableController::onAbortProgressRequested); |
|
153 | 153 | |
|
154 | connect(impl->m_VariableAcquisitionWorker.get(), | |
|
155 | &VariableAcquisitionWorker::variableCanceledRequested, this, | |
|
156 | &VariableController::onAbortAcquisitionRequested); | |
|
157 | ||
|
154 | 158 | connect(impl->m_VariableAcquisitionWorker.get(), &VariableAcquisitionWorker::dataProvided, this, |
|
155 | 159 | &VariableController::onDataProvided); |
|
156 | 160 | connect(impl->m_VariableAcquisitionWorker.get(), |
|
157 | 161 | &VariableAcquisitionWorker::variableRequestInProgress, this, |
|
158 | 162 | &VariableController::onVariableRetrieveDataInProgress); |
|
159 | 163 | |
|
164 | ||
|
160 | 165 | connect(&impl->m_VariableAcquisitionWorkerThread, &QThread::started, |
|
161 | 166 | impl->m_VariableAcquisitionWorker.get(), &VariableAcquisitionWorker::initialize); |
|
162 | 167 | connect(&impl->m_VariableAcquisitionWorkerThread, &QThread::finished, |
@@ -253,10 +258,6 void VariableController::deleteVariables( | |||
|
253 | 258 | } |
|
254 | 259 | } |
|
255 | 260 | |
|
256 | void VariableController::abortProgress(std::shared_ptr<Variable> variable) | |
|
257 | { | |
|
258 | } | |
|
259 | ||
|
260 | 261 | std::shared_ptr<Variable> |
|
261 | 262 | VariableController::createVariable(const QString &name, const QVariantHash &metadata, |
|
262 | 263 | std::shared_ptr<IDataProvider> provider) noexcept |
@@ -269,7 +270,7 VariableController::createVariable(const QString &name, const QVariantHash &meta | |||
|
269 | 270 | |
|
270 | 271 | auto range = impl->m_TimeController->dateTime(); |
|
271 | 272 | |
|
272 |
if (auto newVariable = impl->m_VariableModel->createVariable(name, |
|
|
273 | if (auto newVariable = impl->m_VariableModel->createVariable(name, metadata)) { | |
|
273 | 274 | auto identifier = QUuid::createUuid(); |
|
274 | 275 | |
|
275 | 276 | // store the provider |
@@ -277,11 +278,11 VariableController::createVariable(const QString &name, const QVariantHash &meta | |||
|
277 | 278 | |
|
278 | 279 | // Associate the provider |
|
279 | 280 | impl->m_VariableToProviderMap[newVariable] = provider; |
|
281 | qCInfo(LOG_VariableController()) << "createVariable: " << identifier; | |
|
280 | 282 | impl->m_VariableToIdentifierMap[newVariable] = identifier; |
|
281 | 283 | |
|
282 | 284 | |
|
283 | 285 | auto varRequestId = QUuid::createUuid(); |
|
284 | qCInfo(LOG_VariableController()) << "processRequest for" << name << varRequestId; | |
|
285 | 286 | impl->processRequest(newVariable, range, varRequestId); |
|
286 | 287 | impl->updateVariableRequest(varRequestId); |
|
287 | 288 | |
@@ -322,6 +323,9 void VariableController::onDataProvided(QUuid vIdentifier, const SqpRange &range | |||
|
322 | 323 | |
|
323 | 324 | void VariableController::onVariableRetrieveDataInProgress(QUuid identifier, double progress) |
|
324 | 325 | { |
|
326 | qCDebug(LOG_VariableController()) | |
|
327 | << "TORM: variableController::onVariableRetrieveDataInProgress" | |
|
328 | << QThread::currentThread()->objectName() << progress; | |
|
325 | 329 | if (auto var = impl->findVariable(identifier)) { |
|
326 | 330 | impl->m_VariableModel->setDataProgress(var, progress); |
|
327 | 331 | } |
@@ -333,12 +337,25 void VariableController::onVariableRetrieveDataInProgress(QUuid identifier, doub | |||
|
333 | 337 | |
|
334 | 338 | void VariableController::onAbortProgressRequested(std::shared_ptr<Variable> variable) |
|
335 | 339 | { |
|
336 | qCDebug(LOG_VariableController()) << "TORM: VariableController::onAbortProgressRequested" | |
|
337 | << QThread::currentThread()->objectName(); | |
|
338 | ||
|
339 | 340 | auto it = impl->m_VariableToIdentifierMap.find(variable); |
|
340 | 341 | if (it != impl->m_VariableToIdentifierMap.cend()) { |
|
341 | impl->m_VariableToProviderMap.at(variable)->requestDataAborting(it->second); | |
|
342 | impl->m_VariableAcquisitionWorker->abortProgressRequested(it->second); | |
|
343 | ||
|
344 | QUuid varRequestId; | |
|
345 | auto varIdToVarRequestIdQueueMapIt = impl->m_VarIdToVarRequestIdQueueMap.find(it->second); | |
|
346 | if (varIdToVarRequestIdQueueMapIt != impl->m_VarIdToVarRequestIdQueueMap.cend()) { | |
|
347 | auto &varRequestIdQueue = varIdToVarRequestIdQueueMapIt->second; | |
|
348 | varRequestId = varRequestIdQueue.front(); | |
|
349 | impl->cancelVariableRequest(varRequestId); | |
|
350 | ||
|
351 | // Finish the progression for the request | |
|
352 | impl->m_VariableModel->setDataProgress(variable, 0.0); | |
|
353 | } | |
|
354 | else { | |
|
355 | qCWarning(LOG_VariableController()) | |
|
356 | << tr("Aborting progression of inexistant variable request detected !!!") | |
|
357 | << QThread::currentThread()->objectName(); | |
|
358 | } | |
|
342 | 359 | } |
|
343 | 360 | else { |
|
344 | 361 | qCWarning(LOG_VariableController()) |
@@ -347,6 +364,20 void VariableController::onAbortProgressRequested(std::shared_ptr<Variable> vari | |||
|
347 | 364 | } |
|
348 | 365 | } |
|
349 | 366 | |
|
367 | void VariableController::onAbortAcquisitionRequested(QUuid vIdentifier) | |
|
368 | { | |
|
369 | qCDebug(LOG_VariableController()) << "TORM: variableController::onAbortAcquisitionRequested" | |
|
370 | << QThread::currentThread()->objectName() << vIdentifier; | |
|
371 | ||
|
372 | if (auto var = impl->findVariable(vIdentifier)) { | |
|
373 | this->onAbortProgressRequested(var); | |
|
374 | } | |
|
375 | else { | |
|
376 | qCCritical(LOG_VariableController()) | |
|
377 | << tr("Impossible to abort Acquisition Requestof a null variable"); | |
|
378 | } | |
|
379 | } | |
|
380 | ||
|
350 | 381 | void VariableController::onAddSynchronizationGroupId(QUuid synchronizationGroupId) |
|
351 | 382 | { |
|
352 | 383 | qCDebug(LOG_VariableController()) << "TORM: VariableController::onAddSynchronizationGroupId" |
@@ -431,8 +462,8 void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable> | |||
|
431 | 462 | // For the other, we ask the provider to give them. |
|
432 | 463 | |
|
433 | 464 | auto varRequestId = QUuid::createUuid(); |
|
434 |
qC |
|
|
435 | << QThread::currentThread()->objectName() << varRequestId; | |
|
465 | qCDebug(LOG_VariableController()) << "VariableController::onRequestDataLoading" | |
|
466 | << QThread::currentThread()->objectName() << varRequestId; | |
|
436 | 467 | |
|
437 | 468 | for (const auto &var : variables) { |
|
438 | 469 | qCDebug(LOG_VariableController()) << "processRequest for" << var->name() << varRequestId; |
@@ -549,11 +580,7 void VariableController::VariableControllerPrivate::processRequest(std::shared_p | |||
|
549 | 580 | if (!notInCacheRangeList.empty()) { |
|
550 | 581 | varRequest.m_RangeRequested = varStrategyRangesRequested.first; |
|
551 | 582 | varRequest.m_CacheRangeRequested = varStrategyRangesRequested.second; |
|
552 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM processRequest RR ") << rangeRequested; | |
|
553 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM processRequest R ") | |
|
554 | << varStrategyRangesRequested.first; | |
|
555 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM processRequest CR ") | |
|
556 | << varStrategyRangesRequested.second; | |
|
583 | ||
|
557 | 584 | // store VarRequest |
|
558 | 585 | storeVariableRequest(varId, varRequestId, varRequest); |
|
559 | 586 | |
@@ -566,8 +593,8 void VariableController::VariableControllerPrivate::processRequest(std::shared_p | |||
|
566 | 593 | varProvider); |
|
567 | 594 | |
|
568 | 595 | if (!varRequestIdCanceled.isNull()) { |
|
569 |
qC |
|
|
570 | << varRequestIdCanceled; | |
|
596 | qCDebug(LOG_VariableAcquisitionWorker()) << tr("vsarRequestIdCanceled: ") | |
|
597 | << varRequestIdCanceled; | |
|
571 | 598 | cancelVariableRequest(varRequestIdCanceled); |
|
572 | 599 | } |
|
573 | 600 | } |
@@ -581,7 +608,6 void VariableController::VariableControllerPrivate::processRequest(std::shared_p | |||
|
581 | 608 | } |
|
582 | 609 | } |
|
583 | 610 | else { |
|
584 | ||
|
585 | 611 | varRequest.m_RangeRequested = varStrategyRangesRequested.first; |
|
586 | 612 | varRequest.m_CacheRangeRequested = varStrategyRangesRequested.second; |
|
587 | 613 | // store VarRequest |
@@ -639,6 +665,9 void VariableController::VariableControllerPrivate::registerProvider( | |||
|
639 | 665 | connect(provider.get(), &IDataProvider::dataProvidedProgress, |
|
640 | 666 | m_VariableAcquisitionWorker.get(), |
|
641 | 667 | &VariableAcquisitionWorker::onVariableRetrieveDataInProgress); |
|
668 | connect(provider.get(), &IDataProvider::dataProvidedFailed, | |
|
669 | m_VariableAcquisitionWorker.get(), | |
|
670 | &VariableAcquisitionWorker::onVariableAcquisitionFailed); | |
|
642 | 671 | } |
|
643 | 672 | else { |
|
644 | 673 | qCDebug(LOG_VariableController()) << tr("Cannot register provider, it already exists "); |
@@ -709,12 +738,10 QUuid VariableController::VariableControllerPrivate::acceptVariableRequest( | |||
|
709 | 738 | << varRequestId; |
|
710 | 739 | } |
|
711 | 740 | |
|
712 | qCDebug(LOG_VariableController()) << tr("1: erase REQUEST in QUEUE ?") | |
|
713 | << varRequestIdQueue.size(); | |
|
714 | 741 | varRequestIdQueue.pop_front(); |
|
715 | qCDebug(LOG_VariableController()) << tr("2: erase REQUEST in QUEUE ?") | |
|
716 | << varRequestIdQueue.size(); | |
|
717 | 742 | if (varRequestIdQueue.empty()) { |
|
743 | qCDebug(LOG_VariableController()) | |
|
744 | << tr("TORM Erase REQUEST because it has been accepted") << varId; | |
|
718 | 745 | m_VarIdToVarRequestIdQueueMap.erase(varId); |
|
719 | 746 | } |
|
720 | 747 | } |
@@ -759,9 +786,11 void VariableController::VariableControllerPrivate::updateVariableRequest(QUuid | |||
|
759 | 786 | |
|
760 | 787 | /// @todo MPL: confirm |
|
761 | 788 | // Variable update is notified only if there is no pending request for it |
|
762 | if (m_VarIdToVarRequestIdQueueMap.count(varIdToVarRequestMapIt->first) == 0) { | |
|
763 | emit var->updated(); | |
|
764 | } | |
|
789 | // if | |
|
790 | // (m_VarIdToVarRequestIdQueueMap.count(varIdToVarRequestMapIt->first) | |
|
791 | // == 0) { | |
|
792 | emit var->updated(); | |
|
793 | // } | |
|
765 | 794 | } |
|
766 | 795 | else { |
|
767 | 796 | qCCritical(LOG_VariableController()) |
@@ -97,10 +97,9 bool VariableModel::containsVariable(std::shared_ptr<Variable> variable) const n | |||
|
97 | 97 | } |
|
98 | 98 | |
|
99 | 99 | std::shared_ptr<Variable> VariableModel::createVariable(const QString &name, |
|
100 | const SqpRange &dateTime, | |
|
101 | 100 | const QVariantHash &metadata) noexcept |
|
102 | 101 | { |
|
103 |
auto variable = std::make_shared<Variable>(name, |
|
|
102 | auto variable = std::make_shared<Variable>(name, metadata); | |
|
104 | 103 | addVariable(variable); |
|
105 | 104 | |
|
106 | 105 | return variable; |
@@ -87,8 +87,8 void TestTwoDimArrayData::testCtor_data() | |||
|
87 | 87 | << true << Container{{1., 2., 3., 4., 5.}, |
|
88 | 88 | {6., 7., 8., 9., 10.}, |
|
89 | 89 | {11., 12., 13., 14., 15.}}; |
|
90 | QTest::newRow("invalidInput (invalid data size") | |
|
91 | << InputData{{1., 2., 3., 4., 5., 6., 7.}, 3} << false << Container{{}, {}, {}}; | |
|
90 | QTest::newRow("invalidInput (invalid data size") << InputData{{1., 2., 3., 4., 5., 6., 7.}, 3} | |
|
91 | << false << Container{{}, {}, {}}; | |
|
92 | 92 | QTest::newRow("invalidInput (less than two components") |
|
93 | 93 | << flatten(Container{{1., 2., 3., 4., 5.}}) << false << Container{{}, {}, {}}; |
|
94 | 94 | } |
@@ -24,10 +24,12 void TestVariable::testNotInCacheRangeList() | |||
|
24 | 24 | |
|
25 | 25 | auto varCRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}}; |
|
26 | 26 | auto varCRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; |
|
27 | ||
|
27 | 28 | auto sqpCR |
|
28 | 29 | = SqpRange{DateUtils::secondsSinceEpoch(varCRS), DateUtils::secondsSinceEpoch(varCRE)}; |
|
29 | 30 | |
|
30 |
Variable var{"Var test" |
|
|
31 | Variable var{"Var test"}; | |
|
32 | var.setRange(sqpR); | |
|
31 | 33 | var.setCacheRange(sqpCR); |
|
32 | 34 | |
|
33 | 35 | // 1: [ts,te] < varTS |
@@ -109,7 +111,8 void TestVariable::testInCacheRangeList() | |||
|
109 | 111 | auto sqpCR |
|
110 | 112 | = SqpRange{DateUtils::secondsSinceEpoch(varCRS), DateUtils::secondsSinceEpoch(varCRE)}; |
|
111 | 113 | |
|
112 |
Variable var{"Var test" |
|
|
114 | Variable var{"Var test"}; | |
|
115 | var.setRange(sqpR); | |
|
113 | 116 | var.setCacheRange(sqpCR); |
|
114 | 117 | |
|
115 | 118 | // 1: [ts,te] < varTS |
@@ -32,7 +32,8 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||
|
32 | 32 | auto te2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 20, 0, 0}}; |
|
33 | 33 | auto sqp2 = SqpRange{DateUtils::secondsSinceEpoch(ts2), DateUtils::secondsSinceEpoch(te2)}; |
|
34 | 34 | |
|
35 |
auto var0 = std::make_shared<Variable>("" |
|
|
35 | auto var0 = std::make_shared<Variable>(""); | |
|
36 | var0->setRange(sqp0); | |
|
36 | 37 | |
|
37 | 38 | variableCacheController.addDateTime(var0, sqp0); |
|
38 | 39 | variableCacheController.addDateTime(var0, sqp1); |
@@ -267,7 +268,8 void TestVariableCacheController::testAddDateTime() | |||
|
267 | 268 | auto sqp03 = SqpRange{DateUtils::secondsSinceEpoch(ts03), DateUtils::secondsSinceEpoch(te03)}; |
|
268 | 269 | |
|
269 | 270 | |
|
270 |
auto var0 = std::make_shared<Variable>("" |
|
|
271 | auto var0 = std::make_shared<Variable>(""); | |
|
272 | var0->setRange(sqp0); | |
|
271 | 273 | |
|
272 | 274 | |
|
273 | 275 | // First case: add the first interval to the variable :sqp0 |
@@ -1574,7 +1574,10 void QCPLayerable::applyAntialiasingHint(QCPPainter *painter, bool localAntialia | |||
|
1574 | 1574 | |
|
1575 | 1575 | \see initializeParentPlot |
|
1576 | 1576 | */ |
|
1577 |
void QCPLayerable::parentPlotInitialized(QCustomPlot *parentPlot) |
|
|
1577 | void QCPLayerable::parentPlotInitialized(QCustomPlot *parentPlot) | |
|
1578 | { | |
|
1579 | Q_UNUSED(parentPlot) | |
|
1580 | } | |
|
1578 | 1581 | |
|
1579 | 1582 | /*! \internal |
|
1580 | 1583 | |
@@ -9391,16 +9394,14 void QCPAxisPainterPrivate::draw(QCPPainter *painter) | |||
|
9391 | 9394 | painter->setBrush(QBrush(basePen.color())); |
|
9392 | 9395 | QCPVector2D baseLineVector(baseLine.dx(), baseLine.dy()); |
|
9393 | 9396 | if (lowerEnding.style() != QCPLineEnding::esNone) |
|
9394 | lowerEnding.draw(painter, | |
|
9395 | QCPVector2D(baseLine.p1()) | |
|
9396 | - baseLineVector.normalized() * lowerEnding.realLength() | |
|
9397 | * (lowerEnding.inverted() ? -1 : 1), | |
|
9397 | lowerEnding.draw(painter, QCPVector2D(baseLine.p1()) | |
|
9398 | - baseLineVector.normalized() * lowerEnding.realLength() | |
|
9399 | * (lowerEnding.inverted() ? -1 : 1), | |
|
9398 | 9400 | -baseLineVector); |
|
9399 | 9401 | if (upperEnding.style() != QCPLineEnding::esNone) |
|
9400 | upperEnding.draw(painter, | |
|
9401 | QCPVector2D(baseLine.p2()) | |
|
9402 | + baseLineVector.normalized() * upperEnding.realLength() | |
|
9403 | * (upperEnding.inverted() ? -1 : 1), | |
|
9402 | upperEnding.draw(painter, QCPVector2D(baseLine.p2()) | |
|
9403 | + baseLineVector.normalized() * upperEnding.realLength() | |
|
9404 | * (upperEnding.inverted() ? -1 : 1), | |
|
9404 | 9405 | baseLineVector); |
|
9405 | 9406 | painter->setAntialiasing(antialiasingBackup); |
|
9406 | 9407 | |
@@ -16629,9 +16630,8 void QCPColorGradient::updateColorBuffer() | |||
|
16629 | 16630 | hue -= 1.0; |
|
16630 | 16631 | if (useAlpha) { |
|
16631 | 16632 | const QRgb rgb |
|
16632 | = QColor::fromHsvF(hue, | |
|
16633 |
|
|
|
16634 | + t * highHsv.saturationF(), | |
|
16633 | = QColor::fromHsvF(hue, (1 - t) * lowHsv.saturationF() | |
|
16634 | + t * highHsv.saturationF(), | |
|
16635 | 16635 | (1 - t) * lowHsv.valueF() + t * highHsv.valueF()) |
|
16636 | 16636 | .rgb(); |
|
16637 | 16637 | const float alpha = (1 - t) * lowHsv.alphaF() + t * highHsv.alphaF(); |
@@ -16640,9 +16640,8 void QCPColorGradient::updateColorBuffer() | |||
|
16640 | 16640 | } |
|
16641 | 16641 | else { |
|
16642 | 16642 | mColorBuffer[i] |
|
16643 | = QColor::fromHsvF(hue, | |
|
16644 |
|
|
|
16645 | + t * highHsv.saturationF(), | |
|
16643 | = QColor::fromHsvF(hue, (1 - t) * lowHsv.saturationF() | |
|
16644 | + t * highHsv.saturationF(), | |
|
16646 | 16645 | (1 - t) * lowHsv.valueF() + t * highHsv.valueF()) |
|
16647 | 16646 | .rgb(); |
|
16648 | 16647 | } |
@@ -19999,14 +19998,12 void QCPColorScale::update(UpdatePhase phase) | |||
|
19999 | 19998 | switch (phase) { |
|
20000 | 19999 | case upMargins: { |
|
20001 | 20000 | if (mType == QCPAxis::atBottom || mType == QCPAxis::atTop) { |
|
20002 | setMaximumSize(QWIDGETSIZE_MAX, | |
|
20003 |
|
|
|
20004 |
+ |
|
|
20005 | + margins().bottom()); | |
|
20006 | setMinimumSize(0, | |
|
20007 |
|
|
|
20008 | + mAxisRect.data()->margins().bottom() + margins().top() | |
|
20009 | + margins().bottom()); | |
|
20001 | setMaximumSize(QWIDGETSIZE_MAX, mBarWidth + mAxisRect.data()->margins().top() | |
|
20002 | + mAxisRect.data()->margins().bottom() | |
|
20003 | + margins().top() + margins().bottom()); | |
|
20004 | setMinimumSize(0, mBarWidth + mAxisRect.data()->margins().top() | |
|
20005 | + mAxisRect.data()->margins().bottom() + margins().top() | |
|
20006 | + margins().bottom()); | |
|
20010 | 20007 | } |
|
20011 | 20008 | else { |
|
20012 | 20009 | setMaximumSize(mBarWidth + mAxisRect.data()->margins().left() |
@@ -7,15 +7,18 | |||
|
7 | 7 | |
|
8 | 8 | #include <QLoggingCategory> |
|
9 | 9 | |
|
10 | #include <map> | |
|
10 | 11 | |
|
11 | 12 | Q_DECLARE_LOGGING_CATEGORY(LOG_AmdaProvider) |
|
12 | 13 | |
|
13 | 14 | class QNetworkReply; |
|
15 | class QNetworkRequest; | |
|
14 | 16 | |
|
15 | 17 | /** |
|
16 | 18 | * @brief The AmdaProvider class is an example of how a data provider can generate data |
|
17 | 19 | */ |
|
18 | 20 | class SCIQLOP_AMDA_EXPORT AmdaProvider : public IDataProvider { |
|
21 | Q_OBJECT | |
|
19 | 22 | public: |
|
20 | 23 | explicit AmdaProvider(); |
|
21 | 24 | std::shared_ptr<IDataProvider> clone() const override; |
@@ -24,8 +27,18 public: | |||
|
24 | 27 | |
|
25 | 28 | void requestDataAborting(QUuid acqIdentifier) override; |
|
26 | 29 | |
|
30 | private slots: | |
|
31 | void onReplyDownloadProgress(QUuid acqIdentifier, | |
|
32 | std::shared_ptr<QNetworkRequest> networkRequest, double progress); | |
|
33 | ||
|
27 | 34 | private: |
|
28 | 35 | void retrieveData(QUuid token, const SqpRange &dateTime, const QVariantHash &data); |
|
36 | ||
|
37 | void updateRequestProgress(QUuid acqIdentifier, std::shared_ptr<QNetworkRequest> request, | |
|
38 | double progress); | |
|
39 | ||
|
40 | std::map<QUuid, std::map<std::shared_ptr<QNetworkRequest>, double> > | |
|
41 | m_AcqIdToRequestProgressMap; | |
|
29 | 42 | }; |
|
30 | 43 | |
|
31 | 44 | #endif // SCIQLOP_AMDAPROVIDER_H |
@@ -56,15 +56,17 AmdaProvider::AmdaProvider() | |||
|
56 | 56 | qCDebug(LOG_AmdaProvider()) << tr("AmdaProvider::AmdaProvider") << QThread::currentThread(); |
|
57 | 57 | if (auto app = sqpApp) { |
|
58 | 58 | auto &networkController = app->networkController(); |
|
59 | connect(this, SIGNAL(requestConstructed(QNetworkRequest, QUuid, | |
|
59 | connect(this, SIGNAL(requestConstructed(std::shared_ptr<QNetworkRequest>, QUuid, | |
|
60 | 60 | std::function<void(QNetworkReply *, QUuid)>)), |
|
61 | 61 | &networkController, |
|
62 | SLOT(onProcessRequested(QNetworkRequest, QUuid, | |
|
62 | SLOT(onProcessRequested(std::shared_ptr<QNetworkRequest>, QUuid, | |
|
63 | 63 | std::function<void(QNetworkReply *, QUuid)>))); |
|
64 | 64 | |
|
65 | 65 | |
|
66 |
connect(&sqpApp->networkController(), |
|
|
67 |
SIGNAL( |
|
|
66 | connect(&sqpApp->networkController(), | |
|
67 | SIGNAL(replyDownloadProgress(QUuid, std::shared_ptr<QNetworkRequest>, double)), | |
|
68 | this, | |
|
69 | SLOT(onReplyDownloadProgress(QUuid, std::shared_ptr<QNetworkRequest>, double))); | |
|
68 | 70 | } |
|
69 | 71 | } |
|
70 | 72 | |
@@ -80,8 +82,11 void AmdaProvider::requestDataLoading(QUuid acqIdentifier, const DataProviderPar | |||
|
80 | 82 | const auto times = parameters.m_Times; |
|
81 | 83 | const auto data = parameters.m_Data; |
|
82 | 84 | for (const auto &dateTime : qAsConst(times)) { |
|
85 | qCDebug(LOG_AmdaProvider()) << tr("TORM AmdaProvider::requestDataLoading ") << acqIdentifier | |
|
86 | << dateTime; | |
|
83 | 87 | this->retrieveData(acqIdentifier, dateTime, data); |
|
84 | 88 | |
|
89 | ||
|
85 | 90 | // TORM when AMDA will support quick asynchrone request |
|
86 | 91 | QThread::msleep(1000); |
|
87 | 92 | } |
@@ -95,6 +100,60 void AmdaProvider::requestDataAborting(QUuid acqIdentifier) | |||
|
95 | 100 | } |
|
96 | 101 | } |
|
97 | 102 | |
|
103 | void AmdaProvider::onReplyDownloadProgress(QUuid acqIdentifier, | |
|
104 | std::shared_ptr<QNetworkRequest> networkRequest, | |
|
105 | double progress) | |
|
106 | { | |
|
107 | qCDebug(LOG_AmdaProvider()) << tr("onReplyDownloadProgress") << acqIdentifier | |
|
108 | << networkRequest.get() << progress; | |
|
109 | auto acqIdToRequestProgressMapIt = m_AcqIdToRequestProgressMap.find(acqIdentifier); | |
|
110 | if (acqIdToRequestProgressMapIt != m_AcqIdToRequestProgressMap.end()) { | |
|
111 | ||
|
112 | // Update the progression for the current request | |
|
113 | auto requestPtr = networkRequest; | |
|
114 | auto findRequest = [requestPtr](const auto &entry) { return requestPtr == entry.first; }; | |
|
115 | ||
|
116 | auto &requestProgressMap = acqIdToRequestProgressMapIt->second; | |
|
117 | auto requestProgressMapEnd = requestProgressMap.end(); | |
|
118 | auto requestProgressMapIt | |
|
119 | = std::find_if(requestProgressMap.begin(), requestProgressMapEnd, findRequest); | |
|
120 | ||
|
121 | if (requestProgressMapIt != requestProgressMapEnd) { | |
|
122 | requestProgressMapIt->second = progress; | |
|
123 | } | |
|
124 | else { | |
|
125 | // This case can happened when a progression is send after the request has been | |
|
126 | // finished. | |
|
127 | // Generaly the case when aborting a request | |
|
128 | qCDebug(LOG_AmdaProvider()) << tr("Can't retrieve Request in progress") << acqIdentifier | |
|
129 | << networkRequest.get() << progress; | |
|
130 | } | |
|
131 | ||
|
132 | // Compute the current final progress and notify it | |
|
133 | double finalProgress = 0.0; | |
|
134 | ||
|
135 | auto fraq = requestProgressMap.size(); | |
|
136 | ||
|
137 | for (auto requestProgress : requestProgressMap) { | |
|
138 | finalProgress += requestProgress.second; | |
|
139 | qCDebug(LOG_AmdaProvider()) << tr("Current final progress without fraq:") | |
|
140 | << finalProgress << requestProgress.second; | |
|
141 | } | |
|
142 | ||
|
143 | if (fraq > 0) { | |
|
144 | finalProgress = finalProgress / fraq; | |
|
145 | } | |
|
146 | ||
|
147 | qCDebug(LOG_AmdaProvider()) << tr("Current final progress: ") << fraq << finalProgress; | |
|
148 | emit dataProvidedProgress(acqIdentifier, finalProgress); | |
|
149 | } | |
|
150 | else { | |
|
151 | // This case can happened when a progression is send after the request has been finished. | |
|
152 | // Generaly the case when aborting a request | |
|
153 | emit dataProvidedProgress(acqIdentifier, 100.0); | |
|
154 | } | |
|
155 | } | |
|
156 | ||
|
98 | 157 | void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVariantHash &data) |
|
99 | 158 | { |
|
100 | 159 | // Retrieves product ID from data: if the value is invalid, no request is made |
@@ -103,7 +162,6 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa | |||
|
103 | 162 | qCCritical(LOG_AmdaProvider()) << tr("Can't retrieve data: unknown product id"); |
|
104 | 163 | return; |
|
105 | 164 | } |
|
106 | qCDebug(LOG_AmdaProvider()) << tr("AmdaProvider::retrieveData") << dateTime; | |
|
107 | 165 | |
|
108 | 166 | // Retrieves the data type that determines whether the expected format for the result file is |
|
109 | 167 | // scalar, vector... |
@@ -125,7 +183,7 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa | |||
|
125 | 183 | productValueType](QNetworkReply *reply, QUuid dataId) noexcept { |
|
126 | 184 | |
|
127 | 185 | // Don't do anything if the reply was abort |
|
128 |
if (reply->error() |
|
|
186 | if (reply->error() == QNetworkReply::NoError) { | |
|
129 | 187 | |
|
130 | 188 | if (tempFile) { |
|
131 | 189 | auto replyReadAll = reply->readAll(); |
@@ -141,8 +199,16 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa | |||
|
141 | 199 | } |
|
142 | 200 | else { |
|
143 | 201 | /// @todo ALX : debug |
|
202 | emit dataProvidedFailed(dataId); | |
|
144 | 203 | } |
|
145 | 204 | } |
|
205 | qCDebug(LOG_AmdaProvider()) << tr("acquisition requests erase because of finishing") | |
|
206 | << dataId; | |
|
207 | m_AcqIdToRequestProgressMap.erase(dataId); | |
|
208 | } | |
|
209 | else { | |
|
210 | qCCritical(LOG_AmdaProvider()) << tr("httpDownloadFinished ERROR"); | |
|
211 | emit dataProvidedFailed(dataId); | |
|
146 | 212 | } |
|
147 | 213 | |
|
148 | 214 | }; |
@@ -150,25 +216,68 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa | |||
|
150 | 216 | = [this, httpDownloadFinished, tempFile](QNetworkReply *reply, QUuid dataId) noexcept { |
|
151 | 217 | |
|
152 | 218 | // Don't do anything if the reply was abort |
|
153 |
if (reply->error() |
|
|
219 | if (reply->error() == QNetworkReply::NoError) { | |
|
154 | 220 | auto downloadFileUrl = QUrl{QString{reply->readAll()}}; |
|
155 | 221 | |
|
156 | ||
|
157 | 222 | qCInfo(LOG_AmdaProvider()) |
|
158 | 223 | << tr("TORM AmdaProvider::retrieveData downloadFileUrl:") << downloadFileUrl; |
|
159 | 224 | // Executes request for downloading file // |
|
160 | 225 | |
|
161 | 226 | // Creates destination file |
|
162 | 227 | if (tempFile->open()) { |
|
163 | // Executes request | |
|
164 |
|
|
|
165 | httpDownloadFinished); | |
|
228 | // Executes request and store the request for progression | |
|
229 | auto request = std::make_shared<QNetworkRequest>(downloadFileUrl); | |
|
230 | updateRequestProgress(dataId, request, 0.0); | |
|
231 | emit requestConstructed(request, dataId, httpDownloadFinished); | |
|
166 | 232 | } |
|
233 | else { | |
|
234 | emit dataProvidedFailed(dataId); | |
|
235 | } | |
|
236 | } | |
|
237 | else { | |
|
238 | qCDebug(LOG_AmdaProvider()) | |
|
239 | << tr("acquisition requests erase because of aborting") << dataId; | |
|
240 | qCCritical(LOG_AmdaProvider()) << tr("httpFinishedLambda ERROR"); | |
|
241 | m_AcqIdToRequestProgressMap.erase(dataId); | |
|
242 | emit dataProvidedFailed(dataId); | |
|
167 | 243 | } |
|
168 | 244 | }; |
|
169 | 245 | |
|
170 | 246 | // //////////////// // |
|
171 | 247 | // Executes request // |
|
172 | 248 | // //////////////// // |
|
173 | emit requestConstructed(QNetworkRequest{url}, token, httpFinishedLambda); | |
|
249 | ||
|
250 | auto request = std::make_shared<QNetworkRequest>(url); | |
|
251 | qCDebug(LOG_AmdaProvider()) << tr("First Request creation") << request.get(); | |
|
252 | updateRequestProgress(token, request, 0.0); | |
|
253 | ||
|
254 | emit requestConstructed(request, token, httpFinishedLambda); | |
|
255 | } | |
|
256 | ||
|
257 | void AmdaProvider::updateRequestProgress(QUuid acqIdentifier, | |
|
258 | std::shared_ptr<QNetworkRequest> request, double progress) | |
|
259 | { | |
|
260 | auto acqIdToRequestProgressMapIt = m_AcqIdToRequestProgressMap.find(acqIdentifier); | |
|
261 | if (acqIdToRequestProgressMapIt != m_AcqIdToRequestProgressMap.end()) { | |
|
262 | auto &requestProgressMap = acqIdToRequestProgressMapIt->second; | |
|
263 | auto requestProgressMapIt = requestProgressMap.find(request); | |
|
264 | if (requestProgressMapIt != requestProgressMap.end()) { | |
|
265 | requestProgressMapIt->second = progress; | |
|
266 | qCDebug(LOG_AmdaProvider()) << tr("updateRequestProgress new progress for request") | |
|
267 | << acqIdentifier << request.get() << progress; | |
|
268 | } | |
|
269 | else { | |
|
270 | qCDebug(LOG_AmdaProvider()) << tr("updateRequestProgress new request") << acqIdentifier | |
|
271 | << request.get() << progress; | |
|
272 | acqIdToRequestProgressMapIt->second.insert(std::make_pair(request, progress)); | |
|
273 | } | |
|
274 | } | |
|
275 | else { | |
|
276 | qCDebug(LOG_AmdaProvider()) << tr("updateRequestProgress new acqIdentifier") | |
|
277 | << acqIdentifier << request.get() << progress; | |
|
278 | auto requestProgressMap = std::map<std::shared_ptr<QNetworkRequest>, double>{}; | |
|
279 | requestProgressMap.insert(std::make_pair(request, progress)); | |
|
280 | m_AcqIdToRequestProgressMap.insert( | |
|
281 | std::make_pair(acqIdentifier, std::move(requestProgressMap))); | |
|
282 | } | |
|
174 | 283 | } |
@@ -100,8 +100,6 void TestAmdaAcquisition::testAcquisition() | |||
|
100 | 100 | auto var = vc.createVariable("bx_gse", metaData, provider); |
|
101 | 101 | |
|
102 | 102 | // 1 : Variable creation |
|
103 | QCOMPARE(var->range().m_TStart, sqpR.m_TStart); | |
|
104 | QCOMPARE(var->range().m_TEnd, sqpR.m_TEnd); | |
|
105 | 103 | |
|
106 | 104 | qDebug() << " 1: TIMECONTROLLER" << timeController->dateTime(); |
|
107 | 105 | qDebug() << " 1: RANGE " << var->range(); |
@@ -59,6 +59,9 std::shared_ptr<IDataSeries> CosinusProvider::retrieveData(QUuid acqIdentifier, | |||
|
59 | 59 | progress = currentProgress; |
|
60 | 60 | |
|
61 | 61 | emit dataProvidedProgress(acqIdentifier, progress); |
|
62 | qCInfo(LOG_CosinusProvider()) << "TORM: CosinusProvider::retrieveData" | |
|
63 | << QThread::currentThread()->objectName() << progress; | |
|
64 | // NOTE: Try to use multithread if possible | |
|
62 | 65 | } |
|
63 | 66 | } |
|
64 | 67 | else { |
@@ -69,8 +72,10 std::shared_ptr<IDataSeries> CosinusProvider::retrieveData(QUuid acqIdentifier, | |||
|
69 | 72 | } |
|
70 | 73 | } |
|
71 | 74 | } |
|
72 | emit dataProvidedProgress(acqIdentifier, 0.0); | |
|
73 | ||
|
75 | if (progress != 100) { | |
|
76 | // We can close progression beacause all data has been retrieved | |
|
77 | emit dataProvidedProgress(acqIdentifier, 100); | |
|
78 | } | |
|
74 | 79 | return std::make_shared<ScalarSeries>(std::move(xAxisData), std::move(valuesData), |
|
75 | 80 | Unit{QStringLiteral("t"), true}, Unit{}); |
|
76 | 81 | } |
General Comments 0
You need to be logged in to leave comments.
Login now