##// END OF EJS Templates
It's now possible to create the variable and ask data to be retreived...
perrinel -
r319:c71a61da7f3d
parent child
Show More
@@ -25,12 +25,10 public:
25 * Creates a new variable in the model
25 * Creates a new variable in the model
26 * @param name the name of the new variable
26 * @param name the name of the new variable
27 * @param dateTime the dateTime of the new variable
27 * @param dateTime the dateTime of the new variable
28 * @param defaultDataSeries the default data of the new variable
29 * @return the pointer to the new variable
28 * @return the pointer to the new variable
30 */
29 */
31 std::shared_ptr<Variable>
30 std::shared_ptr<Variable> createVariable(const QString &name,
32 createVariable(const QString &name, const SqpDateTime &dateTime,
31 const SqpDateTime &dateTime) noexcept;
33 std::shared_ptr<IDataSeries> defaultDataSeries) noexcept;
34
32
35 std::shared_ptr<Variable> variable(int index) const;
33 std::shared_ptr<Variable> variable(int index) const;
36
34
@@ -55,7 +55,7 void VariableCacheController::addDateTime(std::shared_ptr<Variable> variable,
55 impl->m_VariableToSqpDateTimeListMap.at(variable), 0);
55 impl->m_VariableToSqpDateTimeListMap.at(variable), 0);
56 }
56 }
57 catch (const std::out_of_range &e) {
57 catch (const std::out_of_range &e) {
58 qCWarning(LOG_VariableCacheController()) << e.what();
58 qCWarning(LOG_VariableCacheController()) << "addDateTime" << e.what();
59 }
59 }
60 }
60 }
61 }
61 }
@@ -71,13 +71,12 VariableCacheController::provideNotInCacheDateTimeList(std::shared_ptr<Variable>
71 // list of date time request associated to the variable
71 // list of date time request associated to the variable
72 // We assume that the list is ordered in a way that l(0) < l(1). We assume also a < b
72 // We assume that the list is ordered in a way that l(0) < l(1). We assume also a < b
73 // (with a & b of type SqpDateTime) means ts(b) > te(a)
73 // (with a & b of type SqpDateTime) means ts(b) > te(a)
74
74 auto it = impl->m_VariableToSqpDateTimeListMap.find(variable);
75 try {
75 if (it != impl->m_VariableToSqpDateTimeListMap.end()) {
76 impl->addInCacheDataByStart(dateTime, impl->m_VariableToSqpDateTimeListMap.at(variable),
76 impl->addInCacheDataByStart(dateTime, it->second, notInCache, 0, dateTime.m_TStart);
77 notInCache, 0, dateTime.m_TStart);
78 }
77 }
79 catch (const std::out_of_range &e) {
78 else {
80 qCWarning(LOG_VariableCacheController()) << e.what();
79 notInCache << dateTime;
81 }
80 }
82
81
83 return notInCache;
82 return notInCache;
@@ -99,8 +99,7 void VariableController::createVariable(const QString &name,
99 /// - default data are generated for the variable, without taking into account the timerange set
99 /// - default data are generated for the variable, without taking into account the timerange set
100 /// in sciqlop
100 /// in sciqlop
101 auto dateTime = impl->m_TimeController->dateTime();
101 auto dateTime = impl->m_TimeController->dateTime();
102 if (auto newVariable = impl->m_VariableModel->createVariable(
102 if (auto newVariable = impl->m_VariableModel->createVariable(name, dateTime)) {
103 name, dateTime, generateDefaultDataSeries(*provider, dateTime))) {
104
103
105 // store the provider
104 // store the provider
106 impl->m_VariableToProviderMap[newVariable] = provider;
105 impl->m_VariableToProviderMap[newVariable] = provider;
@@ -114,10 +113,7 void VariableController::createVariable(const QString &name,
114 };
113 };
115
114
116 connect(provider.get(), &IDataProvider::dataProvided, addDateTimeAcquired);
115 connect(provider.get(), &IDataProvider::dataProvided, addDateTimeAcquired);
117
116 this->onRequestDataLoading(newVariable, dateTime);
118
119 // store in cache
120 impl->m_VariableCacheController->addDateTime(newVariable, dateTime);
121
117
122 // notify the creation
118 // notify the creation
123 emit variableCreated(newVariable);
119 emit variableCreated(newVariable);
@@ -52,9 +52,8 VariableModel::VariableModel(QObject *parent)
52 {
52 {
53 }
53 }
54
54
55 std::shared_ptr<Variable>
55 std::shared_ptr<Variable> VariableModel::createVariable(const QString &name,
56 VariableModel::createVariable(const QString &name, const SqpDateTime &dateTime,
56 const SqpDateTime &dateTime) noexcept
57 std::shared_ptr<IDataSeries> defaultDataSeries) noexcept
58 {
57 {
59 auto insertIndex = rowCount();
58 auto insertIndex = rowCount();
60 beginInsertRows({}, insertIndex, insertIndex);
59 beginInsertRows({}, insertIndex, insertIndex);
@@ -62,7 +61,6 VariableModel::createVariable(const QString &name, const SqpDateTime &dateTime,
62 /// @todo For the moment, the other data of the variable is initialized with default values
61 /// @todo For the moment, the other data of the variable is initialized with default values
63 auto variable = std::make_shared<Variable>(name, QStringLiteral("unit"),
62 auto variable = std::make_shared<Variable>(name, QStringLiteral("unit"),
64 QStringLiteral("mission"), dateTime);
63 QStringLiteral("mission"), dateTime);
65 variable->setDataSeries(std::move(defaultDataSeries));
66
64
67 impl->m_Variables.push_back(variable);
65 impl->m_Variables.push_back(variable);
68
66
General Comments 0
You need to be logged in to leave comments. Login now