@@ -1,1 +1,1 | |||||
1 | Subproject commit 70eb884a0ee3f19fb2a7dc91d2f25f6348d4167d |
|
1 | Subproject commit 54e194b00c35fb5f769eda61234c1b4dd6de3a43 |
@@ -1,199 +1,204 | |||||
1 | #include "CosinusProvider.h" |
|
1 | #include "CosinusProvider.h" | |
2 | #include "MockDefs.h" |
|
2 | #include "MockDefs.h" | |
3 |
|
3 | |||
4 | #include <Data/DataProviderParameters.h> |
|
4 | #include <Data/DataProviderParameters.h> | |
5 | #include <Data/ScalarSeries.h> |
|
5 | #include <Data/ScalarSeries.h> | |
6 | #include <Data/SpectrogramSeries.h> |
|
6 | #include <Data/SpectrogramSeries.h> | |
7 | #include <Data/VectorSeries.h> |
|
7 | #include <Data/VectorSeries.h> | |
8 |
|
8 | |||
9 | #include <cmath> |
|
9 | #include <cmath> | |
10 | #include <set> |
|
10 | #include <set> | |
11 |
|
11 | |||
12 | #include <QFuture> |
|
12 | #include <QFuture> | |
13 | #include <QThread> |
|
13 | #include <QThread> | |
14 | #include <QtConcurrent/QtConcurrent> |
|
14 | #include <QtConcurrent/QtConcurrent> | |
15 |
|
15 | |||
16 |
|
16 | |||
17 | namespace { |
|
17 | namespace { | |
18 |
|
18 | |||
19 | /// Number of bands generated for a spectrogram |
|
19 | /// Number of bands generated for a spectrogram | |
20 | const auto SPECTROGRAM_NUMBER_BANDS = 30; |
|
20 | const auto SPECTROGRAM_NUMBER_BANDS = 30; | |
21 |
|
21 | |||
22 | /// Bands for which to generate NaN values for a spectrogram |
|
22 | /// Bands for which to generate NaN values for a spectrogram | |
23 | const auto SPECTROGRAM_NAN_BANDS = std::set<int>{1, 3, 10, 20}; |
|
23 | const auto SPECTROGRAM_NAN_BANDS = std::set<int>{1, 3, 10, 20}; | |
24 |
|
24 | |||
25 | /// Bands for which to generate zeros for a spectrogram |
|
25 | /// Bands for which to generate zeros for a spectrogram | |
26 | const auto SPECTROGRAM_ZERO_BANDS = std::set<int>{2, 15, 19, 29}; |
|
26 | const auto SPECTROGRAM_ZERO_BANDS = std::set<int>{2, 15, 19, 29}; | |
27 |
|
27 | |||
28 | /// Abstract cosinus type |
|
28 | /// Abstract cosinus type | |
29 | struct ICosinusType { |
|
29 | struct ICosinusType { | |
30 | virtual ~ICosinusType() = default; |
|
30 | virtual ~ICosinusType() = default; | |
31 | /// @return the number of components generated for the type |
|
31 | /// @return the number of components generated for the type | |
32 | virtual std::size_t componentCount() const = 0; |
|
32 | virtual std::size_t componentCount() const = 0; | |
33 | /// @return the data series created for the type |
|
33 | /// @return the data series created for the type | |
34 | virtual IDataSeries* createDataSeries(std::vector<double> xAxisData, |
|
34 | virtual IDataSeries* createDataSeries(std::vector<double> xAxisData, | |
35 | std::vector<double> valuesData) const = 0; |
|
35 | std::vector<double> valuesData) const = 0; | |
36 | /// Generates values (one value per component) |
|
36 | /// Generates values (one value per component) | |
37 | /// @param x the x-axis data used to generate values |
|
37 | /// @param x the x-axis data used to generate values | |
38 | /// @param values the vector in which to insert the generated values |
|
38 | /// @param values the vector in which to insert the generated values | |
39 | /// @param dataIndex the index of insertion of the generated values |
|
39 | /// @param dataIndex the index of insertion of the generated values | |
40 | /// |
|
40 | /// | |
41 | virtual void generateValues(double x, std::vector<double> &values, int dataIndex) const = 0; |
|
41 | virtual void generateValues(double x, std::vector<double> &values, int dataIndex) const = 0; | |
42 | }; |
|
42 | }; | |
43 |
|
43 | |||
44 | struct ScalarCosinus : public ICosinusType { |
|
44 | struct ScalarCosinus : public ICosinusType { | |
45 | std::size_t componentCount() const override { return 1; } |
|
45 | std::size_t componentCount() const override { return 1; } | |
46 |
|
46 | |||
47 | IDataSeries* createDataSeries(std::vector<double> xAxisData, |
|
47 | IDataSeries* createDataSeries(std::vector<double> xAxisData, | |
48 | std::vector<double> valuesData) const override |
|
48 | std::vector<double> valuesData) const override | |
49 | { |
|
49 | { | |
50 | return new ScalarSeries(std::move(xAxisData), std::move(valuesData), |
|
50 | return new ScalarSeries(std::move(xAxisData), std::move(valuesData), | |
51 | Unit{QStringLiteral("t"), true}, Unit{}); |
|
51 | Unit{QStringLiteral("t"), true}, Unit{}); | |
52 | } |
|
52 | } | |
53 |
|
53 | |||
54 | void generateValues(double x, std::vector<double> &values, int dataIndex) const override |
|
54 | void generateValues(double x, std::vector<double> &values, int dataIndex) const override | |
55 | { |
|
55 | { | |
56 | values[dataIndex] = std::cos(x); |
|
56 | values[dataIndex] = std::cos(x); | |
57 | } |
|
57 | } | |
58 | }; |
|
58 | }; | |
59 |
|
59 | |||
60 | struct SpectrogramCosinus : public ICosinusType { |
|
60 | struct SpectrogramCosinus : public ICosinusType { | |
61 | /// Ctor with y-axis |
|
61 | /// Ctor with y-axis | |
62 | explicit SpectrogramCosinus(std::vector<double> yAxisData, Unit yAxisUnit, Unit valuesUnit) |
|
62 | explicit SpectrogramCosinus(std::vector<double> yAxisData, Unit yAxisUnit, Unit valuesUnit) | |
63 | : m_YAxisData{std::move(yAxisData)}, |
|
63 | : m_YAxisData{std::move(yAxisData)}, | |
64 | m_YAxisUnit{std::move(yAxisUnit)}, |
|
64 | m_YAxisUnit{std::move(yAxisUnit)}, | |
65 | m_ValuesUnit{std::move(valuesUnit)} |
|
65 | m_ValuesUnit{std::move(valuesUnit)} | |
66 | { |
|
66 | { | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | std::size_t componentCount() const override { return m_YAxisData.size(); } |
|
69 | std::size_t componentCount() const override { return m_YAxisData.size(); } | |
70 |
|
70 | |||
71 | IDataSeries* createDataSeries(std::vector<double> xAxisData, |
|
71 | IDataSeries* createDataSeries(std::vector<double> xAxisData, | |
72 | std::vector<double> valuesData) const override |
|
72 | std::vector<double> valuesData) const override | |
73 | { |
|
73 | { | |
74 | return new SpectrogramSeries( |
|
74 | return new SpectrogramSeries( | |
75 | std::move(xAxisData), m_YAxisData, std::move(valuesData), |
|
75 | std::move(xAxisData), m_YAxisData, std::move(valuesData), | |
76 | Unit{QStringLiteral("t"), true}, m_YAxisUnit, m_ValuesUnit); |
|
76 | Unit{QStringLiteral("t"), true}, m_YAxisUnit, m_ValuesUnit); | |
77 | } |
|
77 | } | |
78 |
|
78 | |||
79 | void generateValues(double x, std::vector<double> &values, int dataIndex) const override |
|
79 | void generateValues(double x, std::vector<double> &values, int dataIndex) const override | |
80 | { |
|
80 | { | |
81 | auto componentCount = this->componentCount(); |
|
81 | auto componentCount = this->componentCount(); | |
82 | for (int i = 0; i < componentCount; ++i) { |
|
82 | for (int i = 0; i < componentCount; ++i) { | |
83 | auto y = m_YAxisData[i]; |
|
83 | auto y = m_YAxisData[i]; | |
84 |
|
84 | |||
85 | double value; |
|
85 | double value; | |
86 |
|
86 | |||
87 | if (SPECTROGRAM_ZERO_BANDS.find(y) != SPECTROGRAM_ZERO_BANDS.end()) { |
|
87 | // if (SPECTROGRAM_ZERO_BANDS.find(y) != SPECTROGRAM_ZERO_BANDS.end()) { | |
88 | value = 0.; |
|
88 | // value = 0.; | |
89 | } |
|
89 | // } | |
90 | else if (SPECTROGRAM_NAN_BANDS.find(y) != SPECTROGRAM_NAN_BANDS.end()) { |
|
90 | // else if (SPECTROGRAM_NAN_BANDS.find(y) != SPECTROGRAM_NAN_BANDS.end()) { | |
91 | value = std::numeric_limits<double>::quiet_NaN(); |
|
91 | // value = std::numeric_limits<double>::quiet_NaN(); | |
92 | } |
|
92 | // } | |
93 |
else |
|
93 | // else | |
|
94 | { | |||
94 | // Generates value for non NaN/zero bands |
|
95 | // Generates value for non NaN/zero bands | |
95 | auto r = 3 * std::sqrt(x * x + y * y) + 1e-2; |
|
96 | //auto r = 3 * std::sqrt(x * x + y * y) + 1e-2; | |
96 | value = 2 * x * (std::cos(r + 2) / r - std::sin(r + 2) / r); |
|
97 | //value = 2 * x * (std::cos(r + 2) / r - std::sin(r + 2) / r); | |
|
98 | value = x + 10*y; | |||
97 | } |
|
99 | } | |
98 |
|
100 | |||
99 | values[componentCount * dataIndex + i] = value; |
|
101 | values[componentCount * dataIndex + i] = value; | |
100 | } |
|
102 | } | |
101 | } |
|
103 | } | |
102 |
|
104 | |||
103 | std::vector<double> m_YAxisData; |
|
105 | std::vector<double> m_YAxisData; | |
104 | Unit m_YAxisUnit; |
|
106 | Unit m_YAxisUnit; | |
105 | Unit m_ValuesUnit; |
|
107 | Unit m_ValuesUnit; | |
106 | }; |
|
108 | }; | |
107 |
|
109 | |||
108 | struct VectorCosinus : public ICosinusType { |
|
110 | struct VectorCosinus : public ICosinusType { | |
109 | std::size_t componentCount() const override { return 3; } |
|
111 | std::size_t componentCount() const override { return 3; } | |
110 |
|
112 | |||
111 | IDataSeries* createDataSeries(std::vector<double> xAxisData, |
|
113 | IDataSeries* createDataSeries(std::vector<double> xAxisData, | |
112 | std::vector<double> valuesData) const override |
|
114 | std::vector<double> valuesData) const override | |
113 | { |
|
115 | { | |
114 | return new VectorSeries(std::move(xAxisData), std::move(valuesData), |
|
116 | return new VectorSeries(std::move(xAxisData), std::move(valuesData), | |
115 | Unit{QStringLiteral("t"), true}, Unit{}); |
|
117 | Unit{QStringLiteral("t"), true}, Unit{}); | |
116 | } |
|
118 | } | |
117 |
|
119 | |||
118 | void generateValues(double x, std::vector<double> &values, int dataIndex) const override |
|
120 | void generateValues(double x, std::vector<double> &values, int dataIndex) const override | |
119 | { |
|
121 | { | |
120 | // Generates value for each component: cos(x), cos(x)/2, cos(x)/3 |
|
122 | // Generates value for each component: cos(x), cos(x)/2, cos(x)/3 | |
121 | auto xValue = std::cos(x); |
|
123 | auto xValue = std::cos(x); | |
122 | auto componentCount = this->componentCount(); |
|
124 | auto componentCount = this->componentCount(); | |
123 | for (auto i = 0; i < componentCount; ++i) { |
|
125 | for (auto i = 0; i < componentCount; ++i) { | |
124 | values[componentCount * dataIndex + i] = xValue / (i + 1); |
|
126 | values[componentCount * dataIndex + i] = xValue / (i + 1); | |
125 | } |
|
127 | } | |
126 | } |
|
128 | } | |
127 | }; |
|
129 | }; | |
128 |
|
130 | |||
129 | /// Converts string to cosinus type |
|
131 | /// Converts string to cosinus type | |
130 | /// @return the cosinus type if the string could be converted, nullptr otherwise |
|
132 | /// @return the cosinus type if the string could be converted, nullptr otherwise | |
131 | std::unique_ptr<ICosinusType> cosinusType(const QString &type) noexcept |
|
133 | std::unique_ptr<ICosinusType> cosinusType(const QString &type) noexcept | |
132 | { |
|
134 | { | |
133 | if (type.compare(QStringLiteral("scalar"), Qt::CaseInsensitive) == 0) { |
|
135 | if (type.compare(QStringLiteral("scalar"), Qt::CaseInsensitive) == 0) { | |
134 | return std::make_unique<ScalarCosinus>(); |
|
136 | return std::make_unique<ScalarCosinus>(); | |
135 | } |
|
137 | } | |
136 | else if (type.compare(QStringLiteral("spectrogram"), Qt::CaseInsensitive) == 0) { |
|
138 | else if (type.compare(QStringLiteral("spectrogram"), Qt::CaseInsensitive) == 0) { | |
137 | // Generates default y-axis data for spectrogram [0., 1., 2., ...] |
|
139 | // Generates default y-axis data for spectrogram [0., 1., 2., ...] | |
138 | std::vector<double> yAxisData(SPECTROGRAM_NUMBER_BANDS); |
|
140 | std::vector<double> yAxisData(SPECTROGRAM_NUMBER_BANDS); | |
139 |
std::iota(yAxisData.begin(), yAxisData.end(), |
|
141 | std::iota(yAxisData.begin(), yAxisData.end(), 1.); | |
140 |
|
142 | for (auto & v:yAxisData) | ||
|
143 | { | |||
|
144 | v = std::pow(2,v); | |||
|
145 | } | |||
141 | return std::make_unique<SpectrogramCosinus>(std::move(yAxisData), Unit{"eV"}, |
|
146 | return std::make_unique<SpectrogramCosinus>(std::move(yAxisData), Unit{"eV"}, | |
142 | Unit{"eV/(cm^2-s-sr-eV)"}); |
|
147 | Unit{"eV/(cm^2-s-sr-eV)"}); | |
143 | } |
|
148 | } | |
144 | else if (type.compare(QStringLiteral("vector"), Qt::CaseInsensitive) == 0) { |
|
149 | else if (type.compare(QStringLiteral("vector"), Qt::CaseInsensitive) == 0) { | |
145 | return std::make_unique<VectorCosinus>(); |
|
150 | return std::make_unique<VectorCosinus>(); | |
146 | } |
|
151 | } | |
147 | else { |
|
152 | else { | |
148 | return nullptr; |
|
153 | return nullptr; | |
149 | } |
|
154 | } | |
150 | } |
|
155 | } | |
151 |
|
156 | |||
152 | } // namespace |
|
157 | } // namespace | |
153 |
|
158 | |||
154 | std::shared_ptr<IDataProvider> CosinusProvider::clone() const |
|
159 | std::shared_ptr<IDataProvider> CosinusProvider::clone() const | |
155 | { |
|
160 | { | |
156 | // No copy is made in clone |
|
161 | // No copy is made in clone | |
157 | return std::make_shared<CosinusProvider>(); |
|
162 | return std::make_shared<CosinusProvider>(); | |
158 | } |
|
163 | } | |
159 |
|
164 | |||
160 | IDataSeries *CosinusProvider::_generate(const DateTimeRange &range, const QVariantHash &metaData) |
|
165 | IDataSeries *CosinusProvider::_generate(const DateTimeRange &range, const QVariantHash &metaData) | |
161 | { |
|
166 | { | |
162 | auto dataIndex = 0; |
|
167 | auto dataIndex = 0; | |
163 |
|
168 | |||
164 | // Retrieves cosinus type |
|
169 | // Retrieves cosinus type | |
165 | auto typeVariant = metaData.value(COSINUS_TYPE_KEY, COSINUS_TYPE_DEFAULT_VALUE); |
|
170 | auto typeVariant = metaData.value(COSINUS_TYPE_KEY, COSINUS_TYPE_DEFAULT_VALUE); | |
166 | auto type = cosinusType(typeVariant.toString()); |
|
171 | auto type = cosinusType(typeVariant.toString()); | |
167 | auto freqVariant = metaData.value(COSINUS_FREQUENCY_KEY, COSINUS_FREQUENCY_DEFAULT_VALUE); |
|
172 | auto freqVariant = metaData.value(COSINUS_FREQUENCY_KEY, COSINUS_FREQUENCY_DEFAULT_VALUE); | |
168 | double freq = freqVariant.toDouble(); |
|
173 | double freq = freqVariant.toDouble(); | |
169 | double start = std::ceil(range.m_TStart * freq); |
|
174 | double start = std::ceil(range.m_TStart * freq); | |
170 | double end = std::floor(range.m_TEnd * freq); |
|
175 | double end = std::floor(range.m_TEnd * freq); | |
171 | if (end < start) { |
|
176 | if (end < start) { | |
172 | std::swap(start, end); |
|
177 | std::swap(start, end); | |
173 | } |
|
178 | } | |
174 | std::size_t dataCount = static_cast<std::size_t>(end - start + 1); |
|
179 | std::size_t dataCount = static_cast<std::size_t>(end - start + 1); | |
175 | std::size_t componentCount = type->componentCount(); |
|
180 | std::size_t componentCount = type->componentCount(); | |
176 |
|
181 | |||
177 | auto xAxisData = std::vector<double>{}; |
|
182 | auto xAxisData = std::vector<double>{}; | |
178 | xAxisData.resize(dataCount); |
|
183 | xAxisData.resize(dataCount); | |
179 |
|
184 | |||
180 | auto valuesData = std::vector<double>{}; |
|
185 | auto valuesData = std::vector<double>{}; | |
181 | valuesData.resize(dataCount * componentCount); |
|
186 | valuesData.resize(dataCount * componentCount); | |
182 |
|
187 | |||
183 | int progress = 0; |
|
188 | int progress = 0; | |
184 | auto progressEnd = dataCount; |
|
189 | auto progressEnd = dataCount; | |
185 | for (auto time = start; time <= end; ++time, ++dataIndex) |
|
190 | for (auto time = start; time <= end; ++time, ++dataIndex) | |
186 | { |
|
191 | { | |
187 | const auto x = time / freq; |
|
192 | const auto x = time / freq; | |
188 | xAxisData[dataIndex] = x; |
|
193 | xAxisData[dataIndex] = x; | |
189 | // Generates values (depending on the type) |
|
194 | // Generates values (depending on the type) | |
190 | type->generateValues(x, valuesData, dataIndex); |
|
195 | type->generateValues(x, valuesData, dataIndex); | |
191 | } |
|
196 | } | |
192 | return type->createDataSeries(std::move(xAxisData), std::move(valuesData)); |
|
197 | return type->createDataSeries(std::move(xAxisData), std::move(valuesData)); | |
193 | } |
|
198 | } | |
194 |
|
199 | |||
195 | IDataSeries* CosinusProvider::getData(const DataProviderParameters ¶meters) |
|
200 | IDataSeries* CosinusProvider::getData(const DataProviderParameters ¶meters) | |
196 | { |
|
201 | { | |
197 | return _generate(parameters.m_Range, parameters.m_Data); |
|
202 | return _generate(parameters.m_Range, parameters.m_Data); | |
198 | } |
|
203 | } | |
199 |
|
204 |
@@ -1,85 +1,85 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the SciQLOP Software |
|
2 | -- This file is a part of the SciQLOP Software | |
3 | -- Copyright (C) 2018, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2018, Plasma Physics Laboratory - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 2 of the License, or |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | -------------------------------------------------------------------------------*/ |
|
18 | -------------------------------------------------------------------------------*/ | |
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 | #include <string> |
|
22 | #include <string> | |
23 | #include <sstream> |
|
23 | #include <sstream> | |
24 | #include <memory> |
|
24 | #include <memory> | |
25 |
|
25 | |||
26 | #include <pybind11/pybind11.h> |
|
26 | #include <pybind11/pybind11.h> | |
27 | #include <pybind11/operators.h> |
|
27 | #include <pybind11/operators.h> | |
28 | #include <pybind11/embed.h> |
|
28 | #include <pybind11/embed.h> | |
29 | #include <pybind11/numpy.h> |
|
29 | #include <pybind11/numpy.h> | |
30 | #include <pybind11/chrono.h> |
|
30 | #include <pybind11/chrono.h> | |
31 |
|
31 | |||
32 | #include <SqpApplication.h> |
|
32 | #include <SqpApplication.h> | |
33 | #include <Variable/VariableController2.h> |
|
33 | #include <Variable/VariableController2.h> | |
34 | #include <Time/TimeController.h> |
|
34 | #include <Time/TimeController.h> | |
35 | #include <Data/DateTimeRange.h> |
|
35 | #include <Data/DateTimeRange.h> | |
36 | #include <Data/DataSeriesType.h> |
|
36 | #include <Data/DataSeriesType.h> | |
37 | #include <Common/DateUtils.h> |
|
37 | #include <Common/DateUtils.h> | |
38 | #include <Variable/Variable.h> |
|
38 | #include <Variable/Variable.h> | |
39 | #include <Data/ScalarSeries.h> |
|
39 | #include <Data/ScalarSeries.h> | |
40 | #include <Data/VectorSeries.h> |
|
40 | #include <Data/VectorSeries.h> | |
41 |
|
41 | |||
42 | #include <MockPlugin.h> |
|
42 | #include <MockPlugin.h> | |
43 | #include <CosinusProvider.h> |
|
43 | #include <CosinusProvider.h> | |
44 |
|
44 | |||
45 | #include <QFile> |
|
45 | #include <QFile> | |
46 |
|
46 | |||
47 | #include <pywrappers_common.h> |
|
47 | #include <pywrappers_common.h> | |
48 | #include <CoreWrappers.h> |
|
48 | #include <CoreWrappers.h> | |
49 |
|
49 | |||
50 |
|
50 | |||
51 |
|
51 | |||
52 | using namespace std::chrono; |
|
52 | using namespace std::chrono; | |
53 | namespace py = pybind11; |
|
53 | namespace py = pybind11; | |
54 |
|
54 | |||
55 |
|
55 | |||
56 |
|
56 | |||
57 | PYBIND11_MODULE(pytestmockplugin, m){ |
|
57 | PYBIND11_MODULE(pytestmockplugin, m){ | |
58 |
|
58 | |||
59 | int argc = 0; |
|
59 | int argc = 0; | |
60 | char ** argv=nullptr; |
|
60 | char ** argv=nullptr; | |
61 | SqpApplication::setOrganizationName("LPP"); |
|
61 | SqpApplication::setOrganizationName("LPP"); | |
62 | SqpApplication::setOrganizationDomain("lpp.fr"); |
|
62 | SqpApplication::setOrganizationDomain("lpp.fr"); | |
63 | SqpApplication::setApplicationName("SciQLop"); |
|
63 | SqpApplication::setApplicationName("SciQLop"); | |
64 | static SqpApplication app(argc, argv); |
|
64 | static SqpApplication app(argc, argv); | |
65 |
|
65 | |||
66 | auto qtmod = py::module::import("sciqlopqt"); |
|
66 | auto qtmod = py::module::import("sciqlopqt"); | |
67 | auto sciqlopmod = py::module::import("pysciqlopcore"); |
|
67 | auto sciqlopmod = py::module::import("pysciqlopcore"); | |
68 |
|
68 | |||
69 | m.doc() = ""; |
|
69 | m.doc() = ""; | |
70 |
|
70 | |||
71 | py::class_<VariableController2>(m, "VariableController2").def_static("createVariable",[](const QString &name, |
|
71 | py::class_<VariableController2>(m, "VariableController2").def_static("createVariable",[](const QString &name, | |
72 | std::shared_ptr<IDataProvider> provider, const DateTimeRange& range){ |
|
72 | std::shared_ptr<IDataProvider> provider, const DateTimeRange& range){ | |
73 |
return sqpApp->variableController().createVariable(name, {{"cosinusType", "spectrogram"}, {"cosinusFrequency", " |
|
73 | return sqpApp->variableController().createVariable(name, {{"cosinusType", "spectrogram"}, {"cosinusFrequency", "0.1"}}, provider, range); | |
74 | }); |
|
74 | }); | |
75 |
|
75 | |||
76 | py::class_<TimeController>(m,"TimeController") |
|
76 | py::class_<TimeController>(m,"TimeController") | |
77 | .def_static("setTime", [](DateTimeRange range){sqpApp->timeController().setDateTimeRange(range);}); |
|
77 | .def_static("setTime", [](DateTimeRange range){sqpApp->timeController().setDateTimeRange(range);}); | |
78 |
|
78 | |||
79 | auto mock_provider = std::make_shared<CosinusProvider>(); |
|
79 | auto mock_provider = std::make_shared<CosinusProvider>(); | |
80 | m.def("mock_provider",[mock_provider](){return mock_provider;}, py::return_value_policy::copy); |
|
80 | m.def("mock_provider",[mock_provider](){return mock_provider;}, py::return_value_policy::copy); | |
81 |
|
81 | |||
82 | py::class_<CosinusProvider, std::shared_ptr<CosinusProvider>, IDataProvider>(m, "CosinusProvider"); |
|
82 | py::class_<CosinusProvider, std::shared_ptr<CosinusProvider>, IDataProvider>(m, "CosinusProvider"); | |
83 |
|
83 | |||
84 | } |
|
84 | } | |
85 |
|
85 |
General Comments 0
You need to be logged in to leave comments.
Login now