@@ -3,6 +3,9 | |||
|
3 | 3 | |
|
4 | 4 | #include <memory> |
|
5 | 5 | |
|
6 | #include <Data/DataProviderParameters.h> | |
|
7 | #include <Data/IDataProvider.h> | |
|
8 | #include <Data/ScalarSeries.h> | |
|
6 | 9 | #include <Variable/Variable.h> |
|
7 | 10 | #include <Variable/VariableController.h> |
|
8 | 11 | #include <Variable/VariableModel.h> |
@@ -10,6 +13,57 | |||
|
10 | 13 | namespace { |
|
11 | 14 | |
|
12 | 15 | /** |
|
16 | * Generates values according to a range. The value generated for a time t is the number of seconds | |
|
17 | * of difference between t and a reference value (which is midnight -> 00:00:00) | |
|
18 | * | |
|
19 | * Example: For a range between 00:00:10 and 00:00:20, the generated values are | |
|
20 | * {10,11,12,13,14,15,16,17,18,19,20} | |
|
21 | */ | |
|
22 | std::vector<double> values(const SqpRange &range) | |
|
23 | { | |
|
24 | QTime referenceTime{0, 0}; | |
|
25 | ||
|
26 | std::vector<double> result{}; | |
|
27 | ||
|
28 | for (auto i = range.m_TStart; i <= range.m_TEnd; ++i) { | |
|
29 | auto time = DateUtils::dateTime(i).time(); | |
|
30 | result.push_back(referenceTime.secsTo(time)); | |
|
31 | } | |
|
32 | ||
|
33 | return result; | |
|
34 | } | |
|
35 | ||
|
36 | /// Provider used for the tests | |
|
37 | class TestProvider : public IDataProvider { | |
|
38 | std::shared_ptr<IDataProvider> clone() const { return std::make_shared<TestProvider>(); } | |
|
39 | ||
|
40 | void requestDataLoading(QUuid acqIdentifier, const DataProviderParameters ¶meters) override | |
|
41 | { | |
|
42 | const auto &ranges = parameters.m_Times; | |
|
43 | ||
|
44 | for (const auto &range : ranges) { | |
|
45 | // Generates data series | |
|
46 | auto valuesData = values(range); | |
|
47 | ||
|
48 | std::vector<double> xAxisData{}; | |
|
49 | for (auto i = range.m_TStart; i <= range.m_TEnd; ++i) { | |
|
50 | xAxisData.push_back(i); | |
|
51 | } | |
|
52 | ||
|
53 | auto dataSeries = std::make_shared<ScalarSeries>( | |
|
54 | std::move(xAxisData), std::move(valuesData), Unit{"t", true}, Unit{}); | |
|
55 | ||
|
56 | emit dataProvided(acqIdentifier, dataSeries, range); | |
|
57 | } | |
|
58 | } | |
|
59 | ||
|
60 | void requestDataAborting(QUuid acqIdentifier) override | |
|
61 | { | |
|
62 | // Does nothing | |
|
63 | } | |
|
64 | }; | |
|
65 | ||
|
66 | /** | |
|
13 | 67 | * Interface representing an operation performed on a variable controller. |
|
14 | 68 | * This interface is used in tests to apply a set of operations and check the status of the |
|
15 | 69 | * controller after each operation |
General Comments 0
You need to be logged in to leave comments.
Login now