Code cleaning

git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@265 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
Carles Fernandez 2012-10-28 12:38:11 +00:00
parent 6b33aadd0b
commit f0852461fa
10 changed files with 201 additions and 237 deletions

View File

@ -7,7 +7,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
@ -38,8 +38,7 @@ galileo_e1_code_gen_int(int* _dest, char _Signal[3], signed int _prn,
{
std::string _galileo_signal = _Signal;
signed int prn = _prn - 1;
int index;
index=0;
int index = 0;
//int* dest = _dest;
/* A simple error check */
@ -71,19 +70,18 @@ galileo_e1_code_gen_int(int* _dest, char _Signal[3], signed int _prn,
{
return;
}
}
void
galileo_e1_sinboc_11_gen(std::complex<float>* _dest, int* _prn,
unsigned int _length_out)
{
const unsigned int _length_in = Galileo_E1_B_CODE_LENGTH_CHIPS;
unsigned int _period = (unsigned int) (_length_out / _length_in);
for (unsigned int i = 0; i < _length_in; i++)
{
for (unsigned int j = 0; j < (_period / 2); j++)
_dest[i * _period + j] = std::complex<float>((float) _prn[i],
0.0);
@ -92,9 +90,10 @@ galileo_e1_sinboc_11_gen(std::complex<float>* _dest, int* _prn,
_dest[i * _period + j] = std::complex<float>((float) (-_prn[i]),
0.0);
}
}
void
galileo_e1_sinboc_61_gen(std::complex<float>* _dest, int* _prn,
unsigned int _length_out)
@ -104,17 +103,17 @@ galileo_e1_sinboc_61_gen(std::complex<float>* _dest, int* _prn,
for (unsigned int i = 0; i < _length_in; i++)
{
for (unsigned int j = 0; j < _period; j += 2)
_dest[i * _period + j] = std::complex<float>((float) _prn[i],
0.0);
for (unsigned int j = 1; j < _period; j += 2)
_dest[i * _period + j] = std::complex<float>((float) (-_prn[i]),
0.0);
}
}
void
galileo_e1_gen(std::complex<float>* _dest, int* _prn, char _Signal[3])
{
@ -127,7 +126,6 @@ galileo_e1_gen(std::complex<float>* _dest, int* _prn, char _Signal[3])
std::complex<float> sinboc_61[_codeLength];
galileo_e1_sinboc_11_gen(sinboc_11, _prn, _codeLength); //generate sinboc(1,1) 12 samples per chip
galileo_e1_sinboc_61_gen(sinboc_61, _prn, _codeLength); //generate sinboc(6,1) 12 samples per chip
if (_galileo_signal.rfind("1B") != std::string::npos && _galileo_signal.length() >= 2)
@ -148,13 +146,13 @@ galileo_e1_gen(std::complex<float>* _dest, int* _prn, char _Signal[3])
return;
}
void
galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3],
bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift)
{
// This function is based on the GNU software GPS for MATLAB in the Kay Borre book
unsigned int _samplesPerCode;
const unsigned int _codeFreqBasis = Galileo_E1_CODE_CHIP_RATE_HZ; //Hz
unsigned int _codeLength = Galileo_E1_B_CODE_LENGTH_CHIPS;
@ -165,15 +163,11 @@ galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3],
if (_cboc == true)
{
_codeLength = 12 * Galileo_E1_B_CODE_LENGTH_CHIPS;
if (_fs != 12 * _codeFreqBasis)
{
std::complex<float> _signal_E1[_codeLength];
galileo_e1_gen(_signal_E1, primary_code_E1_chips, _Signal); //generate cboc 12 samples per chip
resampler(_signal_E1, _dest, 12 * _codeFreqBasis, _fs,
_codeLength, _samplesPerCode); //resamples code to fs
}
@ -181,19 +175,14 @@ galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3],
{
galileo_e1_gen(_dest, primary_code_E1_chips, _Signal); //generate cboc 12 samples per chip
}
}
else
{
//--- Find number of samples per spreading code ----------------------------
_codeLength = 2 * Galileo_E1_B_CODE_LENGTH_CHIPS;
if (_fs != 2 * _codeFreqBasis)
{
std::complex<float> _signal_E1[_codeLength];
galileo_e1_sinboc_11_gen(_signal_E1, primary_code_E1_chips,
_codeLength); //generate sinboc(1,1) 2 samples per chip
resampler(_signal_E1, _dest, 2 * _codeFreqBasis, _fs,
@ -203,7 +192,6 @@ galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3],
{
galileo_e1_sinboc_11_gen(_dest, primary_code_E1_chips,
_codeLength); //generate sinboc(1,1) 2 samples per chip }
}
}
}

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
@ -29,8 +29,8 @@
* -------------------------------------------------------------------------
*/
#ifndef GALILEO_E1_SIGNAL_PROCESSING_H_
#define GALILEO_E1_SIGNAL_PROCESSING_H_
#ifndef GNSS_SDR_GALILEO_E1_SIGNAL_PROCESSING_H_
#define GNSS_SDR_GALILEO_E1_SIGNAL_PROCESSING_H_
#include <complex>
#include <iostream>
@ -71,4 +71,4 @@ void galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signa
bool _cboc, unsigned int _prn, signed int _fs,
unsigned int _chip_shift);
#endif /* GALILEO_E1_SIGNAL_PROCESSING_H_ */
#endif /* GNSS_SDR_GALILEO_E1_SIGNAL_PROCESSING_H_ */

