@@ -25,6 +25,12 struct ICosinusType { | |||||
25 | std::vector<double> valuesData, |
|
25 | std::vector<double> valuesData, | |
26 | Unit xAxisUnit, |
|
26 | Unit xAxisUnit, | |
27 | Unit valuesUnit) const = 0; |
|
27 | Unit valuesUnit) const = 0; | |
|
28 | /// Generates values (one value per component) | |||
|
29 | /// @param x the x-axis data used to generate values | |||
|
30 | /// @param values the vector in which to insert the generated values | |||
|
31 | /// @param dataIndex the index of insertion of the generated values | |||
|
32 | /// | |||
|
33 | virtual void generateValues(double x, std::vector<double> &values, int dataIndex) const = 0; | |||
28 | }; |
|
34 | }; | |
29 |
|
35 | |||
30 | struct ScalarCosinus : public ICosinusType { |
|
36 | struct ScalarCosinus : public ICosinusType { | |
@@ -37,6 +43,11 struct ScalarCosinus : public ICosinusType { | |||||
37 | return std::make_shared<ScalarSeries>(std::move(xAxisData), std::move(valuesData), |
|
43 | return std::make_shared<ScalarSeries>(std::move(xAxisData), std::move(valuesData), | |
38 | xAxisUnit, valuesUnit); |
|
44 | xAxisUnit, valuesUnit); | |
39 | } |
|
45 | } | |
|
46 | ||||
|
47 | void generateValues(double x, std::vector<double> &values, int dataIndex) const override | |||
|
48 | { | |||
|
49 | values[dataIndex] = std::cos(x); | |||
|
50 | } | |||
40 | }; |
|
51 | }; | |
41 | struct VectorCosinus : public ICosinusType { |
|
52 | struct VectorCosinus : public ICosinusType { | |
42 | int componentCount() const override { return 3; } |
|
53 | int componentCount() const override { return 3; } | |
@@ -48,6 +59,16 struct VectorCosinus : public ICosinusType { | |||||
48 | return std::make_shared<VectorSeries>(std::move(xAxisData), std::move(valuesData), |
|
59 | return std::make_shared<VectorSeries>(std::move(xAxisData), std::move(valuesData), | |
49 | xAxisUnit, valuesUnit); |
|
60 | xAxisUnit, valuesUnit); | |
50 | } |
|
61 | } | |
|
62 | ||||
|
63 | void generateValues(double x, std::vector<double> &values, int dataIndex) const override | |||
|
64 | { | |||
|
65 | // Generates value for each component: cos(x), cos(x)/2, cos(x)/3 | |||
|
66 | auto xValue = std::cos(x); | |||
|
67 | auto componentCount = this->componentCount(); | |||
|
68 | for (auto i = 0; i < componentCount; ++i) { | |||
|
69 | values[componentCount * dataIndex + i] = xValue / (i + 1); | |||
|
70 | } | |||
|
71 | } | |||
51 | }; |
|
72 | }; | |
52 |
|
73 | |||
53 | /// Converts string to cosinus type |
|
74 | /// Converts string to cosinus type | |
@@ -128,16 +149,12 std::shared_ptr<IDataSeries> CosinusProvider::retrieveData(QUuid acqIdentifier, | |||||
128 | for (auto time = start; time <= end; ++time, ++dataIndex) { |
|
149 | for (auto time = start; time <= end; ++time, ++dataIndex) { | |
129 | auto it = m_VariableToEnableProvider.find(acqIdentifier); |
|
150 | auto it = m_VariableToEnableProvider.find(acqIdentifier); | |
130 | if (it != m_VariableToEnableProvider.end() && it.value()) { |
|
151 | if (it != m_VariableToEnableProvider.end() && it.value()) { | |
131 |
const auto |
|
152 | const auto x = time / freq; | |
132 |
|
153 | |||
133 |
xAxisData[dataIndex] = |
|
154 | xAxisData[dataIndex] = x; | |
134 |
|
155 | |||
135 |
// Generates |
|
156 | // Generates values (depending on the type) | |
136 | // Example: for a vector, values will be : cos(x), cos(x)/2, cos(x)/3 |
|
157 | type->generateValues(x, valuesData, dataIndex); | |
137 | auto value = std::cos(timeOnFreq); |
|
|||
138 | for (auto i = 0; i < componentCount; ++i) { |
|
|||
139 | valuesData[componentCount * dataIndex + i] = value / (i + 1); |
|
|||
140 | } |
|
|||
141 |
|
158 | |||
142 | // progression |
|
159 | // progression | |
143 | int currentProgress = (time - start) * 100.0 / progressEnd; |
|
160 | int currentProgress = (time - start) * 100.0 / progressEnd; |
General Comments 0
You need to be logged in to leave comments.
Login now