mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-07-02 10:02:51 +00:00
minor code cleaning
git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@195 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
parent
1c0fed749d
commit
72df1f7ced
@ -8,7 +8,7 @@
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors)
|
||||
* Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
@ -47,7 +47,8 @@
|
||||
using google::LogMessage;
|
||||
|
||||
GNSSFlowgraph::GNSSFlowgraph(ConfigurationInterface *configuration,
|
||||
gr_msg_queue_sptr queue) {
|
||||
gr_msg_queue_sptr queue)
|
||||
{
|
||||
connected_ = false;
|
||||
running_ = false;
|
||||
configuration_ = configuration;
|
||||
@ -55,31 +56,37 @@ GNSSFlowgraph::GNSSFlowgraph(ConfigurationInterface *configuration,
|
||||
block_factory_ = new GNSSBlockFactory();
|
||||
queue_ = queue;
|
||||
//available_GNSS_signals_ = new std::list<Gnss_Satellite>();
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
GNSSFlowgraph::~GNSSFlowgraph() {
|
||||
|
||||
GNSSFlowgraph::~GNSSFlowgraph()
|
||||
{
|
||||
delete block_factory_;
|
||||
|
||||
for (unsigned int i = 0; i < blocks_->size(); i++) {
|
||||
for (unsigned int i = 0; i < blocks_->size(); i++)
|
||||
{
|
||||
delete blocks_->at(i);
|
||||
}
|
||||
blocks_->clear();
|
||||
|
||||
delete blocks_;
|
||||
}
|
||||
|
||||
void GNSSFlowgraph::start() {
|
||||
if (running_) {
|
||||
|
||||
|
||||
void GNSSFlowgraph::start()
|
||||
{
|
||||
if (running_)
|
||||
{
|
||||
LOG_AT_LEVEL(WARNING) << "Already running";
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
top_block_->start();
|
||||
} catch (std::exception& e) {
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
LOG_AT_LEVEL(ERROR) << "Unable to start flowgraph";
|
||||
LOG_AT_LEVEL(ERROR) << e.what();
|
||||
return;
|
||||
@ -88,13 +95,18 @@ void GNSSFlowgraph::start() {
|
||||
running_ = true;
|
||||
}
|
||||
|
||||
void GNSSFlowgraph::stop() {
|
||||
for (unsigned int i = 0; i < channels_count_; i++) {
|
||||
// if(channels_state_[i]==2) channel(i)->
|
||||
|
||||
|
||||
void GNSSFlowgraph::stop()
|
||||
{
|
||||
for (unsigned int i = 0; i < channels_count_; i++)
|
||||
{
|
||||
// if(channels_state_[i]==2) channel(i)->
|
||||
channel(i)->stop();
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < channels_count_; i++) {
|
||||
for (unsigned int i = 0; i < channels_count_; i++)
|
||||
{
|
||||
std::cout << "Channel " << i << " in state " << channels_state_[i]
|
||||
<< std::endl;
|
||||
}
|
||||
@ -104,20 +116,27 @@ void GNSSFlowgraph::stop() {
|
||||
running_ = false;
|
||||
}
|
||||
|
||||
void GNSSFlowgraph::connect() {
|
||||
|
||||
|
||||
void GNSSFlowgraph::connect()
|
||||
{
|
||||
/* Connects the blocks in the flowgraph
|
||||
*
|
||||
* Signal Source > Signal conditioner >> Channels >> Observables >> PVT > Output filter
|
||||
*/
|
||||
DLOG(INFO) << "Connecting flowgraph";
|
||||
if (connected_) {
|
||||
if (connected_)
|
||||
{
|
||||
LOG_AT_LEVEL(WARNING) << "flowgraph already connected";
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
signal_source()->connect(top_block_);
|
||||
} catch (std::exception& e) {
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
LOG_AT_LEVEL(ERROR) << "Can't connect signal source block internally";
|
||||
LOG_AT_LEVEL(ERROR) << e.what();
|
||||
top_block_->disconnect_all();
|
||||
@ -125,9 +144,12 @@ void GNSSFlowgraph::connect() {
|
||||
}
|
||||
|
||||
// Signal Source > Signal conditioner >
|
||||
try {
|
||||
try
|
||||
{
|
||||
signal_conditioner()->connect(top_block_);
|
||||
} catch (std::exception& e) {
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
LOG_AT_LEVEL(ERROR)
|
||||
<< "Can't connect signal conditioner block internally";
|
||||
LOG_AT_LEVEL(ERROR) << e.what();
|
||||
@ -135,10 +157,14 @@ void GNSSFlowgraph::connect() {
|
||||
return;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < channels_count_; i++) {
|
||||
try {
|
||||
for (unsigned int i = 0; i < channels_count_; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
channel(i)->connect(top_block_);
|
||||
} catch (std::exception& e) {
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
LOG_AT_LEVEL(ERROR) << "Can't connect channel " << i
|
||||
<< " internally";
|
||||
LOG_AT_LEVEL(ERROR) << e.what();
|
||||
@ -147,9 +173,12 @@ void GNSSFlowgraph::connect() {
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
observables()->connect(top_block_);
|
||||
} catch (std::exception& e) {
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
LOG_AT_LEVEL(ERROR) << "Can't connect observables block internally";
|
||||
LOG_AT_LEVEL(ERROR) << e.what();
|
||||
top_block_->disconnect_all();
|
||||
@ -157,9 +186,12 @@ void GNSSFlowgraph::connect() {
|
||||
}
|
||||
|
||||
// Signal Source > Signal conditioner >> Channels >> Observables > PVT
|
||||
try {
|
||||
try
|
||||
{
|
||||
pvt()->connect(top_block_);
|
||||
} catch (std::exception& e) {
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
LOG_AT_LEVEL(ERROR) << "Can't connect PVT block internally";
|
||||
LOG_AT_LEVEL(ERROR) << e.what();
|
||||
top_block_->disconnect_all();
|
||||
@ -167,9 +199,12 @@ void GNSSFlowgraph::connect() {
|
||||
}
|
||||
|
||||
// Signal Source > Signal conditioner >> Channels >> Observables > PVT > Output Filter
|
||||
try {
|
||||
try
|
||||
{
|
||||
output_filter()->connect(top_block_);
|
||||
} catch (std::exception& e) {
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
LOG_AT_LEVEL(ERROR) << "Can't connect output filter block internally";
|
||||
LOG_AT_LEVEL(ERROR) << e.what();
|
||||
top_block_->disconnect_all();
|
||||
@ -179,10 +214,13 @@ void GNSSFlowgraph::connect() {
|
||||
DLOG(INFO) << "blocks connected internally";
|
||||
|
||||
// Signal Source > Signal conditioner >
|
||||
try {
|
||||
try
|
||||
{
|
||||
top_block_->connect(signal_source()->get_right_block(), 0,
|
||||
signal_conditioner()->get_left_block(), 0);
|
||||
} catch (std::exception& e) {
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
LOG_AT_LEVEL(ERROR)
|
||||
<< "Can't connect signal source to signal conditioner";
|
||||
LOG_AT_LEVEL(ERROR) << e.what();
|
||||
@ -192,11 +230,15 @@ void GNSSFlowgraph::connect() {
|
||||
DLOG(INFO) << "Signal source connected to signal conditioner";
|
||||
|
||||
// Signal Source > Signal conditioner >> channels_count_ number of Channels in parallel
|
||||
for (unsigned int i = 0; i < channels_count_; i++) {
|
||||
try {
|
||||
for (unsigned int i = 0; i < channels_count_; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
top_block_->connect(signal_conditioner()->get_right_block(), 0,
|
||||
channel(i)->get_left_block(), 0);
|
||||
} catch (std::exception& e) {
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
LOG_AT_LEVEL(ERROR)
|
||||
<< "Can't connect signal conditioner to channel " << i;
|
||||
LOG_AT_LEVEL(ERROR) << e.what();
|
||||
@ -207,10 +249,13 @@ void GNSSFlowgraph::connect() {
|
||||
DLOG(INFO) << "signal conditioner connected to channel " << i;
|
||||
|
||||
// Signal Source > Signal conditioner >> Channels >> Observables
|
||||
try {
|
||||
try
|
||||
{
|
||||
top_block_->connect(channel(i)->get_right_block(), 0,
|
||||
observables()->get_left_block(), i);
|
||||
} catch (std::exception& e) {
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
LOG_AT_LEVEL(ERROR) << "Can't connect channel " << i
|
||||
<< " to observables";
|
||||
LOG_AT_LEVEL(ERROR) << e.what();
|
||||
@ -223,11 +268,14 @@ void GNSSFlowgraph::connect() {
|
||||
<< available_GNSS_signals_.front() << std::endl;
|
||||
available_GNSS_signals_.pop_front();
|
||||
channel(i)->start();
|
||||
if (channels_state_[i] == 1) {
|
||||
if (channels_state_[i] == 1)
|
||||
{
|
||||
channel(i)->start_acquisition();
|
||||
DLOG(INFO) << "Channel " << i
|
||||
<< " connected to observables and ready for acquisition";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
DLOG(INFO) << "Channel " << i
|
||||
<< " connected to observables in standby mode";
|
||||
}
|
||||
@ -236,22 +284,29 @@ void GNSSFlowgraph::connect() {
|
||||
/*
|
||||
* Connect the observables output of each channel to the PVT block
|
||||
*/
|
||||
try {
|
||||
for (unsigned int i = 0; i < channels_count_; i++) {
|
||||
try
|
||||
{
|
||||
for (unsigned int i = 0; i < channels_count_; i++)
|
||||
{
|
||||
top_block_->connect(observables()->get_right_block(), i,
|
||||
pvt()->get_left_block(), i);
|
||||
}
|
||||
} catch (std::exception& e) {
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
LOG_AT_LEVEL(ERROR) << "Can't connect observables to PVT";
|
||||
LOG_AT_LEVEL(ERROR) << e.what();
|
||||
top_block_->disconnect_all();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
top_block_->connect(pvt()->get_right_block(), 0,
|
||||
output_filter()->get_left_block(), 0);
|
||||
} catch (std::exception& e) {
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
LOG_AT_LEVEL(ERROR) << "Can't connect PVT to output filter";
|
||||
LOG_AT_LEVEL(ERROR) << e.what();
|
||||
top_block_->disconnect_all();
|
||||
@ -259,15 +314,18 @@ void GNSSFlowgraph::connect() {
|
||||
}
|
||||
|
||||
DLOG(INFO) << "PVT connected to output filter";
|
||||
|
||||
connected_ = true;
|
||||
DLOG(INFO) << "Flowgraph connected";
|
||||
top_block_->dump();
|
||||
|
||||
}
|
||||
|
||||
void GNSSFlowgraph::wait() {
|
||||
if (!running_) {
|
||||
|
||||
|
||||
|
||||
void GNSSFlowgraph::wait()
|
||||
{
|
||||
if (!running_)
|
||||
{
|
||||
LOG_AT_LEVEL(WARNING) << "Can't apply wait. Flowgraph is not running";
|
||||
return;
|
||||
}
|
||||
@ -276,16 +334,22 @@ void GNSSFlowgraph::wait() {
|
||||
running_ = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Applies an action to the flowgraph
|
||||
*
|
||||
* \param[in] who Who generated the action
|
||||
* \param[in] what What is the action 0: acquisition failed
|
||||
*/
|
||||
void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) {
|
||||
void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what)
|
||||
{
|
||||
DLOG(INFO) << "received " << what << " from " << who;
|
||||
|
||||
switch (what) {
|
||||
switch (what)
|
||||
{
|
||||
case 0:
|
||||
|
||||
DLOG(INFO) << "Channel " << who << " ACQ FAILED satellite "
|
||||
@ -301,12 +365,14 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) {
|
||||
|
||||
DLOG(INFO) << "Channel " << who << " ACQ SUCCESS satellite "
|
||||
<< channel(who)->get_signal().get_satellite();
|
||||
|
||||
channels_state_[who] = 2;
|
||||
acq_channels_count_--;
|
||||
if (acq_channels_count_ < max_acq_channels_) {
|
||||
for (unsigned int i = 0; i < channels_count_; i++) {
|
||||
if (channels_state_[i] == 0) {
|
||||
if (acq_channels_count_ < max_acq_channels_)
|
||||
{
|
||||
for (unsigned int i = 0; i < channels_count_; i++)
|
||||
{
|
||||
if (channels_state_[i] == 0)
|
||||
{
|
||||
channels_state_[i] = 1;
|
||||
acq_channels_count_++;
|
||||
channel(i)->start_acquisition();
|
||||
@ -315,7 +381,8 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) {
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < channels_count_; i++) {
|
||||
for (unsigned int i = 0; i < channels_count_; i++)
|
||||
{
|
||||
std::cout << "Channel " << i << " in state " << channels_state_[i]
|
||||
<< std::endl;
|
||||
}
|
||||
@ -326,16 +393,20 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) {
|
||||
DLOG(INFO) << "Channel " << who << " TRK FAILED satellite "
|
||||
<< channel(who)->get_signal().get_satellite();
|
||||
|
||||
if (acq_channels_count_ < max_acq_channels_) {
|
||||
if (acq_channels_count_ < max_acq_channels_)
|
||||
{
|
||||
channels_state_[who] = 1;
|
||||
acq_channels_count_++;
|
||||
channel(who)->start_acquisition();
|
||||
}else {
|
||||
}
|
||||
else
|
||||
{
|
||||
channels_state_[who] = 0;
|
||||
channel(who)->standby();
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < channels_count_; i++) {
|
||||
for (unsigned int i = 0; i < channels_count_; i++)
|
||||
{
|
||||
std::cout << "Channel " << i << " in state " << channels_state_[i]
|
||||
<< std::endl;
|
||||
}
|
||||
@ -344,51 +415,75 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
DLOG(INFO) << "Number of available satellites: "
|
||||
<< available_GNSS_signals_.size();
|
||||
}
|
||||
|
||||
void GNSSFlowgraph::set_configuration(ConfigurationInterface* configuration) {
|
||||
if (running_) {
|
||||
|
||||
|
||||
void GNSSFlowgraph::set_configuration(ConfigurationInterface* configuration)
|
||||
{
|
||||
if (running_)
|
||||
{
|
||||
LOG_AT_LEVEL(WARNING)
|
||||
<< "Unable to update configuration while flowgraph running";
|
||||
return;
|
||||
}
|
||||
|
||||
if (connected_) {
|
||||
if (connected_)
|
||||
{
|
||||
LOG_AT_LEVEL(WARNING)
|
||||
<< "Unable to update configuration while flowgraph connected";
|
||||
}
|
||||
|
||||
configuration_ = configuration;
|
||||
}
|
||||
|
||||
GNSSBlockInterface* GNSSFlowgraph::signal_source() {
|
||||
|
||||
|
||||
GNSSBlockInterface* GNSSFlowgraph::signal_source()
|
||||
{
|
||||
return blocks_->at(0);
|
||||
}
|
||||
|
||||
GNSSBlockInterface* GNSSFlowgraph::signal_conditioner() {
|
||||
|
||||
|
||||
GNSSBlockInterface* GNSSFlowgraph::signal_conditioner()
|
||||
{
|
||||
return blocks_->at(1);
|
||||
}
|
||||
|
||||
ChannelInterface* GNSSFlowgraph::channel(unsigned int index) {
|
||||
|
||||
|
||||
ChannelInterface* GNSSFlowgraph::channel(unsigned int index)
|
||||
{
|
||||
return (ChannelInterface*) blocks_->at(index + 5);
|
||||
}
|
||||
|
||||
GNSSBlockInterface* GNSSFlowgraph::observables() {
|
||||
|
||||
|
||||
GNSSBlockInterface* GNSSFlowgraph::observables()
|
||||
{
|
||||
return blocks_->at(2);
|
||||
}
|
||||
|
||||
GNSSBlockInterface* GNSSFlowgraph::pvt() {
|
||||
|
||||
|
||||
GNSSBlockInterface* GNSSFlowgraph::pvt()
|
||||
{
|
||||
return blocks_->at(3);
|
||||
}
|
||||
|
||||
GNSSBlockInterface* GNSSFlowgraph::output_filter() {
|
||||
|
||||
|
||||
GNSSBlockInterface* GNSSFlowgraph::output_filter()
|
||||
{
|
||||
return blocks_->at(4);
|
||||
}
|
||||
|
||||
void GNSSFlowgraph::init() {
|
||||
|
||||
|
||||
void GNSSFlowgraph::init()
|
||||
{
|
||||
/*
|
||||
* Instantiates the receiver blocks
|
||||
*/
|
||||
@ -404,7 +499,8 @@ void GNSSFlowgraph::init() {
|
||||
|
||||
channels_count_ = channels->size();
|
||||
|
||||
for (unsigned int i = 0; i < channels_count_; i++) {
|
||||
for (unsigned int i = 0; i < channels_count_; i++)
|
||||
{
|
||||
blocks_->push_back(channels->at(i));
|
||||
}
|
||||
|
||||
@ -415,7 +511,6 @@ void GNSSFlowgraph::init() {
|
||||
// fill the available_GNSS_signals_ queue with the satellites ID's to be searched by the acquisition
|
||||
|
||||
set_signals_list();
|
||||
|
||||
set_channels_state();
|
||||
|
||||
applied_actions_ = 0;
|
||||
@ -423,8 +518,8 @@ void GNSSFlowgraph::init() {
|
||||
DLOG(INFO) << "Blocks instantiated. " << channels_count_ << " channels.";
|
||||
}
|
||||
|
||||
void GNSSFlowgraph::set_signals_list() {
|
||||
|
||||
void GNSSFlowgraph::set_signals_list()
|
||||
{
|
||||
/*
|
||||
* Sets a sequential list of satellites (1...32)
|
||||
*/
|
||||
@ -447,7 +542,8 @@ void GNSSFlowgraph::set_signals_list() {
|
||||
*/
|
||||
|
||||
for (available_gps_prn_iter = available_gps_prn.begin(); available_gps_prn_iter
|
||||
!= available_gps_prn.end(); available_gps_prn_iter++) {
|
||||
!= available_gps_prn.end(); available_gps_prn_iter++)
|
||||
{
|
||||
signal_value = Gnss_Signal(Gnss_Satellite(std::string("GPS"),
|
||||
*available_gps_prn_iter), std::string("1C"));
|
||||
available_GNSS_signals_.push_back(signal_value);
|
||||
@ -455,7 +551,8 @@ void GNSSFlowgraph::set_signals_list() {
|
||||
|
||||
std::list<Gnss_Signal>::iterator gnss_it = available_GNSS_signals_.begin();
|
||||
|
||||
for (unsigned int i = 0; i < channels_count_; i++) {
|
||||
for (unsigned int i = 0; i < channels_count_; i++)
|
||||
{
|
||||
std::string default_system = "GPS";
|
||||
std::string default_signal = "1C";
|
||||
|
||||
@ -471,7 +568,9 @@ void GNSSFlowgraph::set_signals_list() {
|
||||
if ((sat == 0) || (sat == gnss_it->get_satellite().get_PRN())) // 0 = not PRN in configuration file
|
||||
{
|
||||
gnss_it++;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
signal_value = Gnss_Signal(Gnss_Satellite(gnss_system, sat),
|
||||
gnss_signal);
|
||||
available_GNSS_signals_.remove(signal_value);
|
||||
@ -488,12 +587,15 @@ void GNSSFlowgraph::set_signals_list() {
|
||||
|
||||
}
|
||||
|
||||
void GNSSFlowgraph::set_channels_state() {
|
||||
|
||||
|
||||
void GNSSFlowgraph::set_channels_state()
|
||||
{
|
||||
max_acq_channels_ = (configuration_->property("Channels.in_acquisition",
|
||||
channels_count_));
|
||||
|
||||
if (max_acq_channels_ > channels_count_) {
|
||||
if (max_acq_channels_ > channels_count_)
|
||||
{
|
||||
max_acq_channels_ = channels_count_;
|
||||
std::cout
|
||||
<< "Channels_in_acquisition is bigger than number of channels. Variable acq_channels_count_ is set to "
|
||||
@ -502,8 +604,10 @@ void GNSSFlowgraph::set_channels_state() {
|
||||
|
||||
channels_state_.reserve(channels_count_);
|
||||
|
||||
for (unsigned int i = 0; i < channels_count_; i++) {
|
||||
if (i < max_acq_channels_) {
|
||||
for (unsigned int i = 0; i < channels_count_; i++)
|
||||
{
|
||||
if (i < max_acq_channels_)
|
||||
{
|
||||
channels_state_.push_back(1);
|
||||
} else
|
||||
channels_state_.push_back(0);
|
||||
@ -512,13 +616,17 @@ void GNSSFlowgraph::set_channels_state() {
|
||||
|
||||
DLOG(INFO) << acq_channels_count_ << " channels in acquisition state";
|
||||
|
||||
for (unsigned int i = 0; i < channels_count_; i++) {
|
||||
for (unsigned int i = 0; i < channels_count_; i++)
|
||||
{
|
||||
std::cout << "Channel " << i << " in state " << channels_state_[i]
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void GNSSFlowgraph::apply_action(unsigned int what) {
|
||||
|
||||
|
||||
void GNSSFlowgraph::apply_action(unsigned int what)
|
||||
{
|
||||
DLOG(INFO) << "Applied action " << what << " to flowgraph";
|
||||
applied_actions_++;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user