1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-14 20:20:35 +00:00

Modified unit-test

This commit is contained in:
piyush0411 2020-06-28 23:14:16 +05:30
parent 8904eab576
commit 40556f7ac1
2 changed files with 329 additions and 88 deletions

View File

@ -100,6 +100,8 @@ void signal_generator_c::init()
ms_counter_.push_back(0);
data_modulation_.push_back((GALILEO_E5A_I_SECONDARY_CODE.at(0) == '0' ? 1 : -1));
pilot_modulation_.push_back((GALILEO_E5A_Q_SECONDARY_CODE[PRN_[sat]].at(0) == '0' ? 1 : -1));
data_modulation_.push_back((GALILEO_E5B_I_SECONDARY_CODE.at(0) == '0' ? 1 : -1));
pilot_modulation_.push_back((GALILEO_E5B_Q_SECONDARY_CODE[PRN_[sat]].at(0) == '0' ? 1 : -1));
if (system_[sat] == "G")
{

View File

@ -21,9 +21,10 @@
#include "concurrent_queue.h"
#include "configuration_interface.h"
#include "fir_filter.h"
#include "galileo_e5b_pcps_acquisition.h"
#include "gnss_block_factory.h"
#include "gen_signal_source.h"
#include "gnss_block_interface.h"
#include "gnss_sdr_valve.h"
#include "gnss_synchro.h"
@ -31,7 +32,7 @@
#include "pass_through.h"
#include "signal_generator.h"
#include "signal_generator_c.h"
#include <boost/make_shared.hpp>
#include "boost/shared_ptr.hpp"
#include <gnuradio/analog/sig_source_waveform.h>
#include <gnuradio/blocks/file_source.h>
#include <gnuradio/blocks/null_sink.h>
@ -39,11 +40,10 @@
#include <gtest/gtest.h>
#include <pmt/pmt.h>
#include <chrono>
#include <cstdlib>
#include <utility>
#include <thread>
#if HAS_GENERIC_LAMBDA
#else
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#endif
#ifdef GR_GREATER_38
#include <gnuradio/analog/sig_source.h>
@ -51,24 +51,25 @@
#include <gnuradio/analog/sig_source_c.h>
#endif
// ######## GNURADIO BLOCK MESSAGE RECEVER #########
class GalileoE5bPcpsAcquisitionTest_msg_rx;
#if GNURADIO_USES_STD_POINTERS
using GalileoE5bPcpsAcquisitionTest_msg_rx_sptr = std::shared_ptr<GalileoE5bPcpsAcquisitionTest_msg_rx>;
typedef std::shared_ptr<GalileoE5bPcpsAcquisitionTest_msg_rx> GalileoE5bPcpsAcquisitionTest_msg_rx_sptr;
#else
using GalileoE5bPcpsAcquisitionTest_msg_rx_sptr = boost::shared_ptr<GalileoE5bPcpsAcquisitionTest_msg_rx>;
typedef boost::shared_ptr<GalileoE5bPcpsAcquisitionTest_msg_rx> GalileoE5bPcpsAcquisitionTest_msg_rx_sptr;
#endif
GalileoE5bPcpsAcquisitionTest_msg_rx_sptr GalileoE5bPcpsAcquisitionTest_msg_rx_make();
GalileoE5bPcpsAcquisitionTest_msg_rx_sptr GalileoE5bPcpsAcquisitionTest_msg_rx_make(Concurrent_Queue<int>& queue);
class GalileoE5bPcpsAcquisitionTest_msg_rx : public gr::block
{
private:
friend GalileoE5bPcpsAcquisitionTest_msg_rx_sptr GalileoE5bPcpsAcquisitionTest_msg_rx_make();
friend GalileoE5bPcpsAcquisitionTest_msg_rx_sptr GalileoE5bPcpsAcquisitionTest_msg_rx_make(Concurrent_Queue<int>& queue);
void msg_handler_events(pmt::pmt_t msg);
GalileoE5bPcpsAcquisitionTest_msg_rx();
explicit GalileoE5bPcpsAcquisitionTest_msg_rx(Concurrent_Queue<int>& queue);
Concurrent_Queue<int>& channel_internal_queue;
public:
int rx_message;
@ -76,9 +77,9 @@ public:
};
GalileoE5bPcpsAcquisitionTest_msg_rx_sptr GalileoE5bPcpsAcquisitionTest_msg_rx_make()
GalileoE5bPcpsAcquisitionTest_msg_rx_sptr GalileoE5bPcpsAcquisitionTest_msg_rx_make(Concurrent_Queue<int>& queue)
{
return GalileoE5bPcpsAcquisitionTest_msg_rx_sptr(new GalileoE5bPcpsAcquisitionTest_msg_rx());
return GalileoE5bPcpsAcquisitionTest_msg_rx_sptr(new GalileoE5bPcpsAcquisitionTest_msg_rx(queue));
}
@ -86,25 +87,26 @@ void GalileoE5bPcpsAcquisitionTest_msg_rx::msg_handler_events(pmt::pmt_t msg)
{
try
{
int64_t message = pmt::to_long(std::move(msg));
int64_t message = pmt::to_long(msg);
rx_message = message;
channel_internal_queue.push(rx_message);
}
catch (boost::bad_any_cast& e)
{
std::cout << "msg_handler_telemetry Bad any cast!" << std::endl;
LOG(WARNING) << "msg_handler_telemetry Bad any cast!";
rx_message = 0;
}
}
GalileoE5bPcpsAcquisitionTest_msg_rx::GalileoE5bPcpsAcquisitionTest_msg_rx() : gr::block("GalileoE5bPcpsAcquisitionTest_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0))
GalileoE5bPcpsAcquisitionTest_msg_rx::GalileoE5bPcpsAcquisitionTest_msg_rx(Concurrent_Queue<int>& queue) : gr::block("GalileoE5bPcpsAcquisitionTest_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue)
{
this->message_port_register_in(pmt::mp("events"));
this->set_msg_handler(pmt::mp("events"),
#if HAS_GENERIC_LAMBDA
[this](pmt::pmt_t&& PH1) { msg_handler_events(PH1); });
[this](auto&& PH1) { msg_handler_events(PH1); });
#else
#if BOOST_173_OR_GREATER
#if USE_BOOST_BIND_PLACEHOLDERS
boost::bind(&GalileoE5bPcpsAcquisitionTest_msg_rx::msg_handler_events, this, boost::placeholders::_1));
#else
boost::bind(&GalileoE5bPcpsAcquisitionTest_msg_rx::msg_handler_events, this, _1));
@ -114,7 +116,9 @@ GalileoE5bPcpsAcquisitionTest_msg_rx::GalileoE5bPcpsAcquisitionTest_msg_rx() : g
}
GalileoE5bPcpsAcquisitionTest_msg_rx::~GalileoE5bPcpsAcquisitionTest_msg_rx() = default;
GalileoE5bPcpsAcquisitionTest_msg_rx::~GalileoE5bPcpsAcquisitionTest_msg_rx()
{
}
// ###########################################################
@ -124,46 +128,109 @@ class GalileoE5bPcpsAcquisitionTest : public ::testing::Test
protected:
GalileoE5bPcpsAcquisitionTest()
{
factory = std::make_shared<GNSSBlockFactory>();
config = std::make_shared<InMemoryConfiguration>();
item_size = sizeof(gr_complex);
stop = false;
message = 0;
gnss_synchro = Gnss_Synchro();
acquisition = 0;
init();
}
~GalileoE5bPcpsAcquisitionTest() = default;
~GalileoE5bPcpsAcquisitionTest()
{
}
void init();
void config_1();
void config_2();
void start_queue();
void wait_message();
void process_message();
void stop_queue();
Concurrent_Queue<int> channel_internal_queue;
std::shared_ptr<Concurrent_Queue<pmt::pmt_t> > queue;
gr::top_block_sptr top_block;
std::shared_ptr<GNSSBlockFactory> factory;
std::shared_ptr<GalileoE5bPcpsAcquisition> acquisition;
std::shared_ptr<InMemoryConfiguration> config;
Gnss_Synchro gnss_synchro;
size_t item_size;
bool stop;
int message;
std::thread ch_thread;
unsigned int integration_time_ms = 0;
unsigned int fs_in = 0;
double expected_delay_chips = 0.0;
double expected_doppler_hz = 0.0;
float max_doppler_error_hz = 0.0;
float max_delay_error_chips = 0.0;
unsigned int num_of_realizations = 0;
unsigned int realization_counter;
unsigned int detection_counter;
unsigned int correct_estimation_counter;
unsigned int acquired_samples;
unsigned int mean_acq_time_us;
double mse_doppler;
double mse_delay;
};
void GalileoE5bPcpsAcquisitionTest::init()
{
message = 0;
realization_counter = 0;
detection_counter = 0;
correct_estimation_counter = 0;
acquired_samples = 0;
mse_doppler = 0;
mse_delay = 0;
mean_acq_time_us = 0;
}
void GalileoE5bPcpsAcquisitionTest::config_1()
{
gnss_synchro.Channel_ID = 0;
gnss_synchro.System = 'E';
std::string signal = "7X";
signal.copy(gnss_synchro.Signal, 2, 0);
gnss_synchro.PRN = 1;
integration_time_ms = 1;
fs_in = 32e6;
expected_delay_chips = 255;
expected_doppler_hz = -1500;
max_doppler_error_hz = 2 / (3 * integration_time_ms * 1e-3);
max_delay_error_chips = 0.50;
num_of_realizations = 1;
config = std::make_shared<InMemoryConfiguration>();
config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(fs_in));
config->set_property("SignalSource.fs_hz", std::to_string(fs_in));
config->set_property("SignalSource.item_type", "gr_complex");
config->set_property("SignalSource.num_satellites", "1");
config->set_property("SignalSource.system_0", "E");
config->set_property("SignalSource.signal_0", "7X");
config->set_property("SignalSource.PRN_0", "11");
config->set_property("SignalSource.CN0_dB_0", "50");
config->set_property("SignalSource.doppler_Hz_0", std::to_string(1000));
config->set_property("SignalSource.delay_chips_0", std::to_string(50));
config->set_property("SignalSource.delay_sec_0", std::to_string(94));
config->set_property("SignalSource.PRN_0", "10");
config->set_property("SignalSource.CN0_dB_0", "44");
config->set_property("SignalSource.doppler_Hz_0", std::to_string(expected_doppler_hz));
config->set_property("SignalSource.delay_chips_0", std::to_string(expected_delay_chips));
config->set_property("SignalSource.noise_flag", "false");
config->set_property("SignalSource.data_flag", "false");
config->set_property("SignalSource.BW_BB", "0.97");
config->set_property("SignalSource.dump", "false");
config->set_property("SignalSource.dump_filename", "../data/signal_source.dat");
config->set_property("GNSS-SDR.internal_fs_sps", "4000000");
config->set_property("InputFilter.implementation", "Fir_Filter");
config->set_property("InputFilter.input_item_type", "gr_complex");
config->set_property("InputFilter.output_item_type", "gr_complex");
@ -182,46 +249,204 @@ void GalileoE5bPcpsAcquisitionTest::init()
config->set_property("InputFilter.band2_error", "1.0");
config->set_property("InputFilter.filter_type", "bandpass");
config->set_property("InputFilter.grid_density", "16");
config->set_property("Acquisition_7X.item_type", "gr_complex");
config->set_property("Acquisition_7X.coherent_integration_time_ms", "1");
config->set_property("Acquisition_7X.dump", "true");
config->set_property("Acquisition_7X.dump_filename", "./acquisition");
config->set_property("Acquisition_7X.coherent_integration_time_ms",
std::to_string(integration_time_ms));
//config->set_property("Acquisition_7X.max_dwells", "1");
config->set_property("Acquisition_7X.implementation", "Galileo_E5b_PCPS_Acquisition");
config->set_property("Acquisition_7X.threshold", "0.001");
config->set_property("Acquisition_7X.threshold", "0.8");
config->set_property("Acquisition_7X.doppler_max", "10000");
config->set_property("Acquisition_7X.doppler_step", "250");
config->set_property("Acquisition_7X.repeat_satellite", "false");
config->set_property("Acquisition_7X.bit_transition_flag", "false");
config->set_property("Acquisition_7X.dump", "false");
}
void GalileoE5bPcpsAcquisitionTest::config_2()
{
gnss_synchro.Channel_ID = 0;
gnss_synchro.System = 'E';
std::string signal = "7X";
signal.copy(gnss_synchro.Signal, 2, 0);
integration_time_ms = 1;
fs_in = 31.75e6;
expected_delay_chips = 374;
expected_doppler_hz = -2000;
max_doppler_error_hz = 2 / (3 * integration_time_ms * 1e-3);
max_delay_error_chips = 0.50;
num_of_realizations = 100;
config = std::make_shared<InMemoryConfiguration>();
config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(fs_in));
config->set_property("SignalSource.fs_hz", std::to_string(fs_in));
config->set_property("SignalSource.item_type", "gr_complex");
config->set_property("SignalSource.num_satellites", "4");
config->set_property("SignalSource.system_0", "E");
config->set_property("SignalSource.signal_0", "7X");
config->set_property("SignalSource.PRN_0", "10");
config->set_property("SignalSource.CN0_dB_0", "44");
config->set_property("SignalSource.doppler_Hz_0", std::to_string(expected_doppler_hz));
config->set_property("SignalSource.delay_chips_0", std::to_string(expected_delay_chips));
config->set_property("SignalSource.system_0", "E");
config->set_property("SignalSource.signal_0", "7X");
config->set_property("SignalSource.PRN_1", "15");
config->set_property("SignalSource.CN0_dB_1", "44");
config->set_property("SignalSource.doppler_Hz_1", "1000");
config->set_property("SignalSource.delay_chips_1", "100");
config->set_property("SignalSource.system_0", "E");
config->set_property("SignalSource.signal_0", "7X");
config->set_property("SignalSource.PRN_2", "21");
config->set_property("SignalSource.CN0_dB_2", "44");
config->set_property("SignalSource.doppler_Hz_2", "2000");
config->set_property("SignalSource.delay_chips_2", "200");
config->set_property("SignalSource.system_0", "E");
config->set_property("SignalSource.signal_0", "7X");
config->set_property("SignalSource.PRN_3", "22");
config->set_property("SignalSource.CN0_dB_3", "44");
config->set_property("SignalSource.doppler_Hz_3", "3000");
config->set_property("SignalSource.delay_chips_3", "300");
config->set_property("SignalSource.noise_flag", "true");
config->set_property("SignalSource.data_flag", "true");
config->set_property("SignalSource.BW_BB", "0.97");
config->set_property("InputFilter.implementation", "Fir_Filter");
config->set_property("InputFilter.input_item_type", "gr_complex");
config->set_property("InputFilter.output_item_type", "gr_complex");
config->set_property("InputFilter.taps_item_type", "float");
config->set_property("InputFilter.number_of_taps", "11");
config->set_property("InputFilter.number_of_bands", "2");
config->set_property("InputFilter.band1_begin", "0.0");
config->set_property("InputFilter.band1_end", "0.97");
config->set_property("InputFilter.band2_begin", "0.98");
config->set_property("InputFilter.band2_end", "1.0");
config->set_property("InputFilter.ampl1_begin", "1.0");
config->set_property("InputFilter.ampl1_end", "1.0");
config->set_property("InputFilter.ampl2_begin", "0.0");
config->set_property("InputFilter.ampl2_end", "0.0");
config->set_property("InputFilter.band1_error", "1.0");
config->set_property("InputFilter.band2_error", "1.0");
config->set_property("InputFilter.filter_type", "bandpass");
config->set_property("InputFilter.grid_density", "16");
config->set_property("Acquisition_7X.item_type", "gr_complex");
config->set_property("Acquisition_7X.coherent_integration_time_ms",
std::to_string(integration_time_ms));
//config->set_property("Acquisition_7X.max_dwells", "1");
config->set_property("Acquisition_7X.implementation", "Galileo_E5b_PCPS_Acquisition");
//config->set_property("Acquisition_7X.pfa", "0.01");
config->set_property("Acquisition_7X.doppler_max", "10000");
config->set_property("Acquisition_7X.doppler_step", "250");
config->set_property("Acquisition_7X.bit_transition_flag", "false");
config->set_property("Acquisition_7X.dump", "false");
}
void GalileoE5bPcpsAcquisitionTest::start_queue()
{
stop = false;
ch_thread = std::thread(&GalileoE5bPcpsAcquisitionTest::wait_message, this);
}
void GalileoE5bPcpsAcquisitionTest::wait_message()
{
struct timeval tv;
int64_t begin = 0;
int64_t end = 0;
while (!stop)
{
acquisition->reset();
gettimeofday(&tv, NULL);
begin = tv.tv_sec * 1e6 + tv.tv_usec;
channel_internal_queue.wait_and_pop(message);
gettimeofday(&tv, NULL);
end = tv.tv_sec * 1e6 + tv.tv_usec;
mean_acq_time_us += (end - begin);
process_message();
}
}
void GalileoE5bPcpsAcquisitionTest::process_message()
{
if (message == 1)
{
detection_counter++;
// The term -5 is here to correct the additional delay introduced by the FIR filter
// The value 511.0 must be a variable, chips/length
double delay_error_chips = std::abs(static_cast<double>(expected_delay_chips) - (static_cast<double>(gnss_synchro.Acq_delay_samples) - 5.0) * 10230.0 / (static_cast<double>(fs_in) * 1e-3));
double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz);
mse_delay += std::pow(delay_error_chips, 2);
mse_doppler += std::pow(doppler_error_hz, 2);
if ((delay_error_chips < max_delay_error_chips) && (doppler_error_hz < max_doppler_error_hz))
{
correct_estimation_counter++;
}
}
realization_counter++;
std::cout << "Progress: " << round(static_cast<float>(realization_counter) / static_cast<float>(num_of_realizations) * 100.0) << "% \r" << std::flush;
if (realization_counter == num_of_realizations)
{
mse_delay /= num_of_realizations;
mse_doppler /= num_of_realizations;
mean_acq_time_us /= num_of_realizations;
stop_queue();
top_block->stop();
}
}
void GalileoE5bPcpsAcquisitionTest::stop_queue()
{
stop = true;
}
TEST_F(GalileoE5bPcpsAcquisitionTest, Instantiate)
{
init();
#if GNURADIO_USES_STD_POINTERS
std::shared_ptr<GalileoE5bPcpsAcquisition> acquisition = std::make_shared<GalileoE5bPcpsAcquisition>(config.get(), "Acquisition_7X", 1, 0);
#else
boost::shared_ptr<GalileoE5bPcpsAcquisition> acquisition = boost::make_shared<GalileoE5bPcpsAcquisition>(config.get(), "Acquisition_7X", 1, 0);
#endif
config_1();
acquisition = std::make_shared<GalileoE5bPcpsAcquisition>(config.get(), "Acquisition", 1, 0);
}
TEST_F(GalileoE5bPcpsAcquisitionTest, ConnectAndRun)
{
int fs_in = 4000000;
int nsamples = 4000;
int nsamples = floor(fs_in * integration_time_ms * 1e-3);
std::chrono::time_point<std::chrono::system_clock> begin, end;
std::chrono::duration<double> elapsed_seconds(0);
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue = std::make_shared<Concurrent_Queue<pmt::pmt_t>>();
queue = std::make_shared<Concurrent_Queue<pmt::pmt_t> >();
top_block = gr::make_top_block("Acquisition test");
init();
#if GNURADIO_USES_STD_POINTERS
std::shared_ptr<GalileoE5bPcpsAcquisition> acquisition = std::make_shared<GalileoE5bPcpsAcquisition>(config.get(), "Acquisition_7X", 1, 0);
#else
boost::shared_ptr<GalileoE5bPcpsAcquisition> acquisition = boost::make_shared<GalileoE5bPcpsAcquisition>(config.get(), "Acquisition_7X", 1, 0);
#endif
auto msg_rx = GalileoE5bPcpsAcquisitionTest_msg_rx_make();
config_1();
acquisition = std::make_shared<GalileoE5bPcpsAcquisition>(config.get(), "Acquisition_7X", 1, 0);
auto msg_rx = GalileoE5bPcpsAcquisitionTest_msg_rx_make(channel_internal_queue);
ASSERT_NO_THROW({
acquisition->connect(top_block);
@ -245,20 +470,15 @@ TEST_F(GalileoE5bPcpsAcquisitionTest, ConnectAndRun)
TEST_F(GalileoE5bPcpsAcquisitionTest, ValidationOfResults)
{
std::chrono::time_point<std::chrono::system_clock> begin, end;
std::chrono::duration<double> elapsed_seconds(0);
config_1();
queue = std::make_shared<Concurrent_Queue<pmt::pmt_t> >();
top_block = gr::make_top_block("Acquisition test");
double expected_delay_samples = 2920;
double expected_doppler_hz = -632;
init();
std::shared_ptr<GalileoE5bPcpsAcquisition> acquisition = std::make_shared<GalileoE5bPcpsAcquisition>(config.get(), "Acquisition_7X", 1, 0);
std::shared_ptr<FirFilter> input_filter = std::make_shared<FirFilter>(config.get(), "InputFilter", 1, 1);
auto msg_rx = GalileoE5bPcpsAcquisitionTest_msg_rx_make();
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue = std::make_shared<Concurrent_Queue<pmt::pmt_t>>();
acquisition = std::make_shared<GalileoE5bPcpsAcquisition>(config.get(), "Acquisition_7X", 1, 0);
auto msg_rx = GalileoE5bPcpsAcquisitionTest_msg_rx_make(channel_internal_queue);
ASSERT_NO_THROW({
acquisition->set_channel(1);
acquisition->set_channel(0);
}) << "Failure setting channel.";
ASSERT_NO_THROW({
@ -266,51 +486,70 @@ TEST_F(GalileoE5bPcpsAcquisitionTest, ValidationOfResults)
}) << "Failure setting gnss_synchro.";
ASSERT_NO_THROW({
acquisition->set_threshold(0.001);
}) << "Failure setting threshold.";
ASSERT_NO_THROW({
acquisition->set_doppler_max(5000);
acquisition->set_doppler_max(10000);
}) << "Failure setting doppler_max.";
ASSERT_NO_THROW({
acquisition->set_doppler_step(100);
acquisition->set_doppler_step(500);
}) << "Failure setting doppler_step.";
ASSERT_NO_THROW({
acquisition->set_threshold(0.0005);
}) << "Failure setting threshold.";
ASSERT_NO_THROW({
acquisition->connect(top_block);
top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events"));
}) << "Failure connecting acquisition to the top_block.";
acquisition->set_local_code();
acquisition->set_state(1); // Ensure that acquisition starts at the first sample
acquisition->init();
ASSERT_NO_THROW({
std::shared_ptr<GNSSBlockInterface> signal_generator = std::make_shared<SignalGenerator>(config.get(), "SignalSource", 0, 1, queue.get());
std::shared_ptr<GNSSBlockInterface> filter = std::make_shared<FirFilter>(config.get(), "InputFilter", 1, 1);
std::shared_ptr<GNSSBlockInterface> signal_source = std::make_shared<GenSignalSource>(signal_generator, filter, "SignalSource", queue.get());
filter->connect(top_block);
signal_source->connect(top_block);
top_block->connect(signal_source->get_right_block(), 0, acquisition->get_left_block(), 0);
top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events"));
}) << "Failure connecting the blocks of acquisition test.";
EXPECT_NO_THROW({
begin = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
end = std::chrono::system_clock::now();
elapsed_seconds = end - begin;
}) << "Failure running the top_block.";
// i = 0 --> satellite in acquisition is visible
// i = 1 --> satellite in acquisition is not visible
for (unsigned int i = 0; i < 2; i++)
{
init();
uint64_t nsamples = gnss_synchro.Acq_samplestamp_samples;
std::cout << "Acquired " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
if (i == 0)
{
gnss_synchro.PRN = 11; // This satellite is visible
}
else if (i == 1)
{
gnss_synchro.PRN = 19; // This satellite is not visible
}
ASSERT_EQ(1, msg_rx->rx_message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS.";
acquisition->set_local_code();
acquisition->set_state(1); // Ensure that acquisition starts at the first sample
start_queue();
double delay_error_samples = std::abs(expected_delay_samples - gnss_synchro.Acq_delay_samples);
float delay_error_chips = static_cast<float>(delay_error_samples) * 10230.0 / 4000.0;
double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz);
EXPECT_NO_THROW({
top_block->run(); // Start threads and wait
}) << "Failure running the top_block.";
EXPECT_LE(doppler_error_hz, 666) << "Doppler error exceeds the expected value: 666 Hz = 2/(3*integration period)";
EXPECT_LT(delay_error_chips, 0.5) << "Delay error exceeds the expected value: 0.5 chips";
if (i == 0)
{
EXPECT_EQ(1, message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS.";
if (message == 1)
{
EXPECT_EQ(static_cast<unsigned int>(0), correct_estimation_counter) << "Acquisition failure. Incorrect parameters estimation.";
}
}
else if (i == 1)
{
EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL.";
}
ASSERT_NO_THROW({
ch_thread.join();
}) << "Failure while waiting the queue to stop";
}
}