##// END OF EJS Templates
Intialization of network controller
perrinel -
r339:39fcfe63cb2d
parent child
Show More
@@ -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 &parameters) 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,6 +15,7 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>()}
@@ -34,6 +36,7 public:
34 SIGNAL(variableCreated(std::shared_ptr<Variable>)));
36 SIGNAL(variableCreated(std::shared_ptr<Variable>)));
35
37
36 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
38 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
39 m_NetworkController->moveToThread(&m_NetworkControllerThread);
37 m_VariableController->moveToThread(&m_VariableControllerThread);
40 m_VariableController->moveToThread(&m_VariableControllerThread);
38 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
41 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
39
42
@@ -47,6 +50,9 public:
47 m_DataSourceControllerThread.quit();
50 m_DataSourceControllerThread.quit();
48 m_DataSourceControllerThread.wait();
51 m_DataSourceControllerThread.wait();
49
52
53 m_NetworkControllerThread.quit();
54 m_NetworkControllerThread.wait();
55
50 m_VariableControllerThread.quit();
56 m_VariableControllerThread.quit();
51 m_VariableControllerThread.wait();
57 m_VariableControllerThread.wait();
52
58
@@ -57,8 +63,10 public:
57 std::unique_ptr<DataSourceController> m_DataSourceController;
63 std::unique_ptr<DataSourceController> m_DataSourceController;
58 std::unique_ptr<VariableController> m_VariableController;
64 std::unique_ptr<VariableController> m_VariableController;
59 std::unique_ptr<TimeController> m_TimeController;
65 std::unique_ptr<TimeController> m_TimeController;
66 std::unique_ptr<NetworkController> m_NetworkController;
60 std::unique_ptr<VisualizationController> m_VisualizationController;
67 std::unique_ptr<VisualizationController> m_VisualizationController;
61 QThread m_DataSourceControllerThread;
68 QThread m_DataSourceControllerThread;
69 QThread m_NetworkControllerThread;
62 QThread m_VariableControllerThread;
70 QThread m_VariableControllerThread;
63 QThread m_VisualizationControllerThread;
71 QThread m_VisualizationControllerThread;
64 };
72 };
@@ -74,6 +82,11 SqpApplication::SqpApplication(int &argc, char **argv)
74 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
82 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
75 impl->m_DataSourceController.get(), &DataSourceController::finalize);
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 connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(),
90 connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(),
78 &VariableController::initialize);
91 &VariableController::initialize);
79 connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(),
92 connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(),
@@ -85,6 +98,7 SqpApplication::SqpApplication(int &argc, char **argv)
85 impl->m_VisualizationController.get(), &VisualizationController::finalize);
98 impl->m_VisualizationController.get(), &VisualizationController::finalize);
86
99
87 impl->m_DataSourceControllerThread.start();
100 impl->m_DataSourceControllerThread.start();
101 impl->m_NetworkControllerThread.start();
88 impl->m_VariableControllerThread.start();
102 impl->m_VariableControllerThread.start();
89 impl->m_VisualizationControllerThread.start();
103 impl->m_VisualizationControllerThread.start();
90 }
104 }
@@ -102,6 +116,11 DataSourceController &SqpApplication::dataSourceController() noexcept
102 return *impl->m_DataSourceController;
116 return *impl->m_DataSourceController;
103 }
117 }
104
118
119 NetworkController &SqpApplication::networkController() noexcept
120 {
121 return *impl->m_NetworkController;
122 }
123
105 TimeController &SqpApplication::timeController() noexcept
124 TimeController &SqpApplication::timeController() noexcept
106 {
125 {
107 return *impl->m_TimeController;
126 return *impl->m_TimeController;
@@ -33,13 +33,11 QSharedPointer<QCPAxisTicker> axisTicker(bool isTimeAxis)
33 void updateScalarData(QCPAbstractPlottable *component, ScalarSeries &scalarSeries,
33 void updateScalarData(QCPAbstractPlottable *component, ScalarSeries &scalarSeries,
34 const SqpDateTime &dateTime)
34 const SqpDateTime &dateTime)
35 {
35 {
36 QElapsedTimer timer;
37 timer.start();
38 if (auto qcpGraph = dynamic_cast<QCPGraph *>(component)) {
36 if (auto qcpGraph = dynamic_cast<QCPGraph *>(component)) {
39 // Clean the graph
37 // Clean the graph
40 // NAIVE approch
38 // NAIVE approch
41 const auto &xData = scalarSeries.xAxisData()->data();
39 const auto xData = scalarSeries.xAxisData()->data();
42 const auto &valuesData = scalarSeries.valuesData()->data();
40 const auto valuesData = scalarSeries.valuesData()->data();
43 const auto count = xData.count();
41 const auto count = xData.count();
44 qCInfo(LOG_VisualizationGraphHelper()) << "TORM: Current points in cache" << xData.count();
42 qCInfo(LOG_VisualizationGraphHelper()) << "TORM: Current points in cache" << xData.count();
45 auto xValue = QVector<double>(count);
43 auto xValue = QVector<double>(count);
@@ -12,14 +12,12 Q_DECLARE_LOGGING_CATEGORY(LOG_CosinusProvider)
12 */
12 */
13 class CosinusProvider : public IDataProvider {
13 class CosinusProvider : public IDataProvider {
14 public:
14 public:
15 /// @sa IDataProvider::retrieveData()
16 std::shared_ptr<IDataSeries>
17 retrieveData(const DataProviderParameters &parameters) const override;
18
19 void requestDataLoading(const QVector<SqpDateTime> &dateTimeList) override;
15 void requestDataLoading(const QVector<SqpDateTime> &dateTimeList) override;
20
16
21
17
22 private:
18 private:
19 /// @sa IDataProvider::retrieveData()
20 std::shared_ptr<IDataSeries> retrieveData(const DataProviderParameters &parameters) const;
23 std::shared_ptr<IDataSeries> retrieveDataSeries(const SqpDateTime &dateTime);
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