2018-02-03 09:49:03 +00:00
|
|
|
/*!
|
|
|
|
* \file mmse_resampler_test.cc
|
|
|
|
* \brief Executes a resampler based on some input parameters.
|
|
|
|
* \author Carles Fernandez-Prades 2018 cfernandez (at) cttc.cat
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*
|
2019-07-26 10:38:20 +00:00
|
|
|
* Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)
|
2018-02-03 09:49:03 +00:00
|
|
|
*
|
|
|
|
* GNSS-SDR is a software defined Global Navigation
|
|
|
|
* Satellite Systems receiver
|
|
|
|
*
|
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2018-02-03 09:49:03 +00:00
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gnuradio/analog/sig_source_waveform.h>
|
2018-12-09 21:00:09 +00:00
|
|
|
#include <gnuradio/top_block.h>
|
|
|
|
#include <chrono>
|
2018-08-31 11:52:35 +00:00
|
|
|
#ifdef GR_GREATER_38
|
|
|
|
#include <gnuradio/analog/sig_source.h>
|
|
|
|
#else
|
2018-02-03 09:49:03 +00:00
|
|
|
#include <gnuradio/analog/sig_source_c.h>
|
2018-08-31 11:52:35 +00:00
|
|
|
#endif
|
2019-07-18 17:29:14 +00:00
|
|
|
#include "concurrent_queue.h"
|
2018-02-03 09:49:03 +00:00
|
|
|
#include "gnss_sdr_valve.h"
|
|
|
|
#include "mmse_resampler_conditioner.h"
|
2018-12-09 21:00:09 +00:00
|
|
|
#include <gnuradio/blocks/null_sink.h>
|
2018-02-03 09:49:03 +00:00
|
|
|
|
|
|
|
TEST(MmseResamplerTest, InstantiationAndRunTestWarning)
|
|
|
|
{
|
2018-03-03 01:03:39 +00:00
|
|
|
double fs_in = 8000000.0; // Input sampling frequency in Hz
|
|
|
|
double fs_out = 4000000.0; // sampling freuqncy of the resampled signal in Hz
|
2018-02-03 09:49:03 +00:00
|
|
|
std::chrono::time_point<std::chrono::system_clock> start, end;
|
|
|
|
std::chrono::duration<double> elapsed_seconds(0);
|
2019-08-18 23:29:04 +00:00
|
|
|
int nsamples = 1000000; // Number of samples to be computed
|
2020-06-18 09:49:28 +00:00
|
|
|
auto queue = std::make_shared<Concurrent_Queue<pmt::pmt_t>>();
|
|
|
|
auto top_block = gr::make_top_block("mmse_resampler_conditioner_cc_test");
|
2020-04-02 21:59:35 +00:00
|
|
|
auto source = gr::analog::sig_source_c::make(fs_in, gr::analog::GR_SIN_WAVE, 1000.0, 1.0, gr_complex(0.0));
|
2020-06-18 09:49:28 +00:00
|
|
|
auto valve = gnss_sdr_make_valve(sizeof(gr_complex), nsamples, queue.get());
|
2018-02-03 09:49:03 +00:00
|
|
|
|
|
|
|
std::shared_ptr<InMemoryConfiguration> config;
|
|
|
|
config = std::make_shared<InMemoryConfiguration>();
|
|
|
|
|
|
|
|
config->set_property("Resampler.sample_freq_in", std::to_string(fs_in));
|
|
|
|
config->set_property("Resampler.sample_freq_out", std::to_string(fs_out));
|
|
|
|
|
2020-06-18 09:49:28 +00:00
|
|
|
auto resampler = std::make_shared<MmseResamplerConditioner>(config.get(), "Resampler", 1, 1);
|
2018-02-03 09:49:03 +00:00
|
|
|
|
2020-06-18 09:49:28 +00:00
|
|
|
auto sink = gr::blocks::null_sink::make(sizeof(gr_complex));
|
2018-02-03 09:49:03 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
EXPECT_NO_THROW({
|
2018-02-03 09:49:03 +00:00
|
|
|
resampler->connect(top_block);
|
|
|
|
top_block->connect(source, 0, valve, 0);
|
|
|
|
top_block->connect(valve, 0, resampler->get_left_block(), 0);
|
|
|
|
top_block->connect(resampler->get_right_block(), 0, sink, 0);
|
|
|
|
}) << "Connection failure of direct_resampler_conditioner.";
|
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
EXPECT_NO_THROW({
|
2018-02-03 09:49:03 +00:00
|
|
|
start = std::chrono::system_clock::now();
|
2018-03-03 01:03:39 +00:00
|
|
|
top_block->run(); // Start threads and wait
|
2018-02-03 09:49:03 +00:00
|
|
|
end = std::chrono::system_clock::now();
|
|
|
|
elapsed_seconds = end - start;
|
|
|
|
top_block->stop();
|
|
|
|
}) << "Failure running direct_resampler_conditioner.";
|
|
|
|
|
2020-07-07 16:53:50 +00:00
|
|
|
std::cout << "Resampled " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds\n";
|
2018-02-03 09:49:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(MmseResamplerTest, InstantiationAndRunTest2)
|
|
|
|
{
|
2018-03-03 01:03:39 +00:00
|
|
|
double fs_in = 8000000.0; // Input sampling frequency in Hz
|
|
|
|
double fs_out = 4000000.0; // sampling freuqncy of the resampled signal in Hz
|
2018-02-03 09:49:03 +00:00
|
|
|
std::chrono::time_point<std::chrono::system_clock> start, end;
|
|
|
|
std::chrono::duration<double> elapsed_seconds(0);
|
2019-08-18 23:29:04 +00:00
|
|
|
int nsamples = 1000000; // Number of samples to be computed
|
2020-06-18 09:49:28 +00:00
|
|
|
auto queue = std::make_shared<Concurrent_Queue<pmt::pmt_t>>();
|
|
|
|
auto top_block = gr::make_top_block("mmse_resampler_conditioner_cc_test");
|
2020-04-02 21:59:35 +00:00
|
|
|
auto source = gr::analog::sig_source_c::make(fs_in, gr::analog::GR_SIN_WAVE, 1000.0, 1.0, gr_complex(0.0));
|
2020-06-18 09:49:28 +00:00
|
|
|
auto valve = gnss_sdr_make_valve(sizeof(gr_complex), nsamples, queue.get());
|
2018-02-03 09:49:03 +00:00
|
|
|
|
|
|
|
std::shared_ptr<InMemoryConfiguration> config;
|
|
|
|
config = std::make_shared<InMemoryConfiguration>();
|
|
|
|
|
|
|
|
config->set_property("Resampler.sample_freq_in", std::to_string(fs_in));
|
|
|
|
config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(fs_out));
|
|
|
|
|
2020-06-18 09:49:28 +00:00
|
|
|
auto resampler = std::make_shared<MmseResamplerConditioner>(config.get(), "Resampler", 1, 1);
|
2018-02-03 09:49:03 +00:00
|
|
|
|
2020-06-18 09:49:28 +00:00
|
|
|
auto sink = gr::blocks::null_sink::make(sizeof(gr_complex));
|
2018-02-03 09:49:03 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
EXPECT_NO_THROW({
|
2018-02-03 09:49:03 +00:00
|
|
|
resampler->connect(top_block);
|
|
|
|
top_block->connect(source, 0, valve, 0);
|
|
|
|
top_block->connect(valve, 0, resampler->get_left_block(), 0);
|
|
|
|
top_block->connect(resampler->get_right_block(), 0, sink, 0);
|
|
|
|
}) << "Connection failure of direct_resampler_conditioner.";
|
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
EXPECT_NO_THROW({
|
2018-02-03 09:49:03 +00:00
|
|
|
start = std::chrono::system_clock::now();
|
2018-03-03 01:03:39 +00:00
|
|
|
top_block->run(); // Start threads and wait
|
2018-02-03 09:49:03 +00:00
|
|
|
end = std::chrono::system_clock::now();
|
|
|
|
elapsed_seconds = end - start;
|
|
|
|
top_block->stop();
|
|
|
|
}) << "Failure running direct_resampler_conditioner.";
|
|
|
|
|
2020-07-07 16:53:50 +00:00
|
|
|
std::cout << "Resampled " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds\n";
|
2018-02-03 09:49:03 +00:00
|
|
|
}
|