1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-21 06:27:01 +00:00

Code cleaning

git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@277 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
Carles Fernandez 2012-11-01 17:40:26 +00:00
parent 3b489d0107
commit aff4aeefb5
6 changed files with 70 additions and 118 deletions

View File

@ -165,9 +165,11 @@ void FirFilter::init()
std::string filter_type = config_->property(role_ + ".filter_type", default_filter_type);
int grid_density = config_->property(role_ + ".grid_density", default_grid_density);
std::vector<double> taps_d = gr_remez(number_of_taps - 1, bands, ampl,
error_w, filter_type, grid_density);
// gr_remez implements the Parks-McClellan FIR filter design.
// It calculates the optimal (in the Chebyshev/minimax sense) FIR filter
// impulse response given a set of band edges, the desired response on
// those bands, and the weight given to the error in those bands.
std::vector<double> taps_d = gr_remez(number_of_taps - 1, bands, ampl, error_w, filter_type, grid_density);
taps_.reserve(taps_d.size());
for (std::vector<double>::iterator it = taps_d.begin(); it != taps_d.end(); it++)
{

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
* Satellite Systems receiver
@ -53,30 +53,24 @@ GpsL1CaTelemetryDecoder::GpsL1CaTelemetryDecoder(ConfigurationInterface* configu
out_streams_(out_streams),
queue_(queue)
{
std::string default_item_type = "gr_complex";
std::string default_dump_filename = "./navigation.dat";
DLOG(INFO) << "role " << role;
DLOG(INFO) << "vector length " << vector_length_;
vector_length_ = configuration->property(role + ".vector_length", 2048);
dump_ = configuration->property(role + ".dump", false);
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename);
int fs_in;
fs_in = configuration->property("GNSS-SDR.internal_fs_hz", 2048000);
// make telemetry decoder object
telemetry_decoder_ = gps_l1_ca_make_telemetry_decoder_cc(satellite_, 0, (long)fs_in, vector_length_, queue_, dump_); // TODO fix me
DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")";
// set the navigation msg queue;
telemetry_decoder_->set_navigation_queue(&global_gps_nav_msg_queue);
DLOG(INFO) << "global navigation message queue assigned to telemetry_decoder ("<< telemetry_decoder_->unique_id() << ")";
}
GpsL1CaTelemetryDecoder::~GpsL1CaTelemetryDecoder()
{}
@ -95,6 +89,7 @@ void GpsL1CaTelemetryDecoder::connect(gr_top_block_sptr top_block)
DLOG(INFO) << "nothing to connect internally";
}
void GpsL1CaTelemetryDecoder::disconnect(gr_top_block_sptr top_block)
{
// Nothing to disconnect
@ -106,6 +101,7 @@ gr_basic_block_sptr GpsL1CaTelemetryDecoder::get_left_block()
return telemetry_decoder_;
}
gr_basic_block_sptr GpsL1CaTelemetryDecoder::get_right_block()
{
return telemetry_decoder_;

View File

@ -124,12 +124,11 @@ gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc(
d_symbol_accumulator=0;
d_symbol_accumulator_counter = 0;
d_frame_bit_index = 0;
d_preamble_time_seconds=0;
d_preamble_time_seconds = 0;
d_flag_frame_sync = false;
d_GPS_frame_4bytes = 0;
d_prev_GPS_frame_4bytes = 0;
d_flag_parity = false;
//set_history(d_samples_per_bit*8); // At least a history of 8 bits are needed to correlate with the preamble
}
@ -145,12 +144,10 @@ gps_l1_ca_telemetry_decoder_cc::~gps_l1_ca_telemetry_decoder_cc()
bool gps_l1_ca_telemetry_decoder_cc::gps_word_parityCheck(unsigned int gpsword)
{
unsigned int d1, d2, d3, d4, d5, d6, d7, t, parity;
/* XOR as many bits in parallel as possible. The magic constants pick
up bits which are to be XOR'ed together to implement the GPS parity
check algorithm described in IS-GPS-200E. This avoids lengthy shift-
and-xor loops. */
d1 = gpsword & 0xFBFFBF00;
d2 = _lrotl(gpsword,1) & 0x07FFBF01;
d3 = _lrotl(gpsword,2) & 0xFC0F8100;
@ -158,9 +155,7 @@ bool gps_l1_ca_telemetry_decoder_cc::gps_word_parityCheck(unsigned int gpsword)
d5 = _lrotl(gpsword,4) & 0xFC00000E;
d6 = _lrotl(gpsword,5) & 0x07F00001;
d7 = _lrotl(gpsword,6) & 0x00003000;
t = d1 ^ d2 ^ d3 ^ d4 ^ d5 ^ d6 ^ d7;
// Now XOR the 5 6-bit fields together to produce the 6-bit final result.
parity = t ^ _lrotl(t,6) ^ _lrotl(t,12) ^ _lrotl(t,18) ^ _lrotl(t,24);
parity = parity & 0x3F;
@ -243,9 +238,7 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i
}
}
}
//******* SYMBOL TO BIT *******
d_symbol_accumulator += in[0][d_samples_per_bit*8 - 1].Prompt_I; // accumulate the input value in d_symbol_accumulator
d_symbol_accumulator_counter++;
if (d_symbol_accumulator_counter == 20)
@ -256,14 +249,13 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i
}
d_symbol_accumulator = 0;
d_symbol_accumulator_counter = 0;
//******* bits to words ******
d_frame_bit_index++;
if (d_frame_bit_index == 30)
{
d_frame_bit_index = 0;
//parity check
//Each word in wordbuff is composed of:
// parity check
// Each word in wordbuff is composed of:
// Bits 0 to 29 = the GPS data word
// Bits 30 to 31 = 2 LSBs of the GPS word ahead.
// prepare the extended frame [-2 -1 0 ... 30]
@ -301,12 +293,9 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i
d_GPS_frame_4bytes<<=1; //shift 1 bit left the telemetry word
}
}
// output the frame
consume_each(1); //one by one
Gnss_Synchro current_synchro_data; //structure to save the synchronization information and send the output object to the next block
//1. Copy the current tracking output
current_synchro_data=in[0][0];
//2. Add the telemetry decoder information
@ -315,26 +304,24 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i
current_synchro_data.Preamble_timestamp_ms = d_preamble_time_seconds * 1000.0;
current_synchro_data.Prn_timestamp_ms = in[0][0].Tracking_timestamp_secs * 1000.0;
current_synchro_data.Preamble_symbol_counter = fmod((double)(d_sample_counter - d_preamble_index), 6000); //not corrected the preamble correlation lag! -> to be taken into account in TX Time
if(d_dump == true)
{
// MULTIPLEXED FILE RECORDING - Record results to file
try
{
double tmp_double;
tmp_double = current_synchro_data.Preamble_timestamp_ms;
d_dump_file.write((char*)&tmp_double, sizeof(double));
tmp_double = current_synchro_data.Prn_timestamp_ms;
d_dump_file.write((char*)&tmp_double, sizeof(double));
tmp_double = current_synchro_data.Preamble_symbol_counter;
d_dump_file.write((char*)&tmp_double, sizeof(double));
double tmp_double;
tmp_double = current_synchro_data.Preamble_timestamp_ms;
d_dump_file.write((char*)&tmp_double, sizeof(double));
tmp_double = current_synchro_data.Prn_timestamp_ms;
d_dump_file.write((char*)&tmp_double, sizeof(double));
tmp_double = current_synchro_data.Preamble_symbol_counter;
d_dump_file.write((char*)&tmp_double, sizeof(double));
}
catch (std::ifstream::failure e)
{
std::cout << "Exception writing observables dump file " << e.what() << std::endl;
}
}
//3. Make the output (copy the object contents to the GNURadio reserved memory)
*out[0] = current_synchro_data;
return 1;

