1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-31 19:29:17 +00:00

working on the new factory and the tests

This commit is contained in:
Carles Fernandez 2014-04-24 01:53:55 +02:00
parent 15dd3f98bf
commit aa7d6a0f20
6 changed files with 109 additions and 108 deletions

View File

@ -266,6 +266,10 @@ std::unique_ptr<std::vector<std::unique_ptr<GNSSBlockInterface>>> GNSSBlockFacto
* Returns the block with the required configuration and implementation * Returns the block with the required configuration and implementation
* *
* PLEASE ADD YOUR NEW BLOCK HERE!! * PLEASE ADD YOUR NEW BLOCK HERE!!
*
* IMPORTANT NOTE: Acquisition, Tracking and telemetry blocks are only included here for testing purposes.
* To be included in a channel they must be also be included in GetAcqBlock(), GetTrkBlock() and GetTlmBlock()
* (see below)
*/ */
std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetBlock( std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetBlock(
std::shared_ptr<ConfigurationInterface> configuration, std::shared_ptr<ConfigurationInterface> configuration,
@ -559,8 +563,11 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetBlock(
/* /*
* Not very elegant, Acq, Ttk and Tlm blocks must be added here, too. *
* To be fixed! * PLEASE ADD YOUR NEW BLOCK HERE!!
*
* Not very elegant, Acq, Trk and Tlm blocks must be added here, too.
* To be improved!
*/ */
std::unique_ptr<AcquisitionInterface> GNSSBlockFactory::GetAcqBlock( std::unique_ptr<AcquisitionInterface> GNSSBlockFactory::GetAcqBlock(

View File

@ -55,22 +55,31 @@ class GNSSBlockFactory
{ {
public: public:
GNSSBlockFactory(); GNSSBlockFactory();
virtual ~GNSSBlockFactory(); virtual ~GNSSBlockFactory();
std::unique_ptr<GNSSBlockInterface> GetSignalSource(std::shared_ptr<ConfigurationInterface> configuration, std::unique_ptr<GNSSBlockInterface> GetSignalSource(std::shared_ptr<ConfigurationInterface> configuration,
boost::shared_ptr<gr::msg_queue> queue); boost::shared_ptr<gr::msg_queue> queue);
std::unique_ptr<GNSSBlockInterface> GetSignalConditioner(std::shared_ptr<ConfigurationInterface> configuration, std::unique_ptr<GNSSBlockInterface> GetSignalConditioner(std::shared_ptr<ConfigurationInterface> configuration,
boost::shared_ptr<gr::msg_queue> queue); boost::shared_ptr<gr::msg_queue> queue);
std::unique_ptr<GNSSBlockInterface> GetPVT(std::shared_ptr<ConfigurationInterface> configuration, std::unique_ptr<GNSSBlockInterface> GetPVT(std::shared_ptr<ConfigurationInterface> configuration,
boost::shared_ptr<gr::msg_queue> queue); boost::shared_ptr<gr::msg_queue> queue);
std::unique_ptr<GNSSBlockInterface> GetObservables(std::shared_ptr<ConfigurationInterface> configuration, std::unique_ptr<GNSSBlockInterface> GetObservables(std::shared_ptr<ConfigurationInterface> configuration,
boost::shared_ptr<gr::msg_queue> queue); boost::shared_ptr<gr::msg_queue> queue);
std::unique_ptr<GNSSBlockInterface> GetOutputFilter(std::shared_ptr<ConfigurationInterface> configuration, std::unique_ptr<GNSSBlockInterface> GetOutputFilter(std::shared_ptr<ConfigurationInterface> configuration,
boost::shared_ptr<gr::msg_queue> queue); boost::shared_ptr<gr::msg_queue> queue);
std::unique_ptr<GNSSBlockInterface> GetChannel(std::shared_ptr<ConfigurationInterface> configuration, std::unique_ptr<GNSSBlockInterface> GetChannel(std::shared_ptr<ConfigurationInterface> configuration,
std::string acq, std::string trk, std::string tlm, int channel, std::string acq, std::string trk, std::string tlm, int channel,
boost::shared_ptr<gr::msg_queue> queue); boost::shared_ptr<gr::msg_queue> queue);
std::unique_ptr<std::vector<std::unique_ptr<GNSSBlockInterface>>> GetChannels(std::shared_ptr<ConfigurationInterface> configuration, std::unique_ptr<std::vector<std::unique_ptr<GNSSBlockInterface>>> GetChannels(std::shared_ptr<ConfigurationInterface> configuration,
boost::shared_ptr<gr::msg_queue> queue); boost::shared_ptr<gr::msg_queue> queue);
/* /*
* \brief Returns the block with the required configuration and implementation * \brief Returns the block with the required configuration and implementation
*/ */
@ -79,18 +88,17 @@ public:
unsigned int in_streams, unsigned int out_streams, unsigned int in_streams, unsigned int out_streams,
boost::shared_ptr<gr::msg_queue> queue); boost::shared_ptr<gr::msg_queue> queue);
private: private:
std::unique_ptr<AcquisitionInterface> GetAcqBlock( std::unique_ptr<AcquisitionInterface> GetAcqBlock(std::shared_ptr<ConfigurationInterface> configuration,
std::shared_ptr<ConfigurationInterface> configuration,
std::string role, std::string role,
std::string implementation, unsigned int in_streams, std::string implementation, unsigned int in_streams,
unsigned int out_streams, boost::shared_ptr<gr::msg_queue> queue); unsigned int out_streams, boost::shared_ptr<gr::msg_queue> queue);
std::unique_ptr<TrackingInterface> GetTrkBlock(
std::shared_ptr<ConfigurationInterface> configuration, std::unique_ptr<TrackingInterface> GetTrkBlock(std::shared_ptr<ConfigurationInterface> configuration,
std::string role, std::string role,
std::string implementation, unsigned int in_streams, std::string implementation, unsigned int in_streams,
unsigned int out_streams, boost::shared_ptr<gr::msg_queue> queue); unsigned int out_streams, boost::shared_ptr<gr::msg_queue> queue);
std::unique_ptr<TelemetryDecoderInterface> GetTlmBlock(
std::shared_ptr<ConfigurationInterface> configuration, std::unique_ptr<TelemetryDecoderInterface> GetTlmBlock(std::shared_ptr<ConfigurationInterface> configuration,
std::string role, std::string role,
std::string implementation, unsigned int in_streams, std::string implementation, unsigned int in_streams,
unsigned int out_streams, boost::shared_ptr<gr::msg_queue> queue); unsigned int out_streams, boost::shared_ptr<gr::msg_queue> queue);

View File

@ -59,6 +59,7 @@ protected:
{ {
queue = gr::msg_queue::make(0); queue = gr::msg_queue::make(0);
top_block = gr::make_top_block("Acquisition test"); top_block = gr::make_top_block("Acquisition test");
factory = std::make_shared<GNSSBlockFactory>();
item_size = sizeof(gr_complex); item_size = sizeof(gr_complex);
stop = false; stop = false;
message = 0; message = 0;
@ -78,8 +79,9 @@ protected:
gr::msg_queue::sptr queue; gr::msg_queue::sptr queue;
gr::top_block_sptr top_block; gr::top_block_sptr top_block;
GalileoE1PcpsAmbiguousAcquisition *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;
@ -143,7 +145,7 @@ void GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test::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));
@ -214,7 +216,7 @@ void GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test::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));
@ -364,9 +366,8 @@ void GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test::stop_queue()
TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test, Instantiate) TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test, Instantiate)
{ {
config_1(); config_1();
acquisition = new GalileoE1PcpsAmbiguousAcquisition(config, "Acquisition", 1, 1, queue); std::shared_ptr<GNSSBlockInterface> acq_ = factory->GetBlock(config, "Acquisition", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 1, queue);
delete acquisition; acquisition = std::dynamic_pointer_cast<AcquisitionInterface>(acq_);
delete config;
} }
@ -379,7 +380,8 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test, ConnectAndRun)
config_1(); config_1();
acquisition = new GalileoE1PcpsAmbiguousAcquisition(config, "Acquisition", 1, 1, queue); std::shared_ptr<GNSSBlockInterface> acq_ = factory->GetBlock(config, "Acquisition", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 1, queue);
acquisition = std::dynamic_pointer_cast<AcquisitionInterface>(acq_);
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->connect(top_block); acquisition->connect(top_block);
@ -398,16 +400,14 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test, ConnectAndRun)
}) << "Failure running the top_block." << std::endl; }) << "Failure running the 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(GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test, ValidationOfResults) TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test, ValidationOfResults)
{ {
config_1(); config_1();
acquisition = new GalileoE1PcpsAmbiguousAcquisition(config, "Acquisition", 1, 1, queue); std::shared_ptr<GNSSBlockInterface> acq_ = factory->GetBlock(config, "Acquisition", "Galileo_E1_PCPS_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);
@ -441,9 +441,9 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test, ValidationOfResults)
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;
@ -484,9 +484,6 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test, ValidationOfResults)
EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL."; EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL.";
} }
} }
delete acquisition;
delete config;
} }
@ -495,7 +492,8 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test, ValidationOfResultsProbabi
{ {
config_2(); config_2();
acquisition = new GalileoE1PcpsAmbiguousAcquisition(config, "Acquisition", 1, 1, queue); std::shared_ptr<GNSSBlockInterface> acq_ = factory->GetBlock(config, "Acquisition", "Galileo_E1_PCPS_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);
@ -529,16 +527,16 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test, ValidationOfResultsProbabi
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++)
{ {
@ -573,7 +571,4 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test, ValidationOfResultsProbabi
std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl; std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl;
} }
} }
delete acquisition;
delete config;
} }

