@@ -0,0 +1,15 | |||||
|
1 | #ifndef SCIQLOP_SQPDATETIME_H | |||
|
2 | #define SCIQLOP_SQPDATETIME_H | |||
|
3 | ||||
|
4 | /** | |||
|
5 | * @brief The SqpDateTime struct holds the information of time parameters | |||
|
6 | * @sa SqpDateTime | |||
|
7 | */ | |||
|
8 | struct SqpDateTime { | |||
|
9 | /// Start time | |||
|
10 | double m_TStart; | |||
|
11 | /// End time | |||
|
12 | double m_TEnd; | |||
|
13 | }; | |||
|
14 | ||||
|
15 | #endif // SCIQLOP_SQPDATETIME_H |
@@ -1,16 +1,15 | |||||
1 | #ifndef SCIQLOP_DATAPROVIDERPARAMETERS_H |
|
1 | #ifndef SCIQLOP_DATAPROVIDERPARAMETERS_H | |
2 | #define SCIQLOP_DATAPROVIDERPARAMETERS_H |
|
2 | #define SCIQLOP_DATAPROVIDERPARAMETERS_H | |
3 |
|
3 | |||
|
4 | #include "SqpDateTime.h" | |||
|
5 | ||||
4 | /** |
|
6 | /** | |
5 | * @brief The DataProviderParameters struct holds the information needed to retrieve data from a |
|
7 | * @brief The DataProviderParameters struct holds the information needed to retrieve data from a | |
6 | * data provider |
|
8 | * data provider | |
7 | * @sa IDataProvider |
|
9 | * @sa IDataProvider | |
8 | */ |
|
10 | */ | |
9 | struct DataProviderParameters { |
|
11 | struct DataProviderParameters { | |
10 | /// Start time |
|
12 | SqpDateTime m_Time; | |
11 | double m_TStart; |
|
|||
12 | /// End time |
|
|||
13 | double m_TEnd; |
|
|||
14 | }; |
|
13 | }; | |
15 |
|
14 | |||
16 | #endif // SCIQLOP_DATAPROVIDERPARAMETERS_H |
|
15 | #endif // SCIQLOP_DATAPROVIDERPARAMETERS_H |
@@ -1,30 +1,32 | |||||
1 | #include "CosinusProvider.h" |
|
1 | #include "CosinusProvider.h" | |
2 |
|
2 | |||
3 | #include <Data/DataProviderParameters.h> |
|
3 | #include <Data/DataProviderParameters.h> | |
4 | #include <Data/ScalarSeries.h> |
|
4 | #include <Data/ScalarSeries.h> | |
5 |
|
5 | |||
6 | #include <cmath> |
|
6 | #include <cmath> | |
7 |
|
7 | |||
8 | std::unique_ptr<IDataSeries> |
|
8 | std::unique_ptr<IDataSeries> | |
9 | CosinusProvider::retrieveData(const DataProviderParameters ¶meters) const |
|
9 | CosinusProvider::retrieveData(const DataProviderParameters ¶meters) const | |
10 | { |
|
10 | { | |
|
11 | auto dateTime = parameters.m_Time; | |||
|
12 | ||||
11 | // Gets the timerange from the parameters |
|
13 | // Gets the timerange from the parameters | |
12 |
auto start = |
|
14 | auto start = dateTime.m_TStart; | |
13 |
auto end = |
|
15 | auto end = dateTime.m_TEnd; | |
14 |
|
16 | |||
15 | // We assure that timerange is valid |
|
17 | // We assure that timerange is valid | |
16 | if (end < start) { |
|
18 | if (end < start) { | |
17 | std::swap(start, end); |
|
19 | std::swap(start, end); | |
18 | } |
|
20 | } | |
19 |
|
21 | |||
20 | // Generates scalar series containing cosinus values (one value per second) |
|
22 | // Generates scalar series containing cosinus values (one value per second) | |
21 | auto scalarSeries |
|
23 | auto scalarSeries | |
22 | = std::make_unique<ScalarSeries>(end - start, Unit{QStringLiteral("t"), true}, Unit{}); |
|
24 | = std::make_unique<ScalarSeries>(end - start, Unit{QStringLiteral("t"), true}, Unit{}); | |
23 |
|
25 | |||
24 | auto dataIndex = 0; |
|
26 | auto dataIndex = 0; | |
25 | for (auto time = start; time < end; ++time, ++dataIndex) { |
|
27 | for (auto time = start; time < end; ++time, ++dataIndex) { | |
26 | scalarSeries->setData(dataIndex, time, std::cos(time)); |
|
28 | scalarSeries->setData(dataIndex, time, std::cos(time)); | |
27 | } |
|
29 | } | |
28 |
|
30 | |||
29 | return scalarSeries; |
|
31 | return scalarSeries; | |
30 | } |
|
32 | } |
General Comments 0
You need to be logged in to leave comments.
Login now