View File

@ -52,7 +52,6 @@ template<typename Data>class concurrent_queue;
*/
class AcquisitionInterface: public GNSSBlockInterface
{
public:
//virtual void set_active(bool active) = 0;
virtual void set_gnss_synchro(Gnss_Synchro* gnss_synchro) = 0;

View File

@ -68,8 +68,7 @@ public:
{
return false;
}
popped_value=the_queue.front();
popped_value = the_queue.front();
the_queue.pop();
return true;
}
@ -81,10 +80,8 @@ public:
{
the_condition_variable.wait(lock);
}
popped_value=the_queue.front();
popped_value = the_queue.front();
the_queue.pop();
}
};
#endif

View File

@ -77,40 +77,37 @@ using google::LogMessage;
GNSSBlockFactory::GNSSBlockFactory()
{
}
{}
GNSSBlockFactory::~GNSSBlockFactory()
{
}
{}
GNSSBlockInterface* GNSSBlockFactory::GetSignalSource(
ConfigurationInterface *configuration, gr_msg_queue_sptr queue)
{
std::string default_implementation = "File_Signal_Source";
std::string implementation = configuration->property(
"SignalSource.implementation", default_implementation);
DLOG(INFO) << "Getting SignalSource with implementation "
<< implementation;
return GetBlock(configuration, "SignalSource", implementation, 0, 1,
queue);
}
GNSSBlockInterface* GNSSBlockFactory::GetSignalConditioner(
ConfigurationInterface *configuration, gr_msg_queue_sptr queue)
{
std::string default_implementation = "Pass_Through";
std::string signal_conditioner = configuration->property(
"SignalConditioner.implementation", default_implementation);
std::string data_type_adapter;
std::string input_filter;
std::string resampler;
if(signal_conditioner.compare("Pass_Through")==0)
if(signal_conditioner.compare("Pass_Through") == 0)
{
data_type_adapter = "Pass_Through";
input_filter = "Pass_Through";
@ -126,7 +123,6 @@ GNSSBlockInterface* GNSSBlockFactory::GetSignalConditioner(
"Resampler.implementation", default_implementation);
}
DLOG(INFO) << "Getting SignalConditioner with DataTypeAdapter implementation: "
<< data_type_adapter << ", InputFilter implementation: "
<< input_filter << ", and Resampler implementation: "
@ -137,73 +133,63 @@ GNSSBlockInterface* GNSSBlockFactory::GetSignalConditioner(
configuration,"InputFilter", input_filter, 1, 1, queue),
GetBlock(configuration,"Resampler", resampler, 1, 1, queue),
"SignalConditioner", "Signal_Conditioner", queue);
}
GNSSBlockInterface* GNSSBlockFactory::GetObservables(
ConfigurationInterface *configuration, gr_msg_queue_sptr queue)
{
std::string default_implementation = "GPS_L1_CA_Observables";
std::string implementation = configuration->property(
"Observables.implementation", default_implementation);
DLOG(INFO) << "Getting Observables with implementation "
<< implementation;
unsigned int channel_count =
configuration->property("Channels.count", 12);
return GetBlock(configuration, "Observables", implementation,
channel_count, channel_count, queue);
}
GNSSBlockInterface* GNSSBlockFactory::GetPVT(
ConfigurationInterface *configuration, gr_msg_queue_sptr queue)
{
std::string default_implementation = "Pass_Through";
std::string implementation = configuration->property(
"PVT.implementation", default_implementation);
DLOG(INFO) << "Getting PVT with implementation " << implementation;
unsigned int channel_count =
configuration->property("Channels.count", 12);
unsigned int channel_count = configuration->property("Channels.count", 12);
return GetBlock(configuration, "PVT", implementation, channel_count, 1,
queue);
}
GNSSBlockInterface* GNSSBlockFactory::GetOutputFilter(
ConfigurationInterface *configuration, gr_msg_queue_sptr queue)
{
std::string default_implementation = "Null_Sink_Output_Filter";
std::string implementation = configuration->property(
"OutputFilter.implementation", default_implementation);
DLOG(INFO) << "Getting OutputFilter with implementation "
<< implementation;
DLOG(INFO) << "Getting OutputFilter with implementation " << implementation;
return GetBlock(configuration, "OutputFilter", implementation, 1, 0,
queue);
}
GNSSBlockInterface* GNSSBlockFactory::GetChannel(
ConfigurationInterface *configuration, std::string acq,
std::string trk, std::string tlm, int channel,
gr_msg_queue_sptr queue)
{
std::stringstream stream;
stream << channel;
std::string id = stream.str();
DLOG(INFO) << "Instantiating channel " << id;
return new Channel(configuration, channel, GetBlock(configuration,
"Channel", "Pass_Through", 1, 1, queue),
"Channel", "Pass_Through", 1, 1, queue),
(AcquisitionInterface*)GetBlock(configuration, "Acquisition",
acq, 1, 1, queue), (TrackingInterface*)GetBlock(
configuration, "Tracking", trk, 1, 1, queue),
@ -212,23 +198,22 @@ GNSSBlockInterface* GNSSBlockFactory::GetChannel(
"Channel", queue);
}
std::vector<GNSSBlockInterface*>* GNSSBlockFactory::GetChannels(
ConfigurationInterface *configuration, gr_msg_queue_sptr queue)
{
std::string default_implementation = "Pass_Through";
unsigned int channel_count =
configuration->property("Channels.count", 12);
std::vector<GNSSBlockInterface*>* channels = new std::vector<
GNSSBlockInterface*>();
std::string tracking = configuration->property("Tracking.implementation",
default_implementation);
std::string telemetry_decoder = configuration->property(
"TelemetryDecoder.implementation", default_implementation);
for (unsigned int i = 0; i < channel_count; i++)
{
std::string acquisition_implementation_name = "Acquisition"
+ boost::lexical_cast<std::string>(i) + ".implementation";
std::string acquisition_implementation = configuration->property(
@ -241,10 +226,8 @@ std::vector<GNSSBlockInterface*>* GNSSBlockFactory::GetChannels(
// << acquisition_implementation << std::endl;
}
DLOG(INFO) << "Getting " << channel_count << " channels";
return channels;
}
@ -253,7 +236,6 @@ std::vector<GNSSBlockInterface*>* GNSSBlockFactory::GetChannels(
*
* PLEASE ADD YOUR NEW BLOCK HERE!!
*/
GNSSBlockInterface* GNSSBlockFactory::GetBlock(
ConfigurationInterface *configuration, std::string role,
std::string implementation, unsigned int in_streams,
@ -262,37 +244,34 @@ GNSSBlockInterface* GNSSBlockFactory::GetBlock(
GNSSBlockInterface* block = NULL; //Change to nullptr when available in compilers (C++11)
//PASS THROUGH ----------------------------------------------------------------
if (implementation.compare("Pass_Through") == 0)
{
block = new Pass_Through(configuration, role, in_streams, out_streams);
}
{
block = new Pass_Through(configuration, role, in_streams, out_streams);
}
// SIGNAL SOURCES -------------------------------------------------------------
else if (implementation.compare("File_Signal_Source") == 0)
{
try
{
block = new FileSignalSource(configuration, role, in_streams,
out_streams, queue);
try
{
block = new FileSignalSource(configuration, role, in_streams,
out_streams, queue);
}
catch (const std::exception &e)
{
std::cout << "GNSS-SDR program ended." << std::endl;
LOG_AT_LEVEL(INFO) << implementation
<< ": Source file not found";
exit(1);
}
}
catch (const std::exception &e)
{
std::cout << "GNSS-SDR program ended." << std::endl;
LOG_AT_LEVEL(INFO) << implementation
<< ": Source file not found";
exit(1);
}
}
else if (implementation.compare("UHD_Signal_Source") == 0)
else if (implementation.compare("UHD_Signal_Source") == 0)
{
block = new UhdSignalSource(configuration, role, in_streams,
out_streams, queue);
}
#if GN3S_DRIVER
else if (implementation.compare("GN3S_Signal_Source") == 0)
else if (implementation.compare("GN3S_Signal_Source") == 0)
{
block = new Gn3sSignalSource(configuration, role, in_streams,
out_streams, queue);
@ -300,7 +279,7 @@ GNSSBlockInterface* GNSSBlockFactory::GetBlock(
#endif
#if RTLSDR_DRIVER
else if (implementation.compare("Rtlsdr_Signal_Source") == 0)
else if (implementation.compare("Rtlsdr_Signal_Source") == 0)
{
block = new RtlsdrSignalSource(configuration, role, in_streams,
out_streams, queue);
@ -309,10 +288,11 @@ GNSSBlockInterface* GNSSBlockFactory::GetBlock(
// DATA TYPE ADAPTER -----------------------------------------------------------
else if (implementation.compare("Ishort_To_Complex") == 0)
{
block = new IshortToComplex(configuration, role, in_streams,
out_streams, queue);
}
{
block = new IshortToComplex(configuration, role, in_streams,
out_streams, queue);
}
// INPUT FILTER ----------------------------------------------------------------
else if (implementation.compare("Fir_Filter") == 0)
{
@ -326,8 +306,6 @@ GNSSBlockInterface* GNSSBlockFactory::GetBlock(
}
// RESAMPLER -------------------------------------------------------------------
else if (implementation.compare("Direct_Resampler") == 0)
{
block = new DirectResamplerConditioner(configuration, role,
@ -335,7 +313,6 @@ GNSSBlockInterface* GNSSBlockFactory::GetBlock(
}
// ACQUISITION BLOCKS ---------------------------------------------------------
else if (implementation.compare("GPS_L1_CA_PCPS_Acquisition") == 0)
{
block = new GpsL1CaPcpsAcquisition(configuration, role, in_streams,
@ -348,7 +325,6 @@ GNSSBlockInterface* GNSSBlockFactory::GetBlock(
}
// TRACKING BLOCKS -------------------------------------------------------------
else if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking") == 0)
{
block = new GpsL1CaDllPllTracking(configuration, role, in_streams,
@ -366,28 +342,26 @@ GNSSBlockInterface* GNSSBlockFactory::GetBlock(
}
else if (implementation.compare("GPS_L1_CA_TCP_CONNECTOR_Tracking") == 0)
{
block = new GpsL1CaTcpConnectorTracking(configuration, role, in_streams,
out_streams, queue);
block = new GpsL1CaTcpConnectorTracking(configuration, role, in_streams,
out_streams, queue);
}
else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking") == 0)
{
block = new GalileoE1DllPllVemlTracking(configuration, role, in_streams,
out_streams, queue);
block = new GalileoE1DllPllVemlTracking(configuration, role, in_streams,
out_streams, queue);
}
else if (implementation.compare("Galileo_E1_TCP_CONNECTOR_Tracking") == 0)
{
block = new GalileoE1TcpConnectorTracking(configuration, role, in_streams,
out_streams, queue);
block = new GalileoE1TcpConnectorTracking(configuration, role, in_streams,
out_streams, queue);
}
// TELEMETRY DECODERS ----------------------------------------------------------
else if (implementation.compare("GPS_L1_CA_Telemetry_Decoder") == 0)
{
block = new GpsL1CaTelemetryDecoder(configuration, role, in_streams,
out_streams, queue);
}
// OBSERVABLES -----------------------------------------------------------------
else if (implementation.compare("GPS_L1_CA_Observables") == 0)
{
@ -396,7 +370,6 @@ GNSSBlockInterface* GNSSBlockFactory::GetBlock(
}
// PVT -------------------------------------------------------------------------
else if (implementation.compare("GPS_L1_CA_PVT") == 0)
{
block = new GpsL1CaPvt(configuration, role, in_streams,
@ -414,13 +387,11 @@ GNSSBlockInterface* GNSSBlockFactory::GetBlock(
block = new FileOutputFilter(configuration, role, in_streams,
out_streams);
}
else
{
// Log fatal. This causes execution to stop.
LOG_AT_LEVEL(ERROR) << implementation
<< ": Undefined implementation for block";
}
return block;
}