@@ -9,14 +9,6 | |||
|
9 | 9 | class ScalarSeries : public DataSeries<1> { |
|
10 | 10 | public: |
|
11 | 11 | /** |
|
12 | * Ctor | |
|
13 | * @param size the number of data the series will hold | |
|
14 | * @param xAxisUnit x-axis unit | |
|
15 | * @param valuesUnit values unit | |
|
16 | */ | |
|
17 | explicit ScalarSeries(int size, const Unit &xAxisUnit, const Unit &valuesUnit); | |
|
18 | ||
|
19 | /** | |
|
20 | 12 | * Ctor with two vectors. The vectors must have the same size, otherwise a ScalarSeries with no |
|
21 | 13 | * values will be created. |
|
22 | 14 | * @param xAxisData x-axis data |
@@ -25,14 +17,6 public: | |||
|
25 | 17 | explicit ScalarSeries(QVector<double> xAxisData, QVector<double> valuesData, |
|
26 | 18 | const Unit &xAxisUnit, const Unit &valuesUnit); |
|
27 | 19 | |
|
28 | /** | |
|
29 | * Sets data for a specific index. The index has to be valid to be effective | |
|
30 | * @param index the index to which the data will be set | |
|
31 | * @param x the x-axis data | |
|
32 | * @param value the value data | |
|
33 | */ | |
|
34 | void setData(int index, double x, double value) noexcept; | |
|
35 | ||
|
36 | 20 | std::unique_ptr<IDataSeries> clone() const; |
|
37 | 21 | }; |
|
38 | 22 |
@@ -1,11 +1,5 | |||
|
1 | 1 | #include <Data/ScalarSeries.h> |
|
2 | 2 | |
|
3 | ScalarSeries::ScalarSeries(int size, const Unit &xAxisUnit, const Unit &valuesUnit) | |
|
4 | : DataSeries{std::make_shared<ArrayData<1> >(size), xAxisUnit, | |
|
5 | std::make_shared<ArrayData<1> >(size), valuesUnit} | |
|
6 | { | |
|
7 | } | |
|
8 | ||
|
9 | 3 | ScalarSeries::ScalarSeries(QVector<double> xAxisData, QVector<double> valuesData, |
|
10 | 4 | const Unit &xAxisUnit, const Unit &valuesUnit) |
|
11 | 5 | : DataSeries{std::make_shared<ArrayData<1> >(std::move(xAxisData)), xAxisUnit, |
@@ -13,12 +7,6 ScalarSeries::ScalarSeries(QVector<double> xAxisData, QVector<double> valuesData | |||
|
13 | 7 | { |
|
14 | 8 | } |
|
15 | 9 | |
|
16 | void ScalarSeries::setData(int index, double x, double value) noexcept | |
|
17 | { | |
|
18 | xAxisData()->setData(index, x); | |
|
19 | valuesData()->setData(index, value); | |
|
20 | } | |
|
21 | ||
|
22 | 10 | std::unique_ptr<IDataSeries> ScalarSeries::clone() const |
|
23 | 11 | { |
|
24 | 12 | return std::make_unique<ScalarSeries>(*this); |
@@ -19,8 +19,8 std::shared_ptr<IDataSeries> CosinusProvider::retrieveData(QUuid token, const Sq | |||
|
19 | 19 | |
|
20 | 20 | // Gets the timerange from the parameters |
|
21 | 21 | double freq = 100.0; |
|
22 | double start = dateTime.m_TStart * freq; // 100 htz | |
|
23 |
double end = dateTime.m_TEnd * freq; |
|
|
22 | double start = std::ceil(dateTime.m_TStart * freq); // 100 htz | |
|
23 | double end = std::floor(dateTime.m_TEnd * freq); // 100 htz | |
|
24 | 24 | |
|
25 | 25 | // We assure that timerange is valid |
|
26 | 26 | if (end < start) { |
@@ -28,17 +28,23 std::shared_ptr<IDataSeries> CosinusProvider::retrieveData(QUuid token, const Sq | |||
|
28 | 28 | } |
|
29 | 29 | |
|
30 | 30 | // Generates scalar series containing cosinus values (one value per second) |
|
31 | auto scalarSeries | |
|
32 | = std::make_shared<ScalarSeries>(end - start, Unit{QStringLiteral("t"), true}, Unit{}); | |
|
31 | auto dataCount = end - start; | |
|
33 | 32 | |
|
33 | auto xAxisData = QVector<double>{}; | |
|
34 | xAxisData.resize(dataCount); | |
|
35 | ||
|
36 | auto valuesData = QVector<double>{}; | |
|
37 | valuesData.resize(dataCount); | |
|
34 | 38 | |
|
35 | 39 | int progress = 0; |
|
36 |
auto progressEnd = |
|
|
40 | auto progressEnd = dataCount; | |
|
37 | 41 | for (auto time = start; time < end; ++time, ++dataIndex) { |
|
38 | 42 | auto it = m_VariableToEnableProvider.find(token); |
|
39 | 43 | if (it != m_VariableToEnableProvider.end() && it.value()) { |
|
40 | 44 | const auto timeOnFreq = time / freq; |
|
41 | scalarSeries->setData(dataIndex, timeOnFreq, std::cos(timeOnFreq)); | |
|
45 | ||
|
46 | xAxisData.replace(dataIndex, timeOnFreq); | |
|
47 | valuesData.replace(dataIndex, std::cos(timeOnFreq)); | |
|
42 | 48 | |
|
43 | 49 | // progression |
|
44 | 50 | int currentProgress = (time - start) * 100.0 / progressEnd; |
@@ -58,8 +64,8 std::shared_ptr<IDataSeries> CosinusProvider::retrieveData(QUuid token, const Sq | |||
|
58 | 64 | } |
|
59 | 65 | emit dataProvidedProgress(token, 0.0); |
|
60 | 66 | |
|
61 | ||
|
62 | return scalarSeries; | |
|
67 | return std::make_shared<ScalarSeries>(std::move(xAxisData), std::move(valuesData), | |
|
68 | Unit{QStringLiteral("t"), true}, Unit{}); | |
|
63 | 69 | } |
|
64 | 70 | |
|
65 | 71 | void CosinusProvider::requestDataLoading(QUuid token, const DataProviderParameters ¶meters) |
General Comments 0
You need to be logged in to leave comments.
Login now