@@ -1,30 +1,30 | |||
|
1 | 1 | #include "CosinusProvider.h" |
|
2 | 2 | |
|
3 | 3 | #include <Data/DataProviderParameters.h> |
|
4 | 4 | #include <Data/ScalarSeries.h> |
|
5 | 5 | |
|
6 | 6 | #include <cmath> |
|
7 | 7 | |
|
8 | 8 | std::unique_ptr<IDataSeries> |
|
9 | 9 | CosinusProvider::retrieveData(const DataProviderParameters ¶meters) const |
|
10 | 10 | { |
|
11 | 11 | // Gets the timerange from the parameters |
|
12 | 12 | auto start = parameters.m_TStart; |
|
13 | 13 | auto end = parameters.m_TEnd; |
|
14 | 14 | |
|
15 | 15 | // We assure that timerange is valid |
|
16 | 16 | if (end < start) { |
|
17 | 17 | std::swap(start, end); |
|
18 | 18 | } |
|
19 | 19 | |
|
20 | 20 | // Generates scalar series containing cosinus values (one value per second) |
|
21 | 21 | auto scalarSeries |
|
22 | 22 | = std::make_unique<ScalarSeries>(end - start, QStringLiteral("t"), QStringLiteral("")); |
|
23 | 23 | |
|
24 | for (auto time = start; time < end; ++time) { | |
|
25 | auto dataIndex = time - start; | |
|
24 | auto dataIndex = 0; | |
|
25 | for (auto time = start; time < end; ++time, ++dataIndex) { | |
|
26 | 26 | scalarSeries->setData(dataIndex, time, std::cos(time)); |
|
27 | 27 | } |
|
28 | 28 | |
|
29 | 29 | return scalarSeries; |
|
30 | 30 | } |
General Comments 0
You need to be logged in to leave comments.
Login now