1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-08-06 22:04:07 +00:00

Code cleaning

git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@278 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
Carles Fernandez 2012-11-01 18:26:58 +00:00
parent aff4aeefb5
commit 5662d021d5
7 changed files with 129 additions and 138 deletions

View File

@ -6,7 +6,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 * GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver * Satellite Systems receiver
@ -51,18 +51,16 @@ Channel::Channel(ConfigurationInterface *configuration, unsigned int channel,
GNSSBlockInterface *pass_through, AcquisitionInterface *acq, GNSSBlockInterface *pass_through, AcquisitionInterface *acq,
TrackingInterface *trk, TelemetryDecoderInterface *nav, TrackingInterface *trk, TelemetryDecoderInterface *nav,
std::string role, std::string implementation, gr_msg_queue_sptr queue) : std::string role, std::string implementation, gr_msg_queue_sptr queue) :
pass_through_(pass_through), acq_(acq), trk_(trk), nav_(nav), pass_through_(pass_through), acq_(acq), trk_(trk), nav_(nav),
role_(role), implementation_(implementation), channel_(channel), role_(role), implementation_(implementation), channel_(channel),
queue_(queue) queue_(queue)
{ {
stop_ = false; stop_ = false;
acq_->set_channel(channel_); acq_->set_channel(channel_);
trk_->set_channel(channel_); trk_->set_channel(channel_);
nav_->set_channel(channel_); nav_->set_channel(channel_);
gnss_synchro_.Channel_ID=channel_; gnss_synchro_.Channel_ID = channel_;
acq_->set_gnss_synchro(&gnss_synchro_); acq_->set_gnss_synchro(&gnss_synchro_);
trk_->set_gnss_synchro(&gnss_synchro_); trk_->set_gnss_synchro(&gnss_synchro_);
@ -108,32 +106,27 @@ Channel::~Channel()
void Channel::connect(gr_top_block_sptr top_block) void Channel::connect(gr_top_block_sptr top_block)
{ {
if (connected_) if (connected_)
{ {
LOG_AT_LEVEL(WARNING) << "channel already connected internally"; LOG_AT_LEVEL(WARNING) << "channel already connected internally";
return; return;
} }
pass_through_->connect(top_block); pass_through_->connect(top_block);
acq_->connect(top_block); acq_->connect(top_block);
trk_->connect(top_block); trk_->connect(top_block);
nav_->connect(top_block); nav_->connect(top_block);
top_block->connect(pass_through_->get_right_block(), 0, top_block->connect(pass_through_->get_right_block(), 0, acq_->get_left_block(), 0);
acq_->get_left_block(), 0);
DLOG(INFO) << "pass_through_ -> acquisition"; DLOG(INFO) << "pass_through_ -> acquisition";
top_block->connect(pass_through_->get_right_block(), 0, trk_->get_left_block(), 0);
top_block->connect(pass_through_->get_right_block(), 0,
trk_->get_left_block(), 0);
DLOG(INFO) << "pass_through_ -> tracking"; DLOG(INFO) << "pass_through_ -> tracking";
top_block->connect(trk_->get_right_block(), 0, nav_->get_left_block(), 0); top_block->connect(trk_->get_right_block(), 0, nav_->get_left_block(), 0);
DLOG(INFO) << "tracking -> telemetry_decoder"; DLOG(INFO) << "tracking -> telemetry_decoder";
connected_ = true; connected_ = true;
} }
void Channel::disconnect(gr_top_block_sptr top_block) void Channel::disconnect(gr_top_block_sptr top_block)
{ {
if (!connected_) if (!connected_)
@ -141,18 +134,13 @@ void Channel::disconnect(gr_top_block_sptr top_block)
LOG_AT_LEVEL(WARNING) << "Channel already disconnected internally"; LOG_AT_LEVEL(WARNING) << "Channel already disconnected internally";
return; return;
} }
top_block->disconnect(pass_through_->get_right_block(), 0, acq_->get_left_block(), 0);
top_block->disconnect(pass_through_->get_right_block(), 0, top_block->disconnect(pass_through_->get_right_block(), 0, trk_->get_left_block(), 0);
acq_->get_left_block(), 0);
top_block->disconnect(pass_through_->get_right_block(), 0,
trk_->get_left_block(), 0);
top_block->disconnect(trk_->get_right_block(), 0, nav_->get_left_block(), 0); top_block->disconnect(trk_->get_right_block(), 0, nav_->get_left_block(), 0);
pass_through_->disconnect(top_block); pass_through_->disconnect(top_block);
acq_->disconnect(top_block); acq_->disconnect(top_block);
trk_->disconnect(top_block); trk_->disconnect(top_block);
nav_->disconnect(top_block); nav_->disconnect(top_block);
connected_ = false; connected_ = false;
} }
@ -205,12 +193,17 @@ void Channel::run()
channel_internal_queue_.wait_and_pop(message_); channel_internal_queue_.wait_and_pop(message_);
process_channel_messages(); process_channel_messages();
} }
} }
void Channel::standby(){
void Channel::standby()
{
channel_fsm_.Event_gps_failed_tracking_standby(); channel_fsm_.Event_gps_failed_tracking_standby();
} }
/* /*
* Set stop_ to true and blocks the calling thread until * Set stop_ to true and blocks the calling thread until
* the thread of the constructor has completed * the thread of the constructor has completed
@ -218,8 +211,7 @@ void Channel::standby(){
void Channel::stop() void Channel::stop()
{ {
channel_internal_queue_.push(0); //message to stop channel channel_internal_queue_.push(0); //message to stop channel
stop_ = true; stop_ = true;
/* When the boost::thread object that represents a thread of execution /* When the boost::thread object that represents a thread of execution
* is destroyed the thread becomes detached. Once a thread is detached, * is destroyed the thread becomes detached. Once a thread is detached,
* it will continue executing until the invocation of the function or * it will continue executing until the invocation of the function or
@ -234,26 +226,23 @@ void Channel::stop()
ch_thread_.join(); ch_thread_.join();
} }
void Channel::process_channel_messages() void Channel::process_channel_messages()
{ {
switch (message_) switch (message_)
{ {
case 0: case 0:
DLOG(INFO) << "Stop channel " << channel_; DLOG(INFO) << "Stop channel " << channel_;
break; break;
case 1: case 1:
DLOG(INFO) << "Channel " << channel_ << " ACQ SUCCESS satellite " <<
DLOG(INFO) << "Channel " << channel_ gnss_synchro_.System << " " << gnss_synchro_.PRN;
<< " ACQ SUCCESS satellite " << gnss_synchro_.System << " " << gnss_synchro_.PRN;
channel_fsm_.Event_gps_valid_acquisition(); channel_fsm_.Event_gps_valid_acquisition();
break; break;
case 2: case 2:
DLOG(INFO) << "Channel " << channel_
DLOG(INFO) << "Channel " << channel_ << " ACQ FAILED satellite " << gnss_synchro_.System << " " << gnss_synchro_.PRN;
<< " ACQ FAILED satellite " << gnss_synchro_.System << " "<< gnss_synchro_.PRN;
if (repeat_ == true) if (repeat_ == true)
{ {
channel_fsm_.Event_gps_failed_acquisition_repeat(); channel_fsm_.Event_gps_failed_acquisition_repeat();
@ -263,9 +252,6 @@ void Channel::process_channel_messages()
channel_fsm_.Event_gps_failed_acquisition_no_repeat(); channel_fsm_.Event_gps_failed_acquisition_no_repeat();
} }
break; break;
default: default:
LOG_AT_LEVEL(WARNING) << "Default case, invalid message."; LOG_AT_LEVEL(WARNING) << "Default case, invalid message.";
break; break;

View File

@ -40,25 +40,22 @@
#include <gnuradio/gr_io_signature.h> #include <gnuradio/gr_io_signature.h>
#include <glog/log_severity.h> #include <glog/log_severity.h>
#include <glog/logging.h> #include <glog/logging.h>
#include "gnss_synchro.h" #include "gnss_synchro.h"
using google::LogMessage; using google::LogMessage;
gps_l1_ca_observables_cc_sptr gps_l1_ca_observables_cc_sptr
gps_l1_ca_make_observables_cc(unsigned int nchannels, gr_msg_queue_sptr queue, bool dump, std::string dump_filename, int output_rate_ms, bool flag_averaging) gps_l1_ca_make_observables_cc(unsigned int nchannels, gr_msg_queue_sptr queue, bool dump, std::string dump_filename, int output_rate_ms, bool flag_averaging)
{ {
return gps_l1_ca_observables_cc_sptr(new gps_l1_ca_observables_cc(nchannels, queue, dump, dump_filename, output_rate_ms, flag_averaging)); return gps_l1_ca_observables_cc_sptr(new gps_l1_ca_observables_cc(nchannels, queue, dump, dump_filename, output_rate_ms, flag_averaging));
} }
gps_l1_ca_observables_cc::gps_l1_ca_observables_cc(unsigned int nchannels, gr_msg_queue_sptr queue, bool dump, std::string dump_filename, int output_rate_ms, bool flag_averaging) : gps_l1_ca_observables_cc::gps_l1_ca_observables_cc(unsigned int nchannels, gr_msg_queue_sptr queue, bool dump, std::string dump_filename, int output_rate_ms, bool flag_averaging) :
gr_block ("gps_l1_ca_observables_cc", gr_make_io_signature (nchannels, nchannels, sizeof(Gnss_Synchro)), gr_block ("gps_l1_ca_observables_cc", gr_make_io_signature (nchannels, nchannels, sizeof(Gnss_Synchro)),
gr_make_io_signature(nchannels, nchannels, sizeof(Gnss_Synchro))) gr_make_io_signature(nchannels, nchannels, sizeof(Gnss_Synchro)))
{ {
// initialize internal vars // initialize internal vars
d_queue = queue; d_queue = queue;
@ -80,13 +77,16 @@ gps_l1_ca_observables_cc::gps_l1_ca_observables_cc(unsigned int nchannels, gr_ms
d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary);
std::cout << "Observables dump enabled Log file: " << d_dump_filename.c_str() << std::endl; std::cout << "Observables dump enabled Log file: " << d_dump_filename.c_str() << std::endl;
} }
catch (std::ifstream::failure e) { catch (std::ifstream::failure e)
{
std::cout << "Exception opening observables dump file " << e.what() << std::endl; std::cout << "Exception opening observables dump file " << e.what() << std::endl;
} }
} }
} }
} }
gps_l1_ca_observables_cc::~gps_l1_ca_observables_cc() gps_l1_ca_observables_cc::~gps_l1_ca_observables_cc()
{ {
d_dump_file.close(); d_dump_file.close();
@ -94,28 +94,35 @@ gps_l1_ca_observables_cc::~gps_l1_ca_observables_cc()
} }
bool pairCompare_gnss_synchro_Prn_delay_ms( std::pair<int,Gnss_Synchro> a, std::pair<int,Gnss_Synchro> b) bool pairCompare_gnss_synchro_Prn_delay_ms( std::pair<int,Gnss_Synchro> a, std::pair<int,Gnss_Synchro> b)
{ {
return (a.second.Prn_timestamp_ms) < (b.second.Prn_timestamp_ms); return (a.second.Prn_timestamp_ms) < (b.second.Prn_timestamp_ms);
} }
bool pairCompare_gnss_synchro_preamble_symbol_count( std::pair<int,Gnss_Synchro> a, std::pair<int,Gnss_Synchro> b) bool pairCompare_gnss_synchro_preamble_symbol_count( std::pair<int,Gnss_Synchro> a, std::pair<int,Gnss_Synchro> b)
{ {
return (a.second.Preamble_symbol_counter) < (b.second.Preamble_symbol_counter); return (a.second.Preamble_symbol_counter) < (b.second.Preamble_symbol_counter);
} }
bool pairCompare_gnss_synchro_preamble_delay_ms( std::pair<int,Gnss_Synchro> a, std::pair<int,Gnss_Synchro> b) bool pairCompare_gnss_synchro_preamble_delay_ms( std::pair<int,Gnss_Synchro> a, std::pair<int,Gnss_Synchro> b)
{ {
return (a.second.Preamble_timestamp_ms) < (b.second.Preamble_timestamp_ms); return (a.second.Preamble_timestamp_ms) < (b.second.Preamble_timestamp_ms);
} }
bool pairCompare_double( std::pair<int,double> a, std::pair<int,double> b) bool pairCompare_double( std::pair<int,double> a, std::pair<int,double> b)
{ {
return (a.second) < (b.second); return (a.second) < (b.second);
} }
void clearQueue( std::deque<double> &q ) void clearQueue( std::deque<double> &q )
{ {
std::deque<double> empty; std::deque<double> empty;
@ -123,27 +130,21 @@ void clearQueue( std::deque<double> &q )
} }
int gps_l1_ca_observables_cc::general_work (int noutput_items, gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) {
int gps_l1_ca_observables_cc::general_work (int noutput_items, gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
{
Gnss_Synchro **in = (Gnss_Synchro **) &input_items[0]; //Get the input pointer Gnss_Synchro **in = (Gnss_Synchro **) &input_items[0]; //Get the input pointer
Gnss_Synchro **out = (Gnss_Synchro **) &output_items[0]; //Get the output pointer Gnss_Synchro **out = (Gnss_Synchro **) &output_items[0]; //Get the output pointer
Gnss_Synchro current_gnss_synchro[d_nchannels]; Gnss_Synchro current_gnss_synchro[d_nchannels];
// Gnss_Synchro current_gnss_synchro[cd_channels];
// Gnss_Synchro current_gnss_synchro[cd_channels];
std::map<int,Gnss_Synchro> current_gnss_synchro_map; std::map<int,Gnss_Synchro> current_gnss_synchro_map;
std::map<int,Gnss_Synchro> gnss_synchro_aligned_map; std::map<int,Gnss_Synchro> gnss_synchro_aligned_map;
std::map<int,Gnss_Synchro>::iterator gnss_synchro_iter; std::map<int,Gnss_Synchro>::iterator gnss_synchro_iter;
double traveltime_ms; double traveltime_ms;
double pseudorange_m; double pseudorange_m;
d_sample_counter++; //count for the processed samples d_sample_counter++; //count for the processed samples
bool flag_history_ok = true; //flag to indicate that all the queues have filled their GNSS SYNCHRO history bool flag_history_ok = true; //flag to indicate that all the queues have filled their GNSS SYNCHRO history
/* /*
* 1. Read the GNSS SYNCHRO objects from available channels * 1. Read the GNSS SYNCHRO objects from available channels
@ -151,14 +152,13 @@ int gps_l1_ca_observables_cc::general_work (int noutput_items, gr_vector_int &ni
for (unsigned int i=0; i<d_nchannels ; i++) for (unsigned int i=0; i<d_nchannels ; i++)
{ {
//Copy the telemetry decoder data to local copy //Copy the telemetry decoder data to local copy
current_gnss_synchro[i]=in[i][0]; current_gnss_synchro[i] = in[i][0];
if (current_gnss_synchro[i].Flag_valid_word) //if this channel have valid word if (current_gnss_synchro[i].Flag_valid_word) //if this channel have valid word
{ {
//record the word structure in a map for pseudoranges //record the word structure in a map for pseudoranges
current_gnss_synchro_map.insert(std::pair<int,Gnss_Synchro>(current_gnss_synchro[i].Channel_ID, current_gnss_synchro[i])); current_gnss_synchro_map.insert(std::pair<int, Gnss_Synchro>(current_gnss_synchro[i].Channel_ID, current_gnss_synchro[i]));
// RECORD PRN start timestamps history // RECORD PRN start timestamps history
if (d_history_gnss_synchro_deque[i].size()<MAX_TOA_DELAY_MS) if (d_history_gnss_synchro_deque[i].size() < MAX_TOA_DELAY_MS)
{ {
d_history_gnss_synchro_deque[i].push_front(current_gnss_synchro[i]); d_history_gnss_synchro_deque[i].push_front(current_gnss_synchro[i]);
flag_history_ok = false; // at least one channel need more samples flag_history_ok = false; // at least one channel need more samples
@ -177,24 +177,22 @@ int gps_l1_ca_observables_cc::general_work (int noutput_items, gr_vector_int &ni
*/ */
for (unsigned int i=0; i<d_nchannels ; i++) for (unsigned int i=0; i<d_nchannels ; i++)
{ {
current_gnss_synchro[i].Flag_valid_pseudorange = false; current_gnss_synchro[i].Flag_valid_pseudorange = false;
current_gnss_synchro[i].Pseudorange_m = 0.0; current_gnss_synchro[i].Pseudorange_m = 0.0;
current_gnss_synchro[i].Pseudorange_symbol_shift = 0.0; current_gnss_synchro[i].Pseudorange_symbol_shift = 0.0;
} }
/* /*
* 2. Compute RAW pseudorranges: Use only the valid channels (channels that are tracking a satellite) * 2. Compute RAW pseudorranges: Use only the valid channels (channels that are tracking a satellite)
*/ */
if(current_gnss_synchro_map.size() > 0 and flag_history_ok == true) if(current_gnss_synchro_map.size() > 0 and flag_history_ok == true)
{ {
/* /*
* 2.1 Find the correct symbol timestamp in the gnss_synchro history: we have to compare timestamps between channels on the SAME symbol * 2.1 Find the correct symbol timestamp in the gnss_synchro history: we have to compare timestamps between channels on the SAME symbol
* (common TX time algorithm) * (common TX time algorithm)
*/ */
double min_preamble_delay_ms; double min_preamble_delay_ms;
double max_preamble_delay_ms; double max_preamble_delay_ms;
int current_symbol=0; int current_symbol = 0;
int reference_channel; int reference_channel;
int history_shift; int history_shift;
Gnss_Synchro tmp_gnss_synchro; Gnss_Synchro tmp_gnss_synchro;
@ -205,25 +203,24 @@ int gps_l1_ca_observables_cc::general_work (int noutput_items, gr_vector_int &ni
gnss_synchro_iter = max_element(current_gnss_synchro_map.begin(), current_gnss_synchro_map.end(), pairCompare_gnss_synchro_preamble_delay_ms); gnss_synchro_iter = max_element(current_gnss_synchro_map.begin(), current_gnss_synchro_map.end(), pairCompare_gnss_synchro_preamble_delay_ms);
max_preamble_delay_ms = gnss_synchro_iter->second.Preamble_timestamp_ms; //[ms] max_preamble_delay_ms = gnss_synchro_iter->second.Preamble_timestamp_ms; //[ms]
if ((max_preamble_delay_ms-min_preamble_delay_ms)< MAX_TOA_DELAY_MS) if ((max_preamble_delay_ms - min_preamble_delay_ms) < MAX_TOA_DELAY_MS)
{ {
// we have a valid information set. Its time to align the symbols information // we have a valid information set. Its time to align the symbols information
// what is the most delayed symbol in the current set? -> this will be the reference symbol // what is the most delayed symbol in the current set? -> this will be the reference symbol
gnss_synchro_iter=min_element(current_gnss_synchro_map.begin(), current_gnss_synchro_map.end(), pairCompare_gnss_synchro_preamble_symbol_count); gnss_synchro_iter = min_element(current_gnss_synchro_map.begin(), current_gnss_synchro_map.end(), pairCompare_gnss_synchro_preamble_symbol_count);
current_symbol=gnss_synchro_iter->second.Preamble_symbol_counter; current_symbol = gnss_synchro_iter->second.Preamble_symbol_counter;
reference_channel=gnss_synchro_iter->second.Channel_ID; reference_channel = gnss_synchro_iter->second.Channel_ID;
// save it in the aligned symbols map // save it in the aligned symbols map
gnss_synchro_aligned_map.insert(std::pair<int,Gnss_Synchro>(gnss_synchro_iter->second.Channel_ID, gnss_synchro_iter->second)); gnss_synchro_aligned_map.insert(std::pair<int,Gnss_Synchro>(gnss_synchro_iter->second.Channel_ID, gnss_synchro_iter->second));
// Now find where the same symbols were in the rest of the channels searching in the symbol history // Now find where the same symbols were in the rest of the channels searching in the symbol history
for(gnss_synchro_iter = current_gnss_synchro_map.begin(); gnss_synchro_iter != current_gnss_synchro_map.end(); gnss_synchro_iter++) for(gnss_synchro_iter = current_gnss_synchro_map.begin(); gnss_synchro_iter != current_gnss_synchro_map.end(); gnss_synchro_iter++)
{ {
//TODO: Replace the loop using current current_symbol-Preamble_symbol_counter //TODO: Replace the loop using current current_symbol-Preamble_symbol_counter
if (reference_channel!=gnss_synchro_iter->second.Channel_ID) if (reference_channel != gnss_synchro_iter->second.Channel_ID)
{ {
// compute the required symbol history shift in order to match the reference symbol // compute the required symbol history shift in order to match the reference symbol
history_shift=gnss_synchro_iter->second.Preamble_symbol_counter-current_symbol; history_shift = gnss_synchro_iter->second.Preamble_symbol_counter-current_symbol;
if (history_shift<(int)MAX_TOA_DELAY_MS)// and history_shift>=0) if (history_shift < (int)MAX_TOA_DELAY_MS ) // and history_shift>=0)
{ {
tmp_gnss_synchro= d_history_gnss_synchro_deque[gnss_synchro_iter->second.Channel_ID][history_shift]; tmp_gnss_synchro= d_history_gnss_synchro_deque[gnss_synchro_iter->second.Channel_ID][history_shift];
gnss_synchro_aligned_map.insert(std::pair<int,Gnss_Synchro>(gnss_synchro_iter->second.Channel_ID,tmp_gnss_synchro)); gnss_synchro_aligned_map.insert(std::pair<int,Gnss_Synchro>(gnss_synchro_iter->second.Channel_ID,tmp_gnss_synchro));
@ -243,7 +240,6 @@ int gps_l1_ca_observables_cc::general_work (int noutput_items, gr_vector_int &ni
gnss_synchro_iter = max_element(gnss_synchro_aligned_map.begin(), gnss_synchro_aligned_map.end(), pairCompare_gnss_synchro_Prn_delay_ms); gnss_synchro_iter = max_element(gnss_synchro_aligned_map.begin(), gnss_synchro_aligned_map.end(), pairCompare_gnss_synchro_Prn_delay_ms);
max_symbol_timestamp_ms = gnss_synchro_iter->second.Prn_timestamp_ms; //[ms] max_symbol_timestamp_ms = gnss_synchro_iter->second.Prn_timestamp_ms; //[ms]
// check again if this is a valid set of observations // check again if this is a valid set of observations
if ((max_symbol_timestamp_ms - min_symbol_timestamp_ms) < MAX_TOA_DELAY_MS) if ((max_symbol_timestamp_ms - min_symbol_timestamp_ms) < MAX_TOA_DELAY_MS)
/* /*
@ -253,18 +249,17 @@ int gps_l1_ca_observables_cc::general_work (int noutput_items, gr_vector_int &ni
for(gnss_synchro_iter = gnss_synchro_aligned_map.begin(); gnss_synchro_iter != gnss_synchro_aligned_map.end(); gnss_synchro_iter++) for(gnss_synchro_iter = gnss_synchro_aligned_map.begin(); gnss_synchro_iter != gnss_synchro_aligned_map.end(); gnss_synchro_iter++)
{ {
traveltime_ms = gnss_synchro_iter->second.Prn_timestamp_ms - min_symbol_timestamp_ms + GPS_STARTOFFSET_ms; //[ms] traveltime_ms = gnss_synchro_iter->second.Prn_timestamp_ms - min_symbol_timestamp_ms + GPS_STARTOFFSET_ms; //[ms]
pseudorange_m = traveltime_ms*GPS_C_m_ms; // [m] pseudorange_m = traveltime_ms * GPS_C_m_ms; // [m]
// update the pseudorange object // update the pseudorange object
current_gnss_synchro[gnss_synchro_iter->second.Channel_ID]=gnss_synchro_iter->second; current_gnss_synchro[gnss_synchro_iter->second.Channel_ID] = gnss_synchro_iter->second;
current_gnss_synchro[gnss_synchro_iter->second.Channel_ID].Pseudorange_m = pseudorange_m; current_gnss_synchro[gnss_synchro_iter->second.Channel_ID].Pseudorange_m = pseudorange_m;
current_gnss_synchro[gnss_synchro_iter->second.Channel_ID].Pseudorange_symbol_shift = (double)current_symbol; // number of symbols shifted from preamble start symbol current_gnss_synchro[gnss_synchro_iter->second.Channel_ID].Pseudorange_symbol_shift = (double)current_symbol; // number of symbols shifted from preamble start symbol
current_gnss_synchro[gnss_synchro_iter->second.Channel_ID].Flag_valid_pseudorange = true; current_gnss_synchro[gnss_synchro_iter->second.Channel_ID].Flag_valid_pseudorange = true;
current_gnss_synchro[gnss_synchro_iter->second.Channel_ID].Pseudorange_timestamp_ms=max_symbol_timestamp_ms; current_gnss_synchro[gnss_synchro_iter->second.Channel_ID].Pseudorange_timestamp_ms = max_symbol_timestamp_ms;
} }
} }
} }
if(d_dump == true) if(d_dump == true)
{ {
// MULTIPLEXED FILE RECORDING - Record results to file // MULTIPLEXED FILE RECORDING - Record results to file
@ -295,11 +290,11 @@ int gps_l1_ca_observables_cc::general_work (int noutput_items, gr_vector_int &ni
// mod 8/4/2012: always make the observables output // mod 8/4/2012: always make the observables output
//if ((d_sample_counter % d_output_rate_ms) == 0) //if ((d_sample_counter % d_output_rate_ms) == 0)
// { // {
for (unsigned int i=0; i<d_nchannels ; i++) for (unsigned int i=0; i<d_nchannels ; i++)
{ {
*out[i] = current_gnss_synchro[i]; *out[i] = current_gnss_synchro[i];
} }
return 1; //Output the observables return 1; //Output the observables
// } // }
//else //else
// { // {

View File

@ -6,7 +6,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 * GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver * Satellite Systems receiver
@ -45,13 +45,10 @@ FileOutputFilter::FileOutputFilter(ConfigurationInterface* configuration,
in_streams_(in_streams), in_streams_(in_streams),
out_streams_(out_streams) out_streams_(out_streams)
{ {
std::string default_filename = "./output.dat"; std::string default_filename = "./output.dat";
std::string default_item_type = "short"; std::string default_item_type = "short";
filename_ = configuration->property(role + ".filename", default_filename); filename_ = configuration->property(role + ".filename", default_filename);
item_type_ = configuration->property(role + ".item_type", default_item_type); item_type_ = configuration->property(role + ".item_type", default_item_type);
if(item_type_.compare("gr_complex") == 0) if(item_type_.compare("gr_complex") == 0)
{ {
item_size_ = sizeof(gr_complex); item_size_ = sizeof(gr_complex);
@ -69,30 +66,37 @@ FileOutputFilter::FileOutputFilter(ConfigurationInterface* configuration,
LOG_AT_LEVEL(WARNING) << item_type_ << " Unrecognized item type. Using short."; LOG_AT_LEVEL(WARNING) << item_type_ << " Unrecognized item type. Using short.";
item_size_ = sizeof(short); item_size_ = sizeof(short);
} }
file_sink_ = gr_make_file_sink(item_size_, filename_.c_str()); file_sink_ = gr_make_file_sink(item_size_, filename_.c_str());
DLOG(INFO) << "file sink(" << file_sink_->unique_id() << ")"; DLOG(INFO) << "file sink(" << file_sink_->unique_id() << ")";
} }
FileOutputFilter::~FileOutputFilter() FileOutputFilter::~FileOutputFilter()
{} {}
void FileOutputFilter::connect(gr_top_block_sptr top_block) void FileOutputFilter::connect(gr_top_block_sptr top_block)
{ {
DLOG(INFO) << "nothing to connect internally"; DLOG(INFO) << "nothing to connect internally";
} }
void FileOutputFilter::disconnect(gr_top_block_sptr top_block) void FileOutputFilter::disconnect(gr_top_block_sptr top_block)
{ {
// Nothing to disconnect internally // Nothing to disconnect internally
} }
gr_basic_block_sptr FileOutputFilter::get_left_block() gr_basic_block_sptr FileOutputFilter::get_left_block()
{ {
return file_sink_; return file_sink_;
} }
gr_basic_block_sptr FileOutputFilter::get_right_block() gr_basic_block_sptr FileOutputFilter::get_right_block()
{ {
return file_sink_; return file_sink_;

View File

@ -6,7 +6,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 * GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver * Satellite Systems receiver
@ -29,8 +29,6 @@
* ------------------------------------------------------------------------- * -------------------------------------------------------------------------
*/ */
#include "null_sink_output_filter.h" #include "null_sink_output_filter.h"
#include <glog/log_severity.h> #include <glog/log_severity.h>
#include <glog/logging.h> #include <glog/logging.h>
@ -47,10 +45,8 @@ NullSinkOutputFilter::NullSinkOutputFilter(ConfigurationInterface* configuration
in_streams_(in_streams), in_streams_(in_streams),
out_streams_(out_streams) out_streams_(out_streams)
{ {
std::string default_item_type = "short"; std::string default_item_type = "short";
item_type_ = configuration->property(role + ".item_type", default_item_type); item_type_ = configuration->property(role + ".item_type", default_item_type);
if(item_type_.compare("gr_complex") == 0) if(item_type_.compare("gr_complex") == 0)
{ {
item_size_ = sizeof(gr_complex); item_size_ = sizeof(gr_complex);
@ -65,32 +61,41 @@ NullSinkOutputFilter::NullSinkOutputFilter(ConfigurationInterface* configuration
} }
else else
{ {
LOG_AT_LEVEL(WARNING) << item_type_ << " unrecognized item type. Usign float"; LOG_AT_LEVEL(WARNING) << item_type_ << " unrecognized item type. Using float";
item_size_ = sizeof(float); item_size_ = sizeof(float);
} }
sink_ = gr_make_null_sink(item_size_); sink_ = gr_make_null_sink(item_size_);
DLOG(INFO) << "null_sink(" << sink_->unique_id() << ")"; DLOG(INFO) << "null_sink(" << sink_->unique_id() << ")";
} }
NullSinkOutputFilter::~NullSinkOutputFilter() NullSinkOutputFilter::~NullSinkOutputFilter()
{} {}
void NullSinkOutputFilter::connect(gr_top_block_sptr top_block) void NullSinkOutputFilter::connect(gr_top_block_sptr top_block)
{ {
DLOG(INFO) << "nothing to connect internally"; DLOG(INFO) << "nothing to connect internally";
} }
void NullSinkOutputFilter::disconnect(gr_top_block_sptr top_block) void NullSinkOutputFilter::disconnect(gr_top_block_sptr top_block)
{ {
// Nothing to connect // Nothing to connect
} }
gr_basic_block_sptr NullSinkOutputFilter::get_left_block() gr_basic_block_sptr NullSinkOutputFilter::get_left_block()
{ {
return sink_; return sink_;
} }
gr_basic_block_sptr NullSinkOutputFilter::get_right_block() gr_basic_block_sptr NullSinkOutputFilter::get_right_block()
{ {
LOG_AT_LEVEL(WARNING) << "Right block of a signal sink should not be retrieved"; LOG_AT_LEVEL(WARNING) << "Right block of a signal sink should not be retrieved";

View File

@ -10,7 +10,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 * GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver * Satellite Systems receiver
@ -33,8 +33,6 @@
* ------------------------------------------------------------------------- * -------------------------------------------------------------------------
*/ */
#include "file_configuration.h" #include "file_configuration.h"
#include <string> #include <string>
#include <glog/log_severity.h> #include <glog/log_severity.h>
@ -51,12 +49,14 @@ FileConfiguration::FileConfiguration(std::string filename)
init(); init();
} }
FileConfiguration::FileConfiguration() FileConfiguration::FileConfiguration()
{ {
filename_ = "./default_config_file.txt"; filename_ = "./default_config_file.txt";
init(); init();
} }
FileConfiguration::~FileConfiguration() FileConfiguration::~FileConfiguration()
{ {
LOG_AT_LEVEL(INFO) << "Destructor called"; LOG_AT_LEVEL(INFO) << "Destructor called";
@ -65,9 +65,9 @@ FileConfiguration::~FileConfiguration()
delete overrided_; delete overrided_;
} }
std::string FileConfiguration::property(std::string property_name, std::string default_value) std::string FileConfiguration::property(std::string property_name, std::string default_value)
{ {
if(overrided_->is_present(property_name)) if(overrided_->is_present(property_name))
{ {
return overrided_->property(property_name, default_value); return overrided_->property(property_name, default_value);
@ -78,9 +78,9 @@ std::string FileConfiguration::property(std::string property_name, std::string d
} }
} }
bool FileConfiguration::property(std::string property_name, bool default_value) bool FileConfiguration::property(std::string property_name, bool default_value)
{ {
if(overrided_->is_present(property_name)) if(overrided_->is_present(property_name))
{ {
return overrided_->property(property_name, default_value); return overrided_->property(property_name, default_value);
@ -92,9 +92,9 @@ bool FileConfiguration::property(std::string property_name, bool default_value)
} }
} }
long FileConfiguration::property(std::string property_name, long default_value) long FileConfiguration::property(std::string property_name, long default_value)
{ {
if(overrided_->is_present(property_name)) if(overrided_->is_present(property_name))
{ {
return overrided_->property(property_name, default_value); return overrided_->property(property_name, default_value);
@ -106,13 +106,14 @@ long FileConfiguration::property(std::string property_name, long default_value)
} }
} }
int FileConfiguration::property(std::string property_name, int default_value) int FileConfiguration::property(std::string property_name, int default_value)
{ {
if(overrided_->is_present(property_name))
if(overrided_->is_present(property_name)) { {
return overrided_->property(property_name, default_value); return overrided_->property(property_name, default_value);
} }
else else
{ {
std::string empty = ""; std::string empty = "";
@ -120,6 +121,8 @@ int FileConfiguration::property(std::string property_name, int default_value)
} }
} }
unsigned int FileConfiguration::property(std::string property_name, unsigned int default_value) unsigned int FileConfiguration::property(std::string property_name, unsigned int default_value)
{ {
if(overrided_->is_present(property_name)) if(overrided_->is_present(property_name))
@ -133,6 +136,8 @@ unsigned int FileConfiguration::property(std::string property_name, unsigned int
} }
} }
float FileConfiguration::property(std::string property_name, float default_value) float FileConfiguration::property(std::string property_name, float default_value)
{ {
if(overrided_->is_present(property_name)) if(overrided_->is_present(property_name))
@ -146,6 +151,7 @@ float FileConfiguration::property(std::string property_name, float default_value
} }
} }
double FileConfiguration::property(std::string property_name, double default_value) double FileConfiguration::property(std::string property_name, double default_value)
{ {
if(overrided_->is_present(property_name)) if(overrided_->is_present(property_name))
@ -159,20 +165,21 @@ double FileConfiguration::property(std::string property_name, double default_val
} }
} }
void FileConfiguration::set_property(std::string property_name, std::string value) void FileConfiguration::set_property(std::string property_name, std::string value)
{ {
overrided_->set_property(property_name, value); overrided_->set_property(property_name, value);
} }
void FileConfiguration::init() void FileConfiguration::init()
{ {
converter_ = new StringConverter(); converter_ = new StringConverter();
overrided_ = new InMemoryConfiguration(); overrided_ = new InMemoryConfiguration();
ini_reader_ = new INIReader(filename_); ini_reader_ = new INIReader(filename_);
error_ = ini_reader_->ParseError(); error_ = ini_reader_->ParseError();
if(error_ == 0) if(error_ == 0)
{ {
DLOG(INFO) << "Configuration file " << filename_ << " opened with no errors"; DLOG(INFO) << "Configuration file " << filename_ << " opened with no errors";
@ -185,7 +192,6 @@ void FileConfiguration::init()
{ {
LOG_AT_LEVEL(WARNING) << "Unable to open configuration file " << filename_; LOG_AT_LEVEL(WARNING) << "Unable to open configuration file " << filename_;
} }
} }

View File

@ -6,7 +6,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 * GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver * Satellite Systems receiver
@ -36,22 +36,20 @@
InMemoryConfiguration::InMemoryConfiguration() InMemoryConfiguration::InMemoryConfiguration()
{ {
converter_ = new StringConverter(); converter_ = new StringConverter();
} }
InMemoryConfiguration::~InMemoryConfiguration() InMemoryConfiguration::~InMemoryConfiguration()
{ {
properties_.clear(); properties_.clear();
delete converter_; delete converter_;
} }
std::string InMemoryConfiguration::property(std::string property_name, std::string default_value) std::string InMemoryConfiguration::property(std::string property_name, std::string default_value)
{ {
std::map<std::string, std::string>::iterator iter = properties_.find(property_name); std::map<std::string, std::string>::iterator iter = properties_.find(property_name);
if(iter != properties_.end()) if(iter != properties_.end())
{ {
return iter->second; return iter->second;
@ -62,47 +60,55 @@ std::string InMemoryConfiguration::property(std::string property_name, std::stri
} }
} }
bool InMemoryConfiguration::property(std::string property_name, bool default_value) bool InMemoryConfiguration::property(std::string property_name, bool default_value)
{ {
std::string empty = ""; std::string empty = "";
return converter_->convert(property(property_name, empty), default_value); return converter_->convert(property(property_name, empty), default_value);
} }
long InMemoryConfiguration::property(std::string property_name, long default_value) long InMemoryConfiguration::property(std::string property_name, long default_value)
{ {
std::string empty = ""; std::string empty = "";
return converter_->convert(property(property_name, empty), default_value); return converter_->convert(property(property_name, empty), default_value);
} }
int InMemoryConfiguration::property(std::string property_name, int default_value) int InMemoryConfiguration::property(std::string property_name, int default_value)
{ {
std::string empty = ""; std::string empty = "";
return converter_->convert(property(property_name, empty), default_value); return converter_->convert(property(property_name, empty), default_value);
} }
unsigned int InMemoryConfiguration::property(std::string property_name, unsigned int default_value) unsigned int InMemoryConfiguration::property(std::string property_name, unsigned int default_value)
{ {
std::string empty = ""; std::string empty = "";
return converter_->convert(property(property_name, empty), default_value); return converter_->convert(property(property_name, empty), default_value);
} }
float InMemoryConfiguration::property(std::string property_name, float default_value) float InMemoryConfiguration::property(std::string property_name, float default_value)
{ {
std::string empty = ""; std::string empty = "";
return converter_->convert(property(property_name, empty), default_value); return converter_->convert(property(property_name, empty), default_value);
} }
double InMemoryConfiguration::property(std::string property_name, double default_value) double InMemoryConfiguration::property(std::string property_name, double default_value)
{ {
std::string empty = ""; std::string empty = "";
return converter_->convert(property(property_name, empty), default_value); return converter_->convert(property(property_name, empty), default_value);
} }
void InMemoryConfiguration::set_property(std::string property_name, std::string value) void InMemoryConfiguration::set_property(std::string property_name, std::string value)
{ {
properties_.insert(std::make_pair(property_name, value)); properties_.insert(std::make_pair(property_name, value));
} }
bool InMemoryConfiguration::is_present(std::string property_name) bool InMemoryConfiguration::is_present(std::string property_name)
{ {
return (properties_.find(property_name) != properties_.end()); return (properties_.find(property_name) != properties_.end());

View File

@ -43,8 +43,6 @@
#include "GPS_L1_CA.h" #include "GPS_L1_CA.h"
/*! /*!
* \brief This class decodes a GPS NAV Data message as described in IS-GPS-200E * \brief This class decodes a GPS NAV Data message as described in IS-GPS-200E
* *
@ -52,28 +50,25 @@
*/ */
class Gps_Navigation_Message class Gps_Navigation_Message
{ {
private: private:
unsigned long int read_navigation_unsigned(std::bitset<GPS_SUBFRAME_BITS> bits, const bits_slice *slices, int num_of_slices); unsigned long int read_navigation_unsigned(std::bitset<GPS_SUBFRAME_BITS> bits, const bits_slice *slices, int num_of_slices);
signed long int read_navigation_signed(std::bitset<GPS_SUBFRAME_BITS> bits, const bits_slice *slices, int num_of_slices); signed long int read_navigation_signed(std::bitset<GPS_SUBFRAME_BITS> bits, const bits_slice *slices, int num_of_slices);
bool read_navigation_bool(std::bitset<GPS_SUBFRAME_BITS> bits, const bits_slice *slices); bool read_navigation_bool(std::bitset<GPS_SUBFRAME_BITS> bits, const bits_slice *slices);
void print_gps_word_bytes(unsigned int GPS_word); void print_gps_word_bytes(unsigned int GPS_word);
/*
/* * Accounts for the beginning or end of week crossover
* Accounts for the beginning or end of week crossover *
* * See paragraph 20.3.3.3.3.1 (IS-GPS-200E)
* See paragraph 20.3.3.3.3.1 (IS-GPS-200E) * \param[in] - time in seconds
* \param[in] - time in seconds * \param[out] - corrected time, in seconds
* \param[out] - corrected time, in seconds */
*/ double check_t(double time);
double check_t(double time);
public: public:
bool b_update_tow_flag; // flag indicating that this ephemeris set have an updated TOW bool b_update_tow_flag; // flag indicating that this ephemeris set have an updated TOW
bool b_valid_ephemeris_set_flag; // flag indicating that this ephemeris set have passed the validation check bool b_valid_ephemeris_set_flag; // flag indicating that this ephemeris set have passed the validation check
//broadcast orbit 1 //broadcast orbit 1
double d_TOW; //!< Time of GPS Week of the ephemeris set (taken from subframes TOW) [s] double d_TOW; //!< Time of GPS Week of the ephemeris set (taken from subframes TOW) [s]
double d_TOW_SF1; //!< Time of GPS Week from HOW word of Subframe 1 [s] double d_TOW_SF1; //!< Time of GPS Week from HOW word of Subframe 1 [s]
double d_TOW_SF2; //!< Time of GPS Week from HOW word of Subframe 2 [s] double d_TOW_SF2; //!< Time of GPS Week from HOW word of Subframe 2 [s]
double d_TOW_SF3; //!< Time of GPS Week from HOW word of Subframe 3 [s] double d_TOW_SF3; //!< Time of GPS Week from HOW word of Subframe 3 [s]
@ -143,11 +138,9 @@ public:
* accompanying alert, is less than 1E-8 per hour. * accompanying alert, is less than 1E-8 per hour.
*/ */
bool b_integrity_status_flag; bool b_integrity_status_flag;
bool b_alert_flag; //!< If true, indicates that the SV URA may be worse than indicated in d_SV_accuracy, use that SV at our own risk. bool b_alert_flag; //!< If true, indicates that the SV URA may be worse than indicated in d_SV_accuracy, use that SV at our own risk.
bool b_antispoofing_flag; //!< If true, the AntiSpoofing mode is ON in that SV bool b_antispoofing_flag; //!< If true, the AntiSpoofing mode is ON in that SV
// clock terms // clock terms
//double d_master_clock; // GPS transmission time //double d_master_clock; // GPS transmission time
double d_satClkCorr; // GPS clock error double d_satClkCorr; // GPS clock error
@ -159,7 +152,6 @@ public:
double d_satpos_Z; //!< Earth-fixed coordinate z of the satellite [m]. The direction of the IERS (International Earth Rotation and Reference Systems Service) Reference Pole (IRP). double d_satpos_Z; //!< Earth-fixed coordinate z of the satellite [m]. The direction of the IERS (International Earth Rotation and Reference Systems Service) Reference Pole (IRP).
// satellite identification info // satellite identification info
int i_channel_ID; int i_channel_ID;
unsigned int i_satellite_PRN; unsigned int i_satellite_PRN;
@ -167,7 +159,6 @@ public:
double d_subframe_timestamp_ms; //[ms] double d_subframe_timestamp_ms; //[ms]
// Ionospheric parameters // Ionospheric parameters
double d_alpha0; //!< Coefficient 0 of a cubic equation representing the amplitude of the vertical delay [s] double d_alpha0; //!< Coefficient 0 of a cubic equation representing the amplitude of the vertical delay [s]
double d_alpha1; //!< Coefficient 1 of a cubic equation representing the amplitude of the vertical delay [s/semi-circle] double d_alpha1; //!< Coefficient 1 of a cubic equation representing the amplitude of the vertical delay [s/semi-circle]
double d_alpha2; //!< Coefficient 2 of a cubic equation representing the amplitude of the vertical delay [s(semi-circle)^2] double d_alpha2; //!< Coefficient 2 of a cubic equation representing the amplitude of the vertical delay [s(semi-circle)^2]
@ -178,7 +169,6 @@ public:
double d_beta3; //!< Coefficient 3 of a cubic equation representing the period of the model [s(semi-circle)^3] double d_beta3; //!< Coefficient 3 of a cubic equation representing the period of the model [s(semi-circle)^3]
// UTC parameters // UTC parameters
double d_A1; //!< 1st order term of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200E) [s/s] double d_A1; //!< 1st order term of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200E) [s/s]
double d_A0; //!< Constant of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200E) [s] double d_A0; //!< Constant of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200E) [s]
double d_t_OT; //!< Reference time for UTC data (reference 20.3.4.5 and 20.3.3.5.2.4 IS-GPS-200E) [s] double d_t_OT; //!< Reference time for UTC data (reference 20.3.4.5 and 20.3.3.5.2.4 IS-GPS-200E) [s]
@ -201,7 +191,6 @@ public:
*/ */
int subframe_decoder(char *subframe); int subframe_decoder(char *subframe);
/*! /*!
* \brief Computes the position of the satellite * \brief Computes the position of the satellite
* *