##// END OF EJS Templates
Correction MR
perrinel -
r195:ecdf3f75d679
parent child
Show More
@@ -1,15 +1,14
1 1 #ifndef SCIQLOP_SQPDATETIME_H
2 2 #define SCIQLOP_SQPDATETIME_H
3 3
4 4 /**
5 5 * @brief The SqpDateTime struct holds the information of time parameters
6 * @sa SqpDateTime
7 6 */
8 7 struct SqpDateTime {
9 8 /// Start time
10 9 double m_TStart;
11 10 /// End time
12 11 double m_TEnd;
13 12 };
14 13
15 14 #endif // SCIQLOP_SQPDATETIME_H
@@ -1,110 +1,110
1 1 #include <Variable/VariableController.h>
2 2 #include <Variable/VariableModel.h>
3 3
4 4 #include <Data/DataProviderParameters.h>
5 5 #include <Data/IDataProvider.h>
6 6 #include <Data/IDataSeries.h>
7 7 #include <Time/TimeController.h>
8 8
9 9 #include <QDateTime>
10 10 #include <QMutex>
11 11 #include <QThread>
12 12
13 13 Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController")
14 14
15 15 namespace {
16 16
17 17 /// @todo Generates default dataseries, according to the provider passed in parameter. This method
18 18 /// will be deleted when the timerange is recovered from SciQlop
19 19 std::unique_ptr<IDataSeries> generateDefaultDataSeries(const IDataProvider &provider,
20 20 const SqpDateTime &dateTime) noexcept
21 21 {
22 22 auto parameters = DataProviderParameters{dateTime};
23 23
24 24 return provider.retrieveData(parameters);
25 25 }
26 26
27 27 } // namespace
28 28
29 29 struct VariableController::VariableControllerPrivate {
30 30 explicit VariableControllerPrivate(VariableController *parent)
31 31 : m_WorkingMutex{}, m_VariableModel{new VariableModel{parent}}
32 32 {
33 33 }
34 34
35 35 QMutex m_WorkingMutex;
36 36 /// Variable model. The VariableController has the ownership
37 37 VariableModel *m_VariableModel;
38 38
39 TimeController *m_TimeController;
39 TimeController *m_TimeController{nullptr};
40 40 };
41 41
42 42 VariableController::VariableController(QObject *parent)
43 43 : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)}
44 44 {
45 45 qCDebug(LOG_VariableController()) << tr("VariableController construction")
46 46 << QThread::currentThread();
47 47 }
48 48
49 49 VariableController::~VariableController()
50 50 {
51 51 qCDebug(LOG_VariableController()) << tr("VariableController destruction")
52 52 << QThread::currentThread();
53 53 this->waitForFinish();
54 54 }
55 55
56 56 VariableModel *VariableController::variableModel() noexcept
57 57 {
58 58 return impl->m_VariableModel;
59 59 }
60 60
61 61 void VariableController::setTimeController(TimeController *timeController) noexcept
62 62 {
63 63 impl->m_TimeController = timeController;
64 64 }
65 65
66 66 void VariableController::createVariable(const QString &name,
67 67 std::shared_ptr<IDataProvider> provider) noexcept
68 68 {
69 69 // TORM
70 70 // auto dateTime = SqpDateTime{
71 71 // // Remarks : we don't use toSecsSinceEpoch() here (method is for Qt 5.8 or above)
72 72 // static_cast<double>(QDateTime{QDate{2017, 01, 01}, QTime{12, 00}}.toMSecsSinceEpoch()
73 73 // / 1000.),
74 74 // static_cast<double>(QDateTime{QDate{2017, 01, 01}, QTime{12, 01}}.toMSecsSinceEpoch())
75 75 // / 1000.};
76 76
77 77 if (!impl->m_TimeController) {
78 78 qCCritical(LOG_VariableController())
79 79 << tr("Impossible to create variable: The time controller is null");
80 80 return;
81 81 }
82 82
83 83
84 84 /// @todo : for the moment :
85 85 /// - the provider is only used to retrieve data from the variable for its initialization, but
86 86 /// it will be retained later
87 87 /// - default data are generated for the variable, without taking into account the timerange set
88 88 /// in sciqlop
89 89 if (auto newVariable = impl->m_VariableModel->createVariable(
90 90 name, generateDefaultDataSeries(*provider, impl->m_TimeController->dateTime()))) {
91 91 emit variableCreated(newVariable);
92 92 }
93 93 }
94 94
95 95 void VariableController::initialize()
96 96 {
97 97 qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread();
98 98 impl->m_WorkingMutex.lock();
99 99 qCDebug(LOG_VariableController()) << tr("VariableController init END");
100 100 }
101 101
102 102 void VariableController::finalize()
103 103 {
104 104 impl->m_WorkingMutex.unlock();
105 105 }
106 106
107 107 void VariableController::waitForFinish()
108 108 {
109 109 QMutexLocker locker{&impl->m_WorkingMutex};
110 110 }
General Comments 0
You need to be logged in to leave comments. Login now