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