##// END OF EJS Templates
Merge branch 'featureDownloadProgressMock' into develop
perrinel -
r430:de933c7a4f69 merge
parent child
Show More
@@ -40,9 +40,13 public:
40 40
41 41
42 42 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
43 m_DataSourceControllerThread.setObjectName("DataSourceControllerThread");
43 44 m_NetworkController->moveToThread(&m_NetworkControllerThread);
45 m_NetworkControllerThread.setObjectName("NetworkControllerThread");
44 46 m_VariableController->moveToThread(&m_VariableControllerThread);
47 m_VariableControllerThread.setObjectName("VariableControllerThread");
45 48 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
49 m_VisualizationControllerThread.setObjectName("VsualizationControllerThread");
46 50
47 51
48 52 // Additionnal init
@@ -6,7 +6,9
6 6 #include <Data/IDataProvider.h>
7 7
8 8 #include <QLoggingCategory>
9 #include <QUuid>
9 10
11 #include <QHash>
10 12 Q_DECLARE_LOGGING_CATEGORY(LOG_CosinusProvider)
11 13
12 14 /**
@@ -14,15 +16,18 Q_DECLARE_LOGGING_CATEGORY(LOG_CosinusProvider)
14 16 */
15 17 class SCIQLOP_MOCKPLUGIN_EXPORT CosinusProvider : public IDataProvider {
16 18 public:
19 /// @sa IDataProvider::requestDataLoading(). The current impl isn't thread safe.
17 20 void requestDataLoading(QUuid token, const DataProviderParameters &parameters) override;
18 21
19 22
23 /// @sa IDataProvider::requestDataAborting(). The current impl isn't thread safe.
20 24 void requestDataAborting(QUuid identifier) override;
21 25
22 26
23 27 private:
24 /// @sa IDataProvider::retrieveData()
25 std::shared_ptr<IDataSeries> retrieveData(const SqpDateTime &dateTime) const;
28 std::shared_ptr<IDataSeries> retrieveData(QUuid token, const SqpDateTime &dateTime);
29
30 QHash<QUuid, bool> m_VariableToEnableProvider;
26 31 };
27 32
28 33 #endif // SCIQLOP_COSINUSPROVIDER_H
@@ -6,12 +6,15
6 6 #include <cmath>
7 7
8 8 #include <QDateTime>
9 #include <QFuture>
9 10 #include <QThread>
11 #include <QtConcurrent/QtConcurrent>
10 12
11 13 Q_LOGGING_CATEGORY(LOG_CosinusProvider, "CosinusProvider")
12 14
13 std::shared_ptr<IDataSeries> CosinusProvider::retrieveData(const SqpDateTime &dateTime) const
15 std::shared_ptr<IDataSeries> CosinusProvider::retrieveData(QUuid token, const SqpDateTime &dateTime)
14 16 {
17 // TODO: Add Mutex
15 18 auto dataIndex = 0;
16 19
17 20 // Gets the timerange from the parameters
@@ -28,26 +31,65 std::shared_ptr<IDataSeries> CosinusProvider::retrieveData(const SqpDateTime &da
28 31 auto scalarSeries
29 32 = std::make_shared<ScalarSeries>(end - start, Unit{QStringLiteral("t"), true}, Unit{});
30 33
34
35 int progress = 0;
36 auto progressEnd = end - start;
31 37 for (auto time = start; time < end; ++time, ++dataIndex) {
32 const auto timeOnFreq = time / freq;
33 scalarSeries->setData(dataIndex, timeOnFreq, std::cos(timeOnFreq));
38 auto it = m_VariableToEnableProvider.find(token);
39 if (it != m_VariableToEnableProvider.end() && it.value()) {
40 const auto timeOnFreq = time / freq;
41 scalarSeries->setData(dataIndex, timeOnFreq, std::cos(timeOnFreq));
42
43 // progression
44 int currentProgress = (time - start) * 100.0 / progressEnd;
45 if (currentProgress != progress) {
46 progress = currentProgress;
47
48 emit dataProvidedProgress(token, progress);
49 }
50 }
51 else {
52 if (!it.value()) {
53 qCDebug(LOG_CosinusProvider())
54 << "CosinusProvider::retrieveData: ARRET De l'acquisition detecté"
55 << end - time;
56 }
57 }
34 58 }
59 emit dataProvidedProgress(token, 0.0);
60
61
35 62 return scalarSeries;
36 63 }
37 64
38 65 void CosinusProvider::requestDataLoading(QUuid token, const DataProviderParameters &parameters)
39 66 {
67 // TODO: Add Mutex
68 m_VariableToEnableProvider[token] = true;
40 69 qCDebug(LOG_CosinusProvider()) << "CosinusProvider::requestDataLoading"
41 70 << QThread::currentThread()->objectName();
42 71 // NOTE: Try to use multithread if possible
43 72 const auto times = parameters.m_Times;
73
44 74 for (const auto &dateTime : qAsConst(times)) {
45 auto scalarSeries = this->retrieveData(dateTime);
46 emit dataProvided(token, scalarSeries, dateTime);
75 if (m_VariableToEnableProvider[token]) {
76 auto scalarSeries = this->retrieveData(token, dateTime);
77 emit dataProvided(token, scalarSeries, dateTime);
78 }
47 79 }
48 80 }
49 81
50 82 void CosinusProvider::requestDataAborting(QUuid identifier)
51 83 {
52 // TODO
84 // TODO: Add Mutex
85 qCDebug(LOG_CosinusProvider()) << "CosinusProvider::requestDataAborting" << identifier
86 << QThread::currentThread()->objectName();
87 auto it = m_VariableToEnableProvider.find(identifier);
88 if (it != m_VariableToEnableProvider.end()) {
89 it.value() = false;
90 }
91 else {
92 qCWarning(LOG_CosinusProvider())
93 << tr("Aborting progression of inexistant identifier detected !!!");
94 }
53 95 }
General Comments 0
You need to be logged in to leave comments. Login now