View File

@ -56,18 +56,15 @@ protected:
{ {
queue = gr::msg_queue::make(0); queue = gr::msg_queue::make(0);
top_block = gr::make_top_block("Acquisition test"); top_block = gr::make_top_block("Acquisition test");
factory = new 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;
} }
~GalileoE1PcpsAmbiguousAcquisitionTest() ~GalileoE1PcpsAmbiguousAcquisitionTest()
{ {}
delete factory;
delete config;
}
void init(); void init();
void start_queue(); void start_queue();
@ -76,8 +73,8 @@ protected:
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;
@ -101,9 +98,9 @@ void GalileoE1PcpsAmbiguousAcquisitionTest::init()
config->set_property("Acquisition.coherent_integration_time_ms", "4"); config->set_property("Acquisition.coherent_integration_time_ms", "4");
config->set_property("Acquisition.dump", "false"); config->set_property("Acquisition.dump", "false");
config->set_property("Acquisition.implementation", "Galileo_E1_PCPS_Ambiguous_Acquisition"); config->set_property("Acquisition.implementation", "Galileo_E1_PCPS_Ambiguous_Acquisition");
config->set_property("Acquisition.threshold", "0.00001"); config->set_property("Acquisition.threshold", "0.0");
config->set_property("Acquisition.doppler_max", "7000"); config->set_property("Acquisition.doppler_max", "10000");
config->set_property("Acquisition.doppler_step", "125"); config->set_property("Acquisition.doppler_step", "500");
config->set_property("Acquisition.repeat_satellite", "false"); config->set_property("Acquisition.repeat_satellite", "false");
config->set_property("Acquisition1.cboc", "true"); config->set_property("Acquisition1.cboc", "true");
} }
@ -134,8 +131,8 @@ void GalileoE1PcpsAmbiguousAcquisitionTest::stop_queue()
TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, Instantiate) TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, Instantiate)
{ {
init(); init();
GalileoE1PcpsAmbiguousAcquisition *acquisition = new GalileoE1PcpsAmbiguousAcquisition(config, "Acquisition", 1, 1, queue); std::shared_ptr<GNSSBlockInterface> acq_ = factory->GetBlock(config, "Acquisition", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 1, queue);
delete acquisition; std::shared_ptr<AcquisitionInterface> acquisition = std::dynamic_pointer_cast<AcquisitionInterface>(acq_);
} }
@ -148,7 +145,8 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, ConnectAndRun)
long long int end = 0; long long int end = 0;
init(); init();
GalileoE1PcpsAmbiguousAcquisition *acquisition = new GalileoE1PcpsAmbiguousAcquisition(config, "Acquisition", 1, 1, queue); std::shared_ptr<GNSSBlockInterface> acq_ = factory->GetBlock(config, "Acquisition", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 1, queue);
std::shared_ptr<AcquisitionInterface> acquisition = std::dynamic_pointer_cast<AcquisitionInterface>(acq_);
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->connect(top_block); acquisition->connect(top_block);
@ -165,12 +163,10 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, ConnectAndRun)
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
end = tv.tv_sec*1000000 + tv.tv_usec; end = tv.tv_sec*1000000 + tv.tv_usec;
}) << "Failure running the top_block." << std::endl; }) << "Failure running the top_block." << std::endl;
delete acquisition;
std::cout << "Processed " << nsamples << " samples in " << (end-begin) << " microseconds" << std::endl; std::cout << "Processed " << nsamples << " samples in " << (end-begin) << " microseconds" << std::endl;
} }
/*
TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, ValidationOfResults) TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, ValidationOfResults)
{ {
struct timeval tv; struct timeval tv;
@ -179,7 +175,8 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, ValidationOfResults)
double expected_delay_samples = 2920; //18250; double expected_delay_samples = 2920; //18250;
double expected_doppler_hz = -632; double expected_doppler_hz = -632;
init(); init();
GalileoE1PcpsAmbiguousAcquisition *acquisition = new GalileoE1PcpsAmbiguousAcquisition(config, "Acquisition", 1, 1, queue); std::shared_ptr<GNSSBlockInterface> acq_ = factory->GetBlock(config, "Acquisition", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 1, queue);
std::shared_ptr<AcquisitionInterface> acquisition = std::dynamic_pointer_cast<AcquisitionInterface>(acq_);
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_channel(gnss_synchro.Channel_ID); acquisition->set_channel(gnss_synchro.Channel_ID);
@ -194,11 +191,11 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, ValidationOfResults)
}) << "Failure setting channel_internal_queue." << std::endl; }) << "Failure setting channel_internal_queue." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_threshold(config->property("Acquisition.threshold", 0.00001)); 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->set_doppler_max(config->property("Acquisition.doppler_max", 10000)); acquisition->set_doppler_max(config->property("Acquisition.doppler_max", 20000));
}) << "Failure setting doppler_max." << std::endl; }) << "Failure setting doppler_max." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
@ -249,6 +246,5 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, ValidationOfResults)
EXPECT_LE(doppler_error_hz, 166) << "Doppler error exceeds the expected value: 166 Hz = 2/(3*integration period)"; EXPECT_LE(doppler_error_hz, 166) << "Doppler error exceeds the expected value: 166 Hz = 2/(3*integration period)";
EXPECT_LT(delay_error_chips, 0.175) << "Delay error exceeds the expected value: 0.175 chips"; EXPECT_LT(delay_error_chips, 0.175) << "Delay error exceeds the expected value: 0.175 chips";
delete acquisition;
} }
*/

