@@ -27,6 +27,7 DEPRECATE( | |||||
27 | * |
|
27 | * | |
28 | * A data provider is an entity that generates data and returns it according to various parameters |
|
28 | * A data provider is an entity that generates data and returns it according to various parameters | |
29 | * (time interval, product to retrieve the data, etc.) |
|
29 | * (time interval, product to retrieve the data, etc.) | |
|
30 | * Since its client mihgt use it from different threads it has to be either stateless and/or thread safe | |||
30 | * |
|
31 | * | |
31 | * @sa IDataSeries |
|
32 | * @sa IDataSeries | |
32 | */ |
|
33 | */ | |
@@ -37,71 +38,13 public: | |||||
37 | virtual ~IDataProvider() noexcept = default; |
|
38 | virtual ~IDataProvider() noexcept = default; | |
38 | virtual std::shared_ptr<IDataProvider> clone() const = 0; |
|
39 | virtual std::shared_ptr<IDataProvider> clone() const = 0; | |
39 |
|
40 | |||
40 | DEPRECATE( |
|
|||
41 | /** |
|
|||
42 | * @brief requestDataLoading provide datas for the data identified by acqIdentifier and |
|
|||
43 | * parameters |
|
|||
44 | */ |
|
|||
45 | virtual void requestDataLoading(QUuid acqIdentifier, const DataProviderParameters ¶meters) |
|
|||
46 | = 0; |
|
|||
47 | ) |
|
|||
48 |
|
||||
49 | // Synchronous call -> asyncGetData may be written for asynchronous get |
|
41 | // Synchronous call -> asyncGetData may be written for asynchronous get | |
50 | virtual IDataSeries* getData(const DataProviderParameters ¶meters) |
|
42 | virtual IDataSeries* getData(const DataProviderParameters ¶meters) = 0; | |
51 | { |
|
|||
52 | Q_UNUSED(parameters); |
|
|||
53 | return nullptr; |
|
|||
54 | } |
|
|||
55 |
|
||||
56 |
|
||||
57 | DEPRECATE( |
|
|||
58 | /** |
|
|||
59 | * @brief requestDataAborting stop data loading of the data identified by acqIdentifier |
|
|||
60 | */ |
|
|||
61 | virtual void requestDataAborting(QUuid acqIdentifier) = 0; |
|
|||
62 | ) |
|
|||
63 |
|
||||
64 | virtual void abort(QUuid requestID){Q_UNUSED(requestID);} |
|
|||
65 |
|
43 | |||
66 | signals: |
|
44 | signals: | |
67 | DEPRECATE( |
|
|||
68 | /** |
|
|||
69 | * @brief dataProvided send dataSeries under dateTime and that corresponds of the data |
|
|||
70 | * identified by acqIdentifier |
|
|||
71 | */ |
|
|||
72 | void dataProvided(QUuid acqIdentifier, std::shared_ptr<IDataSeries> dateSeriesAcquired, |
|
|||
73 | const DateTimeRange &dataRangeAcquired); |
|
|||
74 | ) |
|
|||
75 |
|
||||
76 | void finished(QUuid requestID, std::shared_ptr<IDataSeries> dataSerie, |
|
|||
77 | const DateTimeRange &range); |
|
|||
78 |
|
||||
79 | DEPRECATE( |
|
|||
80 | /** |
|
|||
81 | * @brief dataProvidedProgress notify the progression of the data identifier by acqIdentifier |
|
|||
82 | */ |
|
|||
83 | void dataProvidedProgress(QUuid acqIdentifier, double progress); |
|
|||
84 | ) |
|
|||
85 |
|
45 | |||
86 | void progress(QUuid requestID, double progress); |
|
46 | void progress(QUuid requestID, double progress); | |
87 |
|
47 | |||
88 | DEPRECATE( |
|
|||
89 | /** |
|
|||
90 | * @brief dataProvidedFailed notify that data acquisition has failed |
|
|||
91 | */ |
|
|||
92 | void dataProvidedFailed(QUuid acqIdentifier); |
|
|||
93 | ) |
|
|||
94 |
|
||||
95 | void failed(QUuid requestID); |
|
|||
96 |
|
||||
97 | /** |
|
|||
98 | * @brief requestConstructed send a request for the data identified by acqIdentifier |
|
|||
99 | * @callback is the methode call by the reply of the request when it is finished. |
|
|||
100 | */ |
|
|||
101 | DEPRECATE( |
|
|||
102 | void requestConstructed(std::shared_ptr<QNetworkRequest> request, QUuid acqIdentifier, |
|
|||
103 | std::function<void(QNetworkReply *, QUuid)> callback); |
|
|||
104 | ) |
|
|||
105 | }; |
|
48 | }; | |
106 |
|
49 | |||
107 | // Required for using shared_ptr in signals/slots |
|
50 | // Required for using shared_ptr in signals/slots |
@@ -57,7 +57,9 public: | |||||
57 | std::vector<IDataSeries*> data; |
|
57 | std::vector<IDataSeries*> data; | |
58 | for(auto range:_ranges) |
|
58 | for(auto range:_ranges) | |
59 | { |
|
59 | { | |
60 |
|
|
60 | auto ds = _provider->getData(DataProviderParameters{{range}, _variable->metadata()}); | |
|
61 | if(ds) | |||
|
62 | data.push_back(ds); | |||
61 | } |
|
63 | } | |
62 | _variable->updateData(data, _range, _cacheRange, true); |
|
64 | _variable->updateData(data, _range, _cacheRange, true); | |
63 | emit transactionComplete(); |
|
65 | emit transactionComplete(); |
@@ -10,6 +10,7 | |||||
10 | #include <QPair> |
|
10 | #include <QPair> | |
11 | #include <QCoreApplication> |
|
11 | #include <QCoreApplication> | |
12 | #include <QReadWriteLock> |
|
12 | #include <QReadWriteLock> | |
|
13 | #include <QThread> | |||
13 |
|
14 | |||
14 | class Downloader::p_Downloader |
|
15 | class Downloader::p_Downloader | |
15 | { |
|
16 | { | |
@@ -56,7 +57,10 public: | |||||
56 | QNetworkRequest request = buildRequest(url, user, passwd); |
|
57 | QNetworkRequest request = buildRequest(url, user, passwd); | |
57 | QNetworkReply *reply = manager.get(request); |
|
58 | QNetworkReply *reply = manager.get(request); | |
58 | while (!reply->isFinished()) |
|
59 | while (!reply->isFinished()) | |
|
60 | { | |||
59 | QCoreApplication::processEvents(); |
|
61 | QCoreApplication::processEvents(); | |
|
62 | QThread::usleep(10000); | |||
|
63 | } | |||
60 | QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); |
|
64 | QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); | |
61 | Response resp = Response(reply->readAll(), status_code.toInt()); |
|
65 | Response resp = Response(reply->readAll(), status_code.toInt()); | |
62 | delete reply; |
|
66 | delete reply; |
@@ -117,7 +117,7 class VariableController2::VariableController2Private | |||||
117 | QMap<QUuid,std::shared_ptr<VariableSynchronizationGroup2>> _synchronizationGroups; |
|
117 | QMap<QUuid,std::shared_ptr<VariableSynchronizationGroup2>> _synchronizationGroups; | |
118 | QReadWriteLock _lock{QReadWriteLock::Recursive}; |
|
118 | QReadWriteLock _lock{QReadWriteLock::Recursive}; | |
119 | }_maps; |
|
119 | }_maps; | |
120 | QThreadPool _ThreadPool; |
|
120 | QThreadPool* _ThreadPool; | |
121 | VCTransactionsQueues _transactions; |
|
121 | VCTransactionsQueues _transactions; | |
122 | std::unique_ptr<VariableCacheStrategy> _cacheStrategy; |
|
122 | std::unique_ptr<VariableCacheStrategy> _cacheStrategy; | |
123 |
|
123 | |||
@@ -153,7 +153,7 class VariableController2::VariableController2Private | |||||
153 | this->_transactionComplete(groupID, transaction); |
|
153 | this->_transactionComplete(groupID, transaction); | |
154 | } |
|
154 | } | |
155 | ); |
|
155 | ); | |
156 |
_ThreadPool |
|
156 | _ThreadPool->start(exe); | |
157 | } |
|
157 | } | |
158 | } |
|
158 | } | |
159 | } |
|
159 | } | |
@@ -229,7 +229,8 public: | |||||
229 | :_cacheStrategy(VariableCacheStrategyFactory::createCacheStrategy(CacheStrategy::SingleThreshold)) |
|
229 | :_cacheStrategy(VariableCacheStrategyFactory::createCacheStrategy(CacheStrategy::SingleThreshold)) | |
230 | { |
|
230 | { | |
231 | Q_UNUSED(parent); |
|
231 | Q_UNUSED(parent); | |
232 |
this->_ThreadPool |
|
232 | this->_ThreadPool = new QThreadPool(); | |
|
233 | this->_ThreadPool->setMaxThreadCount(32); | |||
233 | } |
|
234 | } | |
234 |
|
235 | |||
235 | /* |
|
236 | /* | |
@@ -239,10 +240,7 public: | |||||
239 | */ |
|
240 | */ | |
240 | ~VariableController2Private() |
|
241 | ~VariableController2Private() | |
241 | { |
|
242 | { | |
242 |
|
|
243 | delete this->_ThreadPool; | |
243 | { |
|
|||
244 | this->_ThreadPool.waitForDone(100); |
|
|||
245 | } |
|
|||
246 | } |
|
244 | } | |
247 |
|
245 | |||
248 | std::shared_ptr<Variable> createVariable(const QString &name, const QVariantHash &metadata, std::shared_ptr<IDataProvider> provider) |
|
246 | std::shared_ptr<Variable> createVariable(const QString &name, const QVariantHash &metadata, std::shared_ptr<IDataProvider> provider) | |
@@ -330,7 +328,7 std::shared_ptr<Variable> VariableController2::createVariable(const QString &nam | |||||
330 | auto var = impl->createVariable(name, metadata, provider); |
|
328 | auto var = impl->createVariable(name, metadata, provider); | |
331 | emit variableAdded(var); |
|
329 | emit variableAdded(var); | |
332 | if(!DateTimeRangeHelper::hasnan(range)) |
|
330 | if(!DateTimeRangeHelper::hasnan(range)) | |
333 | impl->changeRange(var,range); |
|
331 | impl->asyncChangeRange(var,range); | |
334 | else |
|
332 | else | |
335 | SCIQLOP_ERROR(VariableController2, "Creating a variable with default constructed DateTimeRange is an error"); |
|
333 | SCIQLOP_ERROR(VariableController2, "Creating a variable with default constructed DateTimeRange is an error"); | |
336 | return var; |
|
334 | return var; |
@@ -42,19 +42,6 public: | |||||
42 | return serie; |
|
42 | return serie; | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 |
|
||||
46 |
|
||||
47 | void requestDataLoading(QUuid acqIdentifier, const DataProviderParameters ¶meters) override |
|
|||
48 | { |
|
|||
49 | Q_UNUSED(acqIdentifier) |
|
|||
50 | Q_UNUSED(parameters) |
|
|||
51 | } |
|
|||
52 |
|
||||
53 | void requestDataAborting(QUuid acqIdentifier) override |
|
|||
54 | { |
|
|||
55 | Q_UNUSED(acqIdentifier) |
|
|||
56 | } |
|
|||
57 |
|
||||
58 | }; |
|
45 | }; | |
59 |
|
46 | |||
60 |
|
47 |
General Comments 0
You need to be logged in to leave comments.
Login now