@@ -7,6 +7,7 | |||||
7 | #include <Common/spimpl.h> |
|
7 | #include <Common/spimpl.h> | |
8 |
|
8 | |||
9 | class IDataProvider; |
|
9 | class IDataProvider; | |
|
10 | class TimeController; | |||
10 | class Variable; |
|
11 | class Variable; | |
11 | class VariableModel; |
|
12 | class VariableModel; | |
12 |
|
13 | |||
@@ -23,6 +24,8 public: | |||||
23 |
|
24 | |||
24 | VariableModel *variableModel() noexcept; |
|
25 | VariableModel *variableModel() noexcept; | |
25 |
|
26 | |||
|
27 | void setTimeController(TimeController *timeController) noexcept; | |||
|
28 | ||||
26 | signals: |
|
29 | signals: | |
27 | /// Signal emitted when a variable has been created |
|
30 | /// Signal emitted when a variable has been created | |
28 | void variableCreated(std::shared_ptr<Variable> variable); |
|
31 | void variableCreated(std::shared_ptr<Variable> variable); |
@@ -4,6 +4,7 | |||||
4 | #include <Data/DataProviderParameters.h> |
|
4 | #include <Data/DataProviderParameters.h> | |
5 | #include <Data/IDataProvider.h> |
|
5 | #include <Data/IDataProvider.h> | |
6 | #include <Data/IDataSeries.h> |
|
6 | #include <Data/IDataSeries.h> | |
|
7 | #include <Time/TimeController.h> | |||
7 |
|
8 | |||
8 | #include <QDateTime> |
|
9 | #include <QDateTime> | |
9 | #include <QMutex> |
|
10 | #include <QMutex> | |
@@ -15,14 +16,10 namespace { | |||||
15 |
|
16 | |||
16 | /// @todo Generates default dataseries, according to the provider passed in parameter. This method |
|
17 | /// @todo Generates default dataseries, according to the provider passed in parameter. This method | |
17 | /// will be deleted when the timerange is recovered from SciQlop |
|
18 | /// will be deleted when the timerange is recovered from SciQlop | |
18 |
std::unique_ptr<IDataSeries> generateDefaultDataSeries(const IDataProvider &provider |
|
19 | std::unique_ptr<IDataSeries> generateDefaultDataSeries(const IDataProvider &provider, | |
|
20 | const SqpDateTime &dateTime) noexcept | |||
19 | { |
|
21 | { | |
20 | auto parameters = DataProviderParameters{ |
|
22 | auto parameters = DataProviderParameters{dateTime}; | |
21 | // Remarks : we don't use toSecsSinceEpoch() here (method is for Qt 5.8 or above) |
|
|||
22 | static_cast<double>(QDateTime{QDate{2017, 01, 01}, QTime{12, 00}}.toMSecsSinceEpoch() |
|
|||
23 | / 1000.), |
|
|||
24 | static_cast<double>(QDateTime{QDate{2017, 01, 01}, QTime{12, 01}}.toMSecsSinceEpoch()) |
|
|||
25 | / 1000.}; |
|
|||
26 |
|
23 | |||
27 | return provider.retrieveData(parameters); |
|
24 | return provider.retrieveData(parameters); | |
28 | } |
|
25 | } | |
@@ -38,6 +35,8 struct VariableController::VariableControllerPrivate { | |||||
38 | QMutex m_WorkingMutex; |
|
35 | QMutex m_WorkingMutex; | |
39 | /// Variable model. The VariableController has the ownership |
|
36 | /// Variable model. The VariableController has the ownership | |
40 | VariableModel *m_VariableModel; |
|
37 | VariableModel *m_VariableModel; | |
|
38 | ||||
|
39 | TimeController *m_TimeController; | |||
41 | }; |
|
40 | }; | |
42 |
|
41 | |||
43 | VariableController::VariableController(QObject *parent) |
|
42 | VariableController::VariableController(QObject *parent) | |
@@ -59,16 +58,36 VariableModel *VariableController::variableModel() noexcept | |||||
59 | return impl->m_VariableModel; |
|
58 | return impl->m_VariableModel; | |
60 | } |
|
59 | } | |
61 |
|
60 | |||
|
61 | void VariableController::setTimeController(TimeController *timeController) noexcept | |||
|
62 | { | |||
|
63 | impl->m_TimeController = timeController; | |||
|
64 | } | |||
|
65 | ||||
62 | void VariableController::createVariable(const QString &name, |
|
66 | void VariableController::createVariable(const QString &name, | |
63 | std::shared_ptr<IDataProvider> provider) noexcept |
|
67 | std::shared_ptr<IDataProvider> provider) noexcept | |
64 | { |
|
68 | { | |
|
69 | // TORM | |||
|
70 | // auto dateTime = SqpDateTime{ | |||
|
71 | // // Remarks : we don't use toSecsSinceEpoch() here (method is for Qt 5.8 or above) | |||
|
72 | // static_cast<double>(QDateTime{QDate{2017, 01, 01}, QTime{12, 00}}.toMSecsSinceEpoch() | |||
|
73 | // / 1000.), | |||
|
74 | // static_cast<double>(QDateTime{QDate{2017, 01, 01}, QTime{12, 01}}.toMSecsSinceEpoch()) | |||
|
75 | // / 1000.}; | |||
|
76 | ||||
|
77 | if (!impl->m_TimeController) { | |||
|
78 | qCCritical(LOG_VariableController()) | |||
|
79 | << tr("Impossible to create variable: The time controller is null"); | |||
|
80 | return; | |||
|
81 | } | |||
|
82 | ||||
|
83 | ||||
65 | /// @todo : for the moment : |
|
84 | /// @todo : for the moment : | |
66 | /// - the provider is only used to retrieve data from the variable for its initialization, but |
|
85 | /// - the provider is only used to retrieve data from the variable for its initialization, but | |
67 | /// it will be retained later |
|
86 | /// it will be retained later | |
68 | /// - default data are generated for the variable, without taking into account the timerange set |
|
87 | /// - default data are generated for the variable, without taking into account the timerange set | |
69 | /// in sciqlop |
|
88 | /// in sciqlop | |
70 | if (auto newVariable |
|
89 | if (auto newVariable = impl->m_VariableModel->createVariable( | |
71 | = impl->m_VariableModel->createVariable(name, generateDefaultDataSeries(*provider))) { |
|
90 | name, generateDefaultDataSeries(*provider, impl->m_TimeController->dateTime()))) { | |
72 | emit variableCreated(newVariable); |
|
91 | emit variableCreated(newVariable); | |
73 | } |
|
92 | } | |
74 | } |
|
93 | } |
@@ -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 TimeController; | |||
19 | class VariableController; |
|
20 | class VariableController; | |
20 | class VisualizationController; |
|
21 | class VisualizationController; | |
21 |
|
22 | |||
@@ -37,6 +38,7 public: | |||||
37 |
|
38 | |||
38 | /// Accessors for the differents sciqlop controllers |
|
39 | /// Accessors for the differents sciqlop controllers | |
39 | DataSourceController &dataSourceController() noexcept; |
|
40 | DataSourceController &dataSourceController() noexcept; | |
|
41 | TimeController &timeController() noexcept; | |||
40 | VariableController &variableController() noexcept; |
|
42 | VariableController &variableController() noexcept; | |
41 | VisualizationController &visualizationController() noexcept; |
|
43 | VisualizationController &visualizationController() noexcept; | |
42 |
|
44 |
@@ -3,6 +3,7 | |||||
3 | #include <Data/IDataProvider.h> |
|
3 | #include <Data/IDataProvider.h> | |
4 | #include <DataSource/DataSourceController.h> |
|
4 | #include <DataSource/DataSourceController.h> | |
5 | #include <QThread> |
|
5 | #include <QThread> | |
|
6 | #include <Time/TimeController.h> | |||
6 | #include <Variable/Variable.h> |
|
7 | #include <Variable/Variable.h> | |
7 | #include <Variable/VariableController.h> |
|
8 | #include <Variable/VariableController.h> | |
8 | #include <Visualization/VisualizationController.h> |
|
9 | #include <Visualization/VisualizationController.h> | |
@@ -13,6 +14,7 class SqpApplication::SqpApplicationPrivate { | |||||
13 | public: |
|
14 | public: | |
14 | SqpApplicationPrivate() |
|
15 | SqpApplicationPrivate() | |
15 | : m_DataSourceController{std::make_unique<DataSourceController>()}, |
|
16 | : m_DataSourceController{std::make_unique<DataSourceController>()}, | |
|
17 | m_TimeController{std::make_unique<TimeController>()}, | |||
16 | m_VariableController{std::make_unique<VariableController>()}, |
|
18 | m_VariableController{std::make_unique<VariableController>()}, | |
17 | m_VisualizationController{std::make_unique<VisualizationController>()} |
|
19 | m_VisualizationController{std::make_unique<VisualizationController>()} | |
18 | { |
|
20 | { | |
@@ -36,6 +38,9 public: | |||||
36 | m_DataSourceController->moveToThread(&m_DataSourceControllerThread); |
|
38 | m_DataSourceController->moveToThread(&m_DataSourceControllerThread); | |
37 | m_VariableController->moveToThread(&m_VariableControllerThread); |
|
39 | m_VariableController->moveToThread(&m_VariableControllerThread); | |
38 | m_VisualizationController->moveToThread(&m_VisualizationControllerThread); |
|
40 | m_VisualizationController->moveToThread(&m_VisualizationControllerThread); | |
|
41 | ||||
|
42 | // Additionnal init | |||
|
43 | m_VariableController->setTimeController(m_TimeController.get()); | |||
39 | } |
|
44 | } | |
40 |
|
45 | |||
41 | virtual ~SqpApplicationPrivate() |
|
46 | virtual ~SqpApplicationPrivate() | |
@@ -53,6 +58,7 public: | |||||
53 |
|
58 | |||
54 | std::unique_ptr<DataSourceController> m_DataSourceController; |
|
59 | std::unique_ptr<DataSourceController> m_DataSourceController; | |
55 | std::unique_ptr<VariableController> m_VariableController; |
|
60 | std::unique_ptr<VariableController> m_VariableController; | |
|
61 | std::unique_ptr<TimeController> m_TimeController; | |||
56 | std::unique_ptr<VisualizationController> m_VisualizationController; |
|
62 | std::unique_ptr<VisualizationController> m_VisualizationController; | |
57 | QThread m_DataSourceControllerThread; |
|
63 | QThread m_DataSourceControllerThread; | |
58 | QThread m_VariableControllerThread; |
|
64 | QThread m_VariableControllerThread; | |
@@ -98,6 +104,11 DataSourceController &SqpApplication::dataSourceController() noexcept | |||||
98 | return *impl->m_DataSourceController; |
|
104 | return *impl->m_DataSourceController; | |
99 | } |
|
105 | } | |
100 |
|
106 | |||
|
107 | TimeController &SqpApplication::timeController() noexcept | |||
|
108 | { | |||
|
109 | return *impl->m_TimeController; | |||
|
110 | } | |||
|
111 | ||||
101 | VariableController &SqpApplication::variableController() noexcept |
|
112 | VariableController &SqpApplication::variableController() noexcept | |
102 | { |
|
113 | { | |
103 | return *impl->m_VariableController; |
|
114 | return *impl->m_VariableController; |
General Comments 0
You need to be logged in to leave comments.
Login now