View File

@ -59,6 +59,7 @@ protected:
{ {
queue = gr::msg_queue::make(0); queue = gr::msg_queue::make(0);
top_block = gr::make_top_block("Acquisition test"); top_block = gr::make_top_block("Acquisition test");
factory = std::make_shared<GNSSBlockFactory>();
item_size = sizeof(gr_complex); item_size = sizeof(gr_complex);
stop = false; stop = false;
message = 0; message = 0;
@ -78,8 +79,9 @@ protected:
gr::msg_queue::sptr queue; gr::msg_queue::sptr queue;
gr::top_block_sptr top_block; gr::top_block_sptr top_block;
GalileoE1PcpsCccwsrAmbiguousAcquisition *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;
@ -142,7 +144,7 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisitionTest::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));
@ -212,7 +214,7 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisitionTest::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));
@ -363,9 +365,8 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisitionTest::stop_queue()
TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, Instantiate) TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, Instantiate)
{ {
config_1(); config_1();
acquisition = new GalileoE1PcpsCccwsrAmbiguousAcquisition(config, "Acquisition", 1, 1, queue); std::shared_ptr<GNSSBlockInterface> acq_ = factory->GetBlock(config, "Acquisition", "Galileo_E1_PCPS_CCCWSR_Ambiguous_Acquisition", 1, 1, queue);
delete acquisition; acquisition = std::dynamic_pointer_cast<AcquisitionInterface>(acq_);
delete config;
} }
TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ConnectAndRun) TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ConnectAndRun)
@ -377,7 +378,8 @@ TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ConnectAndRun)
config_1(); config_1();
acquisition = new GalileoE1PcpsCccwsrAmbiguousAcquisition(config, "Acquisition", 1, 1, queue); std::shared_ptr<GNSSBlockInterface> acq_ = factory->GetBlock(config, "Acquisition", "Galileo_E1_PCPS_CCCWSR_Ambiguous_Acquisition", 1, 1, queue);
acquisition = std::dynamic_pointer_cast<AcquisitionInterface>(acq_);
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->connect(top_block); acquisition->connect(top_block);
@ -393,19 +395,17 @@ TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, 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 the 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(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ValidationOfResults) TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ValidationOfResults)
{ {
config_1(); config_1();
acquisition = new GalileoE1PcpsCccwsrAmbiguousAcquisition(config, "Acquisition", 1, 1, queue); std::shared_ptr<GNSSBlockInterface> acq_ = factory->GetBlock(config, "Acquisition", "Galileo_E1_PCPS_CCCWSR_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);
@ -439,9 +439,9 @@ TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ValidationOfResults)
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;
@ -482,16 +482,14 @@ TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ValidationOfResults)
EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL."; EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL.";
} }
} }
delete acquisition;
delete config;
} }
TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ValidationOfResultsProbabilities) TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ValidationOfResultsProbabilities)
{ {
config_2(); config_2();
acquisition = new GalileoE1PcpsCccwsrAmbiguousAcquisition(config, "Acquisition", 1, 1, queue); std::shared_ptr<GNSSBlockInterface> acq_ = factory->GetBlock(config, "Acquisition", "Galileo_E1_PCPS_CCCWSR_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);
@ -525,16 +523,16 @@ TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ValidationOfResultsProbabili
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,7 +567,4 @@ TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ValidationOfResultsProbabili
std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl; std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl;
} }
} }
delete acquisition;
delete config;
} }