View File

@ -46,6 +46,8 @@ gnss_sdr_valve::gnss_sdr_valve (size_t sizeof_stream_item,
d_nitems (nitems), d_ncopied_items (0), d_queue(queue)
{}
gr_block_sptr gnss_sdr_make_valve (size_t sizeof_stream_item,
int nitems,
gr_msg_queue_sptr queue)
@ -53,6 +55,8 @@ gr_block_sptr gnss_sdr_make_valve (size_t sizeof_stream_item,
return gr_block_sptr (new gnss_sdr_valve (sizeof_stream_item, nitems, queue));
}
int gnss_sdr_valve::work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
@ -63,17 +67,12 @@ int gnss_sdr_valve::work (int noutput_items,
ControlMessageFactory* cmf = new ControlMessageFactory();
d_queue->handle(cmf->GetQueueMessage(200,0));
delete cmf;
return -1; // Done!
}
unsigned n = std::min(d_nitems - d_ncopied_items, noutput_items);
if (n == 0)
return 0;
memcpy (output_items[0], input_items[0], n * input_signature()->sizeof_stream_item (0));
d_ncopied_items += n;
return n;
}

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
@ -30,8 +30,6 @@
*/
#ifndef GNSS_SDR_GNSS_SDR_VALVE_H_
#define GNSS_SDR_GNSS_SDR_VALVE_H_
@ -45,20 +43,17 @@ gr_block_sptr gnss_sdr_make_valve (size_t sizeof_stream_item,
class gnss_sdr_valve : public gr_sync_block
{
friend gr_block_sptr gnss_sdr_make_valve(size_t sizeof_stream_item,
int nitems,
gr_msg_queue_sptr queue);
gnss_sdr_valve (size_t sizeof_stream_item,
int nitems,
gr_msg_queue_sptr queue);
int d_nitems;
int d_ncopied_items;
gr_msg_queue_sptr d_queue;
public:
int work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);

View File

@ -32,7 +32,7 @@
*/
#include "gnss_signal_processing.h"
#include <gr_fxpt.h>
#include <gr_fxpt.h> // fixed point sine and cosine
void complex_exp_gen(std::complex<float>* _dest, double _f, double _fs, unsigned int _samps)
@ -40,7 +40,6 @@ void complex_exp_gen(std::complex<float>* _dest, double _f, double _fs, unsigned
//old
//double phase = 0;
//const double phase_step = (GPS_TWO_PI * _f) / _fs;
//new Fixed Point NCO (faster)
int phase_i = 0;
int phase_step_i;
@ -53,7 +52,6 @@ void complex_exp_gen(std::complex<float>* _dest, double _f, double _fs, unsigned
//old
//_dest[i] = std::complex<float>(cos(phase), sin(phase));
//phase += phase_step;
//new Fixed Point NCO (faster)
gr_fxpt::sincos(phase_i,&sin_f,&cos_f);
_dest[i] = std::complex<float>(cos_f, sin_f);
@ -61,12 +59,12 @@ void complex_exp_gen(std::complex<float>* _dest, double _f, double _fs, unsigned
}
}
void complex_exp_gen_conj(std::complex<float>* _dest, double _f, double _fs, unsigned int _samps)
{
//old
//double phase = 0;
//const double phase_step = (GPS_TWO_PI * _f) / _fs;
//new Fixed Point NCO (faster)
int phase_i = 0;
int phase_step_i;
@ -79,7 +77,6 @@ void complex_exp_gen_conj(std::complex<float>* _dest, double _f, double _fs, uns
//old
//_dest[i] = std::complex<float>(cos(phase), sin(phase));
//phase += phase_step;
//new Fixed Point NCO (faster)
gr_fxpt::sincos(phase_i,&sin_f,&cos_f);
_dest[i] = std::complex<float>(cos_f, -sin_f);
@ -211,7 +208,7 @@ void resampler(std::complex<float>* _from, std::complex<float>* _dest, float _fs
}
else
{
//if repeat the chip -> upsample by nearest neighbourhood interpolation
//if repeat the chip -> upsample by nearest neighborhood interpolation
_dest[i] = _from[_codeValueIndex];
}
}

View File

@ -32,8 +32,8 @@
* -------------------------------------------------------------------------
*/
#ifndef GNSS_SIGNAL_PROCESSING_H_
#define GNSS_SIGNAL_PROCESSING_H_
#ifndef GNSS_SDR_GNSS_SIGNAL_PROCESSING_H_
#define GNSS_SDR_GNSS_SIGNAL_PROCESSING_H_
#include <complex>
#include <iostream>
@ -59,7 +59,6 @@ void complex_exp_gen_conj(std::complex<float>* _dest, double _f, double _fs,
* to binary (the output are 4 ints with +1 or -1 values).
*
*/
void hex_to_binary_converter(int * _dest, char _from);
/*!
@ -70,4 +69,4 @@ void resampler(std::complex<float>* _from, std::complex<float>* _dest,
float _fs_in, float _fs_out, unsigned int _length_in,
unsigned int _length_out);
#endif /* GNSS_SIGNAL_PROCESSING_H_ */
#endif /* GNSS_SDR_GNSS_SIGNAL_PROCESSING_H_ */

View File

@ -7,7 +7,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
@ -31,7 +31,6 @@
*/
#include "gps_sdr_signal_processing.h"
#include <math.h>
#include <stdlib.h>
#include <cmath>
@ -39,7 +38,6 @@
void gps_l1_ca_code_gen_complex(std::complex<float>* _dest, signed int _prn, unsigned int _chip_shift)
{
unsigned int G1[1023];
unsigned int G2[1023];
unsigned int G1_register[10], G2_register[10];
@ -96,16 +94,12 @@ void gps_l1_ca_code_gen_complex(std::complex<float>* _dest, signed int _prn, uns
}
delay++;
delay %= 1023;
//std::cout<<_dest[lcv].real(); //OK
}
}
/*!
* \
/*
* code_gen_complex_sampled, generate GPS L1 C/A code complex for the desired SV ID and sampled to specific sampling frequency
* \
*/
void gps_l1_ca_code_gen_complex_sampled(std::complex<float>* _dest, unsigned int _prn, signed int _fs, unsigned int _chip_shift)
{
@ -124,9 +118,7 @@ void gps_l1_ca_code_gen_complex_sampled(std::complex<float>* _dest, unsigned int
_ts = 1/(float)_fs; // Sampling period in sec
_tc = 1/(float)_codeFreqBasis; // C/A chip period in sec
gps_l1_ca_code_gen_complex(_code,_prn, _chip_shift); //generate C/A code 1 sample per chip
//std::cout<<"ts="<<_ts<<std::endl;
//std::cout<<"tc="<<_tc<<std::endl;
//std::cout<<"sv="<<_prn<<std::endl;
for (signed int i=0; i<_samplesPerCode; i++)
{
//=== Digitizing =======================================================
@ -136,7 +128,6 @@ void gps_l1_ca_code_gen_complex_sampled(std::complex<float>* _dest, unsigned int
// number of samples per millisecond (because one C/A code period is one
// millisecond).
_codeValueIndex = ceil((_ts * ((float)i + 1)) / _tc) - 1;
//--- Make the digitized version of the C/A code -----------------------

View File

@ -7,7 +7,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
@ -30,8 +30,8 @@
* -------------------------------------------------------------------------
*/
#ifndef GPS_SDR_SIGNAL_PROCESSING_H_
#define GPS_SDR_SIGNAL_PROCESSING_H_
#ifndef GNSS_SDR_GPS_SDR_SIGNAL_PROCESSING_H_
#define GNSS_SDR_GPS_SDR_SIGNAL_PROCESSING_H_
#include <complex>
#include <iostream>
@ -41,4 +41,4 @@
void gps_l1_ca_code_gen_complex(std::complex<float>* _dest, signed int _prn, unsigned int _chip_shift);
void gps_l1_ca_code_gen_complex_sampled(std::complex<float>* _dest, unsigned int _prn, signed int _fs, unsigned int _chip_shift);
#endif /* GPS_SDR_SIGNAL_PROCESSING_H_ */
#endif /* GNSS_SDR_GPS_SDR_SIGNAL_PROCESSING_H_ */

View File

@ -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
@ -31,8 +31,6 @@
* -------------------------------------------------------------------------
*/
#include "pass_through.h"
#include <iostream>
#include <gnuradio/gr_io_signature.h>
@ -49,12 +47,9 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro
in_streams_(in_streams),
out_streams_(out_streams)
{
std::string default_item_type = "gr_complex";
item_type_ = configuration->property(role + ".item_type", default_item_type);
vector_size_ = configuration->property(role + ".vector_size", 1);
if(item_type_.compare("float") == 0)
{
item_size_ = sizeof(float);
@ -72,29 +67,38 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro
LOG_AT_LEVEL(WARNING) << item_type_ << " unrecognized item type. Using float";
item_size_ = sizeof(float);
}
kludge_copy_ = gr_make_kludge_copy(item_size_);
DLOG(INFO) << "kludge_copy(" << kludge_copy_->unique_id() << ")";
}
Pass_Through::~Pass_Through()
{}
void Pass_Through::connect(gr_top_block_sptr top_block)
{
DLOG(INFO) << "nothing to connect internally";
}
void Pass_Through::disconnect(gr_top_block_sptr top_block)
{
// Nothing to disconnect
}
gr_basic_block_sptr Pass_Through::get_left_block()
{
return kludge_copy_;
}
gr_basic_block_sptr Pass_Through::get_right_block()
{
return kludge_copy_;

View File

@ -7,7 +7,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
@ -30,9 +30,6 @@
* -------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_PASS_THROUGH_H_
#define GNSS_SDR_PASS_THROUGH_H_
@ -45,7 +42,6 @@ class ConfigurationInterface;
class Pass_Through : public GNSSBlockInterface
{
public:
Pass_Through(ConfigurationInterface* configuration,
std::string role,
@ -53,7 +49,6 @@ public:
unsigned int out_stream);
virtual ~Pass_Through();
std::string role()
{
return role_;
@ -62,7 +57,6 @@ public:
{
return "Pass_Through";
}
std::string item_type()
{
return item_type_;
@ -75,20 +69,17 @@ public:
{
return item_size_;
}
void connect(gr_top_block_sptr top_block);
void disconnect(gr_top_block_sptr top_block);
gr_basic_block_sptr get_left_block();
gr_basic_block_sptr get_right_block();
private:
std::string item_type_;
size_t vector_size_;
std::string role_;
unsigned int in_streams_;
unsigned int out_streams_;
gr_kludge_copy_sptr kludge_copy_;
size_t item_size_;
};