##// END OF EJS Templates
Fixed tests due to async var creation, plus minor stuff...
jeandet -
r30:02d2d8643fcb
parent child
Show More
@@ -10,7 +10,7
10 */
10 */
11 struct DataProviderParameters {
11 struct DataProviderParameters {
12 /// Times for which retrieve data
12 /// Times for which retrieve data
13 QVector<DateTimeRange> m_Times;
13 DateTimeRange m_Range;
14 /// Extra data that can be used by the provider to retrieve data
14 /// Extra data that can be used by the provider to retrieve data
15 QVariantHash m_Data;
15 QVariantHash m_Data;
16 };
16 };
@@ -34,14 +34,13 public:
34 const std::vector<std::shared_ptr<Variable>> variables();
34 const std::vector<std::shared_ptr<Variable>> variables();
35
35
36 bool isReady(const std::shared_ptr<Variable>& variable);
36 bool isReady(const std::shared_ptr<Variable>& variable);
37 bool isReady();
38
37
39
38 void synchronize(const std::shared_ptr<Variable>& var, const std::shared_ptr<Variable>& with);
40 void synchronize(const std::shared_ptr<Variable>& var, const std::shared_ptr<Variable>& with);
39
41
40 const std::vector<std::shared_ptr<Variable>> variables(const std::vector<QUuid>& ids);
42 const std::vector<std::shared_ptr<Variable>> variables(const std::vector<QUuid>& ids);
41
43
42 const std::shared_ptr<Variable>& operator[] (int index) const;
43 std::shared_ptr<Variable> operator[] (int index);
44
45
44
46 signals:
45 signals:
47 void variableAdded(const std::shared_ptr<Variable>&);
46 void variableAdded(const std::shared_ptr<Variable>&);
@@ -52,6 +52,8 public:
52 const QModelIndex &parent) const override;
52 const QModelIndex &parent) const override;
53 virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column,
53 virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column,
54 const QModelIndex &parent) override;
54 const QModelIndex &parent) override;
55 const std::vector<std::shared_ptr<Variable>>& variables() const
56 {return _variables;}
55
57
56 signals:
58 signals:
57 void createVariable(const QVariantHash &productData);
59 void createVariable(const QVariantHash &productData);
@@ -276,6 +276,16 public:
276 return _transactions.active(*_maps.group(*variable));
276 return _transactions.active(*_maps.group(*variable));
277 }
277 }
278
278
279 bool hasPendingTransactions()
280 {
281 bool has = false;
282 for(const auto& var:_maps.variables())
283 {
284 has |= _transactions.active(*_maps.group(*var));
285 }
286 return has;
287 }
288
279 void deleteVariable(const std::shared_ptr<Variable>& variable)
289 void deleteVariable(const std::shared_ptr<Variable>& variable)
280 {
290 {
281 _maps.removeVariable(variable);
291 _maps.removeVariable(variable);
@@ -326,6 +336,7 VariableController2::VariableController2()
326 std::shared_ptr<Variable> VariableController2::createVariable(const QString &name, const QVariantHash &metadata, const std::shared_ptr<IDataProvider>& provider, const DateTimeRange &range)
336 std::shared_ptr<Variable> VariableController2::createVariable(const QString &name, const QVariantHash &metadata, const std::shared_ptr<IDataProvider>& provider, const DateTimeRange &range)
327 {
337 {
328 auto var = impl->createVariable(name, metadata, provider);
338 auto var = impl->createVariable(name, metadata, provider);
339 var->setRange(range); // even with no data this is it's range
329 emit variableAdded(var);
340 emit variableAdded(var);
330 if(!DateTimeRangeHelper::hasnan(range))
341 if(!DateTimeRangeHelper::hasnan(range))
331 impl->asyncChangeRange(var,range);
342 impl->asyncChangeRange(var,range);
@@ -362,7 +373,12 const std::vector<std::shared_ptr<Variable> > VariableController2::variables()
362
373
363 bool VariableController2::isReady(const std::shared_ptr<Variable> &variable)
374 bool VariableController2::isReady(const std::shared_ptr<Variable> &variable)
364 {
375 {
365 return impl->hasPendingTransactions(variable);
376 return !impl->hasPendingTransactions(variable);
377 }
378
379 bool VariableController2::isReady()
380 {
381 return !impl->hasPendingTransactions();
366 }
382 }
367
383
368 void VariableController2::synchronize(const std::shared_ptr<Variable> &var, const std::shared_ptr<Variable> &with)
384 void VariableController2::synchronize(const std::shared_ptr<Variable> &var, const std::shared_ptr<Variable> &with)
@@ -378,13 +394,3 const std::vector<std::shared_ptr<Variable>> VariableController2::variables(cons
378 }
394 }
379 return variables;
395 return variables;
380 }
396 }
381
382 const std::shared_ptr<Variable> &VariableController2::operator[](int index) const
383 {
384 return impl->variable (index);
385 }
386
387 std::shared_ptr<Variable> VariableController2::operator[](int index)
388 {
389 return impl->variable (index);
390 }
@@ -29,8 +29,8 public:
29 IDataSeries* getData(const DataProviderParameters &parameters) override
29 IDataSeries* getData(const DataProviderParameters &parameters) override
30 {
30 {
31 callCounter+=1;
31 callCounter+=1;
32 auto tstart = parameters.m_Times[0].m_TStart;
32 auto tstart = parameters.m_Range.m_TStart;
33 auto tend = parameters.m_Times[0].m_TEnd;
33 auto tend = parameters.m_Range.m_TEnd;
34 std::vector<double> x;
34 std::vector<double> x;
35 std::vector<double> y;
35 std::vector<double> y;
36 for(double i = ceil(tstart);i<=floor(tend);i+=1.) //1 seconde data resolution
36 for(double i = ceil(tstart);i<=floor(tend);i+=1.) //1 seconde data resolution
@@ -20,6 +20,7
20 auto range = DateTimeRange::fromDateTime(QDate(2018,8,7),QTime(14,00),\
20 auto range = DateTimeRange::fromDateTime(QDate(2018,8,7),QTime(14,00),\
21 QDate(2018,8,7),QTime(16,00));\
21 QDate(2018,8,7),QTime(16,00));\
22 auto name = vc.createVariable("name", {}, provider, range);\
22 auto name = vc.createVariable("name", {}, provider, range);\
23 while(!vc.isReady(name))QCoreApplication::processEvents();\
23
24
24 Q_DECLARE_METATYPE(DateTimeRangeTransformation);
25 Q_DECLARE_METATYPE(DateTimeRangeTransformation);
25
26
@@ -56,6 +57,7 private slots:
56 bool callbackCalled = false;
57 bool callbackCalled = false;
57 connect(&vc,&VariableController2::variableDeleted, [&callbackCalled](std::shared_ptr<Variable>){callbackCalled=true;});
58 connect(&vc,&VariableController2::variableDeleted, [&callbackCalled](std::shared_ptr<Variable>){callbackCalled=true;});
58 auto var1 = vc.createVariable("var1", {}, provider, range);
59 auto var1 = vc.createVariable("var1", {}, provider, range);
60 while(!vc.isReady(var1))QCoreApplication::processEvents();
59 QVERIFY(SciQLop::containers::contains(vc.variables(), var1));
61 QVERIFY(SciQLop::containers::contains(vc.variables(), var1));
60 QVERIFY(!callbackCalled);
62 QVERIFY(!callbackCalled);
61 vc.deleteVariable(var1);
63 vc.deleteVariable(var1);
@@ -20,9 +20,11
20 auto range = DateTimeRange::fromDateTime(QDate(2018,8,7),QTime(14,00),\
20 auto range = DateTimeRange::fromDateTime(QDate(2018,8,7),QTime(14,00),\
21 QDate(2018,8,7),QTime(16,00));\
21 QDate(2018,8,7),QTime(16,00));\
22 auto name1 = vc.createVariable("name1", {}, provider, range);\
22 auto name1 = vc.createVariable("name1", {}, provider, range);\
23 while(!vc.isReady(name1))QCoreApplication::processEvents();\
23 auto name2 = vc.cloneVariable(name1);\
24 auto name2 = vc.cloneVariable(name1);\
24 auto name3 = vc.cloneVariable(name2);\
25 auto name3 = vc.cloneVariable(name2);\
25 vc.synchronize(name1,name2);\
26 vc.synchronize(name1,name2);\
27 while(!vc.isReady(name1))QCoreApplication::processEvents();\
26
28
27
29
28 class TestVariableController2WithSync : public QObject
30 class TestVariableController2WithSync : public QObject
General Comments 0
You need to be logged in to leave comments. Login now