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

cleaning flowgraph

This commit is contained in:
Carles Fernandez 2014-04-12 22:02:18 +02:00
parent 6b1c12f111
commit 5bde2595af
6 changed files with 53 additions and 79 deletions

View File

@ -110,11 +110,9 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetSignalSource(
std::shared_ptr<ConfigurationInterface> configuration, boost::shared_ptr<gr::msg_queue> queue) std::shared_ptr<ConfigurationInterface> configuration, boost::shared_ptr<gr::msg_queue> queue)
{ {
std::string default_implementation = "File_Signal_Source"; std::string default_implementation = "File_Signal_Source";
std::string implementation = configuration->property( std::string implementation = configuration->property("SignalSource.implementation", default_implementation);
"SignalSource.implementation", default_implementation);
LOG(INFO) << "Getting SignalSource with implementation " << implementation; LOG(INFO) << "Getting SignalSource with implementation " << implementation;
return GetBlock(configuration, "SignalSource", implementation, 0, 1, return GetBlock(configuration, "SignalSource", implementation, 0, 1, queue);
queue);
} }
@ -148,7 +146,6 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetSignalConditioner(
<< data_type_adapter << ", InputFilter implementation: " << data_type_adapter << ", InputFilter implementation: "
<< input_filter << ", and Resampler implementation: " << input_filter << ", and Resampler implementation: "
<< resampler; << resampler;
//std::unique_ptr<GNSSBlockInterface> conditioner_;
if(signal_conditioner.compare("Array_Signal_Conditioner") == 0) if(signal_conditioner.compare("Array_Signal_Conditioner") == 0)
{ {
@ -695,6 +692,7 @@ std::unique_ptr<TrackingInterface> GNSSBlockFactory::GetTrkBlock(
return std::move(block); return std::move(block);
} }
std::unique_ptr<TelemetryDecoderInterface> GNSSBlockFactory::GetTlmBlock( std::unique_ptr<TelemetryDecoderInterface> GNSSBlockFactory::GetTlmBlock(
std::shared_ptr<ConfigurationInterface> configuration, std::shared_ptr<ConfigurationInterface> configuration,
std::string role, std::string role,

View File

@ -68,8 +68,6 @@ public:
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::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, 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);
/* /*

View File

@ -54,7 +54,8 @@ GNSSFlowgraph::GNSSFlowgraph(std::shared_ptr<ConfigurationInterface> configurati
connected_ = false; connected_ = false;
running_ = false; running_ = false;
configuration_ = configuration; configuration_ = configuration;
//blocks_ = new std::vector<GNSSBlockInterface*>();
std::shared_ptr<std::vector<std::shared_ptr<GNSSBlockInterface>>> blocks_ = std::make_shared<std::vector<std::shared_ptr<GNSSBlockInterface>>>(); std::shared_ptr<std::vector<std::shared_ptr<GNSSBlockInterface>>> blocks_ = std::make_shared<std::vector<std::shared_ptr<GNSSBlockInterface>>>();
queue_ = queue; queue_ = queue;
init(); init();
@ -63,12 +64,7 @@ GNSSFlowgraph::GNSSFlowgraph(std::shared_ptr<ConfigurationInterface> configurati
GNSSFlowgraph::~GNSSFlowgraph() GNSSFlowgraph::~GNSSFlowgraph()
{ {
for (unsigned int i = 0; i < blocks_->size(); i++)
{
//delete blocks_->at(i);
}
blocks_->clear(); blocks_->clear();
//delete blocks_;
} }
@ -130,7 +126,6 @@ void GNSSFlowgraph::connect()
try try
{ {
// sig_source_ = signal_source();
sig_source_ = std::move(blocks_->at(0)); sig_source_ = std::move(blocks_->at(0));
sig_source_->connect(top_block_); sig_source_->connect(top_block_);
} }
@ -162,7 +157,6 @@ void GNSSFlowgraph::connect()
{ {
auto chan_ = std::move(blocks_->at(i + 5)); auto chan_ = std::move(blocks_->at(i + 5));
std::shared_ptr<ChannelInterface> chan = std::dynamic_pointer_cast<ChannelInterface>(chan_); std::shared_ptr<ChannelInterface> chan = std::dynamic_pointer_cast<ChannelInterface>(chan_);
channels_.push_back(chan); channels_.push_back(chan);
channels_.at(i)->connect(top_block_); channels_.at(i)->connect(top_block_);
} }
@ -207,7 +201,6 @@ void GNSSFlowgraph::connect()
{ {
output_filter_ = std::move(blocks_->at(4)); output_filter_ = std::move(blocks_->at(4));
output_filter_->connect(top_block_); output_filter_->connect(top_block_);
std::cout << "helllllout" << std::endl;
} }
catch (std::exception& e) catch (std::exception& e)
{ {
@ -220,8 +213,6 @@ void GNSSFlowgraph::connect()
DLOG(INFO) << "blocks connected internally"; DLOG(INFO) << "blocks connected internally";
// Signal Source > Signal conditioner > // Signal Source > Signal conditioner >
std::cout<< sig_source_->implementation().c_str() <<std::endl;
try try
{ {
if(sig_source_->implementation().compare("Raw_Array_Signal_Source") == 0) if(sig_source_->implementation().compare("Raw_Array_Signal_Source") == 0)
@ -237,7 +228,6 @@ void GNSSFlowgraph::connect()
else else
{ {
//single channel //single channel
// std::cout<<"NORMAL MODE"<<std::endl;
top_block_->connect(sig_source_->get_right_block(), 0, sig_conditioner_->get_left_block(), 0); top_block_->connect(sig_source_->get_right_block(), 0, sig_conditioner_->get_left_block(), 0);
} }
@ -282,12 +272,12 @@ void GNSSFlowgraph::connect()
top_block_->disconnect_all(); top_block_->disconnect_all();
return; return;
} }
std::cout<<"NORMAL MODE"<<std::endl;
channels_.at(i)->set_signal(available_GNSS_signals_.front()); channels_.at(i)->set_signal(available_GNSS_signals_.front());
LOG(INFO) << "Channel " << i << " assigned to " << available_GNSS_signals_.front(); LOG(INFO) << "Channel " << i << " assigned to " << available_GNSS_signals_.front();
available_GNSS_signals_.pop_front(); available_GNSS_signals_.pop_front();
channels_.at(i)->start(); channels_.at(i)->start();
std::cout<<"NORMAL MODE"<<std::endl;
if (channels_state_[i] == 1) if (channels_state_[i] == 1)
{ {
channels_.at(i)->start_acquisition(); channels_.at(i)->start_acquisition();
@ -452,28 +442,19 @@ void GNSSFlowgraph::set_configuration(std::shared_ptr<ConfigurationInterface> co
} }
/*
std::shared_ptr<GNSSBlockInterface> GNSSFlowgraph::signal_source() std::shared_ptr<GNSSBlockInterface> GNSSFlowgraph::signal_source()
{ {
//std::shared_ptr<GNSSBlockInterface> cond_ { blocks_->at(0) }; auto sig_source_ = std::move(blocks_->at(0));
//return cond_;
//return blocks_->at(0);
//std::shared_ptr<GNSSBlockInterface> source_ = std::make_shared<std::shared_ptr<GNSSBlockInterface>>();
//auto source_ = std::move(blocks_->at(0));
sig_source_ = std::move(blocks_->at(0));
//sig_source_ =
//std::cout << source_->implementation().c_str() << std::endl;
return std::move(sig_source_); return std::move(sig_source_);
} }
std::shared_ptr<GNSSBlockInterface> GNSSFlowgraph::signal_conditioner() std::shared_ptr<GNSSBlockInterface> GNSSFlowgraph::signal_conditioner()
{ {
auto cond_ = std::move(blocks_->at(1)); auto sig_conditioner_ = std::move(blocks_->at(1));
return std::move(cond_); return std::move(sig_conditioner_);
} }
@ -489,15 +470,15 @@ std::shared_ptr<ChannelInterface> GNSSFlowgraph::channel(unsigned int index)
std::shared_ptr<GNSSBlockInterface> GNSSFlowgraph::observables() std::shared_ptr<GNSSBlockInterface> GNSSFlowgraph::observables()
{ {
auto obs_ = std::move(blocks_->at(2)); observables_ = std::move(blocks_->at(2));
return std::move(obs_); return std::move(observables_);
} }
std::shared_ptr<GNSSBlockInterface> GNSSFlowgraph::pvt() std::shared_ptr<GNSSBlockInterface> GNSSFlowgraph::pvt()
{ {
auto pvt_ = std::move(blocks_->at(3)); pvt_ = std::move(blocks_->at(3));
return std::move(pvt_); return std::move(pvt_);
} }
@ -508,7 +489,7 @@ std::shared_ptr<GNSSBlockInterface> GNSSFlowgraph::output_filter()
auto output_ = std::move(blocks_->at(4)); auto output_ = std::move(blocks_->at(4));
return std::move(output_); return std::move(output_);
} }
*/
void GNSSFlowgraph::init() void GNSSFlowgraph::init()
@ -530,12 +511,9 @@ void GNSSFlowgraph::init()
blocks_->push_back(pvt_); blocks_->push_back(pvt_);
blocks_->push_back(output_); blocks_->push_back(output_);
std::shared_ptr<std::vector<std::unique_ptr<GNSSBlockInterface>>> channels = block_factory_->GetChannels(configuration_, queue_); std::shared_ptr<std::vector<std::unique_ptr<GNSSBlockInterface>>> channels = block_factory_->GetChannels(configuration_, queue_);
channels_count_ = channels->size(); channels_count_ = channels->size();
for (unsigned int i = 0; i < channels_count_; i++) for (unsigned int i = 0; i < channels_count_; i++)
{ {
std::shared_ptr<GNSSBlockInterface> chan_ = std::move(channels->at(i)); std::shared_ptr<GNSSBlockInterface> chan_ = std::move(channels->at(i));
@ -545,14 +523,11 @@ void GNSSFlowgraph::init()
top_block_ = gr::make_top_block("GNSSFlowgraph"); top_block_ = gr::make_top_block("GNSSFlowgraph");
// fill the available_GNSS_signals_ queue with the satellites ID's to be searched by the acquisition // fill the available_GNSS_signals_ queue with the satellites ID's to be searched by the acquisition
set_signals_list(); set_signals_list();
set_channels_state(); set_channels_state();
applied_actions_ = 0; applied_actions_ = 0;
std::vector<std::shared_ptr<ChannelInterface>> channels_(channels_count_); std::vector<std::shared_ptr<ChannelInterface>> channels_(channels_count_);
//std::shared_ptr<GNSSBlockInterface> sig_source_ = signal_source();
DLOG(INFO) << "Blocks instantiated. " << channels_count_ << " channels."; DLOG(INFO) << "Blocks instantiated. " << channels_count_ << " channels.";
} }

View File

@ -93,12 +93,19 @@ public:
void set_configuration(std::shared_ptr<ConfigurationInterface> configuration); void set_configuration(std::shared_ptr<ConfigurationInterface> configuration);
std::shared_ptr<GNSSBlockInterface> signal_source(); /*std::shared_ptr<GNSSBlockInterface> signal_source();
std::shared_ptr<GNSSBlockInterface> signal_conditioner(); std::shared_ptr<GNSSBlockInterface> signal_conditioner();
std::shared_ptr<ChannelInterface> channel(unsigned int index); std::shared_ptr<ChannelInterface> channel(unsigned int index);
std::shared_ptr<GNSSBlockInterface> observables(); std::shared_ptr<GNSSBlockInterface> observables();
std::shared_ptr<GNSSBlockInterface> pvt(); std::shared_ptr<GNSSBlockInterface> pvt();
std::shared_ptr<GNSSBlockInterface> output_filter(); std::shared_ptr<GNSSBlockInterface> output_filter();*/
std::shared_ptr<GNSSBlockInterface> sig_source_;
std::shared_ptr<GNSSBlockInterface> sig_conditioner_;
std::shared_ptr<GNSSBlockInterface> observables_;
std::shared_ptr<GNSSBlockInterface> pvt_;
std::shared_ptr<GNSSBlockInterface> output_filter_;
std::vector<std::shared_ptr<ChannelInterface>> channels_;
unsigned int applied_actions() unsigned int applied_actions()
{ {
@ -132,15 +139,13 @@ private:
std::string config_file_; std::string config_file_;
std::shared_ptr<ConfigurationInterface> configuration_; std::shared_ptr<ConfigurationInterface> configuration_;
std::shared_ptr<GNSSBlockFactory> block_factory_; std::shared_ptr<GNSSBlockFactory> block_factory_;
//std::shared_ptr<std::vector<std::shared_ptr<GNSSBlockInterface>>> blocks_;
std::shared_ptr<std::vector<std::shared_ptr<GNSSBlockInterface>>> blocks_ = std::make_shared<std::vector<std::shared_ptr<GNSSBlockInterface>>>(); std::shared_ptr<std::vector<std::shared_ptr<GNSSBlockInterface>>> blocks_ = std::make_shared<std::vector<std::shared_ptr<GNSSBlockInterface>>>();
std::shared_ptr<GNSSBlockInterface> sig_source_; /* std::shared_ptr<GNSSBlockInterface> sig_source_;
std::shared_ptr<GNSSBlockInterface> sig_conditioner_; std::shared_ptr<GNSSBlockInterface> sig_conditioner_;
std::shared_ptr<GNSSBlockInterface> observables_; std::shared_ptr<GNSSBlockInterface> observables_;
std::shared_ptr<GNSSBlockInterface> pvt_; std::shared_ptr<GNSSBlockInterface> pvt_;
std::shared_ptr<GNSSBlockInterface> output_filter_; std::shared_ptr<GNSSBlockInterface> output_filter_;
//std::shared_ptr<std::vector<std::shared_ptr<GNSSBlockInterface>>> channels_; std::vector<std::shared_ptr<ChannelInterface>> channels_; */
std::vector<std::shared_ptr<ChannelInterface>> channels_;
gr::top_block_sptr top_block_; gr::top_block_sptr top_block_;
boost::shared_ptr<gr::msg_queue> queue_; boost::shared_ptr<gr::msg_queue> queue_;
std::list<Gnss_Signal> available_GNSS_signals_; std::list<Gnss_Signal> available_GNSS_signals_;

View File

@ -56,36 +56,37 @@ TEST(GNSSFlowgraph, InstantiateConnectStartStop)
config->set_property("SignalSource.filename", filename); config->set_property("SignalSource.filename", filename);
config->set_property("SignalConditioner.implementation", "Pass_Through"); config->set_property("SignalConditioner.implementation", "Pass_Through");
config->set_property("Channels.count", "2"); config->set_property("Channels.count", "2");
config->set_property("Channels.acquisition.implementation", "Pass_Through"); config->set_property("Acquisition.implementation", "GPS_L1_CA_PCPS_Acquisition");
config->set_property("Channels.tracking.implementation", "Pass_Through"); config->set_property("Tracking.implementation", "GPS_L1_CA_DLL_PLL_Tracking");
config->set_property("Channels.telemetry.implementation", "Pass_Through"); config->set_property("TelemetryDecoder.implementation", "GPS_L1_CA_Telemetry_Decoder");
config->set_property("Channels.observables.implementation", "Pass_Through"); //config->set_property("Channels.observables.implementation", "Pass_Through");
config->set_property("Observables.implementation", "GPS_L1_CA_Observables"); config->set_property("Observables.implementation", "GPS_L1_CA_Observables");
config->set_property("PVT.implementation", "GPS_L1_CA_PVT"); config->set_property("PVT.implementation", "GPS_L1_CA_PVT");
config->set_property("OutputFilter.implementation", "Null_Sink_Output_Filter"); config->set_property("OutputFilter.implementation", "Null_Sink_Output_Filter");
GNSSFlowgraph* flowgraph = new GNSSFlowgraph(config, gr::msg_queue::make(0)); std::shared_ptr<GNSSFlowgraph> flowgraph = std::make_shared<GNSSFlowgraph>(config, gr::msg_queue::make(0));
flowgraph->set_configuration(config);
EXPECT_STREQ("File_Signal_Source", flowgraph->signal_source()->implementation().c_str());
EXPECT_STREQ("Pass_Through", flowgraph->signal_conditioner()->implementation().c_str());
EXPECT_STREQ("Channel", flowgraph->channel(0)->implementation().c_str());
EXPECT_STREQ("Pass_Through", ((Channel*)flowgraph->channel(0))->acquisition()->implementation().c_str());
EXPECT_STREQ("Pass_Through", ((Channel*)flowgraph->channel(0))->tracking()->implementation().c_str());
EXPECT_STREQ("Pass_Through", ((Channel*)flowgraph->channel(0))->telemetry()->implementation().c_str());
EXPECT_STREQ("Channel", flowgraph->channel(1)->implementation().c_str());
EXPECT_STREQ("Pass_Through", ((Channel*)flowgraph->channel(1))->acquisition()->implementation().c_str());
EXPECT_STREQ("Pass_Through", ((Channel*)flowgraph->channel(1))->tracking()->implementation().c_str());
EXPECT_STREQ("Pass_Through", ((Channel*)flowgraph->channel(1))->telemetry()->implementation().c_str());
EXPECT_STREQ("GPS_L1_CA_Observables", flowgraph->observables()->implementation().c_str());
EXPECT_STREQ("GPS_L1_CA_PVT", flowgraph->pvt()->implementation().c_str());
EXPECT_STREQ("Null_Sink_Output_Filter", flowgraph->output_filter()->implementation().c_str());
EXPECT_NO_THROW(flowgraph->connect()); EXPECT_NO_THROW(flowgraph->connect());
EXPECT_TRUE(flowgraph->connected()); EXPECT_TRUE(flowgraph->connected());
EXPECT_STREQ("File_Signal_Source", flowgraph->sig_source_->implementation().c_str());
EXPECT_STREQ("Pass_Through", flowgraph->sig_conditioner_->implementation().c_str());
EXPECT_STREQ("Channel", flowgraph->channels_.at(0)->implementation().c_str());
// EXPECT_STREQ("Pass_Through", (flowgraph->channel(0)->acquisition()->implementation().c_str()));
// EXPECT_STREQ("Pass_Through", (flowgraph->channel(0)->tracking()->implementation().c_str());
// EXPECT_STREQ("Pass_Through", (flowgraph->channel(0)->telemetry()->implementation().c_str());
EXPECT_STREQ("Channel", flowgraph->channels_.at(1)->implementation().c_str());
// EXPECT_STREQ("Pass_Through", (flowgraph->channel(1)->acquisition()->implementation().c_str());
// EXPECT_STREQ("Pass_Through", (flowgraph->channel(1)->tracking()->implementation().c_str());
// EXPECT_STREQ("Pass_Through", (flowgraph->channel(1)->telemetry()->implementation().c_str());
EXPECT_STREQ("GPS_L1_CA_Observables", flowgraph->observables_->implementation().c_str());
EXPECT_STREQ("GPS_L1_CA_PVT", flowgraph->pvt_->implementation().c_str());
EXPECT_STREQ("Null_Sink_Output_Filter", flowgraph->output_filter_->implementation().c_str());
EXPECT_NO_THROW(flowgraph->start()); EXPECT_NO_THROW(flowgraph->start());
EXPECT_TRUE(flowgraph->running()); EXPECT_TRUE(flowgraph->running());
flowgraph->stop(); flowgraph->stop();
EXPECT_FALSE(flowgraph->running()); EXPECT_FALSE(flowgraph->running());
delete flowgraph; //delete flowgraph;
} }

View File

@ -285,11 +285,8 @@ TEST(GNSS_Block_Factory_Test, InstantiateChannels)
gr::msg_queue::sptr queue = gr::msg_queue::make(0); gr::msg_queue::sptr queue = gr::msg_queue::make(0);
std::unique_ptr<GNSSBlockFactory> factory; std::unique_ptr<GNSSBlockFactory> factory;
std::unique_ptr<std::vector<std::unique_ptr<GNSSBlockInterface>>> channels = std::move(factory->GetChannels(configuration, queue)); std::unique_ptr<std::vector<std::unique_ptr<GNSSBlockInterface>>> channels = std::move(factory->GetChannels(configuration, queue));
EXPECT_EQ((unsigned int) 2, channels->size()); EXPECT_EQ((unsigned int) 2, channels->size());
channels->erase(channels->begin(), channels->end()); channels->erase(channels->begin(), channels->end());
//channels->clear();
} }