##// END OF EJS Templates
Ported MockPlugin to new Variable2 impl and added dummy python plugin...
Ported MockPlugin to new Variable2 impl and added dummy python plugin Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>

File last commit:

r1423:31110df2feb2
r1423:31110df2feb2
Show More
CosinusProvider.cpp
87 lines | 2.7 KiB | text/x-c | CppLexer
Alexandre Leroux
Creates a default provider that will be returned by the mock plugin
r128 #include "CosinusProvider.h"
Alexandre Leroux
Handles parametric frequency
r782 #include "MockDefs.h"
Alexandre Leroux
Creates a default provider that will be returned by the mock plugin
r128
#include <Data/DataProviderParameters.h>
Ported MockPlugin to new Variable2 impl and added dummy python plugin...
r1423 #include <Data/ScalarTimeSerie.h>
#include <Data/SpectrogramTimeSerie.h>
#include <Data/VectorTimeSerie.h>
Alexandre Leroux
Creates a default provider that will be returned by the mock plugin
r128
Add cmath header missing
r135 #include <cmath>
Alexandre Leroux
Introduces NaN and zero values in data of the mock spectrogram...
r922 #include <set>
Add cmath header missing
r135
Add DownloadProgress emission for mock plugin
r428 #include <QFuture>
Add current progression for thread fix
r364 #include <QThread>
Add DownloadProgress emission for mock plugin
r428 #include <QtConcurrent/QtConcurrent>
Fix the cosinus bug....
r298
The cosinus provider can now handle data request
r231
Ported MockPlugin to new Variable2 impl and added dummy python plugin...
r1423 namespace
{
Alexandre Leroux
Generates vectors (1)...
r784
Alexandre Leroux
Initializes spectrogram management in the plugin...
r895 /// Number of bands generated for a spectrogram
const auto SPECTROGRAM_NUMBER_BANDS = 30;
Alexandre Leroux
Introduces NaN and zero values in data of the mock spectrogram...
r922 /// Bands for which to generate NaN values for a spectrogram
Ported MockPlugin to new Variable2 impl and added dummy python plugin...
r1423 const auto SPECTROGRAM_NAN_BANDS = std::set<int> { 1, 3, 10, 20 };
Alexandre Leroux
Introduces NaN and zero values in data of the mock spectrogram...
r922
/// Bands for which to generate zeros for a spectrogram
Ported MockPlugin to new Variable2 impl and added dummy python plugin...
r1423 const auto SPECTROGRAM_ZERO_BANDS = std::set<int> { 2, 15, 19, 29 };
Alexandre Leroux
Generates vectors (2)...
r785
Alexandre Leroux
Generates vectors (3)...
r786
Alexandre Leroux
Generates vectors (1)...
r784 } // namespace
Alexandre Leroux
Generates and registers clone provider
r712 std::shared_ptr<IDataProvider> CosinusProvider::clone() const
{
// No copy is made in clone
return std::make_shared<CosinusProvider>();
}
Ported MockPlugin to new Variable2 impl and added dummy python plugin...
r1423 TimeSeries::ITimeSerie* CosinusProvider::_generate(
const DateTimeRange& range, const QVariantHash& metaData)
Ported Mock plugin to new IDataProvider interface compatible with...
r1350 {
// Retrieves cosinus type
auto typeVariant = metaData.value(COSINUS_TYPE_KEY, COSINUS_TYPE_DEFAULT_VALUE);
auto freqVariant = metaData.value(COSINUS_FREQUENCY_KEY, COSINUS_FREQUENCY_DEFAULT_VALUE);
Ported MockPlugin to new Variable2 impl and added dummy python plugin...
r1423 const auto fs = 200.;
Ported Mock plugin to new IDataProvider interface compatible with...
r1350 double freq = freqVariant.toDouble();
double start = std::ceil(range.m_TStart * freq);
double end = std::floor(range.m_TEnd * freq);
Ported MockPlugin to new Variable2 impl and added dummy python plugin...
r1423 if (end < start)
{
Ported Mock plugin to new IDataProvider interface compatible with...
r1350 std::swap(start, end);
}
std::size_t dataCount = static_cast<std::size_t>(end - start + 1);
Ported MockPlugin to new Variable2 impl and added dummy python plugin...
r1423 if (typeVariant.toString() == QStringLiteral("scalar"))
Ported Mock plugin to new IDataProvider interface compatible with...
r1350 {
Ported MockPlugin to new Variable2 impl and added dummy python plugin...
r1423 auto ts = new ScalarTimeSerie(dataCount);
std::generate(
std::begin(*ts), std::end(*ts), [range, freq, fs, dt = 1. / freq, i = 0.]() mutable {
auto t = range.m_TStart + i * dt;
i++;
return std::pair<double, double> { t, std::cos(2 * 3.14 * freq / fs * t) };
});
return ts;
Ported Mock plugin to new IDataProvider interface compatible with...
r1350 }
Ported MockPlugin to new Variable2 impl and added dummy python plugin...
r1423 if (typeVariant.toString() == QStringLiteral("vector"))
{
auto ts = new VectorTimeSerie(dataCount);
std::generate(
std::begin(*ts), std::end(*ts), [range, freq, fs, dt = 1. / freq, i = 0.]() mutable {
auto t = range.m_TStart + i * dt;
i++;
return std::pair<double, VectorTimeSerie::raw_value_type> { t,
{ std::cos(2 * 3.14 * freq / fs * t), std::sin(2 * 3.14 * freq / fs * t),
std::cos(2 * 3.14 * freq / fs * t) * std::sin(2 * 3.14 * freq / fs * t) } };
});
return ts;
}
if (typeVariant.toString() == QStringLiteral("spectrogram"))
{
return nullptr;
}
return nullptr;
Alexandre Leroux
Creates a default provider that will be returned by the mock plugin
r128 }
Alexandre Leroux
Use std::shared_ptr in CosinusProvider
r310
Ported MockPlugin to new Variable2 impl and added dummy python plugin...
r1423 TimeSeries::ITimeSerie* CosinusProvider::getData(const DataProviderParameters& parameters)
Ported Mock plugin to new IDataProvider interface compatible with...
r1350 {
[WIP] new generic WS plugin and few other fixes...
r1352 return _generate(parameters.m_Range, parameters.m_Data);
Ported Mock plugin to new IDataProvider interface compatible with...
r1350 }