1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-28 09:54:51 +00:00

Replacing some raw pointers by smart pointers

This commit is contained in:
Carles Fernandez 2014-04-24 00:52:11 +02:00
parent 75aee95bde
commit 6e20c9f8c6
2 changed files with 167 additions and 146 deletions

View File

@ -45,9 +45,9 @@
#include "in_memory_configuration.h" #include "in_memory_configuration.h"
#include "gnss_sdr_valve.h" #include "gnss_sdr_valve.h"
#include "gnss_synchro.h" #include "gnss_synchro.h"
#include "galileo_e1_dll_pll_veml_tracking.h" #include "galileo_e1_dll_pll_veml_tracking.h"
class GalileoE1DllPllVemlTrackingInternalTest: public ::testing::Test class GalileoE1DllPllVemlTrackingInternalTest: public ::testing::Test
{ {
protected: protected:
@ -55,47 +55,43 @@ protected:
{ {
queue = gr::msg_queue::make(0); queue = gr::msg_queue::make(0);
top_block = gr::make_top_block("Tracking test"); top_block = gr::make_top_block("Tracking test");
factory = new GNSSBlockFactory(); std::shared_ptr<GNSSBlockFactory> factory = std::make_shared<GNSSBlockFactory>();
config = new InMemoryConfiguration(); config = std::make_shared<InMemoryConfiguration>();
item_size = sizeof(gr_complex); item_size = sizeof(gr_complex);
stop = false; stop = false;
message = 0; message = 0;
} }
~GalileoE1DllPllVemlTrackingInternalTest() ~GalileoE1DllPllVemlTrackingInternalTest()
{ {}
delete factory;
delete config;
}
void init(); void init();
gr::msg_queue::sptr queue; gr::msg_queue::sptr queue;
gr::top_block_sptr top_block; gr::top_block_sptr top_block;
GNSSBlockFactory* factory; std::shared_ptr<GNSSBlockFactory> factory;
InMemoryConfiguration* config; std::shared_ptr<InMemoryConfiguration> config;
Gnss_Synchro gnss_synchro; Gnss_Synchro gnss_synchro;
size_t item_size; size_t item_size;
concurrent_queue<int> channel_internal_queue; concurrent_queue<int> channel_internal_queue;
bool stop; bool stop;
int message; int message;
boost::thread ch_thread;
}; };
void GalileoE1DllPllVemlTrackingInternalTest::init() void GalileoE1DllPllVemlTrackingInternalTest::init()
{ {
gnss_synchro.Channel_ID=0; gnss_synchro.Channel_ID = 0;
gnss_synchro.System = 'E'; gnss_synchro.System = 'E';
std::string signal = "1B"; std::string signal = "1B";
signal.copy(gnss_synchro.Signal,2,0); signal.copy(gnss_synchro.Signal, 2, 0);
gnss_synchro.PRN=11; gnss_synchro.PRN = 11;
config->set_property("GNSS-SDR.internal_fs_hz", "8000000"); config->set_property("GNSS-SDR.internal_fs_hz", "8000000");
config->set_property("Tracking.item_type", "gr_complex"); config->set_property("Tracking.item_type", "gr_complex");
config->set_property("Tracking.dump", "true"); config->set_property("Tracking.dump", "true");
config->set_property("Tracking.dump_filename", "../data/veml_tracking_ch_"); config->set_property("Tracking.dump_filename", "../data/veml_tracking_ch_");
config->set_property("Tracking.implementation", "Galileo_E1_DLL_PLL_Tracking"); config->set_property("Tracking.implementation", "Galileo_E1_DLL_PLL_VEML_Tracking");
config->set_property("Tracking.early_late_space_chips", "0.15"); config->set_property("Tracking.early_late_space_chips", "0.15");
config->set_property("Tracking.very_early_late_space_chips", "0.6"); config->set_property("Tracking.very_early_late_space_chips", "0.6");
config->set_property("Tracking.pll_bw_hz", "30.0"); config->set_property("Tracking.pll_bw_hz", "30.0");
@ -108,45 +104,62 @@ TEST_F(GalileoE1DllPllVemlTrackingInternalTest, Instantiate)
{ {
init(); init();
GalileoE1DllPllVemlTracking *tracking = new GalileoE1DllPllVemlTracking(config, "Tracking", 1, 1, queue); auto tracking = factory->GetBlock(config, "Tracking", "Galileo_E1_DLL_PLL_VEML_Tracking", 1, 1, queue);
EXPECT_STREQ("Galileo_E1_DLL_PLL_VEML_Tracking", tracking->implementation().c_str()); EXPECT_STREQ("Galileo_E1_DLL_PLL_VEML_Tracking", tracking->implementation().c_str());
delete tracking;
} }
//TEST_F(GalileoE1DllPllVemlTrackingInternalTest, ConnectAndRun)
//{ TEST_F(GalileoE1DllPllVemlTrackingInternalTest, ConnectAndRun)
// int fs_in = 8000000; {
// int nsamples = 80000000; int fs_in = 8000000;
// struct timeval tv; int nsamples = 80000000;
// long long int begin; struct timeval tv;
// long long int end; long long int begin;
// long long int end;
// init(); init();
// GalileoE1DllPllVemlTracking *tracking = new GalileoE1DllPllVemlTracking(config, "Tracking", 1, 1, queue);
// // Example using smart pointers and the block factory
// ASSERT_NO_THROW( { std::shared_ptr<GNSSBlockInterface> trk_ = factory->GetBlock(config, "Tracking", "Galileo_E1_DLL_PLL_VEML_Tracking", 1, 1, queue);
// tracking->connect(top_block); std::shared_ptr<TrackingInterface> tracking = std::dynamic_pointer_cast<TrackingInterface>(trk_);
// gr_block_sptr source = gr::analog::sig_source_c::make(fs_in, gr::analog::GR_SIN_WAVE, 1000, 1, gr_complex(0));
// gr_block_sptr valve = gnss_sdr_make_valve(sizeof(gr_complex), nsamples, queue); ASSERT_NO_THROW( {
// gr_null_sink_sptr sink = gr_make_null_sink(sizeof(Gnss_Synchro)); tracking->set_channel(gnss_synchro.Channel_ID);
// top_block->connect(source, 0, valve, 0); }) << "Failure setting channel." << std::endl;
// top_block->connect(valve, 0, tracking->get_left_block(), 0);
// top_block->connect(tracking->get_right_block(), 0, sink, 0); ASSERT_NO_THROW( {
// tracking->set_gnss_synchro(&gnss_synchro);
// }) << "Failure connecting the blocks of tracking test."<< std::endl; }) << "Failure setting gnss_synchro." << std::endl;
//
// EXPECT_NO_THROW( { ASSERT_NO_THROW( {
// gettimeofday(&tv, NULL); tracking->set_channel_queue(&channel_internal_queue);
// begin = tv.tv_sec *1000000 + tv.tv_usec; }) << "Failure setting channel_internal_queue." << std::endl;
// top_block->run(); // Start threads and wait
// gettimeofday(&tv, NULL);
// end = tv.tv_sec *1000000 + tv.tv_usec; ASSERT_NO_THROW( {
// }) << "Failure running he top_block."<< std::endl; tracking->connect(top_block);
// gr::analog::sig_source_c::sptr source = gr::analog::sig_source_c::make(fs_in, gr::analog::GR_SIN_WAVE, 1000, 1, gr_complex(0));
// delete tracking; boost::shared_ptr<gr::block> valve = gnss_sdr_make_valve(sizeof(gr_complex), nsamples, queue);
// std::cout << "Processed " << nsamples << " samples in " << (end-begin) << " microseconds" << std::endl; gr::blocks::null_sink::sptr sink = gr::blocks::null_sink::make(sizeof(Gnss_Synchro));
// top_block->connect(source, 0, valve, 0);
//} top_block->connect(valve, 0, tracking->get_left_block(), 0);
top_block->connect(tracking->get_right_block(), 0, sink, 0);
}) << "Failure connecting the blocks of tracking test." << std::endl;
tracking->start_tracking();
EXPECT_NO_THROW( {
gettimeofday(&tv, NULL);
begin = tv.tv_sec *1000000 + tv.tv_usec;
top_block->run(); //Start threads and wait
gettimeofday(&tv, NULL);
end = tv.tv_sec *1000000 + tv.tv_usec;
}) << "Failure running the top_block." << std::endl;
std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
}
TEST_F(GalileoE1DllPllVemlTrackingInternalTest, ValidationOfResults) TEST_F(GalileoE1DllPllVemlTrackingInternalTest, ValidationOfResults)
{ {
@ -158,29 +171,32 @@ TEST_F(GalileoE1DllPllVemlTrackingInternalTest, ValidationOfResults)
int num_samples = 80000000; // 8 Msps int num_samples = 80000000; // 8 Msps
unsigned int skiphead_sps = 8000000; // 8 Msps unsigned int skiphead_sps = 8000000; // 8 Msps
init(); init();
GalileoE1DllPllVemlTracking *tracking = new GalileoE1DllPllVemlTracking(config, "Tracking", 1, 1, queue);
// gnss_synchro.Acq_delay_samples=1753; // 4 Msps // Example using smart pointers and the block factory
// gnss_synchro.Acq_doppler_hz=-9500; // 4 Msps std::shared_ptr<GNSSBlockInterface> trk_ = factory->GetBlock(config, "Tracking", "Galileo_E1_DLL_PLL_VEML_Tracking", 1, 1, queue);
std::shared_ptr<TrackingInterface> tracking = std::dynamic_pointer_cast<TrackingInterface>(trk_);
// gnss_synchro.Acq_delay_samples = 1753; // 4 Msps
// gnss_synchro.Acq_doppler_hz = -9500; // 4 Msps
gnss_synchro.Acq_delay_samples = 17256; // 8 Msps gnss_synchro.Acq_delay_samples = 17256; // 8 Msps
gnss_synchro.Acq_doppler_hz = -8750; // 8 Msps gnss_synchro.Acq_doppler_hz = -8750; // 8 Msps
gnss_synchro.Acq_samplestamp_samples = 0; gnss_synchro.Acq_samplestamp_samples = 0;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
tracking->set_channel(gnss_synchro.Channel_ID); tracking->set_channel(gnss_synchro.Channel_ID);
}) << "Failure setting channel."<< std::endl; }) << "Failure setting channel." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
tracking->set_gnss_synchro(&gnss_synchro); tracking->set_gnss_synchro(&gnss_synchro);
}) << "Failure setting gnss_synchro."<< std::endl; }) << "Failure setting gnss_synchro." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
tracking->set_channel_queue(&channel_internal_queue); tracking->set_channel_queue(&channel_internal_queue);
}) << "Failure setting channel_internal_queue."<< std::endl; }) << "Failure setting channel_internal_queue." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
tracking->connect(top_block); tracking->connect(top_block);
}) << "Failure connecting tracking to the top_block."<< std::endl; }) << "Failure connecting tracking to the top_block." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
std::string path = std::string(TEST_PATH); std::string path = std::string(TEST_PATH);
@ -194,8 +210,7 @@ TEST_F(GalileoE1DllPllVemlTrackingInternalTest, ValidationOfResults)
top_block->connect(skip_head, 0, valve, 0); top_block->connect(skip_head, 0, valve, 0);
top_block->connect(valve, 0, tracking->get_left_block(), 0); top_block->connect(valve, 0, tracking->get_left_block(), 0);
top_block->connect(tracking->get_right_block(), 0, sink, 0); top_block->connect(tracking->get_right_block(), 0, sink, 0);
}) << "Failure connecting the blocks of tracking test."<< std::endl; }) << "Failure connecting the blocks of tracking test." << std::endl;
tracking->start_tracking(); tracking->start_tracking();
@ -205,9 +220,7 @@ TEST_F(GalileoE1DllPllVemlTrackingInternalTest, ValidationOfResults)
top_block->run(); // Start threads and wait top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
end = tv.tv_sec *1000000 + tv.tv_usec; end = tv.tv_sec *1000000 + tv.tv_usec;
}) << "Failure running he top_block."<< std::endl; }) << "Failure running the top_block." << std::endl;
std::cout << "Tracked " << num_samples << " samples in " << (end-begin) << " microseconds" << std::endl; std::cout << "Tracked " << num_samples << " samples in " << (end - begin) << " microseconds" << std::endl;
delete tracking;
} }

