2015-05-05 16:18:16 +00:00
/*!
* \ file gps_l2_m_dll_pll_tracking . cc
* \ brief Implementation of an adapter of a DLL + PLL tracking loop block
* for GPS L1 C / A to a TrackingInterface
* \ author Javier Arribas , 2015. jarribas ( at ) cttc . es
*
* Code DLL + carrier PLL according to the algorithms described in :
* K . Borre , D . M . Akos , N . Bertelsen , P . Rinder , and S . H . Jensen ,
* A Software - Defined GPS and Galileo Receiver . A Single - Frequency
* Approach , Birkhauser , 2007
*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*
* Copyright ( C ) 2010 - 2015 ( see AUTHORS file for a list of contributors )
*
* GNSS - SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* This file is part of GNSS - SDR .
*
* GNSS - SDR is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* GNSS - SDR is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with GNSS - SDR . If not , see < http : //www.gnu.org/licenses/>.
*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
# include "gps_l2_m_dll_pll_tracking.h"
# include "configuration_interface.h"
2018-02-26 02:15:53 +00:00
# include "GPS_L2C.h"
2018-02-18 18:28:21 +00:00
# include "gnss_sdr_flags.h"
2018-03-19 15:52:36 +00:00
# include "display.h"
2018-02-26 02:15:53 +00:00
# include <glog/logging.h>
2015-05-05 16:18:16 +00:00
using google : : LogMessage ;
GpsL2MDllPllTracking : : GpsL2MDllPllTracking (
2018-03-03 01:03:39 +00:00
ConfigurationInterface * configuration , std : : string role ,
unsigned int in_streams , unsigned int out_streams ) : role_ ( role ) , in_streams_ ( in_streams ) , out_streams_ ( out_streams )
2015-05-05 16:18:16 +00:00
{
2018-04-05 16:08:49 +00:00
dllpllconf_t trk_param ;
2015-06-16 15:16:20 +00:00
DLOG ( INFO ) < < " role " < < role ;
2015-05-05 16:18:16 +00:00
//################# CONFIGURATION PARAMETERS ########################
std : : string default_item_type = " gr_complex " ;
2018-03-20 11:30:20 +00:00
std : : string item_type = configuration - > property ( role + " .item_type " , default_item_type ) ;
2017-09-02 09:24:44 +00:00
int fs_in_deprecated = configuration - > property ( " GNSS-SDR.internal_fs_hz " , 2048000 ) ;
2018-03-20 11:30:20 +00:00
int fs_in = configuration - > property ( " GNSS-SDR.internal_fs_sps " , fs_in_deprecated ) ;
2018-04-05 16:08:49 +00:00
trk_param . fs_in = fs_in ;
2018-03-20 11:30:20 +00:00
bool dump = configuration - > property ( role + " .dump " , false ) ;
2018-04-05 16:08:49 +00:00
trk_param . dump = dump ;
2018-03-20 11:30:20 +00:00
float pll_bw_hz = configuration - > property ( role + " .pll_bw_hz " , 2.0 ) ;
2018-03-03 01:03:39 +00:00
if ( FLAGS_pll_bw_hz ! = 0.0 ) pll_bw_hz = static_cast < float > ( FLAGS_pll_bw_hz ) ;
2018-04-05 16:08:49 +00:00
trk_param . pll_bw_hz = pll_bw_hz ;
2018-03-20 11:30:20 +00:00
float dll_bw_hz = configuration - > property ( role + " .dll_bw_hz " , 0.75 ) ;
2018-03-03 01:03:39 +00:00
if ( FLAGS_dll_bw_hz ! = 0.0 ) dll_bw_hz = static_cast < float > ( FLAGS_dll_bw_hz ) ;
2018-04-05 16:08:49 +00:00
trk_param . dll_bw_hz = dll_bw_hz ;
2018-03-20 11:30:20 +00:00
float early_late_space_chips = configuration - > property ( role + " .early_late_space_chips " , 0.5 ) ;
2018-04-05 16:08:49 +00:00
trk_param . early_late_space_chips = early_late_space_chips ;
trk_param . early_late_space_narrow_chips = 0.0 ;
2015-05-05 16:18:16 +00:00
std : : string default_dump_filename = " ./track_ch " ;
2018-04-03 17:28:56 +00:00
std : : string dump_filename = configuration - > property ( role + " .dump_filename " , default_dump_filename ) ;
2018-04-05 16:08:49 +00:00
trk_param . dump_filename = dump_filename ;
2018-03-20 11:30:20 +00:00
int vector_length = std : : round ( static_cast < double > ( fs_in ) / ( static_cast < double > ( GPS_L2_M_CODE_RATE_HZ ) / static_cast < double > ( GPS_L2_M_CODE_LENGTH_CHIPS ) ) ) ;
2018-04-05 16:08:49 +00:00
trk_param . vector_length = vector_length ;
2018-03-19 15:52:36 +00:00
int symbols_extended_correlator = configuration - > property ( role + " .extend_correlation_symbols " , 1 ) ;
if ( symbols_extended_correlator ! = 1 )
{
std : : cout < < TEXT_RED < < " WARNING: Extended coherent integration is not allowed in GPS L2. Coherent integration has been set to 20 ms (1 symbol) " < < TEXT_RESET < < std : : endl ;
}
2018-04-05 16:08:49 +00:00
trk_param . extend_correlation_symbols = 1 ;
2018-03-20 11:30:20 +00:00
bool track_pilot = configuration - > property ( role + " .track_pilot " , false ) ;
if ( track_pilot )
{
std : : cout < < TEXT_RED < < " WARNING: GPS L2 does not have pilot signal. Data tracking has been enabled " < < TEXT_RESET < < std : : endl ;
}
2018-04-05 16:08:49 +00:00
trk_param . track_pilot = false ;
trk_param . very_early_late_space_chips = 0.0 ;
trk_param . very_early_late_space_narrow_chips = 0.0 ;
trk_param . pll_bw_narrow_hz = 0.0 ;
trk_param . dll_bw_narrow_hz = 0.0 ;
trk_param . system = ' G ' ;
char sig_ [ 3 ] = " 2S " ;
std : : memcpy ( trk_param . signal , sig_ , 3 ) ;
2015-05-05 16:18:16 +00:00
//################# MAKE TRACKING GNURadio object ###################
if ( item_type . compare ( " gr_complex " ) = = 0 )
{
item_size_ = sizeof ( gr_complex ) ;
2018-04-06 08:10:32 +00:00
tracking_ = dll_pll_veml_make_tracking ( trk_param ) ;
2015-05-05 16:18:16 +00:00
}
else
{
2015-05-17 09:02:27 +00:00
item_size_ = sizeof ( gr_complex ) ;
2015-05-05 16:18:16 +00:00
LOG ( WARNING ) < < item_type < < " unknown tracking item type. " ;
}
2015-05-17 09:02:27 +00:00
channel_ = 0 ;
2015-05-05 16:18:16 +00:00
DLOG ( INFO ) < < " tracking( " < < tracking_ - > unique_id ( ) < < " ) " ;
}
GpsL2MDllPllTracking : : ~ GpsL2MDllPllTracking ( )
2018-03-03 01:03:39 +00:00
{
}
2015-05-05 16:18:16 +00:00
void GpsL2MDllPllTracking : : start_tracking ( )
{
2018-04-05 19:15:51 +00:00
tracking_ - > start_tracking ( ) ;
2015-05-05 16:18:16 +00:00
}
2018-04-05 19:15:51 +00:00
2015-05-05 16:18:16 +00:00
/*
* Set tracking channel unique ID
*/
void GpsL2MDllPllTracking : : set_channel ( unsigned int channel )
{
channel_ = channel ;
2018-04-05 19:15:51 +00:00
tracking_ - > set_channel ( channel ) ;
2015-05-05 16:18:16 +00:00
}
void GpsL2MDllPllTracking : : set_gnss_synchro ( Gnss_Synchro * p_gnss_synchro )
{
2018-04-05 19:15:51 +00:00
tracking_ - > set_gnss_synchro ( p_gnss_synchro ) ;
2015-05-05 16:18:16 +00:00
}
2018-04-05 19:15:51 +00:00
2015-05-05 16:18:16 +00:00
void GpsL2MDllPllTracking : : connect ( gr : : top_block_sptr top_block )
{
2018-03-03 01:03:39 +00:00
if ( top_block )
{ /* top_block is not null */
} ;
2016-05-02 21:46:30 +00:00
//nothing to connect, now the tracking uses gr_sync_decimator
2015-05-05 16:18:16 +00:00
}
2018-04-05 19:15:51 +00:00
2015-05-05 16:18:16 +00:00
void GpsL2MDllPllTracking : : disconnect ( gr : : top_block_sptr top_block )
{
2018-03-03 01:03:39 +00:00
if ( top_block )
{ /* top_block is not null */
} ;
2016-05-02 21:46:30 +00:00
//nothing to disconnect, now the tracking uses gr_sync_decimator
2015-05-05 16:18:16 +00:00
}
2018-04-05 19:15:51 +00:00
2015-05-05 16:18:16 +00:00
gr : : basic_block_sptr GpsL2MDllPllTracking : : get_left_block ( )
{
2018-04-05 19:15:51 +00:00
return tracking_ ;
2015-05-05 16:18:16 +00:00
}
2018-04-05 19:15:51 +00:00
2015-05-05 16:18:16 +00:00
gr : : basic_block_sptr GpsL2MDllPllTracking : : get_right_block ( )
{
2018-04-05 19:15:51 +00:00
return tracking_ ;
2015-05-05 16:18:16 +00:00
}