@@ -0,0 +1,30 | |||
|
1 | #ifndef SCIQLOP_NETWORKCONTROLLER_H | |
|
2 | #define SCIQLOP_NETWORKCONTROLLER_H | |
|
3 | ||
|
4 | #include <QLoggingCategory> | |
|
5 | #include <QObject> | |
|
6 | ||
|
7 | #include <Common/spimpl.h> | |
|
8 | ||
|
9 | Q_DECLARE_LOGGING_CATEGORY(LOG_NetworkController) | |
|
10 | ||
|
11 | /** | |
|
12 | * @brief The NetworkController class aims to handle all network connection of SciQlop. | |
|
13 | */ | |
|
14 | class NetworkController : public QObject { | |
|
15 | Q_OBJECT | |
|
16 | public: | |
|
17 | explicit NetworkController(QObject *parent = 0); | |
|
18 | ||
|
19 | ||
|
20 | void initialize(); | |
|
21 | void finalize(); | |
|
22 | ||
|
23 | private: | |
|
24 | void waitForFinish(); | |
|
25 | ||
|
26 | class NetworkControllerPrivate; | |
|
27 | spimpl::unique_impl_ptr<NetworkControllerPrivate> impl; | |
|
28 | }; | |
|
29 | ||
|
30 | #endif // SCIQLOP_NETWORKCONTROLLER_H |
@@ -0,0 +1,33 | |||
|
1 | #include "Network/NetworkController.h" | |
|
2 | ||
|
3 | #include <QMutex> | |
|
4 | #include <QThread> | |
|
5 | ||
|
6 | Q_LOGGING_CATEGORY(LOG_NetworkController, "NetworkController") | |
|
7 | ||
|
8 | struct NetworkController::NetworkControllerPrivate { | |
|
9 | explicit NetworkControllerPrivate(NetworkController *parent) : m_WorkingMutex{} {} | |
|
10 | QMutex m_WorkingMutex; | |
|
11 | }; | |
|
12 | ||
|
13 | NetworkController::NetworkController(QObject *parent) | |
|
14 | : QObject(parent), impl{spimpl::make_unique_impl<NetworkControllerPrivate>(this)} | |
|
15 | { | |
|
16 | } | |
|
17 | ||
|
18 | void NetworkController::initialize() | |
|
19 | { | |
|
20 | qCDebug(LOG_NetworkController()) << tr("NetworkController init") << QThread::currentThread(); | |
|
21 | impl->m_WorkingMutex.lock(); | |
|
22 | qCDebug(LOG_NetworkController()) << tr("NetworkController init END"); | |
|
23 | } | |
|
24 | ||
|
25 | void NetworkController::finalize() | |
|
26 | { | |
|
27 | impl->m_WorkingMutex.unlock(); | |
|
28 | } | |
|
29 | ||
|
30 | void NetworkController::waitForFinish() | |
|
31 | { | |
|
32 | QMutexLocker locker{&impl->m_WorkingMutex}; | |
|
33 | } |
@@ -26,10 +26,6 class IDataProvider : public QObject { | |||
|
26 | 26 | public: |
|
27 | 27 | virtual ~IDataProvider() noexcept = default; |
|
28 | 28 | |
|
29 | virtual std::shared_ptr<IDataSeries> | |
|
30 | retrieveData(const DataProviderParameters ¶meters) const = 0; | |
|
31 | ||
|
32 | ||
|
33 | 29 | virtual void requestDataLoading(const QVector<SqpDateTime> &dateTimeList) = 0; |
|
34 | 30 | |
|
35 | 31 | signals: |
@@ -17,20 +17,6 | |||
|
17 | 17 | |
|
18 | 18 | Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController") |
|
19 | 19 | |
|
20 | namespace { | |
|
21 | ||
|
22 | /// @todo Generates default dataseries, according to the provider passed in parameter. This method | |
|
23 | /// will be deleted when the timerange is recovered from SciQlop | |
|
24 | std::shared_ptr<IDataSeries> generateDefaultDataSeries(const IDataProvider &provider, | |
|
25 | const SqpDateTime &dateTime) noexcept | |
|
26 | { | |
|
27 | auto parameters = DataProviderParameters{dateTime}; | |
|
28 | ||
|
29 | return provider.retrieveData(parameters); | |
|
30 | } | |
|
31 | ||
|
32 | } // namespace | |
|
33 | ||
|
34 | 20 | struct VariableController::VariableControllerPrivate { |
|
35 | 21 | explicit VariableControllerPrivate(VariableController *parent) |
|
36 | 22 | : m_WorkingMutex{}, |
@@ -16,6 +16,7 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication) | |||
|
16 | 16 | #define sqpApp (static_cast<SqpApplication *>(QCoreApplication::instance())) |
|
17 | 17 | |
|
18 | 18 | class DataSourceController; |
|
19 | class NetworkController; | |
|
19 | 20 | class TimeController; |
|
20 | 21 | class VariableController; |
|
21 | 22 | class VisualizationController; |
@@ -38,6 +39,7 public: | |||
|
38 | 39 | |
|
39 | 40 | /// Accessors for the differents sciqlop controllers |
|
40 | 41 | DataSourceController &dataSourceController() noexcept; |
|
42 | NetworkController &networkController() noexcept; | |
|
41 | 43 | TimeController &timeController() noexcept; |
|
42 | 44 | VariableController &variableController() noexcept; |
|
43 | 45 | VisualizationController &visualizationController() noexcept; |
@@ -2,6 +2,7 | |||
|
2 | 2 | |
|
3 | 3 | #include <Data/IDataProvider.h> |
|
4 | 4 | #include <DataSource/DataSourceController.h> |
|
5 | #include <Network/NetworkController.h> | |
|
5 | 6 | #include <QThread> |
|
6 | 7 | #include <Time/TimeController.h> |
|
7 | 8 | #include <Variable/Variable.h> |
@@ -14,6 +15,7 class SqpApplication::SqpApplicationPrivate { | |||
|
14 | 15 | public: |
|
15 | 16 | SqpApplicationPrivate() |
|
16 | 17 | : m_DataSourceController{std::make_unique<DataSourceController>()}, |
|
18 | m_NetworkController{std::make_unique<NetworkController>()}, | |
|
17 | 19 | m_TimeController{std::make_unique<TimeController>()}, |
|
18 | 20 | m_VariableController{std::make_unique<VariableController>()}, |
|
19 | 21 | m_VisualizationController{std::make_unique<VisualizationController>()} |
@@ -34,6 +36,7 public: | |||
|
34 | 36 | SIGNAL(variableCreated(std::shared_ptr<Variable>))); |
|
35 | 37 | |
|
36 | 38 | m_DataSourceController->moveToThread(&m_DataSourceControllerThread); |
|
39 | m_NetworkController->moveToThread(&m_NetworkControllerThread); | |
|
37 | 40 | m_VariableController->moveToThread(&m_VariableControllerThread); |
|
38 | 41 | m_VisualizationController->moveToThread(&m_VisualizationControllerThread); |
|
39 | 42 | |
@@ -47,6 +50,9 public: | |||
|
47 | 50 | m_DataSourceControllerThread.quit(); |
|
48 | 51 | m_DataSourceControllerThread.wait(); |
|
49 | 52 | |
|
53 | m_NetworkControllerThread.quit(); | |
|
54 | m_NetworkControllerThread.wait(); | |
|
55 | ||
|
50 | 56 | m_VariableControllerThread.quit(); |
|
51 | 57 | m_VariableControllerThread.wait(); |
|
52 | 58 | |
@@ -57,8 +63,10 public: | |||
|
57 | 63 | std::unique_ptr<DataSourceController> m_DataSourceController; |
|
58 | 64 | std::unique_ptr<VariableController> m_VariableController; |
|
59 | 65 | std::unique_ptr<TimeController> m_TimeController; |
|
66 | std::unique_ptr<NetworkController> m_NetworkController; | |
|
60 | 67 | std::unique_ptr<VisualizationController> m_VisualizationController; |
|
61 | 68 | QThread m_DataSourceControllerThread; |
|
69 | QThread m_NetworkControllerThread; | |
|
62 | 70 | QThread m_VariableControllerThread; |
|
63 | 71 | QThread m_VisualizationControllerThread; |
|
64 | 72 | }; |
@@ -74,6 +82,11 SqpApplication::SqpApplication(int &argc, char **argv) | |||
|
74 | 82 | connect(&impl->m_DataSourceControllerThread, &QThread::finished, |
|
75 | 83 | impl->m_DataSourceController.get(), &DataSourceController::finalize); |
|
76 | 84 | |
|
85 | connect(&impl->m_NetworkControllerThread, &QThread::started, impl->m_NetworkController.get(), | |
|
86 | &NetworkController::initialize); | |
|
87 | connect(&impl->m_NetworkControllerThread, &QThread::finished, impl->m_NetworkController.get(), | |
|
88 | &NetworkController::finalize); | |
|
89 | ||
|
77 | 90 | connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(), |
|
78 | 91 | &VariableController::initialize); |
|
79 | 92 | connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(), |
@@ -85,6 +98,7 SqpApplication::SqpApplication(int &argc, char **argv) | |||
|
85 | 98 | impl->m_VisualizationController.get(), &VisualizationController::finalize); |
|
86 | 99 | |
|
87 | 100 | impl->m_DataSourceControllerThread.start(); |
|
101 | impl->m_NetworkControllerThread.start(); | |
|
88 | 102 | impl->m_VariableControllerThread.start(); |
|
89 | 103 | impl->m_VisualizationControllerThread.start(); |
|
90 | 104 | } |
@@ -102,6 +116,11 DataSourceController &SqpApplication::dataSourceController() noexcept | |||
|
102 | 116 | return *impl->m_DataSourceController; |
|
103 | 117 | } |
|
104 | 118 | |
|
119 | NetworkController &SqpApplication::networkController() noexcept | |
|
120 | { | |
|
121 | return *impl->m_NetworkController; | |
|
122 | } | |
|
123 | ||
|
105 | 124 | TimeController &SqpApplication::timeController() noexcept |
|
106 | 125 | { |
|
107 | 126 | return *impl->m_TimeController; |
@@ -33,13 +33,11 QSharedPointer<QCPAxisTicker> axisTicker(bool isTimeAxis) | |||
|
33 | 33 | void updateScalarData(QCPAbstractPlottable *component, ScalarSeries &scalarSeries, |
|
34 | 34 | const SqpDateTime &dateTime) |
|
35 | 35 | { |
|
36 | QElapsedTimer timer; | |
|
37 | timer.start(); | |
|
38 | 36 | if (auto qcpGraph = dynamic_cast<QCPGraph *>(component)) { |
|
39 | 37 | // Clean the graph |
|
40 | 38 | // NAIVE approch |
|
41 |
const auto |
|
|
42 |
const auto |
|
|
39 | const auto xData = scalarSeries.xAxisData()->data(); | |
|
40 | const auto valuesData = scalarSeries.valuesData()->data(); | |
|
43 | 41 | const auto count = xData.count(); |
|
44 | 42 | qCInfo(LOG_VisualizationGraphHelper()) << "TORM: Current points in cache" << xData.count(); |
|
45 | 43 | auto xValue = QVector<double>(count); |
@@ -12,14 +12,12 Q_DECLARE_LOGGING_CATEGORY(LOG_CosinusProvider) | |||
|
12 | 12 | */ |
|
13 | 13 | class CosinusProvider : public IDataProvider { |
|
14 | 14 | public: |
|
15 | /// @sa IDataProvider::retrieveData() | |
|
16 | std::shared_ptr<IDataSeries> | |
|
17 | retrieveData(const DataProviderParameters ¶meters) const override; | |
|
18 | ||
|
19 | 15 | void requestDataLoading(const QVector<SqpDateTime> &dateTimeList) override; |
|
20 | 16 | |
|
21 | 17 | |
|
22 | 18 | private: |
|
19 | /// @sa IDataProvider::retrieveData() | |
|
20 | std::shared_ptr<IDataSeries> retrieveData(const DataProviderParameters ¶meters) const; | |
|
23 | 21 | std::shared_ptr<IDataSeries> retrieveDataSeries(const SqpDateTime &dateTime); |
|
24 | 22 | }; |
|
25 | 23 |
General Comments 0
You need to be logged in to leave comments.
Login now