@@ -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 | public: |
|
26 | public: | |
27 | virtual ~IDataProvider() noexcept = default; |
|
27 | virtual ~IDataProvider() noexcept = default; | |
28 |
|
28 | |||
29 | virtual std::shared_ptr<IDataSeries> |
|
|||
30 | retrieveData(const DataProviderParameters ¶meters) const = 0; |
|
|||
31 |
|
||||
32 |
|
||||
33 | virtual void requestDataLoading(const QVector<SqpDateTime> &dateTimeList) = 0; |
|
29 | virtual void requestDataLoading(const QVector<SqpDateTime> &dateTimeList) = 0; | |
34 |
|
30 | |||
35 | signals: |
|
31 | signals: |
@@ -17,20 +17,6 | |||||
17 |
|
17 | |||
18 | Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController") |
|
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 | struct VariableController::VariableControllerPrivate { |
|
20 | struct VariableController::VariableControllerPrivate { | |
35 | explicit VariableControllerPrivate(VariableController *parent) |
|
21 | explicit VariableControllerPrivate(VariableController *parent) | |
36 | : m_WorkingMutex{}, |
|
22 | : m_WorkingMutex{}, |
@@ -16,6 +16,7 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication) | |||||
16 | #define sqpApp (static_cast<SqpApplication *>(QCoreApplication::instance())) |
|
16 | #define sqpApp (static_cast<SqpApplication *>(QCoreApplication::instance())) | |
17 |
|
17 | |||
18 | class DataSourceController; |
|
18 | class DataSourceController; | |
|
19 | class NetworkController; | |||
19 | class TimeController; |
|
20 | class TimeController; | |
20 | class VariableController; |
|
21 | class VariableController; | |
21 | class VisualizationController; |
|
22 | class VisualizationController; | |
@@ -38,6 +39,7 public: | |||||
38 |
|
39 | |||
39 | /// Accessors for the differents sciqlop controllers |
|
40 | /// Accessors for the differents sciqlop controllers | |
40 | DataSourceController &dataSourceController() noexcept; |
|
41 | DataSourceController &dataSourceController() noexcept; | |
|
42 | NetworkController &networkController() noexcept; | |||
41 | TimeController &timeController() noexcept; |
|
43 | TimeController &timeController() noexcept; | |
42 | VariableController &variableController() noexcept; |
|
44 | VariableController &variableController() noexcept; | |
43 | VisualizationController &visualizationController() noexcept; |
|
45 | VisualizationController &visualizationController() noexcept; |
@@ -2,6 +2,7 | |||||
2 |
|
2 | |||
3 | #include <Data/IDataProvider.h> |
|
3 | #include <Data/IDataProvider.h> | |
4 | #include <DataSource/DataSourceController.h> |
|
4 | #include <DataSource/DataSourceController.h> | |
|
5 | #include <Network/NetworkController.h> | |||
5 | #include <QThread> |
|
6 | #include <QThread> | |
6 | #include <Time/TimeController.h> |
|
7 | #include <Time/TimeController.h> | |
7 | #include <Variable/Variable.h> |
|
8 | #include <Variable/Variable.h> | |
@@ -14,18 +15,11 class SqpApplication::SqpApplicationPrivate { | |||||
14 | public: |
|
15 | public: | |
15 | SqpApplicationPrivate() |
|
16 | SqpApplicationPrivate() | |
16 | : m_DataSourceController{std::make_unique<DataSourceController>()}, |
|
17 | : m_DataSourceController{std::make_unique<DataSourceController>()}, | |
|
18 | m_NetworkController{std::make_unique<NetworkController>()}, | |||
17 | m_TimeController{std::make_unique<TimeController>()}, |
|
19 | m_TimeController{std::make_unique<TimeController>()}, | |
18 | m_VariableController{std::make_unique<VariableController>()}, |
|
20 | m_VariableController{std::make_unique<VariableController>()}, | |
19 | m_VisualizationController{std::make_unique<VisualizationController>()} |
|
21 | m_VisualizationController{std::make_unique<VisualizationController>()} | |
20 | { |
|
22 | { | |
21 | QThread::currentThread()->setObjectName("MainThread"); |
|
|||
22 | m_DataSourceController->moveToThread(&m_DataSourceControllerThread); |
|
|||
23 | m_DataSourceControllerThread.setObjectName("DataSourceControllerThread"); |
|
|||
24 | m_VariableController->moveToThread(&m_VariableControllerThread); |
|
|||
25 | m_VariableControllerThread.setObjectName("VariableControllerThread"); |
|
|||
26 | m_VisualizationController->moveToThread(&m_VisualizationControllerThread); |
|
|||
27 | m_VisualizationControllerThread.setObjectName("VisualizationControllerThread"); |
|
|||
28 |
|
||||
29 | // /////////////////////////////// // |
|
23 | // /////////////////////////////// // | |
30 | // Connections between controllers // |
|
24 | // Connections between controllers // | |
31 | // /////////////////////////////// // |
|
25 | // /////////////////////////////// // | |
@@ -43,6 +37,12 public: | |||||
43 | SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), Qt::DirectConnection); |
|
37 | SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), Qt::DirectConnection); | |
44 |
|
38 | |||
45 |
|
39 | |||
|
40 | m_DataSourceController->moveToThread(&m_DataSourceControllerThread); | |||
|
41 | m_NetworkController->moveToThread(&m_NetworkControllerThread); | |||
|
42 | m_VariableController->moveToThread(&m_VariableControllerThread); | |||
|
43 | m_VisualizationController->moveToThread(&m_VisualizationControllerThread); | |||
|
44 | ||||
|
45 | ||||
46 | // Additionnal init |
|
46 | // Additionnal init | |
47 | m_VariableController->setTimeController(m_TimeController.get()); |
|
47 | m_VariableController->setTimeController(m_TimeController.get()); | |
48 | } |
|
48 | } | |
@@ -53,6 +53,9 public: | |||||
53 | m_DataSourceControllerThread.quit(); |
|
53 | m_DataSourceControllerThread.quit(); | |
54 | m_DataSourceControllerThread.wait(); |
|
54 | m_DataSourceControllerThread.wait(); | |
55 |
|
55 | |||
|
56 | m_NetworkControllerThread.quit(); | |||
|
57 | m_NetworkControllerThread.wait(); | |||
|
58 | ||||
56 | m_VariableControllerThread.quit(); |
|
59 | m_VariableControllerThread.quit(); | |
57 | m_VariableControllerThread.wait(); |
|
60 | m_VariableControllerThread.wait(); | |
58 |
|
61 | |||
@@ -63,8 +66,10 public: | |||||
63 | std::unique_ptr<DataSourceController> m_DataSourceController; |
|
66 | std::unique_ptr<DataSourceController> m_DataSourceController; | |
64 | std::unique_ptr<VariableController> m_VariableController; |
|
67 | std::unique_ptr<VariableController> m_VariableController; | |
65 | std::unique_ptr<TimeController> m_TimeController; |
|
68 | std::unique_ptr<TimeController> m_TimeController; | |
|
69 | std::unique_ptr<NetworkController> m_NetworkController; | |||
66 | std::unique_ptr<VisualizationController> m_VisualizationController; |
|
70 | std::unique_ptr<VisualizationController> m_VisualizationController; | |
67 | QThread m_DataSourceControllerThread; |
|
71 | QThread m_DataSourceControllerThread; | |
|
72 | QThread m_NetworkControllerThread; | |||
68 | QThread m_VariableControllerThread; |
|
73 | QThread m_VariableControllerThread; | |
69 | QThread m_VisualizationControllerThread; |
|
74 | QThread m_VisualizationControllerThread; | |
70 | }; |
|
75 | }; | |
@@ -80,6 +85,11 SqpApplication::SqpApplication(int &argc, char **argv) | |||||
80 | connect(&impl->m_DataSourceControllerThread, &QThread::finished, |
|
85 | connect(&impl->m_DataSourceControllerThread, &QThread::finished, | |
81 | impl->m_DataSourceController.get(), &DataSourceController::finalize); |
|
86 | impl->m_DataSourceController.get(), &DataSourceController::finalize); | |
82 |
|
87 | |||
|
88 | connect(&impl->m_NetworkControllerThread, &QThread::started, impl->m_NetworkController.get(), | |||
|
89 | &NetworkController::initialize); | |||
|
90 | connect(&impl->m_NetworkControllerThread, &QThread::finished, impl->m_NetworkController.get(), | |||
|
91 | &NetworkController::finalize); | |||
|
92 | ||||
83 | connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(), |
|
93 | connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(), | |
84 | &VariableController::initialize); |
|
94 | &VariableController::initialize); | |
85 | connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(), |
|
95 | connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(), | |
@@ -91,6 +101,7 SqpApplication::SqpApplication(int &argc, char **argv) | |||||
91 | impl->m_VisualizationController.get(), &VisualizationController::finalize); |
|
101 | impl->m_VisualizationController.get(), &VisualizationController::finalize); | |
92 |
|
102 | |||
93 | impl->m_DataSourceControllerThread.start(); |
|
103 | impl->m_DataSourceControllerThread.start(); | |
|
104 | impl->m_NetworkControllerThread.start(); | |||
94 | impl->m_VariableControllerThread.start(); |
|
105 | impl->m_VariableControllerThread.start(); | |
95 | impl->m_VisualizationControllerThread.start(); |
|
106 | impl->m_VisualizationControllerThread.start(); | |
96 | } |
|
107 | } | |
@@ -108,6 +119,11 DataSourceController &SqpApplication::dataSourceController() noexcept | |||||
108 | return *impl->m_DataSourceController; |
|
119 | return *impl->m_DataSourceController; | |
109 | } |
|
120 | } | |
110 |
|
121 | |||
|
122 | NetworkController &SqpApplication::networkController() noexcept | |||
|
123 | { | |||
|
124 | return *impl->m_NetworkController; | |||
|
125 | } | |||
|
126 | ||||
111 | TimeController &SqpApplication::timeController() noexcept |
|
127 | TimeController &SqpApplication::timeController() noexcept | |
112 | { |
|
128 | { | |
113 | return *impl->m_TimeController; |
|
129 | return *impl->m_TimeController; |
@@ -14,14 +14,12 Q_DECLARE_LOGGING_CATEGORY(LOG_CosinusProvider) | |||||
14 | */ |
|
14 | */ | |
15 | class SCIQLOP_MOCKPLUGIN_EXPORT CosinusProvider : public IDataProvider { |
|
15 | class SCIQLOP_MOCKPLUGIN_EXPORT CosinusProvider : public IDataProvider { | |
16 | public: |
|
16 | public: | |
17 | /// @sa IDataProvider::retrieveData() |
|
|||
18 | std::shared_ptr<IDataSeries> |
|
|||
19 | retrieveData(const DataProviderParameters ¶meters) const override; |
|
|||
20 |
|
||||
21 | void requestDataLoading(const QVector<SqpDateTime> &dateTimeList) override; |
|
17 | void requestDataLoading(const QVector<SqpDateTime> &dateTimeList) override; | |
22 |
|
18 | |||
23 |
|
19 | |||
24 | private: |
|
20 | private: | |
|
21 | /// @sa IDataProvider::retrieveData() | |||
|
22 | std::shared_ptr<IDataSeries> retrieveData(const DataProviderParameters ¶meters) const; | |||
25 | std::shared_ptr<IDataSeries> retrieveDataSeries(const SqpDateTime &dateTime); |
|
23 | std::shared_ptr<IDataSeries> retrieveDataSeries(const SqpDateTime &dateTime); | |
26 | }; |
|
24 | }; | |
27 |
|
25 |
General Comments 0
You need to be logged in to leave comments.
Login now