View File

@ -61,11 +61,11 @@ protected:
item_size = sizeof(gr_complex); item_size = sizeof(gr_complex);
stop = false; stop = false;
message = 0; message = 0;
factory = std::make_shared<GNSSBlockFactory>();
} }
~GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test() ~GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test()
{ {}
}
void init(); void init();
void config_1(); void config_1();
@ -77,8 +77,9 @@ protected:
gr::msg_queue::sptr queue; gr::msg_queue::sptr queue;
gr::top_block_sptr top_block; gr::top_block_sptr top_block;
GalileoE1Pcps8msAmbiguousAcquisition *acquisition; std::shared_ptr<AcquisitionInterface> acquisition;
InMemoryConfiguration* config; std::shared_ptr<GNSSBlockFactory> factory;
std::shared_ptr<InMemoryConfiguration> config;
Gnss_Synchro gnss_synchro; Gnss_Synchro gnss_synchro;
size_t item_size; size_t item_size;
concurrent_queue<int> channel_internal_queue; concurrent_queue<int> channel_internal_queue;
@ -129,7 +130,7 @@ void GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test::config_1()
gnss_synchro.Channel_ID = 0; gnss_synchro.Channel_ID = 0;
gnss_synchro.System = 'E'; gnss_synchro.System = 'E';
std::string signal = "1C"; std::string signal = "1C";
signal.copy(gnss_synchro.Signal,2,0); signal.copy(gnss_synchro.Signal, 2, 0);
integration_time_ms = 8; integration_time_ms = 8;
fs_in = 4e6; fs_in = 4e6;
@ -141,7 +142,7 @@ void GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test::config_1()
num_of_realizations = 1; num_of_realizations = 1;
config = new InMemoryConfiguration(); config = std::make_shared<InMemoryConfiguration>();
config->set_property("GNSS-SDR.internal_fs_hz", std::to_string(fs_in)); config->set_property("GNSS-SDR.internal_fs_hz", std::to_string(fs_in));
@ -154,10 +155,8 @@ void GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test::config_1()
config->set_property("SignalSource.system_0", "E"); config->set_property("SignalSource.system_0", "E");
config->set_property("SignalSource.PRN_0", "10"); config->set_property("SignalSource.PRN_0", "10");
config->set_property("SignalSource.CN0_dB_0", "44"); config->set_property("SignalSource.CN0_dB_0", "44");
config->set_property("SignalSource.doppler_Hz_0", config->set_property("SignalSource.doppler_Hz_0", std::to_string(expected_doppler_hz));
std::to_string(expected_doppler_hz)); config->set_property("SignalSource.delay_chips_0", std::to_string(expected_delay_chips));
config->set_property("SignalSource.delay_chips_0",
std::to_string(expected_delay_chips));
config->set_property("SignalSource.noise_flag", "false"); config->set_property("SignalSource.noise_flag", "false");
config->set_property("SignalSource.data_flag", "false"); config->set_property("SignalSource.data_flag", "false");
@ -184,8 +183,7 @@ void GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test::config_1()
config->set_property("Acquisition.item_type", "gr_complex"); config->set_property("Acquisition.item_type", "gr_complex");
config->set_property("Acquisition.if", "0"); config->set_property("Acquisition.if", "0");
config->set_property("Acquisition.coherent_integration_time_ms", config->set_property("Acquisition.coherent_integration_time_ms", std::to_string(integration_time_ms));
std::to_string(integration_time_ms));
config->set_property("Acquisition.max_dwells", "1"); config->set_property("Acquisition.max_dwells", "1");
config->set_property("Acquisition.implementation", "Galileo_E1_PCPS_8ms_Ambiguous_Acquisition"); config->set_property("Acquisition.implementation", "Galileo_E1_PCPS_8ms_Ambiguous_Acquisition");
config->set_property("Acquisition.threshold", "0.2"); config->set_property("Acquisition.threshold", "0.2");
@ -199,7 +197,7 @@ void GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test::config_2()
gnss_synchro.Channel_ID = 0; gnss_synchro.Channel_ID = 0;
gnss_synchro.System = 'E'; gnss_synchro.System = 'E';
std::string signal = "1C"; std::string signal = "1C";
signal.copy(gnss_synchro.Signal,2,0); signal.copy(gnss_synchro.Signal, 2, 0);
integration_time_ms = 8; integration_time_ms = 8;
fs_in = 4e6; fs_in = 4e6;
@ -211,7 +209,7 @@ void GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test::config_2()
num_of_realizations = 100; num_of_realizations = 100;
config = new InMemoryConfiguration(); config = std::make_shared<InMemoryConfiguration>();
config->set_property("GNSS-SDR.internal_fs_hz", std::to_string(fs_in)); config->set_property("GNSS-SDR.internal_fs_hz", std::to_string(fs_in));
@ -224,10 +222,8 @@ void GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test::config_2()
config->set_property("SignalSource.system_0", "E"); config->set_property("SignalSource.system_0", "E");
config->set_property("SignalSource.PRN_0", "10"); config->set_property("SignalSource.PRN_0", "10");
config->set_property("SignalSource.CN0_dB_0", "44"); config->set_property("SignalSource.CN0_dB_0", "44");
config->set_property("SignalSource.doppler_Hz_0", config->set_property("SignalSource.doppler_Hz_0", std::to_string(expected_doppler_hz));
std::to_string(expected_doppler_hz)); config->set_property("SignalSource.delay_chips_0", std::to_string(expected_delay_chips));
config->set_property("SignalSource.delay_chips_0",
std::to_string(expected_delay_chips));
config->set_property("SignalSource.system_1", "E"); config->set_property("SignalSource.system_1", "E");
config->set_property("SignalSource.PRN_1", "15"); config->set_property("SignalSource.PRN_1", "15");
@ -272,8 +268,7 @@ void GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test::config_2()
config->set_property("Acquisition.item_type", "gr_complex"); config->set_property("Acquisition.item_type", "gr_complex");
config->set_property("Acquisition.if", "0"); config->set_property("Acquisition.if", "0");
config->set_property("Acquisition.coherent_integration_time_ms", config->set_property("Acquisition.coherent_integration_time_ms", std::to_string(integration_time_ms));
std::to_string(integration_time_ms));
config->set_property("Acquisition.max_dwells", "1"); config->set_property("Acquisition.max_dwells", "1");
config->set_property("Acquisition.implementation", "Galileo_E1_PCPS_8ms_Ambiguous_Acquisition"); config->set_property("Acquisition.implementation", "Galileo_E1_PCPS_8ms_Ambiguous_Acquisition");
config->set_property("Acquisition.pfa", "0.1"); config->set_property("Acquisition.pfa", "0.1");
@ -355,8 +350,6 @@ void GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test::process_message()
stop_queue(); stop_queue();
top_block->stop(); top_block->stop();
//std::cout << std::endl;
} }
} }
@ -368,9 +361,7 @@ void GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test::stop_queue()
TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, Instantiate) TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, Instantiate)
{ {
config_1(); config_1();
acquisition = new GalileoE1Pcps8msAmbiguousAcquisition(config, "Acquisition", 1, 1, queue); std::shared_ptr<GNSSBlockInterface> acq_ = factory->GetBlock(config, "Acquisition", "Galileo_E1_PCPS_8ms_Ambiguous_Acquisition", 1, 1, queue);
delete acquisition;
delete config;
} }
TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ConnectAndRun) TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ConnectAndRun)
@ -382,7 +373,32 @@ TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ConnectAndRun)
config_1(); config_1();
acquisition = new GalileoE1Pcps8msAmbiguousAcquisition(config, "Acquisition", 1, 1, queue); std::shared_ptr<GNSSBlockInterface> acq_ = factory->GetBlock(config, "Acquisition", "Galileo_E1_PCPS_8ms_Ambiguous_Acquisition", 1, 1, queue);
acquisition = std::dynamic_pointer_cast<AcquisitionInterface>(acq_);
ASSERT_NO_THROW( {
acquisition->set_channel(1);
}) << "Failure setting channel." << std::endl;
ASSERT_NO_THROW( {
acquisition->set_gnss_synchro(&gnss_synchro);
}) << "Failure setting gnss_synchro." << std::endl;
ASSERT_NO_THROW( {
acquisition->set_channel_queue(&channel_internal_queue);
}) << "Failure setting channel_internal_queue." << std::endl;
ASSERT_NO_THROW( {
acquisition->set_doppler_max(config->property("Acquisition.doppler_max", 10000));
}) << "Failure setting doppler_max." << std::endl;
ASSERT_NO_THROW( {
acquisition->set_doppler_step(config->property("Acquisition.doppler_step", 500));
}) << "Failure setting doppler_step." << std::endl;
ASSERT_NO_THROW( {
acquisition->set_threshold(config->property("Acquisition.threshold", 0.0));
}) << "Failure setting threshold." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->connect(top_block); acquisition->connect(top_block);
@ -390,7 +406,7 @@ TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ConnectAndRun)
boost::shared_ptr<gr::block> valve = gnss_sdr_make_valve(sizeof(gr_complex), nsamples, queue); boost::shared_ptr<gr::block> valve = gnss_sdr_make_valve(sizeof(gr_complex), nsamples, queue);
top_block->connect(source, 0, valve, 0); top_block->connect(source, 0, valve, 0);
top_block->connect(valve, 0, acquisition->get_left_block(), 0); top_block->connect(valve, 0, acquisition->get_left_block(), 0);
}) << "Failure connecting the blocks of acquisition test."<< std::endl; }) << "Failure connecting the blocks of acquisition test." << std::endl;
EXPECT_NO_THROW( { EXPECT_NO_THROW( {
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
@ -398,60 +414,58 @@ TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ConnectAndRun)
top_block->run(); // Start threads and wait top_block->run(); // Start threads and wait
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
end = tv.tv_sec *1e6 + tv.tv_usec; end = tv.tv_sec *1e6 + tv.tv_usec;
}) << "Failure running he top_block."<< std::endl; }) << "Failure running he top_block." << std::endl;
std::cout << "Processed " << nsamples << " samples in " << (end-begin) << " microseconds" << std::endl; std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
delete acquisition;
delete config;
} }
TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ValidationOfResults) TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ValidationOfResults)
{ {
config_1(); config_1();
acquisition = new GalileoE1Pcps8msAmbiguousAcquisition(config, "Acquisition", 1, 1, queue); std::shared_ptr<GNSSBlockInterface> acq_ = factory->GetBlock(config, "Acquisition", "Galileo_E1_PCPS_8ms_Ambiguous_Acquisition", 1, 1, queue);
acquisition = std::dynamic_pointer_cast<AcquisitionInterface>(acq_);
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_channel(1); acquisition->set_channel(1);
}) << "Failure setting channel."<< std::endl; }) << "Failure setting channel." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_gnss_synchro(&gnss_synchro); acquisition->set_gnss_synchro(&gnss_synchro);
}) << "Failure setting gnss_synchro."<< std::endl; }) << "Failure setting gnss_synchro." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_channel_queue(&channel_internal_queue); acquisition->set_channel_queue(&channel_internal_queue);
}) << "Failure setting channel_internal_queue."<< std::endl; }) << "Failure setting channel_internal_queue." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_doppler_max(config->property("Acquisition.doppler_max", 10000)); acquisition->set_doppler_max(config->property("Acquisition.doppler_max", 10000));
}) << "Failure setting doppler_max."<< std::endl; }) << "Failure setting doppler_max." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_doppler_step(config->property("Acquisition.doppler_step", 500)); acquisition->set_doppler_step(config->property("Acquisition.doppler_step", 500));
}) << "Failure setting doppler_step."<< std::endl; }) << "Failure setting doppler_step." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_threshold(config->property("Acquisition.threshold", 0.0)); acquisition->set_threshold(config->property("Acquisition.threshold", 0.0));
}) << "Failure setting threshold."<< std::endl; }) << "Failure setting threshold." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->connect(top_block); acquisition->connect(top_block);
}) << "Failure connecting acquisition to the top_block."<< std::endl; }) << "Failure connecting acquisition to the top_block." << std::endl;
acquisition->init(); acquisition->init();
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
boost::shared_ptr<GenSignalSource> signal_source; boost::shared_ptr<GenSignalSource> signal_source;
SignalGenerator* signal_generator = new SignalGenerator(config, "SignalSource", 0, 1, queue); SignalGenerator* signal_generator = new SignalGenerator(config.get(), "SignalSource", 0, 1, queue);
FirFilter* filter = new FirFilter(config, "InputFilter", 1, 1, queue); FirFilter* filter = new FirFilter(config.get(), "InputFilter", 1, 1, queue);
signal_source.reset(new GenSignalSource(config, signal_generator, filter, "SignalSource", queue)); signal_source.reset(new GenSignalSource(config.get(), signal_generator, filter, "SignalSource", queue));
signal_source->connect(top_block); signal_source->connect(top_block);
top_block->connect(signal_source->get_right_block(), 0, acquisition->get_left_block(), 0); top_block->connect(signal_source->get_right_block(), 0, acquisition->get_left_block(), 0);
}) << "Failure connecting the blocks of acquisition test." << std::endl; }) << "Failure connecting the blocks of acquisition test." << std::endl;
// i = 0 --> sallite in acquisition is visible // i = 0 --> satellite in acquisition is visible
// i = 1 --> satellite in acquisition is not visible // i = 1 --> satellite in acquisition is not visible
for (unsigned int i = 0; i < 2; i++) for (unsigned int i = 0; i < 2; i++)
{ {
@ -472,80 +486,77 @@ TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ValidationOfResults)
EXPECT_NO_THROW( { EXPECT_NO_THROW( {
top_block->run(); // Start threads and wait top_block->run(); // Start threads and wait
}) << "Failure running the top_block."<< std::endl; }) << "Failure running the top_block." << std::endl;
if (i == 0) if (i == 0)
{ {
EXPECT_EQ(1, message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS."; EXPECT_EQ(1, message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS.";
if (message == 1) if (message == 1)
{ {
EXPECT_EQ((unsigned int)1, correct_estimation_counter) << "Acquisition failure. Incorrect parameters estimation."; EXPECT_EQ((unsigned int)1, correct_estimation_counter) << "Acquisition failure. Incorrect parameters estimation.";
} }
} }
else if (i == 1) else if (i == 1)
{ {
EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL."; EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL.";
} }
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
ch_thread.timed_join(boost::posix_time::seconds(1)); ch_thread.timed_join(boost::posix_time::seconds(1));
}) << "Failure while waiting the queue to stop" << std::endl; }) << "Failure while waiting the queue to stop" << std::endl;
} }
delete acquisition;
delete config;
} }
TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ValidationOfResultsProbabilities) TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ValidationOfResultsProbabilities)
{ {
config_2(); config_2();
acquisition = new GalileoE1Pcps8msAmbiguousAcquisition(config, "Acquisition", 1, 1, queue); std::shared_ptr<GNSSBlockInterface> acq_ = factory->GetBlock(config, "Acquisition", "Galileo_E1_PCPS_8ms_Ambiguous_Acquisition", 1, 1, queue);
acquisition = std::dynamic_pointer_cast<AcquisitionInterface>(acq_);
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_channel(1); acquisition->set_channel(1);
}) << "Failure setting channel."<< std::endl; }) << "Failure setting channel." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_gnss_synchro(&gnss_synchro); acquisition->set_gnss_synchro(&gnss_synchro);
}) << "Failure setting gnss_synchro."<< std::endl; }) << "Failure setting gnss_synchro." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_channel_queue(&channel_internal_queue); acquisition->set_channel_queue(&channel_internal_queue);
}) << "Failure setting channel_internal_queue."<< std::endl; }) << "Failure setting channel_internal_queue." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_doppler_max(config->property("Acquisition.doppler_max", 10000)); acquisition->set_doppler_max(config->property("Acquisition.doppler_max", 10000));
}) << "Failure setting doppler_max."<< std::endl; }) << "Failure setting doppler_max." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_doppler_step(config->property("Acquisition.doppler_step", 500)); acquisition->set_doppler_step(config->property("Acquisition.doppler_step", 500));
}) << "Failure setting doppler_step."<< std::endl; }) << "Failure setting doppler_step." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_threshold(config->property("Acquisition.threshold", 0.0)); acquisition->set_threshold(config->property("Acquisition.threshold", 0.0));
}) << "Failure setting threshold."<< std::endl; }) << "Failure setting threshold." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->connect(top_block); acquisition->connect(top_block);
}) << "Failure connecting acquisition to the top_block."<< std::endl; }) << "Failure connecting acquisition to the top_block." << std::endl;
acquisition->init(); acquisition->init();
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
boost::shared_ptr<GenSignalSource> signal_source; boost::shared_ptr<GenSignalSource> signal_source;
SignalGenerator* signal_generator = new SignalGenerator(config, "SignalSource", 0, 1, queue); SignalGenerator* signal_generator = new SignalGenerator(config.get(), "SignalSource", 0, 1, queue);
FirFilter* filter = new FirFilter(config, "InputFilter", 1, 1, queue); FirFilter* filter = new FirFilter(config.get(), "InputFilter", 1, 1, queue);
signal_source.reset(new GenSignalSource(config, signal_generator, filter, "SignalSource", queue)); signal_source.reset(new GenSignalSource(config.get(), signal_generator, filter, "SignalSource", queue));
signal_source->connect(top_block); signal_source->connect(top_block);
top_block->connect(signal_source->get_right_block(), 0, acquisition->get_left_block(), 0); top_block->connect(signal_source->get_right_block(), 0, acquisition->get_left_block(), 0);
}) << "Failure connecting the blocks of acquisition test." << std::endl; }) << "Failure connecting the blocks of acquisition test." << std::endl;
std::cout << "Probability of false alarm (target) = " << 0.1 << std::endl; std::cout << "Probability of false alarm (target) = " << 0.1 << std::endl;
// i = 0 --> sallite in acquisition is visible (prob of detection and prob of detection with wrong estimation) // i = 0 --> satellite in acquisition is visible (prob of detection and prob of detection with wrong estimation)
// i = 1 --> satellite in acquisition is not visible (prob of false detection) // i = 1 --> satellite in acquisition is not visible (prob of false detection)
for (unsigned int i = 0; i < 2; i++) for (unsigned int i = 0; i < 2; i++)
{ {
@ -569,22 +580,19 @@ TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ValidationOfResultsProb
}) << "Failure running the top_block." << std::endl; }) << "Failure running the top_block." << std::endl;
if (i == 0) if (i == 0)
{ {
std::cout << "Estimated probability of detection = " << Pd << std::endl; std::cout << "Estimated probability of detection = " << Pd << std::endl;
std::cout << "Estimated probability of false alarm (satellite present) = " << Pfa_p << std::endl; std::cout << "Estimated probability of false alarm (satellite present) = " << Pfa_p << std::endl;
std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl; std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl;
} }
else if (i == 1) else if (i == 1)
{ {
std::cout << "Estimated probability of false alarm (satellite absent) = " << Pfa_a << std::endl; std::cout << "Estimated probability of false alarm (satellite absent) = " << Pfa_a << std::endl;
std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl; std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl;
} }
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
ch_thread.timed_join(boost::posix_time::seconds(1)); ch_thread.timed_join(boost::posix_time::seconds(1));
}) << "Failure while waiting the queue to stop" << std::endl; }) << "Failure while waiting the queue to stop" << std::endl;
} }
delete acquisition;
delete config;
} }