From bb6da5f7b025326b54bf94b3608bc509079933f8 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 11 Apr 2014 20:18:59 +0200 Subject: [PATCH 01/18] First attempt to design a smart ptr only factory. Compiles and passes the thest but does not connect the flowgraph --- src/core/receiver/file_configuration.h | 2 +- src/core/receiver/gnss_block_factory.cc | 441 +++++++++++++----- src/core/receiver/gnss_block_factory.h | 41 +- src/core/receiver/gnss_flowgraph.cc | 119 +++-- src/core/receiver/gnss_flowgraph.h | 17 +- .../gnss_block/gnss_block_factory_test.cc | 218 +++------ 6 files changed, 517 insertions(+), 321 deletions(-) diff --git a/src/core/receiver/file_configuration.h b/src/core/receiver/file_configuration.h index 1f939ccd7..4ff6af626 100644 --- a/src/core/receiver/file_configuration.h +++ b/src/core/receiver/file_configuration.h @@ -60,7 +60,7 @@ public: FileConfiguration(std::string filename); FileConfiguration(); //! Virtual destructor - virtual ~FileConfiguration(); + ~FileConfiguration(); std::string property(std::string property_name, std::string default_value); bool property(std::string property_name, bool default_value); long property(std::string property_name, long default_value); diff --git a/src/core/receiver/gnss_block_factory.cc b/src/core/receiver/gnss_block_factory.cc index a6a5d01e7..203a5da4b 100644 --- a/src/core/receiver/gnss_block_factory.cc +++ b/src/core/receiver/gnss_block_factory.cc @@ -33,6 +33,7 @@ * ------------------------------------------------------------------------- */ + #include "gnss_block_factory.h" #include #include @@ -83,15 +84,15 @@ #endif #if GN3S_DRIVER - #include "gn3s_signal_source.h" + #include "gn3s_signal_source.h" #endif #if RAW_ARRAY_DRIVER - #include "raw_array_signal_source.h" + #include "raw_array_signal_source.h" #endif #if RTLSDR_DRIVER - #include "rtlsdr_signal_source.h" + #include "rtlsdr_signal_source.h" #endif using google::LogMessage; @@ -105,7 +106,7 @@ GNSSBlockFactory::~GNSSBlockFactory() {} -GNSSBlockInterface* GNSSBlockFactory::GetSignalSource( +std::unique_ptr GNSSBlockFactory::GetSignalSource( std::shared_ptr configuration, boost::shared_ptr queue) { std::string default_implementation = "File_Signal_Source"; @@ -118,7 +119,7 @@ GNSSBlockInterface* GNSSBlockFactory::GetSignalSource( -GNSSBlockInterface* GNSSBlockFactory::GetSignalConditioner( +std::unique_ptr GNSSBlockFactory::GetSignalConditioner( std::shared_ptr configuration, boost::shared_ptr queue) { std::string default_implementation = "Pass_Through"; @@ -147,30 +148,33 @@ GNSSBlockInterface* GNSSBlockFactory::GetSignalConditioner( << data_type_adapter << ", InputFilter implementation: " << input_filter << ", and Resampler implementation: " << resampler; + //std::unique_ptr conditioner_; if(signal_conditioner.compare("Array_Signal_Conditioner") == 0) { //instantiate the array version - return new ArraySignalConditioner(configuration.get(), GetBlock(configuration, - "DataTypeAdapter", data_type_adapter, 1, 1, queue), GetBlock( - configuration,"InputFilter", input_filter, 1, 1, queue), - GetBlock(configuration,"Resampler", resampler, 1, 1, queue), - "SignalConditioner", "Signal_Conditioner", queue); + std::unique_ptr conditioner_(new ArraySignalConditioner(configuration.get(), GetBlock(configuration, + "DataTypeAdapter", data_type_adapter, 1, 1, queue).release(), GetBlock( + configuration,"InputFilter", input_filter, 1, 1, queue).release(), + GetBlock(configuration,"Resampler", resampler, 1, 1, queue).release(), + "SignalConditioner", "Signal_Conditioner", queue)); + return conditioner_; } else { - //normal version - return new SignalConditioner(configuration.get(), GetBlock(configuration, - "DataTypeAdapter", data_type_adapter, 1, 1, queue), GetBlock( - configuration,"InputFilter", input_filter, 1, 1, queue), - GetBlock(configuration,"Resampler", resampler, 1, 1, queue), - "SignalConditioner", "Signal_Conditioner", queue); + //single-antenna version + std::unique_ptr conditioner_(new SignalConditioner(configuration.get(), GetBlock(configuration, + "DataTypeAdapter", data_type_adapter, 1, 1, queue).release(), GetBlock( + configuration,"InputFilter", input_filter, 1, 1, queue).release(), + GetBlock(configuration,"Resampler", resampler, 1, 1, queue).release(), + "SignalConditioner", "Signal_Conditioner", queue)); + return conditioner_; } } -GNSSBlockInterface* GNSSBlockFactory::GetObservables(std::shared_ptr configuration, +std::unique_ptr GNSSBlockFactory::GetObservables(std::shared_ptr configuration, boost::shared_ptr queue) { std::string default_implementation = "GPS_L1_CA_Observables"; @@ -182,7 +186,7 @@ GNSSBlockInterface* GNSSBlockFactory::GetObservables(std::shared_ptr configuration, +std::unique_ptr GNSSBlockFactory::GetPVT(std::shared_ptr configuration, boost::shared_ptr queue) { std::string default_implementation = "Pass_Through"; @@ -194,7 +198,7 @@ GNSSBlockInterface* GNSSBlockFactory::GetPVT(std::shared_ptr configuration, +std::unique_ptr GNSSBlockFactory::GetOutputFilter(std::shared_ptr configuration, boost::shared_ptr queue) { std::string default_implementation = "Null_Sink_Output_Filter"; @@ -204,7 +208,7 @@ GNSSBlockInterface* GNSSBlockFactory::GetOutputFilter(std::shared_ptr GNSSBlockFactory::GetChannel( std::shared_ptr configuration, std::string acq, std::string trk, std::string tlm, int channel, boost::shared_ptr queue) @@ -215,23 +219,31 @@ GNSSBlockInterface* GNSSBlockFactory::GetChannel( LOG(INFO) << "Instantiating Channel " << id << " with Acquisition Implementation: " << acq << ", Tracking Implementation: " << trk << ", Telemetry Decoder implementation: " << tlm; - return new Channel(configuration.get(), channel, GetBlock(configuration, - "Channel", "Pass_Through", 1, 1, queue), - (AcquisitionInterface*)GetBlock(configuration, "Acquisition", acq, 1, 1, queue), - (TrackingInterface*)GetBlock(configuration, "Tracking", trk, 1, 1, queue), - (TelemetryDecoderInterface*)GetBlock(configuration, "TelemetryDecoder", tlm, 1, 1, queue), - "Channel", "Channel", queue); + std::unique_ptr pass_through_ = GetBlock(configuration, "Channel", "Pass_Through", 1, 1, queue); + std::unique_ptr acq_ = GetAcqBlock(configuration, "Acquisition", acq, 1, 1, queue); + std::unique_ptr trk_ = GetTrkBlock(configuration, "Tracking", trk, 1, 1, queue); + std::unique_ptr tlm_ = GetTlmBlock(configuration, "TelemetryDecoder", tlm, 1, 1, queue); + + std::unique_ptr channel_(new Channel(configuration.get(), channel, pass_through_.release(), + acq_.release(), + trk_.release(), + tlm_.release(), + "Channel", "Channel", queue)); + + return channel_; } -std::vector* GNSSBlockFactory::GetChannels( +std::unique_ptr>> GNSSBlockFactory::GetChannels( std::shared_ptr configuration, boost::shared_ptr queue) { std::string default_implementation = "Pass_Through"; unsigned int channel_count = configuration->property("Channels.count", 12); LOG(INFO) << "Getting " << channel_count << " channels"; - std::vector* channels = new std::vector(); + + std::unique_ptr>> channels(new std::vector>()); + std::string tracking = configuration->property("Tracking.implementation", default_implementation); std::string telemetry_decoder = configuration->property("TelemetryDecoder.implementation", default_implementation); std::string acquisition_implementation = configuration->property("Acquisition.implementation", default_implementation); @@ -239,15 +251,15 @@ std::vector* GNSSBlockFactory::GetChannels( for (unsigned int i = 0; i < channel_count; i++) { std::string acquisition_implementation_specific = configuration->property( - "Acquisition"+ boost::lexical_cast(i) + ".implementation", - default_implementation); + "Acquisition" + boost::lexical_cast(i) + ".implementation", + default_implementation); if(acquisition_implementation_specific.compare(default_implementation) != 0) { - acquisition_implementation = acquisition_implementation_specific; + acquisition_implementation = acquisition_implementation_specific; } - channels->push_back(GetChannel(configuration, - acquisition_implementation, tracking, telemetry_decoder, i, - queue)); + + channels->push_back(std::move(GetChannel(configuration, + acquisition_implementation, tracking, telemetry_decoder, i, queue))); } return channels; } @@ -258,18 +270,19 @@ std::vector* GNSSBlockFactory::GetChannels( * * PLEASE ADD YOUR NEW BLOCK HERE!! */ -GNSSBlockInterface* GNSSBlockFactory::GetBlock( +std::unique_ptr GNSSBlockFactory::GetBlock( std::shared_ptr configuration, std::string role, std::string implementation, unsigned int in_streams, unsigned int out_streams, boost::shared_ptr queue) { - GNSSBlockInterface* block = NULL; //Change to nullptr when available in compilers (C++11) + std::unique_ptr block; //PASS THROUGH ---------------------------------------------------------------- if (implementation.compare("Pass_Through") == 0) { - block = new Pass_Through(configuration.get(), role, in_streams, out_streams); + std::unique_ptr block_(new Pass_Through(configuration.get(), role, in_streams, out_streams)); + block = std::move(block_); } // SIGNAL SOURCES ------------------------------------------------------------- @@ -277,9 +290,11 @@ GNSSBlockInterface* GNSSBlockFactory::GetBlock( { try { - block = new FileSignalSource(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new FileSignalSource(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } + catch (const std::exception &e) { std::cout << "GNSS-SDR program ended." << std::endl; @@ -291,8 +306,10 @@ GNSSBlockInterface* GNSSBlockFactory::GetBlock( { try { - block = new NsrFileSignalSource(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new NsrFileSignalSource(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } catch (const std::exception &e) { @@ -303,208 +320,412 @@ GNSSBlockInterface* GNSSBlockFactory::GetBlock( } else if (implementation.compare("UHD_Signal_Source") == 0) { - block = new UhdSignalSource(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new UhdSignalSource(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } #if GN3S_DRIVER else if (implementation.compare("GN3S_Signal_Source") == 0) { - block = new Gn3sSignalSource(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new Gn3sSignalSource(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } #endif #if RAW_ARRAY_DRIVER else if (implementation.compare("Raw_Array_Signal_Source") == 0) { - block = new RawArraySignalSource(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new RawArraySignalSource(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } #endif #if RTLSDR_DRIVER else if (implementation.compare("Rtlsdr_Signal_Source") == 0) { - block = new RtlsdrSignalSource(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new RtlsdrSignalSource(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } #endif // DATA TYPE ADAPTER ----------------------------------------------------------- else if (implementation.compare("Ishort_To_Complex") == 0) { - block = new IshortToComplex(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptrblock_(new IshortToComplex(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } // INPUT FILTER ---------------------------------------------------------------- else if (implementation.compare("Fir_Filter") == 0) { - block = new FirFilter(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new FirFilter(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } else if (implementation.compare("Freq_Xlating_Fir_Filter") == 0) { - block = new FreqXlatingFirFilter(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new FreqXlatingFirFilter(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } else if (implementation.compare("Beamformer_Filter") == 0) { - block = new BeamformerFilter(configuration.get(), role, in_streams, - out_streams); + std::unique_ptr block_(new BeamformerFilter(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); } // RESAMPLER ------------------------------------------------------------------- else if (implementation.compare("Direct_Resampler") == 0) { - block = new DirectResamplerConditioner(configuration.get(), role, - in_streams, out_streams); + std::unique_ptr block_(new DirectResamplerConditioner(configuration.get(), role, + in_streams, out_streams)); + block = std::move(block_); } // ACQUISITION BLOCKS --------------------------------------------------------- else if (implementation.compare("GPS_L1_CA_PCPS_Acquisition") == 0) { - block = new GpsL1CaPcpsAcquisition(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new GpsL1CaPcpsAcquisition(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } else if (implementation.compare("GPS_L1_CA_PCPS_Assisted_Acquisition") == 0) { - block = new GpsL1CaPcpsAssistedAcquisition(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new GpsL1CaPcpsAssistedAcquisition(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } else if (implementation.compare("GPS_L1_CA_PCPS_Tong_Acquisition") == 0) { - block = new GpsL1CaPcpsTongAcquisition(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new GpsL1CaPcpsTongAcquisition(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } else if (implementation.compare("GPS_L1_CA_PCPS_Multithread_Acquisition") == 0) { - block = new GpsL1CaPcpsMultithreadAcquisition(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new GpsL1CaPcpsMultithreadAcquisition(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } #if OPENCL_BLOCKS else if (implementation.compare("GPS_L1_CA_PCPS_OpenCl_Acquisition") == 0) { - block = new GpsL1CaPcpsOpenClAcquisition(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new GpsL1CaPcpsOpenClAcquisition(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } #endif else if (implementation.compare("GPS_L1_CA_PCPS_Acquisition_Fine_Doppler") == 0) { - block = new GpsL1CaPcpsAcquisitionFineDoppler(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new GpsL1CaPcpsAcquisitionFineDoppler(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } else if (implementation.compare("Galileo_E1_PCPS_Ambiguous_Acquisition") == 0) { - block = new GalileoE1PcpsAmbiguousAcquisition(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new GalileoE1PcpsAmbiguousAcquisition(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } else if (implementation.compare("Galileo_E1_PCPS_8ms_Ambiguous_Acquisition") == 0) { - block = new GalileoE1Pcps8msAmbiguousAcquisition(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new GalileoE1Pcps8msAmbiguousAcquisition(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } else if (implementation.compare("Galileo_E1_PCPS_Tong_Ambiguous_Acquisition") == 0) { - block = new GalileoE1PcpsTongAmbiguousAcquisition(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new GalileoE1PcpsTongAmbiguousAcquisition(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } else if (implementation.compare("Galileo_E1_PCPS_CCCWSR_Ambiguous_Acquisition") == 0) { - block = new GalileoE1PcpsCccwsrAmbiguousAcquisition(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new GalileoE1PcpsCccwsrAmbiguousAcquisition(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } // TRACKING BLOCKS ------------------------------------------------------------- else if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking") == 0) { - block = new GpsL1CaDllPllTracking(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new GpsL1CaDllPllTracking(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } else if (implementation.compare("GPS_L1_CA_DLL_PLL_Optim_Tracking") == 0) { - block = new GpsL1CaDllPllOptimTracking(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new GpsL1CaDllPllOptimTracking(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } else if (implementation.compare("GPS_L1_CA_DLL_FLL_PLL_Tracking") == 0) { - block = new GpsL1CaDllFllPllTracking(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new GpsL1CaDllFllPllTracking(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } else if (implementation.compare("GPS_L1_CA_TCP_CONNECTOR_Tracking") == 0) { - block = new GpsL1CaTcpConnectorTracking(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new GpsL1CaTcpConnectorTracking(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking") == 0) { - block = new GalileoE1DllPllVemlTracking(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new GalileoE1DllPllVemlTracking(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } else if (implementation.compare("Galileo_E1_TCP_CONNECTOR_Tracking") == 0) { - block = new GalileoE1TcpConnectorTracking(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new GalileoE1TcpConnectorTracking(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } // TELEMETRY DECODERS ---------------------------------------------------------- else if (implementation.compare("GPS_L1_CA_Telemetry_Decoder") == 0) { - block = new GpsL1CaTelemetryDecoder(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new GpsL1CaTelemetryDecoder(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } else if (implementation.compare("Galileo_E1B_Telemetry_Decoder") == 0) { - block = new GalileoE1BTelemetryDecoder(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new GalileoE1BTelemetryDecoder(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } else if (implementation.compare("SBAS_L1_Telemetry_Decoder") == 0) { - block = new SbasL1TelemetryDecoder(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new SbasL1TelemetryDecoder(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } // OBSERVABLES ----------------------------------------------------------------- else if (implementation.compare("GPS_L1_CA_Observables") == 0) { - block = new GpsL1CaObservables(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new GpsL1CaObservables(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } else if (implementation.compare("Galileo_E1B_Observables") == 0) { - block = new GalileoE1Observables(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new GalileoE1Observables(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } // PVT ------------------------------------------------------------------------- else if (implementation.compare("GPS_L1_CA_PVT") == 0) { - block = new GpsL1CaPvt(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new GpsL1CaPvt(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } else if (implementation.compare("GALILEO_E1_PVT") == 0) { - block = new GalileoE1Pvt(configuration.get(), role, in_streams, - out_streams, queue); + std::unique_ptr block_(new GalileoE1Pvt(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); } // OUTPUT FILTERS -------------------------------------------------------------- else if (implementation.compare("Null_Sink_Output_Filter") == 0) { - block = new NullSinkOutputFilter(configuration.get(), role, in_streams, - out_streams); + std::unique_ptr block_(new NullSinkOutputFilter(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); } else if (implementation.compare("File_Output_Filter") == 0) { - block = new FileOutputFilter(configuration.get(), role, in_streams, - out_streams); + std::unique_ptr block_(new FileOutputFilter(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); } else { // Log fatal. This causes execution to stop. LOG(ERROR) << implementation << ": Undefined implementation for block"; } - return block; + return std::move(block); +} + + +std::unique_ptr GNSSBlockFactory::GetAcqBlock( + std::shared_ptr configuration, + std::string role, + std::string implementation, unsigned int in_streams, + unsigned int out_streams, boost::shared_ptr queue) +{ + std::unique_ptr block; + // ACQUISITION BLOCKS --------------------------------------------------------- + if (implementation.compare("GPS_L1_CA_PCPS_Acquisition") == 0) + { + std::unique_ptr block_(new GpsL1CaPcpsAcquisition(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + else if (implementation.compare("GPS_L1_CA_PCPS_Assisted_Acquisition") == 0) + { + std::unique_ptr block_(new GpsL1CaPcpsAssistedAcquisition(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + else if (implementation.compare("GPS_L1_CA_PCPS_Tong_Acquisition") == 0) + { + std::unique_ptr block_(new GpsL1CaPcpsTongAcquisition(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + else if (implementation.compare("GPS_L1_CA_PCPS_Multithread_Acquisition") == 0) + { + std::unique_ptr block_(new GpsL1CaPcpsMultithreadAcquisition(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + +#if OPENCL_BLOCKS + else if (implementation.compare("GPS_L1_CA_PCPS_OpenCl_Acquisition") == 0) + { + std::unique_ptr block_(new GpsL1CaPcpsOpenClAcquisition(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } +#endif + + else if (implementation.compare("GPS_L1_CA_PCPS_Acquisition_Fine_Doppler") == 0) + { + std::unique_ptr block_(new GpsL1CaPcpsAcquisitionFineDoppler(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + else if (implementation.compare("Galileo_E1_PCPS_Ambiguous_Acquisition") == 0) + { + std::unique_ptr block_(new GalileoE1PcpsAmbiguousAcquisition(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + else if (implementation.compare("Galileo_E1_PCPS_8ms_Ambiguous_Acquisition") == 0) + { + std::unique_ptr block_(new GalileoE1Pcps8msAmbiguousAcquisition(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + else if (implementation.compare("Galileo_E1_PCPS_Tong_Ambiguous_Acquisition") == 0) + { + std::unique_ptr block_(new GalileoE1PcpsTongAmbiguousAcquisition(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + else if (implementation.compare("Galileo_E1_PCPS_CCCWSR_Ambiguous_Acquisition") == 0) + { + std::unique_ptr block_(new GalileoE1PcpsCccwsrAmbiguousAcquisition(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + else + { + // Log fatal. This causes execution to stop. + LOG(ERROR) << implementation << ": Undefined implementation for block"; + } + return std::move(block); +} + + +std::unique_ptr GNSSBlockFactory::GetTrkBlock( + std::shared_ptr configuration, + std::string role, + std::string implementation, unsigned int in_streams, + unsigned int out_streams, boost::shared_ptr queue) +{ + std::unique_ptr block; + +// TRACKING BLOCKS ------------------------------------------------------------- + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking") == 0) + { + std::unique_ptr block_(new GpsL1CaDllPllTracking(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + else if (implementation.compare("GPS_L1_CA_DLL_PLL_Optim_Tracking") == 0) + { + std::unique_ptr block_(new GpsL1CaDllPllOptimTracking(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + else if (implementation.compare("GPS_L1_CA_DLL_FLL_PLL_Tracking") == 0) + { + std::unique_ptr block_(new GpsL1CaDllFllPllTracking(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + else if (implementation.compare("GPS_L1_CA_TCP_CONNECTOR_Tracking") == 0) + { + std::unique_ptr block_(new GpsL1CaTcpConnectorTracking(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking") == 0) + { + std::unique_ptr block_(new GalileoE1DllPllVemlTracking(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + else if (implementation.compare("Galileo_E1_TCP_CONNECTOR_Tracking") == 0) + { + std::unique_ptr block_(new GalileoE1TcpConnectorTracking(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + else + { + // Log fatal. This causes execution to stop. + LOG(ERROR) << implementation << ": Undefined implementation for block"; + } + return std::move(block); +} + +std::unique_ptr GNSSBlockFactory::GetTlmBlock( + std::shared_ptr configuration, + std::string role, + std::string implementation, unsigned int in_streams, + unsigned int out_streams, boost::shared_ptr queue) +{ + std::unique_ptr block; + +// TELEMETRY DECODERS ---------------------------------------------------------- + if (implementation.compare("GPS_L1_CA_Telemetry_Decoder") == 0) + { + std::unique_ptr block_(new GpsL1CaTelemetryDecoder(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } +else if (implementation.compare("Galileo_E1B_Telemetry_Decoder") == 0) + { + std::unique_ptr block_(new GalileoE1BTelemetryDecoder(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } +else if (implementation.compare("SBAS_L1_Telemetry_Decoder") == 0) + { + std::unique_ptr block_(new SbasL1TelemetryDecoder(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } +else + { + // Log fatal. This causes execution to stop. + LOG(ERROR) << implementation << ": Undefined implementation for block"; + } + return std::move(block); } diff --git a/src/core/receiver/gnss_block_factory.h b/src/core/receiver/gnss_block_factory.h index c39a262ff..04d986724 100644 --- a/src/core/receiver/gnss_block_factory.h +++ b/src/core/receiver/gnss_block_factory.h @@ -38,10 +38,14 @@ #include #include +#include #include class ConfigurationInterface; class GNSSBlockInterface; +class AcquisitionInterface; +class TrackingInterface; +class TelemetryDecoderInterface; /*! * \brief Class that produces all kinds of GNSS blocks @@ -51,28 +55,47 @@ class GNSSBlockFactory public: GNSSBlockFactory(); virtual ~GNSSBlockFactory(); - GNSSBlockInterface* GetSignalSource(std::shared_ptr configuration, + std::unique_ptr GetSignalSource(std::shared_ptr configuration, boost::shared_ptr queue); - GNSSBlockInterface* GetSignalConditioner(std::shared_ptr configuration, + std::unique_ptr GetSignalConditioner(std::shared_ptr configuration, boost::shared_ptr queue); - GNSSBlockInterface* GetPVT(std::shared_ptr configuration, + std::unique_ptr GetPVT(std::shared_ptr configuration, boost::shared_ptr queue); - GNSSBlockInterface* GetObservables(std::shared_ptr configuration, + std::unique_ptr GetObservables(std::shared_ptr configuration, boost::shared_ptr queue); - GNSSBlockInterface* GetOutputFilter(std::shared_ptr configuration, + std::unique_ptr GetOutputFilter(std::shared_ptr configuration, boost::shared_ptr queue); - GNSSBlockInterface* GetChannel(std::shared_ptr configuration, + std::unique_ptr GetChannel(std::shared_ptr configuration, std::string acq, std::string trk, std::string tlm, int channel, boost::shared_ptr queue); - std::vector* GetChannels(std::shared_ptr configuration, - boost::shared_ptr queue); + //std::unique_ptr>> GetChannels(std::shared_ptr configuration, + //std::vector> GetChannels(std::shared_ptr configuration, + std::unique_ptr>> GetChannels(std::shared_ptr configuration, + boost::shared_ptr queue); /* * \brief Returns the block with the required configuration and implementation */ - GNSSBlockInterface* GetBlock(std::shared_ptr configuration, + std::unique_ptr GetBlock(std::shared_ptr configuration, std::string role, std::string implementation, unsigned int in_streams, unsigned int out_streams, boost::shared_ptr queue); +private: + std::unique_ptr GetAcqBlock( + std::shared_ptr configuration, + std::string role, + std::string implementation, unsigned int in_streams, + unsigned int out_streams, boost::shared_ptr queue); + std::unique_ptr GetTrkBlock( + std::shared_ptr configuration, + std::string role, + std::string implementation, unsigned int in_streams, + unsigned int out_streams, boost::shared_ptr queue); + std::unique_ptr GetTlmBlock( + std::shared_ptr configuration, + std::string role, + std::string implementation, unsigned int in_streams, + unsigned int out_streams, boost::shared_ptr queue); }; #endif /*GNSS_SDR_BLOCK_FACTORY_H_*/ + diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 6606283b1..ea4a3e058 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -54,7 +54,8 @@ GNSSFlowgraph::GNSSFlowgraph(std::shared_ptr configurati connected_ = false; running_ = false; configuration_ = configuration; - blocks_ = new std::vector(); + //blocks_ = new std::vector(); + std::shared_ptr>> blocks_ = std::make_shared>>(); queue_ = queue; init(); } @@ -64,10 +65,10 @@ GNSSFlowgraph::~GNSSFlowgraph() { for (unsigned int i = 0; i < blocks_->size(); i++) { - delete blocks_->at(i); + //delete blocks_->at(i); } blocks_->clear(); - delete blocks_; + //delete blocks_; } @@ -129,7 +130,10 @@ void GNSSFlowgraph::connect() try { - signal_source()->connect(top_block_); + std::cout << "helllllo" << std::endl; + //signal_source()->connect(top_block_); + blocks_->at(0)->connect(top_block_); + std::cout << "helllllo" << std::endl; } catch (std::exception& e) { @@ -440,42 +444,55 @@ void GNSSFlowgraph::set_configuration(std::shared_ptr co -GNSSBlockInterface* GNSSFlowgraph::signal_source() +std::shared_ptr GNSSFlowgraph::signal_source() { - return blocks_->at(0); + //std::shared_ptr cond_ { blocks_->at(0) }; + //return cond_; + //return blocks_->at(0); + std::shared_ptr source_ = std::move(blocks_->at(0)); + return source_; + } -GNSSBlockInterface* GNSSFlowgraph::signal_conditioner() +std::shared_ptr GNSSFlowgraph::signal_conditioner() { return blocks_->at(1); } -ChannelInterface* GNSSFlowgraph::channel(unsigned int index) +std::shared_ptr GNSSFlowgraph::channel(unsigned int index) { - return (ChannelInterface*) blocks_->at(index + 5); + //return (ChannelInterface*) blocks_->at(index + 5); + //std::shared_ptr sptr = std::make_shared(blocks_->at(index + 5)); + //return blocks_->at(index + 5); + std::shared_ptr chan_ = blocks_->at(index + 5); + + std::shared_ptr chan = std::dynamic_pointer_cast(chan_); + + return chan; + //return sptr; } -GNSSBlockInterface* GNSSFlowgraph::observables() +std::shared_ptr GNSSFlowgraph::observables() { return blocks_->at(2); } -GNSSBlockInterface* GNSSFlowgraph::pvt() +std::shared_ptr GNSSFlowgraph::pvt() { return blocks_->at(3); } -GNSSBlockInterface* GNSSFlowgraph::output_filter() +std::shared_ptr GNSSFlowgraph::output_filter() { return blocks_->at(4); } @@ -487,24 +504,36 @@ void GNSSFlowgraph::init() /* * Instantiates the receiver blocks */ - blocks_->push_back(block_factory_->GetSignalSource(configuration_, queue_)); - blocks_->push_back(block_factory_->GetSignalConditioner(configuration_, queue_)); - blocks_->push_back(block_factory_->GetObservables(configuration_, queue_)); - blocks_->push_back(block_factory_->GetPVT(configuration_, queue_)); - blocks_->push_back(block_factory_->GetOutputFilter(configuration_, queue_)); + std::shared_ptr block_factory_ = std::make_shared(); + std::shared_ptr>> blocks_ = std::make_shared>>(); - std::vector* channels = block_factory_->GetChannels(configuration_, queue_); + std::unique_ptr signal_source_ = block_factory_->GetSignalSource(configuration_, queue_); + std::shared_ptr cond_ = block_factory_->GetSignalConditioner(configuration_, queue_); + std::shared_ptr obs_ = block_factory_->GetObservables(configuration_, queue_); + std::shared_ptr pvt_ = block_factory_->GetPVT(configuration_, queue_); + std::shared_ptr output_ = block_factory_->GetOutputFilter(configuration_, queue_); + + blocks_->push_back(std::move(signal_source_)); + blocks_->push_back(cond_); + blocks_->push_back(obs_); + blocks_->push_back(pvt_); + blocks_->push_back(output_); + + + std::shared_ptr>> channels = block_factory_->GetChannels(configuration_, queue_); channels_count_ = channels->size(); + for (unsigned int i = 0; i < channels_count_; i++) { - blocks_->push_back(channels->at(i)); + std::shared_ptr chan_ = std::move(channels->at(i)); + blocks_->push_back(chan_); } top_block_ = gr::make_top_block("GNSSFlowgraph"); - delete channels; + //delete channels; // fill the available_GNSS_signals_ queue with the satellites ID's to be searched by the acquisition @@ -543,37 +572,37 @@ void GNSSFlowgraph::set_signals_list() if (default_system.compare(std::string("GPS")) == 0) { - /* - * Loop to create GPS L1 C/A signals - */ - std::set available_gps_prn = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, - 29, 30, 31, 32 }; + /* + * Loop to create GPS L1 C/A signals + */ + std::set available_gps_prn = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, + 29, 30, 31, 32 }; - for (available_gnss_prn_iter = available_gps_prn.begin(); - available_gnss_prn_iter != available_gps_prn.end(); - available_gnss_prn_iter++) - { - available_GNSS_signals_.push_back(Gnss_Signal(Gnss_Satellite(std::string("GPS"), - *available_gnss_prn_iter), std::string("1C"))); - } + for (available_gnss_prn_iter = available_gps_prn.begin(); + available_gnss_prn_iter != available_gps_prn.end(); + available_gnss_prn_iter++) + { + available_GNSS_signals_.push_back(Gnss_Signal(Gnss_Satellite(std::string("GPS"), + *available_gnss_prn_iter), std::string("1C"))); + } } if (default_system.compare(std::string("SBAS")) == 0) { - /* - * Loop to create SBAS L1 C/A signals - */ - std::set available_sbas_prn = {120, 124, 126}; + /* + * Loop to create SBAS L1 C/A signals + */ + std::set available_sbas_prn = {120, 124, 126}; - for (available_gnss_prn_iter = available_sbas_prn.begin(); - available_gnss_prn_iter != available_sbas_prn.end(); - available_gnss_prn_iter++) - { - available_GNSS_signals_.push_back(Gnss_Signal(Gnss_Satellite(std::string("SBAS"), - *available_gnss_prn_iter), std::string("1C"))); - } + for (available_gnss_prn_iter = available_sbas_prn.begin(); + available_gnss_prn_iter != available_sbas_prn.end(); + available_gnss_prn_iter++) + { + available_GNSS_signals_.push_back(Gnss_Signal(Gnss_Satellite(std::string("SBAS"), + *available_gnss_prn_iter), std::string("1C"))); + } } @@ -636,7 +665,7 @@ void GNSSFlowgraph::set_signals_list() // for (available_gnss_list_iter = available_GNSS_signals_.begin(); available_gnss_list_iter // != available_GNSS_signals_.end(); available_gnss_list_iter++) // { -// std::cout << *available_gnss_list_iter << std::endl; +// std::cout << *available_gnss_list_iter << std::endl; // } } diff --git a/src/core/receiver/gnss_flowgraph.h b/src/core/receiver/gnss_flowgraph.h index 4a3556cad..ff793df26 100644 --- a/src/core/receiver/gnss_flowgraph.h +++ b/src/core/receiver/gnss_flowgraph.h @@ -93,12 +93,12 @@ public: void set_configuration(std::shared_ptr configuration); - GNSSBlockInterface* signal_source(); - GNSSBlockInterface* signal_conditioner(); - ChannelInterface* channel(unsigned int index); - GNSSBlockInterface* observables(); - GNSSBlockInterface* pvt(); - GNSSBlockInterface* output_filter(); + std::shared_ptr signal_source(); + std::shared_ptr signal_conditioner(); + std::shared_ptr channel(unsigned int index); + std::shared_ptr observables(); + std::shared_ptr pvt(); + std::shared_ptr output_filter(); unsigned int applied_actions() { @@ -131,8 +131,9 @@ private: unsigned int applied_actions_; std::string config_file_; std::shared_ptr configuration_; - std::unique_ptr block_factory_; - std::vector* blocks_; + std::shared_ptr block_factory_; + std::shared_ptr>> blocks_; + //std::shared_ptr>> channels_; gr::top_block_sptr top_block_; boost::shared_ptr queue_; std::list available_GNSS_signals_; diff --git a/src/tests/gnss_block/gnss_block_factory_test.cc b/src/tests/gnss_block/gnss_block_factory_test.cc index 4aec97829..dc09aff06 100644 --- a/src/tests/gnss_block/gnss_block_factory_test.cc +++ b/src/tests/gnss_block/gnss_block_factory_test.cc @@ -43,7 +43,7 @@ #include "observables_interface.h" #include "pvt_interface.h" #include "gnss_block_factory.h" - +#include "channel.h" TEST(GNSS_Block_Factory_Test, InstantiateFileSignalSource) { @@ -53,11 +53,13 @@ TEST(GNSS_Block_Factory_Test, InstantiateFileSignalSource) std::string filename = path + "signal_samples/GPS_L1_CA_ID_1_Fs_4Msps_2ms.dat"; configuration->set_property("SignalSource.filename", filename); gr::msg_queue::sptr queue = gr::msg_queue::make(0); + // Example of a factory as a shared_ptr std::shared_ptr factory = std::make_shared(); - GNSSBlockInterface *signal_source = factory->GetSignalSource(configuration, queue); + // Example of a block as a shared_ptr + std::shared_ptr signal_source = factory->GetSignalSource(configuration, queue); + LOG(INFO) << "signal source created"; EXPECT_STREQ("SignalSource", signal_source->role().c_str()); EXPECT_STREQ("File_Signal_Source", signal_source->implementation().c_str()); - delete signal_source; } @@ -66,11 +68,12 @@ TEST(GNSS_Block_Factory_Test, InstantiateUHDSignalSource) std::shared_ptr configuration = std::make_shared(); configuration->set_property("SignalSource.implementation", "UHD_Signal_Source"); gr::msg_queue::sptr queue = gr::msg_queue::make(0); - std::shared_ptr factory = std::make_shared(); - GNSSBlockInterface *signal_source = factory->GetSignalSource(configuration, queue); + // Example of a factory created with auto + auto factory = new GNSSBlockFactory(); + // Example of a block created with auto + auto signal_source = factory->GetSignalSource(configuration, queue); EXPECT_STREQ("SignalSource", signal_source->role().c_str()); EXPECT_STREQ("UHD_Signal_Source", signal_source->implementation().c_str()); - delete signal_source; } @@ -79,12 +82,11 @@ TEST(GNSS_Block_Factory_Test, InstantiateWrongSignalSource) std::shared_ptr configuration = std::make_shared(); configuration->set_property("SignalSource.implementation", "Pepito"); gr::msg_queue::sptr queue = gr::msg_queue::make(0); - - GNSSBlockFactory *factory = new GNSSBlockFactory(); - GNSSBlockInterface *signal_source = factory->GetSignalSource(configuration, queue); - - EXPECT_EQ(NULL, signal_source); - delete factory; + // Example of a factory as a unique_ptr + std::unique_ptr factory; + // Example of a block as a unique_ptr + std::unique_ptr signal_source = factory->GetSignalSource(configuration, queue); + EXPECT_EQ(nullptr, signal_source); } @@ -93,14 +95,10 @@ TEST(GNSS_Block_Factory_Test, InstantiateSignalConditioner) std::shared_ptr configuration = std::make_shared(); configuration->set_property("SignalConditioner.implementation", "Signal_Conditioner"); gr::msg_queue::sptr queue = gr::msg_queue::make(0); - - std::shared_ptr factory = std::make_shared(); - GNSSBlockInterface *signal_conditioner = factory->GetSignalConditioner(configuration, queue); - + std::unique_ptr factory; + std::unique_ptr signal_conditioner = factory->GetSignalConditioner(configuration, queue); EXPECT_STREQ("SignalConditioner", signal_conditioner->role().c_str()); EXPECT_STREQ("Signal_Conditioner", signal_conditioner->implementation().c_str()); - - delete signal_conditioner; } @@ -130,13 +128,11 @@ TEST(GNSS_Block_Factory_Test, InstantiateFIRFilter) configuration->set_property("InputFilter.filter_type", "bandpass"); configuration->set_property("InputFilter.grid_density", "16"); - std::shared_ptr factory = std::make_shared(); - GNSSBlockInterface *input_filter = factory->GetBlock(configuration, "InputFilter", "Fir_Filter", 1,1, queue); + std::unique_ptr factory; + std::unique_ptr input_filter = factory->GetBlock(configuration, "InputFilter", "Fir_Filter", 1,1, queue); EXPECT_STREQ("InputFilter", input_filter->role().c_str()); EXPECT_STREQ("Fir_Filter", input_filter->implementation().c_str()); - - delete input_filter; } TEST(GNSS_Block_Factory_Test, InstantiateFreqXlatingFIRFilter) @@ -167,14 +163,11 @@ TEST(GNSS_Block_Factory_Test, InstantiateFreqXlatingFIRFilter) configuration->set_property("InputFilter.sampling_frequency","4000000"); configuration->set_property("InputFilter.IF","34000"); - - std::shared_ptr factory = std::make_shared(); - GNSSBlockInterface *input_filter = factory->GetBlock(configuration, "InputFilter", "Freq_Xlating_Fir_Filter", 1,1, queue); + std::unique_ptr factory; + std::unique_ptr input_filter = factory->GetBlock(configuration, "InputFilter", "Freq_Xlating_Fir_Filter", 1,1, queue); EXPECT_STREQ("InputFilter", input_filter->role().c_str()); EXPECT_STREQ("Freq_Xlating_Fir_Filter", input_filter->implementation().c_str()); - - delete input_filter; } TEST(GNSS_Block_Factory_Test, InstantiateDirectResampler) @@ -182,14 +175,10 @@ TEST(GNSS_Block_Factory_Test, InstantiateDirectResampler) std::shared_ptr configuration = std::make_shared(); configuration->set_property("Resampler.implementation", "Direct_Resampler"); gr::msg_queue::sptr queue = gr::msg_queue::make(0); - - std::shared_ptr factory = std::make_shared(); - GNSSBlockInterface *resampler = factory->GetBlock(configuration, "Resampler", "Direct_Resampler", 1,1, queue); - + std::unique_ptr factory; + std::unique_ptr resampler = factory->GetBlock(configuration, "Resampler", "Direct_Resampler", 1,1, queue); EXPECT_STREQ("Resampler", resampler->role().c_str()); EXPECT_STREQ("Direct_Resampler", resampler->implementation().c_str()); - - delete resampler; } TEST(GNSS_Block_Factory_Test, InstantiateGpsL1CaPcpsAcquisition) @@ -197,14 +186,11 @@ TEST(GNSS_Block_Factory_Test, InstantiateGpsL1CaPcpsAcquisition) std::shared_ptr configuration = std::make_shared(); configuration->set_property("Acquisition.implementation", "GPS_L1_CA_PCPS_Acquisition"); gr::msg_queue::sptr queue = gr::msg_queue::make(0); - - std::shared_ptr factory = std::make_shared(); - AcquisitionInterface *acquisition = (AcquisitionInterface*)factory->GetBlock(configuration, "Acquisition", "GPS_L1_CA_PCPS_Acquisition", 1, 1, queue); - + std::unique_ptr factory; + std::shared_ptr acq_ = factory->GetBlock(configuration, "Acquisition", "GPS_L1_CA_PCPS_Acquisition", 1, 1, queue); + std::shared_ptr acquisition = std::dynamic_pointer_cast(acq_); EXPECT_STREQ("Acquisition", acquisition->role().c_str()); EXPECT_STREQ("GPS_L1_CA_PCPS_Acquisition", acquisition->implementation().c_str()); - - delete acquisition; } @@ -213,14 +199,11 @@ TEST(GNSS_Block_Factory_Test, InstantiateGalileoE1PcpsAmbiguousAcquisition) std::shared_ptr configuration = std::make_shared(); configuration->set_property("Acquisition.implementation", "Galileo_E1_PCPS_Ambiguous_Acquisition"); gr::msg_queue::sptr queue = gr::msg_queue::make(0); - - std::shared_ptr factory = std::make_shared(); - AcquisitionInterface *acquisition = (AcquisitionInterface*)factory->GetBlock(configuration, "Acquisition", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 1, queue); - + std::unique_ptr factory; + std::shared_ptr acq_ = factory->GetBlock(configuration, "Acquisition", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 1, queue); + std::shared_ptr acquisition = std::dynamic_pointer_cast(acq_); EXPECT_STREQ("Acquisition", acquisition->role().c_str()); EXPECT_STREQ("Galileo_E1_PCPS_Ambiguous_Acquisition", acquisition->implementation().c_str()); - - delete acquisition; } @@ -229,14 +212,11 @@ TEST(GNSS_Block_Factory_Test, InstantiateGpsL1CaDllFllPllTracking) std::shared_ptr configuration = std::make_shared(); configuration->set_property("Tracking.implementation", "GPS_L1_CA_DLL_FLL_PLL_Tracking"); gr::msg_queue::sptr queue = gr::msg_queue::make(0); - - std::shared_ptr factory = std::make_shared(); - TrackingInterface *tracking = (TrackingInterface*)factory->GetBlock(configuration, "Tracking", "GPS_L1_CA_DLL_FLL_PLL_Tracking", 1, 1, queue); - + std::unique_ptr factory; + std::shared_ptr trk_ = factory->GetBlock(configuration, "Tracking", "GPS_L1_CA_DLL_FLL_PLL_Tracking", 1, 1, queue); + std::shared_ptr tracking = std::dynamic_pointer_cast(trk_); EXPECT_STREQ("Tracking", tracking->role().c_str()); EXPECT_STREQ("GPS_L1_CA_DLL_FLL_PLL_Tracking", tracking->implementation().c_str()); - - delete tracking; } @@ -245,14 +225,11 @@ TEST(GNSS_Block_Factory_Test, InstantiateGpsL1CaDllPllTracking) std::shared_ptr configuration = std::make_shared(); configuration->set_property("Tracking.implementation", "GPS_L1_CA_DLL_PLL_Tracking"); gr::msg_queue::sptr queue = gr::msg_queue::make(0); - - std::shared_ptr factory = std::make_shared(); - TrackingInterface *tracking = (TrackingInterface*)factory->GetBlock(configuration, "Tracking", "GPS_L1_CA_DLL_PLL_Tracking", 1, 1, queue); - + std::unique_ptr factory; + std::shared_ptr trk_ = factory->GetBlock(configuration, "Tracking", "GPS_L1_CA_DLL_PLL_Tracking", 1, 1, queue); + std::shared_ptr tracking = std::dynamic_pointer_cast(trk_); EXPECT_STREQ("Tracking", tracking->role().c_str()); EXPECT_STREQ("GPS_L1_CA_DLL_PLL_Tracking", tracking->implementation().c_str()); - - delete tracking; } @@ -261,14 +238,11 @@ TEST(GNSS_Block_Factory_Test, InstantiateGpsL1CaTcpConnectorTracking) std::shared_ptr configuration = std::make_shared(); configuration->set_property("Tracking.implementation", "GPS_L1_CA_TCP_CONNECTOR_Tracking"); gr::msg_queue::sptr queue = gr::msg_queue::make(0); - - std::shared_ptr factory = std::make_shared(); - TrackingInterface *tracking = (TrackingInterface*)factory->GetBlock(configuration, "Tracking", "GPS_L1_CA_TCP_CONNECTOR_Tracking", 1, 1, queue); - + std::unique_ptr factory; + std::shared_ptr trk_ = factory->GetBlock(configuration, "Tracking", "GPS_L1_CA_TCP_CONNECTOR_Tracking", 1, 1, queue); + std::shared_ptr tracking = std::dynamic_pointer_cast(trk_); EXPECT_STREQ("Tracking", tracking->role().c_str()); EXPECT_STREQ("GPS_L1_CA_TCP_CONNECTOR_Tracking", tracking->implementation().c_str()); - - delete tracking; } @@ -277,14 +251,11 @@ TEST(GNSS_Block_Factory_Test, InstantiateGalileoE1DllPllVemlTracking) std::shared_ptr configuration = std::make_shared(); configuration->set_property("Tracking.implementation", "Galileo_E1_DLL_PLL_VEML_Tracking"); gr::msg_queue::sptr queue = gr::msg_queue::make(0); - - std::shared_ptr factory = std::make_shared(); - TrackingInterface *tracking = (TrackingInterface*)factory->GetBlock(configuration, "Tracking", "Galileo_E1_DLL_PLL_VEML_Tracking", 1, 1, queue); - + std::unique_ptr factory; + std::shared_ptr trk_ = factory->GetBlock(configuration, "Tracking", "Galileo_E1_DLL_PLL_VEML_Tracking", 1, 1, queue); + std::shared_ptr tracking = std::dynamic_pointer_cast(trk_); EXPECT_STREQ("Tracking", tracking->role().c_str()); EXPECT_STREQ("Galileo_E1_DLL_PLL_VEML_Tracking", tracking->implementation().c_str()); - - delete tracking; } @@ -293,42 +264,32 @@ TEST(GNSS_Block_Factory_Test, InstantiateGpsL1CaTelemetryDecoder) std::shared_ptr configuration = std::make_shared(); configuration->set_property("TelemetryDecoder.implementation", "GPS_L1_CA_Telemetry_Decoder"); gr::msg_queue::sptr queue = gr::msg_queue::make(0); - - std::shared_ptr factory = std::make_shared(); - TelemetryDecoderInterface *telemetry_decoder = (TelemetryDecoderInterface*)factory->GetBlock(configuration, "TelemetryDecoder", "GPS_L1_CA_Telemetry_Decoder", 1, 1, queue); - + std::unique_ptr factory; + std::shared_ptr telemetry_decoder = factory->GetBlock(configuration, "TelemetryDecoder", "GPS_L1_CA_Telemetry_Decoder", 1, 1, queue); EXPECT_STREQ("TelemetryDecoder", telemetry_decoder->role().c_str()); EXPECT_STREQ("GPS_L1_CA_Telemetry_Decoder", telemetry_decoder->implementation().c_str()); - - delete telemetry_decoder; } + TEST(GNSS_Block_Factory_Test, InstantiateChannels) { std::shared_ptr configuration = std::make_shared(); - configuration->set_property("Channels.count", "2"); configuration->set_property("Channels.in_acquisition", "2"); configuration->set_property("Tracking.implementation","GPS_L1_CA_DLL_FLL_PLL_Tracking"); configuration->set_property("TelemetryDecoder.implementation","GPS_L1_CA_Telemetry_Decoder"); - configuration->set_property("Channel0.item_type", "gr_complex"); configuration->set_property("Acquisition0.implementation", "GPS_L1_CA_PCPS_Acquisition"); - configuration->set_property("Channel1.item_type", "gr_complex"); configuration->set_property("Acquisition1.implementation", "GPS_L1_CA_PCPS_Acquisition"); - gr::msg_queue::sptr queue = gr::msg_queue::make(0); - - std::shared_ptr factory = std::make_shared(); - - std::vector* channels = factory->GetChannels(configuration, queue); + std::unique_ptr factory; + std::unique_ptr>> channels = std::move(factory->GetChannels(configuration, queue)); EXPECT_EQ((unsigned int) 2, channels->size()); -; - for(unsigned int i=0 ; isize() ; i++) delete channels->at(i); - channels->clear(); - delete channels; + + channels->erase(channels->begin(), channels->end()); + //channels->clear(); } @@ -337,13 +298,10 @@ TEST(GNSS_Block_Factory_Test, InstantiateObservables) std::shared_ptr configuration = std::make_shared(); configuration->set_property("Observables.implementation", "Pass_Through"); gr::msg_queue::sptr queue = gr::msg_queue::make(0); - - std::shared_ptr factory = std::make_shared(); - ObservablesInterface *observables = (ObservablesInterface*)factory->GetObservables(configuration, queue); - + std::unique_ptr factory; + auto observables = factory->GetObservables(configuration, queue); EXPECT_STREQ("Observables", observables->role().c_str()); EXPECT_STREQ("Pass_Through", observables->implementation().c_str()); - delete observables; } @@ -352,43 +310,24 @@ TEST(GNSS_Block_Factory_Test, InstantiateGpsL1CaObservables) std::shared_ptr configuration = std::make_shared(); configuration->set_property("Observables.implementation", "GPS_L1_CA_Observables"); gr::msg_queue::sptr queue = gr::msg_queue::make(0); - - std::shared_ptr factory = std::make_shared(); - ObservablesInterface *observables = (ObservablesInterface*)factory->GetObservables(configuration, queue); - + std::unique_ptr factory; + std::unique_ptr observables = factory->GetObservables(configuration, queue); EXPECT_STREQ("Observables", observables->role().c_str()); EXPECT_STREQ("GPS_L1_CA_Observables", observables->implementation().c_str()); - delete observables; } -TEST(GNSS_Block_Factory_Test, InstantiateWrongObservables) -{ - std::shared_ptr configuration = std::make_shared(); - configuration->set_property("Observables.implementation", "Pepito"); - gr::msg_queue::sptr queue = gr::msg_queue::make(0); - std::shared_ptr factory = std::make_shared(); - ObservablesInterface *observables = (ObservablesInterface*)factory->GetObservables(configuration, queue); - - EXPECT_EQ(NULL, observables); - - delete observables; -} TEST(GNSS_Block_Factory_Test, InstantiatePvt) { std::shared_ptr configuration = std::make_shared(); configuration->set_property("PVT.implementation", "Pass_Through"); gr::msg_queue::sptr queue = gr::msg_queue::make(0); - - std::shared_ptr factory = std::make_shared(); - PvtInterface *pvt = (PvtInterface*)factory->GetPVT(configuration, queue); - - EXPECT_STREQ("PVT", pvt->role().c_str()); - EXPECT_STREQ("Pass_Through", pvt->implementation().c_str()); - - delete pvt; + std::unique_ptr factory; + auto pvt_ = factory->GetPVT(configuration, queue); + EXPECT_STREQ("PVT", pvt_->role().c_str()); + EXPECT_STREQ("Pass_Through", pvt_->implementation().c_str()); } @@ -397,14 +336,11 @@ TEST(GNSS_Block_Factory_Test, InstantiateGpsL1CaPvt) std::shared_ptr configuration = std::make_shared(); configuration->set_property("PVT.implementation", "GPS_L1_CA_PVT"); gr::msg_queue::sptr queue = gr::msg_queue::make(0); - - std::shared_ptr factory = std::make_shared(); - PvtInterface *pvt = (PvtInterface*)factory->GetPVT(configuration, queue); - + std::unique_ptr factory; + std::shared_ptr pvt_ = factory->GetPVT(configuration, queue); + std::shared_ptr pvt = std::dynamic_pointer_cast(pvt_); EXPECT_STREQ("PVT", pvt->role().c_str()); EXPECT_STREQ("GPS_L1_CA_PVT", pvt->implementation().c_str()); - - delete pvt; } @@ -413,13 +349,10 @@ TEST(GNSS_Block_Factory_Test, InstantiateWrongPvt) std::shared_ptr configuration = std::make_shared(); configuration->set_property("PVT.implementation", "Pepito"); gr::msg_queue::sptr queue = gr::msg_queue::make(0); - - std::shared_ptr factory = std::make_shared(); - PvtInterface *pvt = (PvtInterface*)factory->GetPVT(configuration, queue); - - EXPECT_EQ(NULL, pvt); - - delete pvt; + std::unique_ptr factory; + std::shared_ptr pvt_ = factory->GetPVT(configuration, queue); + std::shared_ptr pvt = std::dynamic_pointer_cast(pvt_); + EXPECT_EQ(nullptr, pvt); } @@ -429,14 +362,10 @@ TEST(GNSS_Block_Factory_Test, InstantiateNullSinkOutputFilter) std::shared_ptr configuration = std::make_shared(); configuration->set_property("OutputFilter.implementation", "Null_Sink_Output_Filter"); gr::msg_queue::sptr queue = gr::msg_queue::make(0); - - std::shared_ptr factory = std::make_shared(); - GNSSBlockInterface *output_filter = factory->GetOutputFilter(configuration, queue); - + std::unique_ptr factory; + std::unique_ptr output_filter = factory->GetOutputFilter(configuration, queue); EXPECT_STREQ("OutputFilter", output_filter->role().c_str()); EXPECT_STREQ("Null_Sink_Output_Filter", output_filter->implementation().c_str()); - - delete output_filter; } @@ -445,14 +374,10 @@ TEST(GNSS_Block_Factory_Test, InstantiateFileOutputFilter) std::shared_ptr configuration = std::make_shared(); configuration->set_property("OutputFilter.implementation", "File_Output_Filter"); gr::msg_queue::sptr queue = gr::msg_queue::make(0); - - std::shared_ptr factory = std::make_shared(); - GNSSBlockInterface *output_filter = factory->GetOutputFilter(configuration, queue); - + std::unique_ptr factory; + std::unique_ptr output_filter = factory->GetOutputFilter(configuration, queue); EXPECT_STREQ("OutputFilter", output_filter->role().c_str()); EXPECT_STREQ("File_Output_Filter", output_filter->implementation().c_str()); - - delete output_filter; } @@ -461,10 +386,7 @@ TEST(GNSS_Block_Factory_Test, InstantiateWrongOutputFilter) std::shared_ptr configuration = std::make_shared(); configuration->set_property("OutputFilter.implementation", "Pepito"); gr::msg_queue::sptr queue = gr::msg_queue::make(0); - - std::shared_ptr factory = std::make_shared(); - GNSSBlockInterface *output_filter = factory->GetOutputFilter(configuration, queue); - - EXPECT_EQ(NULL, output_filter); - delete output_filter; + std::unique_ptr factory; + std::unique_ptr output_filter = factory->GetOutputFilter(configuration, queue); + EXPECT_EQ(nullptr, output_filter); } From 5a79a708a1a7a17a7908a651d3f1f759e064b609 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 11 Apr 2014 22:13:41 +0200 Subject: [PATCH 02/18] Soem advances in the flowgraph --- src/core/receiver/gnss_flowgraph.cc | 39 +++++++++++++++++------------ src/core/receiver/gnss_flowgraph.h | 4 ++- src/utils/front-end-cal/main.cc | 6 ++--- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index ea4a3e058..26f5d6023 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -130,10 +130,7 @@ void GNSSFlowgraph::connect() try { - std::cout << "helllllo" << std::endl; - //signal_source()->connect(top_block_); - blocks_->at(0)->connect(top_block_); - std::cout << "helllllo" << std::endl; + signal_source()->connect(top_block_); } catch (std::exception& e) { @@ -200,6 +197,7 @@ void GNSSFlowgraph::connect() try { output_filter()->connect(top_block_); + std::cout << "helllllout" << std::endl; } catch (std::exception& e) { @@ -213,7 +211,7 @@ void GNSSFlowgraph::connect() // Signal Source > Signal conditioner > - + std::cout<< *signal_source()->implementation().c_str() <implementation().compare("Raw_Array_Signal_Source") == 0) @@ -229,7 +227,7 @@ void GNSSFlowgraph::connect() else { //single channel - // std::cout<<"NORMAL MODE"<connect(signal_source()->get_right_block(), 0, signal_conditioner()->get_left_block(), 0); } @@ -449,8 +447,10 @@ std::shared_ptr GNSSFlowgraph::signal_source() //std::shared_ptr cond_ { blocks_->at(0) }; //return cond_; //return blocks_->at(0); - std::shared_ptr source_ = std::move(blocks_->at(0)); - return source_; + //std::shared_ptr source_ = std::make_shared>(); + auto source_ = std::move(blocks_->at(0)); + //std::cout << source_->implementation().c_str() << std::endl; + return std::move(source_); } @@ -458,7 +458,10 @@ std::shared_ptr GNSSFlowgraph::signal_source() std::shared_ptr GNSSFlowgraph::signal_conditioner() { - return blocks_->at(1); + //return blocks_->at(1); + auto cond_ = std::move(blocks_->at(1)); + //std::cout << source_->implementation().c_str() << std::endl; + return std::move(cond_); } @@ -468,7 +471,7 @@ std::shared_ptr GNSSFlowgraph::channel(unsigned int index) //return (ChannelInterface*) blocks_->at(index + 5); //std::shared_ptr sptr = std::make_shared(blocks_->at(index + 5)); //return blocks_->at(index + 5); - std::shared_ptr chan_ = blocks_->at(index + 5); + auto chan_ = std::move(blocks_->at(index + 5)); std::shared_ptr chan = std::dynamic_pointer_cast(chan_); @@ -480,21 +483,24 @@ std::shared_ptr GNSSFlowgraph::channel(unsigned int index) std::shared_ptr GNSSFlowgraph::observables() { - return blocks_->at(2); + auto obs_ = std::move(blocks_->at(2)); + return std::move(obs_); } std::shared_ptr GNSSFlowgraph::pvt() { - return blocks_->at(3); + auto pvt_ = std::move(blocks_->at(3)); + return std::move(pvt_); } std::shared_ptr GNSSFlowgraph::output_filter() { - return blocks_->at(4); + auto output_ = std::move(blocks_->at(4)); + return std::move(output_); } @@ -505,15 +511,16 @@ void GNSSFlowgraph::init() * Instantiates the receiver blocks */ std::shared_ptr block_factory_ = std::make_shared(); - std::shared_ptr>> blocks_ = std::make_shared>>(); + //std::shared_ptr>> blocks_ = std::make_shared>>(); + + std::shared_ptr signal_source_ = block_factory_->GetSignalSource(configuration_, queue_); - std::unique_ptr signal_source_ = block_factory_->GetSignalSource(configuration_, queue_); std::shared_ptr cond_ = block_factory_->GetSignalConditioner(configuration_, queue_); std::shared_ptr obs_ = block_factory_->GetObservables(configuration_, queue_); std::shared_ptr pvt_ = block_factory_->GetPVT(configuration_, queue_); std::shared_ptr output_ = block_factory_->GetOutputFilter(configuration_, queue_); - blocks_->push_back(std::move(signal_source_)); + blocks_->push_back(signal_source_); blocks_->push_back(cond_); blocks_->push_back(obs_); blocks_->push_back(pvt_); diff --git a/src/core/receiver/gnss_flowgraph.h b/src/core/receiver/gnss_flowgraph.h index ff793df26..fe788db97 100644 --- a/src/core/receiver/gnss_flowgraph.h +++ b/src/core/receiver/gnss_flowgraph.h @@ -132,7 +132,9 @@ private: std::string config_file_; std::shared_ptr configuration_; std::shared_ptr block_factory_; - std::shared_ptr>> blocks_; + //std::shared_ptr>> blocks_; + std::shared_ptr>> blocks_ = std::make_shared>>(); + //std::shared_ptr>> channels_; gr::top_block_sptr top_block_; boost::shared_ptr queue_; diff --git a/src/utils/front-end-cal/main.cc b/src/utils/front-end-cal/main.cc index ec67dac00..ce4a64149 100644 --- a/src/utils/front-end-cal/main.cc +++ b/src/utils/front-end-cal/main.cc @@ -155,10 +155,10 @@ bool front_end_capture(std::shared_ptr configuration) queue = gr::msg_queue::make(0); top_block = gr::make_top_block("Acquisition test"); - GNSSBlockInterface *source; + std::shared_ptr source; source = block_factory.GetSignalSource(configuration, queue); - GNSSBlockInterface *conditioner = block_factory.GetSignalConditioner(configuration,queue); + std::shared_ptr conditioner = block_factory.GetSignalConditioner(configuration,queue); gr::block_sptr sink; sink = gr::blocks::file_sink::make(sizeof(gr_complex), "tmp_capture.dat"); @@ -192,7 +192,7 @@ bool front_end_capture(std::shared_ptr configuration) } //delete conditioner; - delete source; + //delete source; return true; } From 6b1c12f111705fc1dd3539c7baa2cf699846b046 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 12 Apr 2014 19:45:45 +0200 Subject: [PATCH 03/18] Rewriting flowgraph with smart pointers --- src/core/receiver/gnss_flowgraph.cc | 96 +++++++++++++++-------------- src/core/receiver/gnss_flowgraph.h | 9 ++- 2 files changed, 57 insertions(+), 48 deletions(-) diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 26f5d6023..e793dd407 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -102,7 +102,7 @@ void GNSSFlowgraph::stop() for (unsigned int i = 0; i < channels_count_; i++) { // if(channels_state_[i]==2) channel(i)-> - channel(i)->stop(); + channels_.at(i)->stop(); } for (unsigned int i = 0; i < channels_count_; i++) { @@ -130,7 +130,9 @@ void GNSSFlowgraph::connect() try { - signal_source()->connect(top_block_); + // sig_source_ = signal_source(); + sig_source_ = std::move(blocks_->at(0)); + sig_source_->connect(top_block_); } catch (std::exception& e) { @@ -143,7 +145,8 @@ void GNSSFlowgraph::connect() // Signal Source > Signal conditioner > try { - signal_conditioner()->connect(top_block_); + sig_conditioner_ = std::move(blocks_->at(1)); + sig_conditioner_->connect(top_block_); } catch (std::exception& e) { @@ -157,7 +160,11 @@ void GNSSFlowgraph::connect() { try { - channel(i)->connect(top_block_); + auto chan_ = std::move(blocks_->at(i + 5)); + std::shared_ptr chan = std::dynamic_pointer_cast(chan_); + + channels_.push_back(chan); + channels_.at(i)->connect(top_block_); } catch (std::exception& e) { @@ -170,7 +177,8 @@ void GNSSFlowgraph::connect() try { - observables()->connect(top_block_); + observables_ = std::move(blocks_->at(2)); + observables_->connect(top_block_); } catch (std::exception& e) { @@ -183,7 +191,8 @@ void GNSSFlowgraph::connect() // Signal Source > Signal conditioner >> Channels >> Observables > PVT try { - pvt()->connect(top_block_); + pvt_ = std::move(blocks_->at(3)); + pvt_->connect(top_block_); } catch (std::exception& e) { @@ -196,7 +205,8 @@ void GNSSFlowgraph::connect() // Signal Source > Signal conditioner >> Channels >> Observables > PVT > Output Filter try { - output_filter()->connect(top_block_); + output_filter_ = std::move(blocks_->at(4)); + output_filter_->connect(top_block_); std::cout << "helllllout" << std::endl; } catch (std::exception& e) @@ -211,24 +221,24 @@ void GNSSFlowgraph::connect() // Signal Source > Signal conditioner > - std::cout<< *signal_source()->implementation().c_str() <implementation().c_str() <implementation().compare("Raw_Array_Signal_Source") == 0) + if(sig_source_->implementation().compare("Raw_Array_Signal_Source") == 0) { //Multichannel Array std::cout << "ARRAY MODE" << std::endl; for (int i = 0; i < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; i++) { std::cout << "connecting ch "<< i << std::endl; - top_block_->connect(signal_source()->get_right_block(), i, signal_conditioner()->get_left_block(), i); + top_block_->connect(sig_source_->get_right_block(), i, sig_conditioner_->get_left_block(), i); } } else { //single channel - //std::cout<<"NORMAL MODE"<connect(signal_source()->get_right_block(), 0, signal_conditioner()->get_left_block(), 0); + // std::cout<<"NORMAL MODE"<connect(sig_source_->get_right_block(), 0, sig_conditioner_->get_left_block(), 0); } } @@ -246,8 +256,8 @@ void GNSSFlowgraph::connect() { try { - top_block_->connect(signal_conditioner()->get_right_block(), 0, - channel(i)->get_left_block(), 0); + top_block_->connect(sig_conditioner_->get_right_block(), 0, + channels_.at(i)->get_left_block(), 0); } catch (std::exception& e) { @@ -262,8 +272,8 @@ void GNSSFlowgraph::connect() // Signal Source > Signal conditioner >> Channels >> Observables try { - top_block_->connect(channel(i)->get_right_block(), 0, - observables()->get_left_block(), i); + top_block_->connect(channels_.at(i)->get_right_block(), 0, + observables_->get_left_block(), i); } catch (std::exception& e) { @@ -272,14 +282,15 @@ void GNSSFlowgraph::connect() top_block_->disconnect_all(); return; } - - channel(i)->set_signal(available_GNSS_signals_.front()); + std::cout<<"NORMAL MODE"<set_signal(available_GNSS_signals_.front()); LOG(INFO) << "Channel " << i << " assigned to " << available_GNSS_signals_.front(); available_GNSS_signals_.pop_front(); - channel(i)->start(); + channels_.at(i)->start(); + std::cout<<"NORMAL MODE"<start_acquisition(); + channels_.at(i)->start_acquisition(); LOG(INFO) << "Channel " << i << " connected to observables and ready for acquisition"; } @@ -297,7 +308,7 @@ void GNSSFlowgraph::connect() { for (unsigned int i = 0; i < channels_count_; i++) { - top_block_->connect(observables()->get_right_block(), i, pvt()->get_left_block(), i); + top_block_->connect(observables_->get_right_block(), i, pvt_->get_left_block(), i); } } catch (std::exception& e) @@ -310,7 +321,7 @@ void GNSSFlowgraph::connect() try { - top_block_->connect(pvt()->get_right_block(), 0, output_filter()->get_left_block(), 0); + top_block_->connect(pvt_->get_right_block(), 0, output_filter_->get_left_block(), 0); } catch (std::exception& e) { @@ -358,23 +369,23 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) switch (what) { case 0: - LOG(INFO) << "Channel " << who << " ACQ FAILED satellite " << channel(who)->get_signal().get_satellite(); - available_GNSS_signals_.push_back(channel(who)->get_signal()); + LOG(INFO) << "Channel " << who << " ACQ FAILED satellite " << channels_.at(who)->get_signal().get_satellite(); + available_GNSS_signals_.push_back(channels_.at(who)->get_signal()); - while (channel(who)->get_signal().get_satellite().get_system() != available_GNSS_signals_.front().get_satellite().get_system()) + while (channels_.at(who)->get_signal().get_satellite().get_system() != available_GNSS_signals_.front().get_satellite().get_system()) { available_GNSS_signals_.push_back(available_GNSS_signals_.front()); available_GNSS_signals_.pop_front(); } - channel(who)->set_signal(available_GNSS_signals_.front()); + channels_.at(who)->set_signal(available_GNSS_signals_.front()); available_GNSS_signals_.pop_front(); - channel(who)->start_acquisition(); + channels_.at(who)->start_acquisition(); break; // TODO: Tracking messages case 1: - LOG(INFO) << "Channel " << who << " ACQ SUCCESS satellite " << channel(who)->get_signal().get_satellite(); + LOG(INFO) << "Channel " << who << " ACQ SUCCESS satellite " << channels_.at(who)->get_signal().get_satellite(); channels_state_[who] = 2; acq_channels_count_--; if (acq_channels_count_ < max_acq_channels_) @@ -385,7 +396,7 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) { channels_state_[i] = 1; acq_channels_count_++; - channel(i)->start_acquisition(); + channels_.at(i)->start_acquisition(); break; } } @@ -398,17 +409,17 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) break; case 2: - LOG(INFO) << "Channel " << who << " TRK FAILED satellite " << channel(who)->get_signal().get_satellite(); + LOG(INFO) << "Channel " << who << " TRK FAILED satellite " << channels_.at(who)->get_signal().get_satellite(); if (acq_channels_count_ < max_acq_channels_) { channels_state_[who] = 1; acq_channels_count_++; - channel(who)->start_acquisition(); + channels_.at(who)->start_acquisition(); } else { channels_state_[who] = 0; - channel(who)->standby(); + channels_.at(who)->standby(); } for (unsigned int i = 0; i < channels_count_; i++) @@ -448,9 +459,12 @@ std::shared_ptr GNSSFlowgraph::signal_source() //return cond_; //return blocks_->at(0); //std::shared_ptr source_ = std::make_shared>(); - auto source_ = std::move(blocks_->at(0)); + + //auto source_ = std::move(blocks_->at(0)); + sig_source_ = std::move(blocks_->at(0)); + //sig_source_ = //std::cout << source_->implementation().c_str() << std::endl; - return std::move(source_); + return std::move(sig_source_); } @@ -458,9 +472,7 @@ std::shared_ptr GNSSFlowgraph::signal_source() std::shared_ptr GNSSFlowgraph::signal_conditioner() { - //return blocks_->at(1); auto cond_ = std::move(blocks_->at(1)); - //std::cout << source_->implementation().c_str() << std::endl; return std::move(cond_); } @@ -468,15 +480,9 @@ std::shared_ptr GNSSFlowgraph::signal_conditioner() std::shared_ptr GNSSFlowgraph::channel(unsigned int index) { - //return (ChannelInterface*) blocks_->at(index + 5); - //std::shared_ptr sptr = std::make_shared(blocks_->at(index + 5)); - //return blocks_->at(index + 5); auto chan_ = std::move(blocks_->at(index + 5)); - std::shared_ptr chan = std::dynamic_pointer_cast(chan_); - return chan; - //return sptr; } @@ -511,10 +517,8 @@ void GNSSFlowgraph::init() * Instantiates the receiver blocks */ std::shared_ptr block_factory_ = std::make_shared(); - //std::shared_ptr>> blocks_ = std::make_shared>>(); std::shared_ptr signal_source_ = block_factory_->GetSignalSource(configuration_, queue_); - std::shared_ptr cond_ = block_factory_->GetSignalConditioner(configuration_, queue_); std::shared_ptr obs_ = block_factory_->GetObservables(configuration_, queue_); std::shared_ptr pvt_ = block_factory_->GetPVT(configuration_, queue_); @@ -540,15 +544,15 @@ void GNSSFlowgraph::init() top_block_ = gr::make_top_block("GNSSFlowgraph"); - //delete channels; - // 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; + std::vector> channels_(channels_count_); + //std::shared_ptr sig_source_ = signal_source(); DLOG(INFO) << "Blocks instantiated. " << channels_count_ << " channels."; } diff --git a/src/core/receiver/gnss_flowgraph.h b/src/core/receiver/gnss_flowgraph.h index fe788db97..9b6832de3 100644 --- a/src/core/receiver/gnss_flowgraph.h +++ b/src/core/receiver/gnss_flowgraph.h @@ -134,8 +134,13 @@ private: std::shared_ptr block_factory_; //std::shared_ptr>> blocks_; std::shared_ptr>> blocks_ = std::make_shared>>(); - - //std::shared_ptr>> channels_; + std::shared_ptr sig_source_; + std::shared_ptr sig_conditioner_; + std::shared_ptr observables_; + std::shared_ptr pvt_; + std::shared_ptr output_filter_; + //std::shared_ptr>> channels_; + std::vector> channels_; gr::top_block_sptr top_block_; boost::shared_ptr queue_; std::list available_GNSS_signals_; From 5bde2595af9ba75ba6e3138167f5f29f5f1b5149 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 12 Apr 2014 22:02:18 +0200 Subject: [PATCH 04/18] cleaning flowgraph --- src/core/receiver/gnss_block_factory.cc | 10 ++-- src/core/receiver/gnss_block_factory.h | 4 +- src/core/receiver/gnss_flowgraph.cc | 53 +++++-------------- src/core/receiver/gnss_flowgraph.h | 17 +++--- src/tests/flowgraph/gnss_flowgraph_test.cc | 45 ++++++++-------- .../gnss_block/gnss_block_factory_test.cc | 3 -- 6 files changed, 53 insertions(+), 79 deletions(-) diff --git a/src/core/receiver/gnss_block_factory.cc b/src/core/receiver/gnss_block_factory.cc index 203a5da4b..098753e03 100644 --- a/src/core/receiver/gnss_block_factory.cc +++ b/src/core/receiver/gnss_block_factory.cc @@ -110,11 +110,9 @@ std::unique_ptr GNSSBlockFactory::GetSignalSource( std::shared_ptr configuration, boost::shared_ptr queue) { std::string default_implementation = "File_Signal_Source"; - std::string implementation = configuration->property( - "SignalSource.implementation", default_implementation); + std::string implementation = configuration->property("SignalSource.implementation", default_implementation); LOG(INFO) << "Getting SignalSource with implementation " << implementation; - return GetBlock(configuration, "SignalSource", implementation, 0, 1, - queue); + return GetBlock(configuration, "SignalSource", implementation, 0, 1, queue); } @@ -148,7 +146,6 @@ std::unique_ptr GNSSBlockFactory::GetSignalConditioner( << data_type_adapter << ", InputFilter implementation: " << input_filter << ", and Resampler implementation: " << resampler; - //std::unique_ptr conditioner_; if(signal_conditioner.compare("Array_Signal_Conditioner") == 0) { @@ -569,7 +566,7 @@ std::unique_ptr GNSSBlockFactory::GetAcqBlock( { std::unique_ptr block; // ACQUISITION BLOCKS --------------------------------------------------------- - if (implementation.compare("GPS_L1_CA_PCPS_Acquisition") == 0) + if (implementation.compare("GPS_L1_CA_PCPS_Acquisition") == 0) { std::unique_ptr block_(new GpsL1CaPcpsAcquisition(configuration.get(), role, in_streams, out_streams, queue)); @@ -695,6 +692,7 @@ std::unique_ptr GNSSBlockFactory::GetTrkBlock( return std::move(block); } + std::unique_ptr GNSSBlockFactory::GetTlmBlock( std::shared_ptr configuration, std::string role, diff --git a/src/core/receiver/gnss_block_factory.h b/src/core/receiver/gnss_block_factory.h index 04d986724..482b83f6a 100644 --- a/src/core/receiver/gnss_block_factory.h +++ b/src/core/receiver/gnss_block_factory.h @@ -68,10 +68,8 @@ public: std::unique_ptr GetChannel(std::shared_ptr configuration, std::string acq, std::string trk, std::string tlm, int channel, boost::shared_ptr queue); - //std::unique_ptr>> GetChannels(std::shared_ptr configuration, - //std::vector> GetChannels(std::shared_ptr configuration, std::unique_ptr>> GetChannels(std::shared_ptr configuration, - boost::shared_ptr queue); + boost::shared_ptr queue); /* * \brief Returns the block with the required configuration and implementation */ diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index e793dd407..41c0e5315 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -54,7 +54,8 @@ GNSSFlowgraph::GNSSFlowgraph(std::shared_ptr configurati connected_ = false; running_ = false; configuration_ = configuration; - //blocks_ = new std::vector(); + + std::shared_ptr>> blocks_ = std::make_shared>>(); queue_ = queue; init(); @@ -63,12 +64,7 @@ GNSSFlowgraph::GNSSFlowgraph(std::shared_ptr configurati GNSSFlowgraph::~GNSSFlowgraph() { - for (unsigned int i = 0; i < blocks_->size(); i++) - { - //delete blocks_->at(i); - } blocks_->clear(); - //delete blocks_; } @@ -130,7 +126,6 @@ void GNSSFlowgraph::connect() try { - // sig_source_ = signal_source(); sig_source_ = std::move(blocks_->at(0)); sig_source_->connect(top_block_); } @@ -160,9 +155,8 @@ void GNSSFlowgraph::connect() { try { - auto chan_ = std::move(blocks_->at(i + 5)); - std::shared_ptr chan = std::dynamic_pointer_cast(chan_); - + auto chan_ = std::move(blocks_->at(i + 5)); + std::shared_ptr chan = std::dynamic_pointer_cast(chan_); channels_.push_back(chan); channels_.at(i)->connect(top_block_); } @@ -207,7 +201,6 @@ void GNSSFlowgraph::connect() { output_filter_ = std::move(blocks_->at(4)); output_filter_->connect(top_block_); - std::cout << "helllllout" << std::endl; } catch (std::exception& e) { @@ -220,8 +213,6 @@ void GNSSFlowgraph::connect() DLOG(INFO) << "blocks connected internally"; // Signal Source > Signal conditioner > - - std::cout<< sig_source_->implementation().c_str() <implementation().compare("Raw_Array_Signal_Source") == 0) @@ -237,7 +228,6 @@ void GNSSFlowgraph::connect() else { //single channel - // std::cout<<"NORMAL MODE"<connect(sig_source_->get_right_block(), 0, sig_conditioner_->get_left_block(), 0); } @@ -282,12 +272,12 @@ void GNSSFlowgraph::connect() top_block_->disconnect_all(); return; } - std::cout<<"NORMAL MODE"<set_signal(available_GNSS_signals_.front()); LOG(INFO) << "Channel " << i << " assigned to " << available_GNSS_signals_.front(); available_GNSS_signals_.pop_front(); channels_.at(i)->start(); - std::cout<<"NORMAL MODE"<start_acquisition(); @@ -452,28 +442,19 @@ void GNSSFlowgraph::set_configuration(std::shared_ptr co } - +/* std::shared_ptr GNSSFlowgraph::signal_source() { - //std::shared_ptr cond_ { blocks_->at(0) }; - //return cond_; - //return blocks_->at(0); - //std::shared_ptr source_ = std::make_shared>(); - - //auto source_ = std::move(blocks_->at(0)); - sig_source_ = std::move(blocks_->at(0)); - //sig_source_ = - //std::cout << source_->implementation().c_str() << std::endl; + auto sig_source_ = std::move(blocks_->at(0)); return std::move(sig_source_); - } std::shared_ptr GNSSFlowgraph::signal_conditioner() { - auto cond_ = std::move(blocks_->at(1)); - return std::move(cond_); + auto sig_conditioner_ = std::move(blocks_->at(1)); + return std::move(sig_conditioner_); } @@ -489,15 +470,15 @@ std::shared_ptr GNSSFlowgraph::channel(unsigned int index) std::shared_ptr GNSSFlowgraph::observables() { - auto obs_ = std::move(blocks_->at(2)); - return std::move(obs_); + observables_ = std::move(blocks_->at(2)); + return std::move(observables_); } std::shared_ptr GNSSFlowgraph::pvt() { - auto pvt_ = std::move(blocks_->at(3)); + pvt_ = std::move(blocks_->at(3)); return std::move(pvt_); } @@ -508,7 +489,7 @@ std::shared_ptr GNSSFlowgraph::output_filter() auto output_ = std::move(blocks_->at(4)); return std::move(output_); } - +*/ void GNSSFlowgraph::init() @@ -530,12 +511,9 @@ void GNSSFlowgraph::init() blocks_->push_back(pvt_); blocks_->push_back(output_); - std::shared_ptr>> channels = block_factory_->GetChannels(configuration_, queue_); channels_count_ = channels->size(); - - for (unsigned int i = 0; i < channels_count_; i++) { std::shared_ptr chan_ = std::move(channels->at(i)); @@ -545,14 +523,11 @@ void GNSSFlowgraph::init() top_block_ = gr::make_top_block("GNSSFlowgraph"); // 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; std::vector> channels_(channels_count_); - //std::shared_ptr sig_source_ = signal_source(); DLOG(INFO) << "Blocks instantiated. " << channels_count_ << " channels."; } diff --git a/src/core/receiver/gnss_flowgraph.h b/src/core/receiver/gnss_flowgraph.h index 9b6832de3..6f5818072 100644 --- a/src/core/receiver/gnss_flowgraph.h +++ b/src/core/receiver/gnss_flowgraph.h @@ -93,12 +93,19 @@ public: void set_configuration(std::shared_ptr configuration); - std::shared_ptr signal_source(); + /*std::shared_ptr signal_source(); std::shared_ptr signal_conditioner(); std::shared_ptr channel(unsigned int index); std::shared_ptr observables(); std::shared_ptr pvt(); - std::shared_ptr output_filter(); + std::shared_ptr output_filter();*/ + + std::shared_ptr sig_source_; + std::shared_ptr sig_conditioner_; + std::shared_ptr observables_; + std::shared_ptr pvt_; + std::shared_ptr output_filter_; + std::vector> channels_; unsigned int applied_actions() { @@ -132,15 +139,13 @@ private: std::string config_file_; std::shared_ptr configuration_; std::shared_ptr block_factory_; - //std::shared_ptr>> blocks_; std::shared_ptr>> blocks_ = std::make_shared>>(); - std::shared_ptr sig_source_; + /* std::shared_ptr sig_source_; std::shared_ptr sig_conditioner_; std::shared_ptr observables_; std::shared_ptr pvt_; std::shared_ptr output_filter_; - //std::shared_ptr>> channels_; - std::vector> channels_; + std::vector> channels_; */ gr::top_block_sptr top_block_; boost::shared_ptr queue_; std::list available_GNSS_signals_; diff --git a/src/tests/flowgraph/gnss_flowgraph_test.cc b/src/tests/flowgraph/gnss_flowgraph_test.cc index a53a83fb1..25e674548 100644 --- a/src/tests/flowgraph/gnss_flowgraph_test.cc +++ b/src/tests/flowgraph/gnss_flowgraph_test.cc @@ -56,36 +56,37 @@ TEST(GNSSFlowgraph, InstantiateConnectStartStop) config->set_property("SignalSource.filename", filename); config->set_property("SignalConditioner.implementation", "Pass_Through"); config->set_property("Channels.count", "2"); - config->set_property("Channels.acquisition.implementation", "Pass_Through"); - config->set_property("Channels.tracking.implementation", "Pass_Through"); - config->set_property("Channels.telemetry.implementation", "Pass_Through"); - config->set_property("Channels.observables.implementation", "Pass_Through"); + config->set_property("Acquisition.implementation", "GPS_L1_CA_PCPS_Acquisition"); + config->set_property("Tracking.implementation", "GPS_L1_CA_DLL_PLL_Tracking"); + config->set_property("TelemetryDecoder.implementation", "GPS_L1_CA_Telemetry_Decoder"); + //config->set_property("Channels.observables.implementation", "Pass_Through"); config->set_property("Observables.implementation", "GPS_L1_CA_Observables"); config->set_property("PVT.implementation", "GPS_L1_CA_PVT"); config->set_property("OutputFilter.implementation", "Null_Sink_Output_Filter"); - GNSSFlowgraph* flowgraph = new GNSSFlowgraph(config, gr::msg_queue::make(0)); - - EXPECT_STREQ("File_Signal_Source", flowgraph->signal_source()->implementation().c_str()); - EXPECT_STREQ("Pass_Through", flowgraph->signal_conditioner()->implementation().c_str()); - EXPECT_STREQ("Channel", flowgraph->channel(0)->implementation().c_str()); - EXPECT_STREQ("Pass_Through", ((Channel*)flowgraph->channel(0))->acquisition()->implementation().c_str()); - EXPECT_STREQ("Pass_Through", ((Channel*)flowgraph->channel(0))->tracking()->implementation().c_str()); - EXPECT_STREQ("Pass_Through", ((Channel*)flowgraph->channel(0))->telemetry()->implementation().c_str()); - EXPECT_STREQ("Channel", flowgraph->channel(1)->implementation().c_str()); - EXPECT_STREQ("Pass_Through", ((Channel*)flowgraph->channel(1))->acquisition()->implementation().c_str()); - EXPECT_STREQ("Pass_Through", ((Channel*)flowgraph->channel(1))->tracking()->implementation().c_str()); - EXPECT_STREQ("Pass_Through", ((Channel*)flowgraph->channel(1))->telemetry()->implementation().c_str()); - EXPECT_STREQ("GPS_L1_CA_Observables", flowgraph->observables()->implementation().c_str()); - EXPECT_STREQ("GPS_L1_CA_PVT", flowgraph->pvt()->implementation().c_str()); - EXPECT_STREQ("Null_Sink_Output_Filter", flowgraph->output_filter()->implementation().c_str()); - - EXPECT_NO_THROW(flowgraph->connect()); + std::shared_ptr flowgraph = std::make_shared(config, gr::msg_queue::make(0)); + flowgraph->set_configuration(config); + EXPECT_NO_THROW(flowgraph->connect()); EXPECT_TRUE(flowgraph->connected()); + EXPECT_STREQ("File_Signal_Source", flowgraph->sig_source_->implementation().c_str()); + EXPECT_STREQ("Pass_Through", flowgraph->sig_conditioner_->implementation().c_str()); + EXPECT_STREQ("Channel", flowgraph->channels_.at(0)->implementation().c_str()); + // EXPECT_STREQ("Pass_Through", (flowgraph->channel(0)->acquisition()->implementation().c_str())); + // EXPECT_STREQ("Pass_Through", (flowgraph->channel(0)->tracking()->implementation().c_str()); + // EXPECT_STREQ("Pass_Through", (flowgraph->channel(0)->telemetry()->implementation().c_str()); + EXPECT_STREQ("Channel", flowgraph->channels_.at(1)->implementation().c_str()); + // EXPECT_STREQ("Pass_Through", (flowgraph->channel(1)->acquisition()->implementation().c_str()); + // EXPECT_STREQ("Pass_Through", (flowgraph->channel(1)->tracking()->implementation().c_str()); + // EXPECT_STREQ("Pass_Through", (flowgraph->channel(1)->telemetry()->implementation().c_str()); + EXPECT_STREQ("GPS_L1_CA_Observables", flowgraph->observables_->implementation().c_str()); + EXPECT_STREQ("GPS_L1_CA_PVT", flowgraph->pvt_->implementation().c_str()); + EXPECT_STREQ("Null_Sink_Output_Filter", flowgraph->output_filter_->implementation().c_str()); + + EXPECT_NO_THROW(flowgraph->start()); EXPECT_TRUE(flowgraph->running()); flowgraph->stop(); EXPECT_FALSE(flowgraph->running()); - delete flowgraph; + //delete flowgraph; } diff --git a/src/tests/gnss_block/gnss_block_factory_test.cc b/src/tests/gnss_block/gnss_block_factory_test.cc index dc09aff06..a966fda64 100644 --- a/src/tests/gnss_block/gnss_block_factory_test.cc +++ b/src/tests/gnss_block/gnss_block_factory_test.cc @@ -285,11 +285,8 @@ TEST(GNSS_Block_Factory_Test, InstantiateChannels) gr::msg_queue::sptr queue = gr::msg_queue::make(0); std::unique_ptr factory; std::unique_ptr>> channels = std::move(factory->GetChannels(configuration, queue)); - EXPECT_EQ((unsigned int) 2, channels->size()); - channels->erase(channels->begin(), channels->end()); - //channels->clear(); } From a5af6ea88931416080d0253f46199466a8d174cc Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 13 Apr 2014 00:32:16 +0200 Subject: [PATCH 05/18] Cleaning flowgraph --- src/core/receiver/gnss_flowgraph.cc | 49 ----------------------------- src/core/receiver/gnss_flowgraph.h | 22 +++---------- 2 files changed, 4 insertions(+), 67 deletions(-) diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 41c0e5315..4f6d2625f 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -442,55 +442,6 @@ void GNSSFlowgraph::set_configuration(std::shared_ptr co } -/* -std::shared_ptr GNSSFlowgraph::signal_source() -{ - auto sig_source_ = std::move(blocks_->at(0)); - return std::move(sig_source_); -} - - - -std::shared_ptr GNSSFlowgraph::signal_conditioner() -{ - auto sig_conditioner_ = std::move(blocks_->at(1)); - return std::move(sig_conditioner_); -} - - - -std::shared_ptr GNSSFlowgraph::channel(unsigned int index) -{ - auto chan_ = std::move(blocks_->at(index + 5)); - std::shared_ptr chan = std::dynamic_pointer_cast(chan_); - return chan; -} - - - -std::shared_ptr GNSSFlowgraph::observables() -{ - observables_ = std::move(blocks_->at(2)); - return std::move(observables_); -} - - - -std::shared_ptr GNSSFlowgraph::pvt() -{ - pvt_ = std::move(blocks_->at(3)); - return std::move(pvt_); -} - - - -std::shared_ptr GNSSFlowgraph::output_filter() -{ - auto output_ = std::move(blocks_->at(4)); - return std::move(output_); -} -*/ - void GNSSFlowgraph::init() { diff --git a/src/core/receiver/gnss_flowgraph.h b/src/core/receiver/gnss_flowgraph.h index 6f5818072..cf6b91bd7 100644 --- a/src/core/receiver/gnss_flowgraph.h +++ b/src/core/receiver/gnss_flowgraph.h @@ -93,20 +93,6 @@ public: void set_configuration(std::shared_ptr configuration); - /*std::shared_ptr signal_source(); - std::shared_ptr signal_conditioner(); - std::shared_ptr channel(unsigned int index); - std::shared_ptr observables(); - std::shared_ptr pvt(); - std::shared_ptr output_filter();*/ - - std::shared_ptr sig_source_; - std::shared_ptr sig_conditioner_; - std::shared_ptr observables_; - std::shared_ptr pvt_; - std::shared_ptr output_filter_; - std::vector> channels_; - unsigned int applied_actions() { return applied_actions_; @@ -122,11 +108,11 @@ public: private: void init(); - /*! + /* * \brief Populates the SV PRN list available for acquisition and tracking */ void set_signals_list(); - /*! + /* * \brief Initializes the channels state (start acquisition or keep standby) using the configuration parameters (number of channels and max channels in acquisition) */ void set_channels_state(); @@ -140,12 +126,12 @@ private: std::shared_ptr configuration_; std::shared_ptr block_factory_; std::shared_ptr>> blocks_ = std::make_shared>>(); - /* std::shared_ptr sig_source_; + std::shared_ptr sig_source_; std::shared_ptr sig_conditioner_; std::shared_ptr observables_; std::shared_ptr pvt_; std::shared_ptr output_filter_; - std::vector> channels_; */ + std::vector> channels_; gr::top_block_sptr top_block_; boost::shared_ptr queue_; std::list available_GNSS_signals_; From 55da7e971635e2f0b5934c24cd2099eed8e079c0 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 13 Apr 2014 02:51:00 +0200 Subject: [PATCH 06/18] replacing raw pointers by smart pointers in the control message factory --- src/core/receiver/control_message_factory.cc | 10 ++--- src/core/receiver/control_message_factory.h | 3 +- src/core/receiver/control_thread.cc | 2 - src/core/receiver/control_thread.h | 9 +++-- src/core/receiver/gnss_block_factory.h | 9 +++-- src/core/receiver/gnss_flowgraph.cc | 2 +- src/core/receiver/gnss_flowgraph.h | 6 ++- .../control_message_factory_test.cc | 38 +++++++------------ 8 files changed, 35 insertions(+), 44 deletions(-) diff --git a/src/core/receiver/control_message_factory.cc b/src/core/receiver/control_message_factory.cc index 87797fdd3..56d77c55f 100644 --- a/src/core/receiver/control_message_factory.cc +++ b/src/core/receiver/control_message_factory.cc @@ -55,9 +55,9 @@ boost::shared_ptr ControlMessageFactory::GetQueueMessage(unsigned i } -std::vector* ControlMessageFactory::GetControlMessages(boost::shared_ptr queue_message) +std::shared_ptr>> ControlMessageFactory::GetControlMessages(boost::shared_ptr queue_message) { - std::vector* control_messages = new std::vector(); + std::shared_ptr>> control_messages = std::make_shared>>(); unsigned int control_messages_count = queue_message->length() / sizeof(ControlMessage); if(queue_message->length() % sizeof(ControlMessage) != 0) { @@ -66,10 +66,10 @@ std::vector* ControlMessageFactory::GetControlMessages(boost::s LOG(WARNING) << "Ignoring this queue message to prevent unexpected results."; return control_messages; } - for(unsigned int i=0; ipush_back(new ControlMessage); - memcpy(control_messages->at(i), queue_message->msg() + (i*sizeof(ControlMessage)), sizeof(ControlMessage)); + control_messages->push_back(std::make_shared()); + memcpy(control_messages->at(i).get(), queue_message->msg() + (i*sizeof(ControlMessage)), sizeof(ControlMessage)); } return control_messages; } diff --git a/src/core/receiver/control_message_factory.h b/src/core/receiver/control_message_factory.h index f17e02f0b..eb993853c 100644 --- a/src/core/receiver/control_message_factory.h +++ b/src/core/receiver/control_message_factory.h @@ -31,6 +31,7 @@ #ifndef GNSS_SDR_CONTROL_MESSAGE_FACTORY_H_ #define GNSS_SDR_CONTROL_MESSAGE_FACTORY_H_ +#include #include #include @@ -58,7 +59,7 @@ public: virtual ~ControlMessageFactory(); boost::shared_ptr GetQueueMessage(unsigned int who, unsigned int what); - std::vector* GetControlMessages(gr::message::sptr queue_message); + std::shared_ptr>> GetControlMessages(gr::message::sptr queue_message); }; #endif /*GNSS_SDR_CONTROL_MESSAGE_FACTORY_H_*/ diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index e346aca66..aa4669e18 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -402,11 +402,9 @@ void ControlThread::process_control_messages() { flowgraph_->apply_action(control_messages_->at(i)->who, control_messages_->at(i)->what); } - delete control_messages_->at(i); processed_control_messages_++; } control_messages_->clear(); - delete control_messages_; DLOG(INFO) << "Processed all control messages"; } diff --git a/src/core/receiver/control_thread.h b/src/core/receiver/control_thread.h index f5318302e..a46ad5335 100644 --- a/src/core/receiver/control_thread.h +++ b/src/core/receiver/control_thread.h @@ -35,6 +35,7 @@ #ifndef GNSS_SDR_CONTROL_THREAD_H_ #define GNSS_SDR_CONTROL_THREAD_H_ +#include #include #include #include @@ -101,11 +102,11 @@ public: /*! * \brief Instantiates a flowgraph * - * \return Returns a flowgraph object + * \return Returns a pointer to a flowgraph object */ - GNSSFlowgraph* flowgraph() + std::shared_ptr flowgraph() { - return flowgraph_.get(); + return flowgraph_; } @@ -177,7 +178,7 @@ private: std::shared_ptr configuration_; boost::shared_ptr control_queue_; std::shared_ptr control_message_factory_; - std::vector *control_messages_; + std::shared_ptr>> control_messages_; bool stop_; bool delete_configuration_; unsigned int processed_control_messages_; diff --git a/src/core/receiver/gnss_block_factory.h b/src/core/receiver/gnss_block_factory.h index 482b83f6a..11c21b96f 100644 --- a/src/core/receiver/gnss_block_factory.h +++ b/src/core/receiver/gnss_block_factory.h @@ -1,16 +1,17 @@ /*! * \file gnss_block_factory.h - * \brief Interface of a factory that returns instances of GNSS blocks. + * \brief Interface of a factory that returns smart pointers to GNSS blocks. * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com * Luis Esteve, 2011. luis(at)epsilon-formacion.com * Javier Arribas, 2011. jarribas(at)cttc.es + * Carles Fernandez-Prades, 2014. cfernandez(at)cttc.es * * This class encapsulates the complexity behind the instantiation * of GNSS blocks. * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2014 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -36,9 +37,9 @@ #ifndef GNSS_SDR_BLOCK_FACTORY_H_ #define GNSS_SDR_BLOCK_FACTORY_H_ -#include -#include #include +#include +#include #include class ConfigurationInterface; diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 4f6d2625f..7f63547d2 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -3,6 +3,7 @@ * \brief Implementation of a GNSS receiver flowgraph * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com * Luis Esteve, 2012. luis(at)epsilon-formacion.com + * Carles Fernandez-Prades, 2014. cfernandez(at)cttc.es * * Detailed description of the file here if needed. * @@ -35,7 +36,6 @@ #include "unistd.h" #include #include -#include #include #include #include diff --git a/src/core/receiver/gnss_flowgraph.h b/src/core/receiver/gnss_flowgraph.h index cf6b91bd7..493a4868c 100644 --- a/src/core/receiver/gnss_flowgraph.h +++ b/src/core/receiver/gnss_flowgraph.h @@ -3,6 +3,7 @@ * \brief Interface of a GNSS receiver flowgraph. * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com * Luis Esteve, 2011. luis(at)epsilon-formacion.com + * Carles Fernandez-Prades, 2014. cfernandez(at)cttc.es * * It contains a signal source, * a signal conditioner, a set of channels, a pvt and an output filter. @@ -35,10 +36,11 @@ #ifndef GNSS_SDR_GNSS_FLOWGRAPH_H_ #define GNSS_SDR_GNSS_FLOWGRAPH_H_ +#include +#include +#include #include #include -#include -#include #include #include #include "GPS_L1_CA.h" diff --git a/src/tests/control_thread/control_message_factory_test.cc b/src/tests/control_thread/control_message_factory_test.cc index c54cfcbb4..879a2ce29 100644 --- a/src/tests/control_thread/control_message_factory_test.cc +++ b/src/tests/control_thread/control_message_factory_test.cc @@ -39,17 +39,13 @@ TEST(Control_Message_Factory_Test, GetQueueMessage) { - ControlMessageFactory *factory = new ControlMessageFactory(); - + std::shared_ptr factory = std::make_shared(); gr::message::sptr queue_message = factory->GetQueueMessage(0, 0); - ControlMessage *control_message = (ControlMessage*)queue_message->msg(); - + std::shared_ptr control_message = std::make_shared(); unsigned int expected0 = 0; EXPECT_EQ(expected0, control_message->who); EXPECT_EQ(expected0, control_message->what); EXPECT_EQ(sizeof(ControlMessage), queue_message->length()); - - delete factory; } @@ -57,48 +53,40 @@ TEST(Control_Message_Factory_Test, GetQueueMessage) TEST(Control_Message_Factory_Test, GetControlMessages) { - ControlMessageFactory *factory = new ControlMessageFactory(); - ControlMessage *control_message = new ControlMessage; + std::shared_ptr factory = std::make_shared(); + gr::message::sptr queue_message = gr::message::make(0, 0, 0, sizeof(ControlMessage)); + std::shared_ptr control_message = std::make_shared(); control_message->who = 1; control_message->what = 4; - gr::message::sptr queue_message = gr::message::make(0, 0, 0, sizeof(ControlMessage)); - memcpy(queue_message->msg(), control_message, sizeof(ControlMessage)); - std::vector *control_messages = factory->GetControlMessages(queue_message); + memcpy(queue_message->msg(), control_message.get(), sizeof(ControlMessage)); + std::shared_ptr>> control_messages = factory->GetControlMessages(queue_message); unsigned int expected1 = 1; unsigned int expected4 = 4; EXPECT_EQ(expected1, control_messages->size()); EXPECT_EQ(expected1, control_messages->at(0)->who); EXPECT_EQ(expected4, control_messages->at(0)->what); - - delete control_message; - delete control_messages; - delete factory; } - +/* TEST(Control_Message_Factory_Test, GetControlMessagesWrongSize) { - ControlMessageFactory *factory = new ControlMessageFactory(); - ControlMessage *control_message = new ControlMessage; + std::shared_ptr factory = std::make_shared(); + std::shared_ptr control_message = std::make_shared(); control_message->who = 1; control_message->what = 4; int another_int = 10; gr::message::sptr queue_message = gr::message::make(0, 0, 0, sizeof(ControlMessage) + sizeof(int)); - memcpy(queue_message->msg(), control_message, sizeof(ControlMessage)); + memcpy(queue_message->msg(), control_message.get(), sizeof(ControlMessage)); memcpy(queue_message->msg() + sizeof(ControlMessage), &another_int, sizeof(int)); - std::vector *control_messages = factory->GetControlMessages(queue_message); + std::shared_ptr>> control_messages = factory->GetControlMessages(queue_message); unsigned int expected0 = 0; EXPECT_EQ(expected0, control_messages->size()); - - delete control_message; - delete control_messages; - delete factory; -} +} */ From 307ae28d50e38158c148b469641fcba99a0a5cc4 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 13 Apr 2014 18:58:52 +0200 Subject: [PATCH 07/18] Last retouches of the new factory and flowgraph. --- src/core/receiver/control_thread.cc | 1 + src/core/receiver/control_thread.h | 2 - src/core/receiver/gnss_block_factory.cc | 159 ++++++++++++------------ src/core/receiver/gnss_block_factory.h | 18 +-- src/core/receiver/gnss_flowgraph.cc | 103 ++++++++------- src/core/receiver/gnss_flowgraph.h | 11 +- 6 files changed, 145 insertions(+), 149 deletions(-) diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index aa4669e18..fad855655 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -179,6 +179,7 @@ void ControlThread::run() galileo_ephemeris_data_collector_thread_.timed_join(boost::posix_time::seconds(1)); galileo_iono_data_collector_thread_.timed_join(boost::posix_time::seconds(1)); galileo_utc_model_data_collector_thread_.timed_join(boost::posix_time::seconds(1)); + //Join keyboard threads keyboard_thread_.timed_join(boost::posix_time::seconds(1)); diff --git a/src/core/receiver/control_thread.h b/src/core/receiver/control_thread.h index a46ad5335..f20e09a57 100644 --- a/src/core/receiver/control_thread.h +++ b/src/core/receiver/control_thread.h @@ -109,7 +109,6 @@ public: return flowgraph_; } - private: //SUPL assistance classes gnss_sdr_supl_client supl_client_acquisition_; @@ -172,7 +171,6 @@ private: void galileo_iono_data_collector(); - void apply_action(unsigned int what); std::shared_ptr flowgraph_; std::shared_ptr configuration_; diff --git a/src/core/receiver/gnss_block_factory.cc b/src/core/receiver/gnss_block_factory.cc index 098753e03..7e49115f0 100644 --- a/src/core/receiver/gnss_block_factory.cc +++ b/src/core/receiver/gnss_block_factory.cc @@ -139,7 +139,7 @@ std::unique_ptr GNSSBlockFactory::GetSignalConditioner( input_filter = configuration->property( "InputFilter.implementation", default_implementation); resampler = configuration->property( - "Resampler.implementation", default_implementation); + "Resampler.implementation", default_implementation); } LOG(INFO) << "Getting SignalConditioner with DataTypeAdapter implementation: " @@ -517,11 +517,11 @@ std::unique_ptr GNSSBlockFactory::GetBlock( } else if (implementation.compare("Galileo_E1B_Observables") == 0) - { + { std::unique_ptr block_(new GalileoE1Observables(configuration.get(), role, in_streams, - out_streams, queue)); + out_streams, queue)); block = std::move(block_); - } + } // PVT ------------------------------------------------------------------------- else if (implementation.compare("GPS_L1_CA_PVT") == 0) @@ -558,6 +558,11 @@ std::unique_ptr GNSSBlockFactory::GetBlock( } +/* + * Not very elegant, Acq, Ttk and Tlm blocks must be added here, too. + * To be fixed! + */ + std::unique_ptr GNSSBlockFactory::GetAcqBlock( std::shared_ptr configuration, std::string role, @@ -631,11 +636,11 @@ std::unique_ptr GNSSBlockFactory::GetAcqBlock( block = std::move(block_); } else - { - // Log fatal. This causes execution to stop. - LOG(ERROR) << implementation << ": Undefined implementation for block"; - } - return std::move(block); + { + // Log fatal. This causes execution to stop. + LOG(ERROR) << implementation << ": Undefined implementation for block"; + } + return std::move(block); } @@ -647,49 +652,49 @@ std::unique_ptr GNSSBlockFactory::GetTrkBlock( { std::unique_ptr block; -// TRACKING BLOCKS ------------------------------------------------------------- - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking") == 0) - { - std::unique_ptr block_(new GpsL1CaDllPllTracking(configuration.get(), role, in_streams, - out_streams, queue)); - block = std::move(block_); - } - else if (implementation.compare("GPS_L1_CA_DLL_PLL_Optim_Tracking") == 0) - { - std::unique_ptr block_(new GpsL1CaDllPllOptimTracking(configuration.get(), role, in_streams, - out_streams, queue)); - block = std::move(block_); - } - else if (implementation.compare("GPS_L1_CA_DLL_FLL_PLL_Tracking") == 0) - { - std::unique_ptr block_(new GpsL1CaDllFllPllTracking(configuration.get(), role, in_streams, - out_streams, queue)); - block = std::move(block_); - } - else if (implementation.compare("GPS_L1_CA_TCP_CONNECTOR_Tracking") == 0) - { - std::unique_ptr block_(new GpsL1CaTcpConnectorTracking(configuration.get(), role, in_streams, - out_streams, queue)); - block = std::move(block_); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking") == 0) - { - std::unique_ptr block_(new GalileoE1DllPllVemlTracking(configuration.get(), role, in_streams, - out_streams, queue)); - block = std::move(block_); - } - else if (implementation.compare("Galileo_E1_TCP_CONNECTOR_Tracking") == 0) - { - std::unique_ptr block_(new GalileoE1TcpConnectorTracking(configuration.get(), role, in_streams, - out_streams, queue)); - block = std::move(block_); - } - else - { - // Log fatal. This causes execution to stop. - LOG(ERROR) << implementation << ": Undefined implementation for block"; - } - return std::move(block); + // TRACKING BLOCKS ------------------------------------------------------------- + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking") == 0) + { + std::unique_ptr block_(new GpsL1CaDllPllTracking(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + else if (implementation.compare("GPS_L1_CA_DLL_PLL_Optim_Tracking") == 0) + { + std::unique_ptr block_(new GpsL1CaDllPllOptimTracking(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + else if (implementation.compare("GPS_L1_CA_DLL_FLL_PLL_Tracking") == 0) + { + std::unique_ptr block_(new GpsL1CaDllFllPllTracking(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + else if (implementation.compare("GPS_L1_CA_TCP_CONNECTOR_Tracking") == 0) + { + std::unique_ptr block_(new GpsL1CaTcpConnectorTracking(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking") == 0) + { + std::unique_ptr block_(new GalileoE1DllPllVemlTracking(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + else if (implementation.compare("Galileo_E1_TCP_CONNECTOR_Tracking") == 0) + { + std::unique_ptr block_(new GalileoE1TcpConnectorTracking(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + else + { + // Log fatal. This causes execution to stop. + LOG(ERROR) << implementation << ": Undefined implementation for block"; + } + return std::move(block); } @@ -701,29 +706,29 @@ std::unique_ptr GNSSBlockFactory::GetTlmBlock( { std::unique_ptr block; -// TELEMETRY DECODERS ---------------------------------------------------------- - if (implementation.compare("GPS_L1_CA_Telemetry_Decoder") == 0) - { - std::unique_ptr block_(new GpsL1CaTelemetryDecoder(configuration.get(), role, in_streams, - out_streams, queue)); - block = std::move(block_); - } -else if (implementation.compare("Galileo_E1B_Telemetry_Decoder") == 0) - { - std::unique_ptr block_(new GalileoE1BTelemetryDecoder(configuration.get(), role, in_streams, - out_streams, queue)); - block = std::move(block_); - } -else if (implementation.compare("SBAS_L1_Telemetry_Decoder") == 0) - { - std::unique_ptr block_(new SbasL1TelemetryDecoder(configuration.get(), role, in_streams, - out_streams, queue)); - block = std::move(block_); - } -else - { - // Log fatal. This causes execution to stop. - LOG(ERROR) << implementation << ": Undefined implementation for block"; - } - return std::move(block); + // TELEMETRY DECODERS ---------------------------------------------------------- + if (implementation.compare("GPS_L1_CA_Telemetry_Decoder") == 0) + { + std::unique_ptr block_(new GpsL1CaTelemetryDecoder(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + else if (implementation.compare("Galileo_E1B_Telemetry_Decoder") == 0) + { + std::unique_ptr block_(new GalileoE1BTelemetryDecoder(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + else if (implementation.compare("SBAS_L1_Telemetry_Decoder") == 0) + { + std::unique_ptr block_(new SbasL1TelemetryDecoder(configuration.get(), role, in_streams, + out_streams, queue)); + block = std::move(block_); + } + else + { + // Log fatal. This causes execution to stop. + LOG(ERROR) << implementation << ": Undefined implementation for block"; + } + return std::move(block); } diff --git a/src/core/receiver/gnss_block_factory.h b/src/core/receiver/gnss_block_factory.h index 11c21b96f..7a56f5d46 100644 --- a/src/core/receiver/gnss_block_factory.h +++ b/src/core/receiver/gnss_block_factory.h @@ -70,7 +70,7 @@ public: std::string acq, std::string trk, std::string tlm, int channel, boost::shared_ptr queue); std::unique_ptr>> GetChannels(std::shared_ptr configuration, - boost::shared_ptr queue); + boost::shared_ptr queue); /* * \brief Returns the block with the required configuration and implementation */ @@ -85,15 +85,15 @@ private: std::string implementation, unsigned int in_streams, unsigned int out_streams, boost::shared_ptr queue); std::unique_ptr GetTrkBlock( - std::shared_ptr configuration, - std::string role, - std::string implementation, unsigned int in_streams, - unsigned int out_streams, boost::shared_ptr queue); + std::shared_ptr configuration, + std::string role, + std::string implementation, unsigned int in_streams, + unsigned int out_streams, boost::shared_ptr queue); std::unique_ptr GetTlmBlock( - std::shared_ptr configuration, - std::string role, - std::string implementation, unsigned int in_streams, - unsigned int out_streams, boost::shared_ptr queue); + std::shared_ptr configuration, + std::string role, + std::string implementation, unsigned int in_streams, + unsigned int out_streams, boost::shared_ptr queue); }; #endif /*GNSS_SDR_BLOCK_FACTORY_H_*/ diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 7f63547d2..8ad49ee4f 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -487,7 +487,6 @@ void GNSSFlowgraph::set_signals_list() /* * Sets a sequential list of GNSS satellites */ - std::set::iterator available_gnss_prn_iter; /* @@ -498,7 +497,6 @@ void GNSSFlowgraph::set_signals_list() /* * Read GNSS-SDR default GNSS system and signal */ - std::string default_system = configuration_->property("Channel.system", std::string("GPS")); std::string default_signal = configuration_->property("Channel.signal", std::string("1C")); @@ -506,60 +504,59 @@ void GNSSFlowgraph::set_signals_list() * Loop to create the list of GNSS Signals * To add signals from other systems, add another loop 'for' */ - if (default_system.compare(std::string("GPS")) == 0) - { - /* - * Loop to create GPS L1 C/A signals - */ - std::set available_gps_prn = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, - 29, 30, 31, 32 }; + { + /* + * Loop to create GPS L1 C/A signals + */ + std::set available_gps_prn = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, + 29, 30, 31, 32 }; - for (available_gnss_prn_iter = available_gps_prn.begin(); - available_gnss_prn_iter != available_gps_prn.end(); - available_gnss_prn_iter++) - { - available_GNSS_signals_.push_back(Gnss_Signal(Gnss_Satellite(std::string("GPS"), - *available_gnss_prn_iter), std::string("1C"))); - } - } + for (available_gnss_prn_iter = available_gps_prn.begin(); + available_gnss_prn_iter != available_gps_prn.end(); + available_gnss_prn_iter++) + { + available_GNSS_signals_.push_back(Gnss_Signal(Gnss_Satellite(std::string("GPS"), + *available_gnss_prn_iter), std::string("1C"))); + } + } if (default_system.compare(std::string("SBAS")) == 0) - { - /* - * Loop to create SBAS L1 C/A signals - */ - std::set available_sbas_prn = {120, 124, 126}; + { + /* + * Loop to create SBAS L1 C/A signals + */ + std::set available_sbas_prn = {120, 124, 126}; - for (available_gnss_prn_iter = available_sbas_prn.begin(); - available_gnss_prn_iter != available_sbas_prn.end(); - available_gnss_prn_iter++) - { - available_GNSS_signals_.push_back(Gnss_Signal(Gnss_Satellite(std::string("SBAS"), - *available_gnss_prn_iter), std::string("1C"))); - } - } + for (available_gnss_prn_iter = available_sbas_prn.begin(); + available_gnss_prn_iter != available_sbas_prn.end(); + available_gnss_prn_iter++) + { + available_GNSS_signals_.push_back(Gnss_Signal(Gnss_Satellite(std::string("SBAS"), + *available_gnss_prn_iter), std::string("1C"))); + } + } if (default_system.compare(std::string("Galileo")) == 0) - { - /* - * Loop to create the list of Galileo E1 B signals - */ - std::set available_galileo_prn = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36}; - - for (available_gnss_prn_iter = available_galileo_prn.begin(); - available_gnss_prn_iter != available_galileo_prn.end(); - available_gnss_prn_iter++) { - available_GNSS_signals_.push_back(Gnss_Signal(Gnss_Satellite(std::string("Galileo"), - *available_gnss_prn_iter), std::string("1B"))); + /* + * Loop to create the list of Galileo E1 B signals + */ + std::set available_galileo_prn = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36}; + + for (available_gnss_prn_iter = available_galileo_prn.begin(); + available_gnss_prn_iter != available_galileo_prn.end(); + available_gnss_prn_iter++) + { + available_GNSS_signals_.push_back(Gnss_Signal(Gnss_Satellite(std::string("Galileo"), + *available_gnss_prn_iter), std::string("1B"))); + } } - } /* * Ordering the list of signals from configuration file @@ -594,16 +591,16 @@ void GNSSFlowgraph::set_signals_list() available_GNSS_signals_.insert(gnss_it, signal_value); } } -// **** FOR DEBUGGING THE LIST OF GNSS SIGNALS **** -// + // **** FOR DEBUGGING THE LIST OF GNSS SIGNALS **** + // //std::cout<<"default_system="<set_property("Test.filename", file); config->set_property("Test.item_type", "float"); - FileOutputFilter *output_filter = new FileOutputFilter(config, "Test", 1, 0); - delete output_filter; + std::unique_ptr output_filter(new FileOutputFilter(config.get(), "Test", 1, 0)); + unsigned int res = 0; + if (output_filter) res = 1; + ASSERT_EQ(1, res); } diff --git a/src/tests/gnss_block/file_signal_source_test.cc b/src/tests/gnss_block/file_signal_source_test.cc index 0b15b505a..d5a96b967 100644 --- a/src/tests/gnss_block/file_signal_source_test.cc +++ b/src/tests/gnss_block/file_signal_source_test.cc @@ -39,7 +39,7 @@ TEST(FileSignalSource, Instantiate) { boost::shared_ptr queue = gr::msg_queue::make(0); - InMemoryConfiguration* config = new InMemoryConfiguration(); + std::shared_ptr config = std::make_shared(); config->set_property("Test.samples", "0"); config->set_property("Test.sampling_frequency", "0"); @@ -49,19 +49,16 @@ TEST(FileSignalSource, Instantiate) config->set_property("Test.item_type", "gr_complex"); config->set_property("Test.repeat", "false"); - FileSignalSource *signal_source = new FileSignalSource(config, "Test", 1, 1, queue); + std::unique_ptr signal_source(new FileSignalSource(config.get(), "Test", 1, 1, queue)); - //EXPECT_STREQ("../src/tests/signal_samples/GPS_L1_CA_ID_1_Fs_4Msps_2ms.dat", signal_source->filename().c_str()); EXPECT_STREQ("gr_complex", signal_source->item_type().c_str()); EXPECT_TRUE(signal_source->repeat() == false); - - delete signal_source; } TEST(FileSignalSource, InstantiateFileNotExists) { boost::shared_ptr queue = gr::msg_queue::make(0); - InMemoryConfiguration* config = new InMemoryConfiguration(); + std::shared_ptr config = std::make_shared(); config->set_property("Test.samples", "0"); config->set_property("Test.sampling_frequency", "0"); @@ -69,5 +66,5 @@ TEST(FileSignalSource, InstantiateFileNotExists) config->set_property("Test.item_type", "gr_complex"); config->set_property("Test.repeat", "false"); - EXPECT_THROW(new FileSignalSource(config, "Test", 1, 1, queue), std::exception); + EXPECT_THROW(auto uptr(new FileSignalSource(config.get(), "Test", 1, 1, queue)), std::exception); } diff --git a/src/tests/gnss_block/fir_filter_test.cc b/src/tests/gnss_block/fir_filter_test.cc index df536c821..80306af08 100644 --- a/src/tests/gnss_block/fir_filter_test.cc +++ b/src/tests/gnss_block/fir_filter_test.cc @@ -51,22 +51,22 @@ protected: { queue = gr::msg_queue::make(0); top_block = gr::make_top_block("Fir filter test"); - config = new InMemoryConfiguration(); + config = std::make_shared(); item_size = sizeof(gr_complex); } ~Fir_Filter_Test() - { - delete config; - } + {} + void init(); boost::shared_ptr queue; gr::top_block_sptr top_block; - InMemoryConfiguration* config; + std::shared_ptr config; size_t item_size; }; void Fir_Filter_Test::init() { + config->set_property("InputFilter.number_of_taps", "4"); config->set_property("InputFilter.number_of_bands", "2"); @@ -92,8 +92,10 @@ void Fir_Filter_Test::init() TEST_F(Fir_Filter_Test, Instantiate) { init(); - FirFilter *filter = new FirFilter(config, "InputFilter", 1, 1, queue); - delete filter; + std::unique_ptr filter(new FirFilter(config.get(), "InputFilter", 1, 1, queue)); + unsigned int res = 0; + if (filter) res = 1; + ASSERT_EQ(1, res); } @@ -107,7 +109,7 @@ TEST_F(Fir_Filter_Test, ConnectAndRun) init(); - FirFilter *filter = new FirFilter(config, "InputFilter", 1, 1, queue); + std::shared_ptr filter = std::make_shared(config.get(), "InputFilter", 1, 1, queue); ASSERT_NO_THROW( { filter->connect(top_block); @@ -126,8 +128,6 @@ TEST_F(Fir_Filter_Test, ConnectAndRun) top_block->run(); // Start threads and wait gettimeofday(&tv, NULL); end = tv.tv_sec *1000000 + tv.tv_usec; - }) << "Failure running he top_block."<< std::endl; - std::cout << "Filtered " << nsamples << " samples in " << (end-begin) << " microseconds" << std::endl; - - delete filter; + }) << "Failure running the top_block." << std::endl; + //std::cout << "Filtered " << nsamples << " samples in " << (end-begin) << " microseconds" << std::endl; } diff --git a/src/tests/gnss_block/rtcm_printer_test.cc b/src/tests/gnss_block/rtcm_printer_test.cc index c6c5d49ac..7c42b8199 100644 --- a/src/tests/gnss_block/rtcm_printer_test.cc +++ b/src/tests/gnss_block/rtcm_printer_test.cc @@ -42,8 +42,7 @@ TEST(Rtcm_Printer_Test, Instantiate) std::string filename = "hello.rtcm"; bool flag_rtcm_tty_port = false; std::string rtcm_dump_devname = "/dev/pts/4"; - Rtcm_Printer *RTCM_printer = new Rtcm_Printer(filename, flag_rtcm_tty_port, rtcm_dump_devname); - delete RTCM_printer; + std::unique_ptr RTCM_printer(new Rtcm_Printer(filename, flag_rtcm_tty_port, rtcm_dump_devname)); } TEST(Rtcm_Printer_Test, Instantiate_and_Run) @@ -68,10 +67,9 @@ TEST(Rtcm_Printer_Test, Instantiate_and_Run) bool flag_rtcm_tty_port = false; std::string rtcm_dump_devname = "/dev/pts/4"; - Rtcm_Printer *RTCM_printer = new Rtcm_Printer(filename, flag_rtcm_tty_port, rtcm_dump_devname); + std::unique_ptr RTCM_printer(new Rtcm_Printer(filename, flag_rtcm_tty_port, rtcm_dump_devname)); std::string reference_msg = "D300133ED7D30202980EDEEF34B4BD62AC0941986F33360B98"; std::string testing_msg = RTCM_printer->print_M1005_test(); EXPECT_EQ(reference_msg, testing_msg); - delete RTCM_printer; } From e52206008acae1b26af07b9f2531aee4f0669998 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 15 Apr 2014 15:03:54 +0200 Subject: [PATCH 09/18] Adding documentation --- src/core/receiver/control_thread.h | 40 +++++++++++++++++++----------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/src/core/receiver/control_thread.h b/src/core/receiver/control_thread.h index f20e09a57..fe02d0602 100644 --- a/src/core/receiver/control_thread.h +++ b/src/core/receiver/control_thread.h @@ -1,11 +1,11 @@ /*! - * \file control_thread.h + * \file control_thread.h * \brief Interface of the receiver control plane * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com * * GNSS Receiver Control Plane: connects the flowgraph, starts running it, * and while it does not stop, reads the control messages generated by the blocks, - * process them, and apply the corresponding actions. + * processes them, and applies the corresponding actions. * * ------------------------------------------------------------------------- * @@ -19,7 +19,7 @@ * 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. + * (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 @@ -47,7 +47,10 @@ class ConfigurationInterface; /*! - * \brief This class represents the main thread of the application, aka Control Thread. + * \brief This class represents the main thread of the application, so the name is ControlThread. + * This is the GNSS Receiver Control Plane: it connects the flowgraph, starts running it, + * and while it does not stop, reads the control messages generated by the blocks, + * processes them, and applies the corresponding actions. */ class ControlThread { @@ -102,7 +105,7 @@ public: /*! * \brief Instantiates a flowgraph * - * \return Returns a pointer to a flowgraph object + * \return Returns a smart pointer to a flowgraph object */ std::shared_ptr flowgraph() { @@ -128,47 +131,53 @@ private: void process_control_messages(); /* - * \brief Blocking function that reads the GPS ephemeris queue and updates the shared ephemeris map, accessible from the PVT block + * Blocking function that reads the GPS ephemeris queue and updates the shared ephemeris map, accessible from the PVT block */ void gps_ephemeris_data_collector(); + /* - * \brief Writes the ephemeris map to a local XML file + * Writes the ephemeris map to a local XML file */ void gps_ephemeris_data_write_to_XML(); + /* - * \brief Blocking function that reads the UTC model queue and updates the shared map, accessible from the PVT block + * Blocking function that reads the UTC model queue and updates the shared map, accessible from the PVT block */ void gps_utc_model_data_collector(); /* - * \brief Write the latest GPS UTC model to XML file + * Write the latest GPS UTC model to XML file */ void gps_utc_model_data_write_to_XML(); /* - * \brief Blocking function that reads the iono model queue and updates the shared map, accessible from the PVT block + * Blocking function that reads the iono model queue and updates the shared map, accessible from the PVT block */ void gps_iono_data_collector(); /* - * \brief Write the latest GPS IONO model to XML file + * Write the latest GPS IONO model to XML file */ void gps_iono_data_write_to_XML(); /* - * \brief Blocking function that reads the GPS assistance queue + * Blocking function that reads the GPS assistance queue */ void gps_acq_assist_data_collector(); /* - * \brief Blocking function that reads the Galileo ephemeris queue and updates the shared ephemeris map, accessible from the PVT block + * Blocking function that reads the Galileo ephemeris queue and updates the shared ephemeris map, accessible from the PVT block */ void galileo_ephemeris_data_collector(); + /* - * \brief Blocking function that reads the UTC model queue and updates the shared map, accessible from the PVT block - */ + * Blocking function that reads the UTC model queue and updates the shared map, accessible from the PVT block + */ void galileo_utc_model_data_collector(); + /* + * Blocking function that reads the iono data queue and updates the shared map, accessible from the PVT block + */ void galileo_iono_data_collector(); void apply_action(unsigned int what); @@ -182,6 +191,7 @@ private: unsigned int processed_control_messages_; unsigned int applied_actions_; boost::thread keyboard_thread_; + boost::thread gps_ephemeris_data_collector_thread_; boost::thread gps_iono_data_collector_thread_; boost::thread gps_utc_model_data_collector_thread_; From 9ea9225172d7e2436d472995c85125f0a1e37d82 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 23 Apr 2014 19:38:22 +0200 Subject: [PATCH 10/18] Testing how sourceforge interprets the markdown syntax --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 05a476f84..fc78dee57 100644 --- a/README.md +++ b/README.md @@ -19,16 +19,20 @@ Tested distributions: Ubuntu 12.04, 12.10, 13.04, 13.10 and 14.04 (32 and 64 bit ### Install GNU Radio: - Downloading, building and installing [GNU Radio](http://gnuradio.org/redmine/projects/gnuradio/wiki "GNU Radio's Homepage") and all its dependencies is not a simple task. We recommend to use [PyBOMBS](http://gnuradio.org/redmine/projects/pybombs/wiki) (Python Build Overlay Managed Bundle System), the GNU Radio install management system that automatically does all the work for you. In a terminal, type: + ``` $ git clone git://github.com/pybombs/pybombs $ cd pybombs ``` + Configure PyBOMBS: + ``` $ ./pybombs config ``` You can safely accept the default options but for ```prefix```. We recommend to put ```/usr/local``` there. After the configuration, you should get something similar to: + ``` gituser = username prefix = /usr/local @@ -39,10 +43,13 @@ timeout = 30 cmakebuildtype = RelWithDebInfo builddocs = OFF ``` + Then, you are ready to download and install [UHD](http://files.ettus.com/uhd_docs/manual/html/) (the Universal Hardware Driver), GNU Radio and all their required dependencies by doing: + ``` $ sudo ./pybombs install uhd gnuradio ``` + This can take some time (up to two hours to complete, depending on your system), and installs the latest versions of the Universal Hardware Driver (UHD) and GNU Radio in your system, including all their dependencies. In case you do not want to use PyBOMBS and prefer to build and install GNU Radio manually from source, follow instructions at the [GNU Radio Build Guide](http://gnuradio.org/redmine/projects/gnuradio/wiki/BuildGuide). From 93cea146484b28171321d26b2adaa5e9b4ad7491 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 23 Apr 2014 19:51:12 +0200 Subject: [PATCH 11/18] testing problems with return carriage --- README.md | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 72 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fc78dee57..9e06ce5c0 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,8 @@ In case you do not want to use PyBOMBS and prefer to build and install GNU Radio ### Install other libraries used by GNSS-SDR: -#### Install the [Armadillo](http://arma.sourceforge.net/ "Armdillo's Homepage") C++ linear algebra library: +#### Install the [Armadillo](http://arma.sourceforge.net/ "Armadillo's Homepage") C++ linear algebra library: + ``` $ sudo apt-get install libblas-dev liblapack-dev gfortran # For Debian/Ubuntu/LinuxMint $ sudo yum install lapack-devel blas-devel gcc-fortran # For Fedora/CentOS/RHEL @@ -72,7 +73,8 @@ $ sudo make install The full stop separated from "cmake" by a space is important. [CMake](http://www.cmake.org/ "CMake's Homepage") will figure out what other libraries are currently installed and will modify Armadillo's configuration correspondingly. CMake will also generate a run-time armadillo library, which is a combined alias for all the relevant libraries present on your system (eg. BLAS, LAPACK and ATLAS). -#### Install [Gflags](http://code.google.com/p/gflags/ "gflags' Homepage"), a commandline flags processing module for C++: +#### Install [Gflags](http://code.google.com/p/gflags/ "Gflags' Homepage"), a commandline flags processing module for C++: + ``` $ wget http://gflags.googlecode.com/files/gflags-2.0.zip $ unzip gflags-2.0.zip @@ -82,7 +84,9 @@ $ make $ sudo make install $ sudo ldconfig ``` + #### Install [Glog](http://code.google.com/p/google-glog/ "Glog's Homepage"), a library that implements application-level logging: + ``` $ wget http://google-glog.googlecode.com/files/glog-0.3.3.tar.gz $ tar xvfz glog-0.3.3.tar.gz @@ -94,6 +98,7 @@ $ sudo ldconfig ``` #### Build the [Google C++ Testing Framework](http://code.google.com/p/googletest/ "Googletest Homepage"), also known as googletest: + ``` $ wget http://googletest.googlecode.com/files/gtest-1.7.0.zip $ unzip gtest-1.7.0.zip @@ -103,21 +108,28 @@ $ make ``` Please **DO NOT install** gtest (do *not* type ```sudo make install```). Every user needs to compile his tests using the same compiler flags used to compile the installed Google Test libraries; otherwise he may run into undefined behaviors (i.e. the tests can behave strangely and may even crash for no obvious reasons). The reason is that C++ has this thing called the One-Definition Rule: if two C++ source files contain different definitions of the same class/function/variable, and you link them together, you violate the rule. The linker may or may not catch the error (in many cases it is not required by the C++ standard to catch the violation). If it does not, you get strange run-time behaviors that are unexpected and hard to debug. If you compile Google Test and your test code using different compiler flags, they may see different definitions of the same class/function/variable (e.g. due to the use of ```#if``` in Google Test). Therefore, for your sanity, we recommend to avoid installing pre-compiled Google Test libraries. Instead, each project should compile Google Test itself such that it can be sure that the same flags are used for both Google Test and the tests. The building system of GNSS-SDR does the compilation and linking of gtest its own tests; it is only required that you tell the system where the gtest folder that you downloaded resides. Just add to your ```$HOME/.bashrc``` file the following line: + ``` $ export GTEST_DIR=/home/username/gtest-1.7.0 ``` + changing /home/username/gtest-1.7.0 by the actual directory where you downloaded gtest. Again, it is recommended to add this line to your ```$HOME/.bashrc``` file. #### Install the [SSL development libraries](https://www.openssl.org/ "OpenSSL's Homepage"): + ``` $ sudo apt-get install libssl-dev # For Debian/Ubuntu/LinuxMint $ sudo yum install openssl-devel # For Fedora/CentOS/RHEL ``` + ### Clone GNSS-SDR's Git repository: + ``` $ git clone git://git.code.sf.net/p/gnss-sdr/cttc gnss-sdr ``` + Cloning the GNSS-SDR repository as in the line above will create a folder named gnss-sdr with the following structure: + ``` |-gnss-sdr |---build <- where gnss-sdr is built @@ -141,6 +153,7 @@ Cloning the GNSS-SDR repository as in the line above will create a folder named - Go to GR-GN3S root directory, compile and install the driver (read the drivers/gr-gn3s/README for more information): + ``` $ cd gnss-sdr/drivers/gr-gn3s $ cd build @@ -149,10 +162,13 @@ $ make $ sudo make install $ sudo ldconfig ``` + - Set the environment variable ```GN3S_DRIVER=1``` in order to enable the GN3S_Signal_Source in GNSS-SDR: + ``` $ export GN3S_DRIVER=1 ``` + In order to gain access to USB ports, gnss-sdr should be used as root. In addition, the driver requires access to the GN3S firmware binary file. It should be available in the same path where the application is called. @@ -164,6 +180,7 @@ Please copy this file to the application path. The GNSS-SDR default path is gnss ###### Build RTL-SDR support (OPTIONAL): - Install the [OsmoSDR](http://sdr.osmocom.org/trac/ "OsmoSDR's Homepage") library and GNU Radio's source block: + ``` $ git clone git://git.osmocom.org/osmo-sdr.git $ cd osmo-sdr/software/libosmosdr @@ -183,14 +200,19 @@ $ make $ sudo make install $ sudo ldconfig ``` + - Set the environment variable ```RTLSDR_DRIVER=1``` in order to enable the Rtlsdr_Signal_Source in GNSS-SDR: + ``` $ export RTLSDR_DRIVER=1 ``` + - In order to compile the RTLSDR adapter you should also provide the path to the gr-osmosdr source code using: + ``` $ export OSMOSDR_ROOT=/path/to/gr-osmosdr ``` + The default will be ```OSMOSDR_ROOT=/usr/local``` (in order to disable the Rtlsdr_Signal_Source compilation, you should remove the RTLSDR_DRIVER variable and build again GNSS-SDR). @@ -198,54 +220,74 @@ The default will be ```OSMOSDR_ROOT=/usr/local``` ### Build GNSS-SDR - Go to GNSS-SDR's build directory: + ``` $ cd gnss-sdr/build ``` + - Configure and build the application: + ``` $ cmake ../ $ make ``` + By default, CMake is configured to build the release version. If you want to build the debug version, please use: + ``` cmake ../ -DCMAKE_BUILD_TYPE=Debug ``` + - Move the executables to the install folder: + ``` $ make install ``` + - If everything goes well, two new executables will be created at gnss-sdr/install, namely ```gnss-sdr``` and ```run_tests```. - You can create the documentation by doing: + ``` $ make doc ``` + from the gnss-sdr/build folder. This will generate HTML documentation that can be retrieved pointing your browser of preference to gnss-sdr/docs/html/index.html. If a LaTeX installation is detected in your system, + ``` $ make pdfmanual ``` + will create a PDF manual at gnss-sdr/docs/GNSS-SDR_manual.pdf. Please note that the PDF generation requires some fonts to be installed on the host system. In Ubuntu 12.10, those fonts do not come by default. You can install them by doing: + ``` $ sudo apt-get install texlive-fonts-recommended ``` + and then run ```cmake ../``` and make pdfmanual again. Finally, + ``` $ make doc-clean ``` + will remove the content of previously-generated documentation. - By default, CMake will build the Release version, meaning that the compiler will generate a faster, optimized executable. This is the recommended build type when using a RF front-end and you need to attain real time. If you are working with a file (and thus without real-time constraints), you may want to obtain more information about the internals of the receiver, as well as more fine-grained logging. This can be done by building the Debug version, by doing: + ``` $ cd gnss-sdr/build $ cmake -DCMAKE_BUILD_TYPE=Debug ../ $ make $ make install ``` + - If you are using Eclipse as your development environment, CMake can create the project for you. Type: + ``` $ cmake -G "Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DECLIPSE_CDT4_GENERATE_SOURCE_PROJECT=TRUE -DCMAKE_ECLIPSE_VERSION=3.7 -DCMAKE_ECLIPSE_MAKE_ARGUMENTS=-j8 ../ ``` + and then import the created project file into Eclipse: 1. Import project using Menu File -> Import. @@ -268,6 +310,7 @@ If you still have not installed [Xcode](http://developer.apple.com/xcode/), do i Then, [install Macports](http://www.macports.org/install.php). If you are upgrading from a previous installation, please follow the [migration rules](http://trac.macports.org/wiki/Migration). In a terminal, type: + ``` $ sudo port selfupdate $ sudo port upgrade outdated @@ -275,7 +318,9 @@ $ sudo port install doxygen +latex $ sudo port install uhd gnuradio $ sudo port install armadillo ``` -Install [Gflags](http://code.google.com/p/gflags/ "gflags' Homepage") manually from the trunk: + +Install [Gflags](http://code.google.com/p/gflags/ "Gflags' Homepage") manually from the trunk: + ``` $ svn checkout http://gflags.googlecode.com/svn/trunk gflags-trunk $ cd gflags-trunk @@ -283,7 +328,9 @@ $ CXXFLAGS="-stdlib=libc++" CC=clang CXX=clang++ ./configure $ make $ sudo make install ``` + Install [Glog](http://code.google.com/p/google-glog/ "Glog's Homepage") manually from the subversion repository. Revision 142 is known to work well: + ``` $ svn checkout -r142 http://google-glog.googlecode.com/svn/trunk/ google-glog $ cd google-glog @@ -291,7 +338,9 @@ $ CXXFLAGS="-stdlib=libc++" CC=clang CXX=clang++ ./configure $ make $ sudo make install ``` + Finally, you are ready to clone the GNSS-SDR repository and build the software: + ``` $ git clone git://git.code.sf.net/p/gnss-sdr/cttc gnss-sdr $ cd gnss-sdr/build @@ -301,10 +350,13 @@ $ make install ``` This will create two executables at gnss-sdr/install, namely ```gnss-sdr``` and ```run_tests```. The documentation can be built by: + ``` $ make doc ``` + and can be viewed doing: + ``` $ open ../docs/html/index.html ``` @@ -320,25 +372,32 @@ Xcode -> Preferences -> Downloads -> Components -> Command Line Tools Then, install Macports via [Mac OS X Package (.pkg) installer](http://www.macports.org/install.php). Once MacPorts is properly installed on your system, open a terminal and type: + ``` $ sudo port selfupdate $ sudo port install gcc48 $ sudo port select --set gcc mp-gcc48 ``` + Install [X11 via XQuartz-2.7.4.dmg](http://xquartz.macosforge.org/landing/) (needed by gnuradio-companion but not by GNSS-SDR). Install GNU Radio: + ``` $ sudo port install gnuradio ``` + Install other dependencies: + ``` $ sudo port install armadillo ``` -The libraries [Gflags](http://code.google.com/p/gflags/ "gflags' Homepage") and [Glog](http://code.google.com/p/google-glog/ "Glog's Homepage") should be installed manually, and in that particular order (same steps as above). If they are not already installed + +The libraries [Gflags](http://code.google.com/p/gflags/ "Gflags' Homepage") and [Glog](http://code.google.com/p/google-glog/ "Glog's Homepage") should be installed manually, and in that particular order (same steps as above). If they are not already installed when building GNSS-SDR, [CMake](http://www.cmake.org/ "CMake's Homepage") will download, build and link them statically for you when doing ```make```, but they will not remain installed in the system. Then, you are ready to clone the GNSS-SDR repository and build the software: + ``` $ git clone git://git.code.sf.net/p/gnss-sdr/cttc gnss-sdr $ cd gnss-sdr/build @@ -346,11 +405,15 @@ $ cmake ../ -DCMAKE_CXX_COMPILER=g++ $ make $ make install ``` + This will create two executables at gnss-sdr/install, namely ```gnss-sdr``` and ```run_tests```. The documentation can be built by: + ``` $ make doc ``` + and can be viewed doing: + ``` $ open ../docs/html/index.html ``` @@ -360,16 +423,21 @@ Updating GNSS-SDR ================= If you cloned GNSS-SDR some days ago, it is possible that some developer has updated files at the Git repository. You can update your working copy by doing: + ``` $ git checkout master # Switch to branch you want to update $ git pull origin master # Download the newest code from our repository ``` + or, if you want to test the lastest developments: + ``` $ git checkout next $ git pull origin next ``` + Before rebuilding the source code, it is safe (and recommended) to remove the remainders of old compilations: + ``` $ rm -rf gnss-sdr/build/* ``` From 70799aa21e6733f0442945381eb5caca0ff27929 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 23 Apr 2014 20:32:06 +0200 Subject: [PATCH 12/18] testing markdown --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9e06ce5c0..a43df6747 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ $ ./pybombs config You can safely accept the default options but for ```prefix```. We recommend to put ```/usr/local``` there. After the configuration, you should get something similar to: -``` +~~~~~~ gituser = username prefix = /usr/local satisfy_order = deb,src # For Debian/Ubuntu/LinuxMint @@ -42,7 +42,8 @@ forcepkgs = timeout = 30 cmakebuildtype = RelWithDebInfo builddocs = OFF -``` +~~~~~~ + Then, you are ready to download and install [UHD](http://files.ettus.com/uhd_docs/manual/html/) (the Universal Hardware Driver), GNU Radio and all their required dependencies by doing: From 493717289e6400ffbb578b84fb77e053007b7a20 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 23 Apr 2014 20:37:52 +0200 Subject: [PATCH 13/18] Formating in such as way that looks good in SourceForge and GitHub --- README.md | 166 +++++++++++++++++++++++++++--------------------------- 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/README.md b/README.md index a43df6747..5240220a9 100644 --- a/README.md +++ b/README.md @@ -20,16 +20,16 @@ Tested distributions: Ubuntu 12.04, 12.10, 13.04, 13.10 and 14.04 (32 and 64 bit - Downloading, building and installing [GNU Radio](http://gnuradio.org/redmine/projects/gnuradio/wiki "GNU Radio's Homepage") and all its dependencies is not a simple task. We recommend to use [PyBOMBS](http://gnuradio.org/redmine/projects/pybombs/wiki) (Python Build Overlay Managed Bundle System), the GNU Radio install management system that automatically does all the work for you. In a terminal, type: -``` +~~~~~~ $ git clone git://github.com/pybombs/pybombs $ cd pybombs -``` +~~~~~~ Configure PyBOMBS: -``` +~~~~~~ $ ./pybombs config -``` +~~~~~~ You can safely accept the default options but for ```prefix```. We recommend to put ```/usr/local``` there. After the configuration, you should get something similar to: @@ -47,9 +47,9 @@ builddocs = OFF Then, you are ready to download and install [UHD](http://files.ettus.com/uhd_docs/manual/html/) (the Universal Hardware Driver), GNU Radio and all their required dependencies by doing: -``` +~~~~~~ $ sudo ./pybombs install uhd gnuradio -``` +~~~~~~ This can take some time (up to two hours to complete, depending on your system), and installs the latest versions of the Universal Hardware Driver (UHD) and GNU Radio in your system, including all their dependencies. In case you do not want to use PyBOMBS and prefer to build and install GNU Radio manually from source, follow instructions at the [GNU Radio Build Guide](http://gnuradio.org/redmine/projects/gnuradio/wiki/BuildGuide). @@ -59,7 +59,7 @@ In case you do not want to use PyBOMBS and prefer to build and install GNU Radio #### Install the [Armadillo](http://arma.sourceforge.net/ "Armadillo's Homepage") C++ linear algebra library: -``` +~~~~~~ $ sudo apt-get install libblas-dev liblapack-dev gfortran # For Debian/Ubuntu/LinuxMint $ sudo yum install lapack-devel blas-devel gcc-fortran # For Fedora/CentOS/RHEL $ sudo zypper install lapack-devel blas-devel gcc-fortran # For OpenSUSE @@ -70,13 +70,13 @@ $ cd armadillo-4.100.2 $ cmake . $ make $ sudo make install -``` +~~~~~~ The full stop separated from "cmake" by a space is important. [CMake](http://www.cmake.org/ "CMake's Homepage") will figure out what other libraries are currently installed and will modify Armadillo's configuration correspondingly. CMake will also generate a run-time armadillo library, which is a combined alias for all the relevant libraries present on your system (eg. BLAS, LAPACK and ATLAS). #### Install [Gflags](http://code.google.com/p/gflags/ "Gflags' Homepage"), a commandline flags processing module for C++: -``` +~~~~~~ $ wget http://gflags.googlecode.com/files/gflags-2.0.zip $ unzip gflags-2.0.zip $ cd gflags-2.0 @@ -84,11 +84,11 @@ $ ./configure $ make $ sudo make install $ sudo ldconfig -``` +~~~~~~ #### Install [Glog](http://code.google.com/p/google-glog/ "Glog's Homepage"), a library that implements application-level logging: -``` +~~~~~~ $ wget http://google-glog.googlecode.com/files/glog-0.3.3.tar.gz $ tar xvfz glog-0.3.3.tar.gz $ cd glog-0.3.3 @@ -96,42 +96,42 @@ $ ./configure $ make $ sudo make install $ sudo ldconfig -``` +~~~~~~ #### Build the [Google C++ Testing Framework](http://code.google.com/p/googletest/ "Googletest Homepage"), also known as googletest: -``` +~~~~~~ $ wget http://googletest.googlecode.com/files/gtest-1.7.0.zip $ unzip gtest-1.7.0.zip $ cd gtest-1.7.0 $ ./configure $ make -``` +~~~~~~ Please **DO NOT install** gtest (do *not* type ```sudo make install```). Every user needs to compile his tests using the same compiler flags used to compile the installed Google Test libraries; otherwise he may run into undefined behaviors (i.e. the tests can behave strangely and may even crash for no obvious reasons). The reason is that C++ has this thing called the One-Definition Rule: if two C++ source files contain different definitions of the same class/function/variable, and you link them together, you violate the rule. The linker may or may not catch the error (in many cases it is not required by the C++ standard to catch the violation). If it does not, you get strange run-time behaviors that are unexpected and hard to debug. If you compile Google Test and your test code using different compiler flags, they may see different definitions of the same class/function/variable (e.g. due to the use of ```#if``` in Google Test). Therefore, for your sanity, we recommend to avoid installing pre-compiled Google Test libraries. Instead, each project should compile Google Test itself such that it can be sure that the same flags are used for both Google Test and the tests. The building system of GNSS-SDR does the compilation and linking of gtest its own tests; it is only required that you tell the system where the gtest folder that you downloaded resides. Just add to your ```$HOME/.bashrc``` file the following line: -``` +~~~~~~ $ export GTEST_DIR=/home/username/gtest-1.7.0 -``` +~~~~~~ changing /home/username/gtest-1.7.0 by the actual directory where you downloaded gtest. Again, it is recommended to add this line to your ```$HOME/.bashrc``` file. #### Install the [SSL development libraries](https://www.openssl.org/ "OpenSSL's Homepage"): -``` +~~~~~~ $ sudo apt-get install libssl-dev # For Debian/Ubuntu/LinuxMint $ sudo yum install openssl-devel # For Fedora/CentOS/RHEL -``` +~~~~~~ ### Clone GNSS-SDR's Git repository: -``` +~~~~~~ $ git clone git://git.code.sf.net/p/gnss-sdr/cttc gnss-sdr -``` +~~~~~~ Cloning the GNSS-SDR repository as in the line above will create a folder named gnss-sdr with the following structure: -``` +~~~~~~ |-gnss-sdr |---build <- where gnss-sdr is built |---cmake <- CMake-related files @@ -147,7 +147,7 @@ Cloning the GNSS-SDR repository as in the line above will create a folder named |-----main |-----tests |-----utils <- some utilities (e.g. Matlab scripts) -``` +~~~~~~ ###### Build GN3S V2 Custom firmware and driver (OPTIONAL): @@ -155,20 +155,20 @@ Cloning the GNSS-SDR repository as in the line above will create a folder named - Go to GR-GN3S root directory, compile and install the driver (read the drivers/gr-gn3s/README for more information): -``` +~~~~~~ $ cd gnss-sdr/drivers/gr-gn3s $ cd build $ cmake ../ $ make $ sudo make install $ sudo ldconfig -``` +~~~~~~ - Set the environment variable ```GN3S_DRIVER=1``` in order to enable the GN3S_Signal_Source in GNSS-SDR: -``` +~~~~~~ $ export GN3S_DRIVER=1 -``` +~~~~~~ In order to gain access to USB ports, gnss-sdr should be used as root. In addition, the driver requires access to the GN3S firmware binary file. @@ -182,7 +182,7 @@ Please copy this file to the application path. The GNSS-SDR default path is gnss - Install the [OsmoSDR](http://sdr.osmocom.org/trac/ "OsmoSDR's Homepage") library and GNU Radio's source block: -``` +~~~~~~ $ git clone git://git.osmocom.org/osmo-sdr.git $ cd osmo-sdr/software/libosmosdr $ mkdir build @@ -200,19 +200,19 @@ $ cmake ../ -Wno-dev $ make $ sudo make install $ sudo ldconfig -``` +~~~~~~ - Set the environment variable ```RTLSDR_DRIVER=1``` in order to enable the Rtlsdr_Signal_Source in GNSS-SDR: -``` +~~~~~~ $ export RTLSDR_DRIVER=1 -``` +~~~~~~ - In order to compile the RTLSDR adapter you should also provide the path to the gr-osmosdr source code using: -``` +~~~~~~ $ export OSMOSDR_ROOT=/path/to/gr-osmosdr -``` +~~~~~~ The default will be ```OSMOSDR_ROOT=/usr/local``` @@ -222,72 +222,72 @@ The default will be ```OSMOSDR_ROOT=/usr/local``` - Go to GNSS-SDR's build directory: -``` +~~~~~~ $ cd gnss-sdr/build -``` +~~~~~~ - Configure and build the application: -``` +~~~~~~ $ cmake ../ $ make -``` +~~~~~~ By default, CMake is configured to build the release version. If you want to build the debug version, please use: -``` -cmake ../ -DCMAKE_BUILD_TYPE=Debug -``` +~~~~~~ +$ cmake ../ -DCMAKE_BUILD_TYPE=Debug +~~~~~~ - Move the executables to the install folder: -``` +~~~~~~ $ make install -``` +~~~~~~ - If everything goes well, two new executables will be created at gnss-sdr/install, namely ```gnss-sdr``` and ```run_tests```. - You can create the documentation by doing: -``` +~~~~~~ $ make doc -``` +~~~~~~ from the gnss-sdr/build folder. This will generate HTML documentation that can be retrieved pointing your browser of preference to gnss-sdr/docs/html/index.html. If a LaTeX installation is detected in your system, -``` +~~~~~~ $ make pdfmanual -``` +~~~~~~ will create a PDF manual at gnss-sdr/docs/GNSS-SDR_manual.pdf. Please note that the PDF generation requires some fonts to be installed on the host system. In Ubuntu 12.10, those fonts do not come by default. You can install them by doing: -``` +~~~~~~ $ sudo apt-get install texlive-fonts-recommended -``` +~~~~~~ and then run ```cmake ../``` and make pdfmanual again. Finally, -``` +~~~~~~ $ make doc-clean -``` +~~~~~~ will remove the content of previously-generated documentation. - By default, CMake will build the Release version, meaning that the compiler will generate a faster, optimized executable. This is the recommended build type when using a RF front-end and you need to attain real time. If you are working with a file (and thus without real-time constraints), you may want to obtain more information about the internals of the receiver, as well as more fine-grained logging. This can be done by building the Debug version, by doing: -``` +~~~~~~ $ cd gnss-sdr/build $ cmake -DCMAKE_BUILD_TYPE=Debug ../ $ make $ make install -``` +~~~~~~ - If you are using Eclipse as your development environment, CMake can create the project for you. Type: -``` +~~~~~~ $ cmake -G "Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DECLIPSE_CDT4_GENERATE_SOURCE_PROJECT=TRUE -DCMAKE_ECLIPSE_VERSION=3.7 -DCMAKE_ECLIPSE_MAKE_ARGUMENTS=-j8 ../ -``` +~~~~~~ and then import the created project file into Eclipse: @@ -312,55 +312,55 @@ Then, [install Macports](http://www.macports.org/install.php). If you are upgrad In a terminal, type: -``` +~~~~~~ $ sudo port selfupdate $ sudo port upgrade outdated $ sudo port install doxygen +latex $ sudo port install uhd gnuradio $ sudo port install armadillo -``` +~~~~~~ Install [Gflags](http://code.google.com/p/gflags/ "Gflags' Homepage") manually from the trunk: -``` +~~~~~~ $ svn checkout http://gflags.googlecode.com/svn/trunk gflags-trunk $ cd gflags-trunk $ CXXFLAGS="-stdlib=libc++" CC=clang CXX=clang++ ./configure $ make $ sudo make install -``` +~~~~~~ Install [Glog](http://code.google.com/p/google-glog/ "Glog's Homepage") manually from the subversion repository. Revision 142 is known to work well: -``` +~~~~~~ $ svn checkout -r142 http://google-glog.googlecode.com/svn/trunk/ google-glog $ cd google-glog $ CXXFLAGS="-stdlib=libc++" CC=clang CXX=clang++ ./configure $ make $ sudo make install -``` +~~~~~~ Finally, you are ready to clone the GNSS-SDR repository and build the software: -``` +~~~~~~ $ git clone git://git.code.sf.net/p/gnss-sdr/cttc gnss-sdr $ cd gnss-sdr/build $ cmake ../ -DCMAKE_CXX_COMPILER=/usr/bin/clang++ $ make $ make install -``` +~~~~~~ This will create two executables at gnss-sdr/install, namely ```gnss-sdr``` and ```run_tests```. The documentation can be built by: -``` +~~~~~~ $ make doc -``` +~~~~~~ and can be viewed doing: -``` +~~~~~~ $ open ../docs/html/index.html -``` +~~~~~~ ### Mac OS X 10.8 Mountain Lion @@ -374,50 +374,50 @@ Then, install Macports via [Mac OS X Package (.pkg) installer](http://www.macpor Once MacPorts is properly installed on your system, open a terminal and type: -``` +~~~~~~ $ sudo port selfupdate $ sudo port install gcc48 $ sudo port select --set gcc mp-gcc48 -``` +~~~~~~ Install [X11 via XQuartz-2.7.4.dmg](http://xquartz.macosforge.org/landing/) (needed by gnuradio-companion but not by GNSS-SDR). Install GNU Radio: -``` +~~~~~~ $ sudo port install gnuradio -``` +~~~~~~ Install other dependencies: -``` +~~~~~~ $ sudo port install armadillo -``` +~~~~~~ The libraries [Gflags](http://code.google.com/p/gflags/ "Gflags' Homepage") and [Glog](http://code.google.com/p/google-glog/ "Glog's Homepage") should be installed manually, and in that particular order (same steps as above). If they are not already installed when building GNSS-SDR, [CMake](http://www.cmake.org/ "CMake's Homepage") will download, build and link them statically for you when doing ```make```, but they will not remain installed in the system. Then, you are ready to clone the GNSS-SDR repository and build the software: -``` +~~~~~~ $ git clone git://git.code.sf.net/p/gnss-sdr/cttc gnss-sdr $ cd gnss-sdr/build $ cmake ../ -DCMAKE_CXX_COMPILER=g++ $ make $ make install -``` +~~~~~~ This will create two executables at gnss-sdr/install, namely ```gnss-sdr``` and ```run_tests```. The documentation can be built by: -``` +~~~~~~ $ make doc -``` +~~~~~~ and can be viewed doing: -``` +~~~~~~ $ open ../docs/html/index.html -``` +~~~~~~ Updating GNSS-SDR @@ -425,23 +425,23 @@ Updating GNSS-SDR If you cloned GNSS-SDR some days ago, it is possible that some developer has updated files at the Git repository. You can update your working copy by doing: -``` +~~~~~~ $ git checkout master # Switch to branch you want to update $ git pull origin master # Download the newest code from our repository -``` +~~~~~~ or, if you want to test the lastest developments: -``` +~~~~~~ $ git checkout next $ git pull origin next -``` +~~~~~~ Before rebuilding the source code, it is safe (and recommended) to remove the remainders of old compilations: -``` +~~~~~~ $ rm -rf gnss-sdr/build/* -``` +~~~~~~ If you are interested in contributing to the development of GNSS-SDR, please check out [how to do it](http://gnss-sdr.org/documentation/how-contribute-source-code "How to contribute to GNSS-SDR source code"). From 9fef34da0b4689af600a378108d81387ec59791e Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 23 Apr 2014 20:44:37 +0200 Subject: [PATCH 14/18] SourceForge & Gthub formatting --- README.md | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 5240220a9..df387ecf4 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Tested distributions: Ubuntu 12.04, 12.10, 13.04, 13.10 and 14.04 (32 and 64 bit - Downloading, building and installing [GNU Radio](http://gnuradio.org/redmine/projects/gnuradio/wiki "GNU Radio's Homepage") and all its dependencies is not a simple task. We recommend to use [PyBOMBS](http://gnuradio.org/redmine/projects/pybombs/wiki) (Python Build Overlay Managed Bundle System), the GNU Radio install management system that automatically does all the work for you. In a terminal, type: + ~~~~~~ $ git clone git://github.com/pybombs/pybombs $ cd pybombs @@ -152,8 +153,8 @@ Cloning the GNSS-SDR repository as in the line above will create a folder named ###### Build GN3S V2 Custom firmware and driver (OPTIONAL): -- Go to GR-GN3S root directory, compile and install the driver - (read the drivers/gr-gn3s/README for more information): +- Go to GR-GN3S root directory, compile and install the driver (read the drivers/gr-gn3s/README for more information): + ~~~~~~ $ cd gnss-sdr/drivers/gr-gn3s @@ -164,17 +165,16 @@ $ sudo make install $ sudo ldconfig ~~~~~~ + - Set the environment variable ```GN3S_DRIVER=1``` in order to enable the GN3S_Signal_Source in GNSS-SDR: + ~~~~~~ $ export GN3S_DRIVER=1 ~~~~~~ -In order to gain access to USB ports, gnss-sdr should be used as root. -In addition, the driver requires access to the GN3S firmware binary file. -It should be available in the same path where the application is called. -GNSS-SDR comes with a pre-compiled custom GN3S firmware available at gnss-sdr/firmware/GN3S_v2/bin/gn3s_firmware.ihx. -Please copy this file to the application path. The GNSS-SDR default path is gnss-sdr/install +In order to gain access to USB ports, gnss-sdr should be used as root. In addition, the driver requires access to the GN3S firmware binary file. It should be available in the same path where the application is called. +GNSS-SDR comes with a pre-compiled custom GN3S firmware available at gnss-sdr/firmware/GN3S_v2/bin/gn3s_firmware.ihx. Please copy this file to the application path. The GNSS-SDR default path is gnss-sdr/install (in order to disable the GN3S_Signal_Source compilation, you should remove the GN3S_DRIVER variable and build again GNSS-SDR). @@ -182,6 +182,7 @@ Please copy this file to the application path. The GNSS-SDR default path is gnss - Install the [OsmoSDR](http://sdr.osmocom.org/trac/ "OsmoSDR's Homepage") library and GNU Radio's source block: + ~~~~~~ $ git clone git://git.osmocom.org/osmo-sdr.git $ cd osmo-sdr/software/libosmosdr @@ -202,18 +203,23 @@ $ sudo make install $ sudo ldconfig ~~~~~~ + - Set the environment variable ```RTLSDR_DRIVER=1``` in order to enable the Rtlsdr_Signal_Source in GNSS-SDR: + ~~~~~~ $ export RTLSDR_DRIVER=1 ~~~~~~ + - In order to compile the RTLSDR adapter you should also provide the path to the gr-osmosdr source code using: + ~~~~~~ $ export OSMOSDR_ROOT=/path/to/gr-osmosdr ~~~~~~ + The default will be ```OSMOSDR_ROOT=/usr/local``` (in order to disable the Rtlsdr_Signal_Source compilation, you should remove the RTLSDR_DRIVER variable and build again GNSS-SDR). @@ -454,21 +460,21 @@ Getting started 1. After building the code, you will find the ```gnss-sdr``` executable file at gnss-sdr/install. 2. In post-processing mode, you have to provide a captured GNSS signal file. - 1. The signal file can be easily recorded using the GNU Radio file sink in ```gr_complex``` mode. - 2. You will need a GPS active antenna, a [USRP](http://www.ettus.com/product) and a suitable USRP daughter board to receive GPS L1 C/A signals. GNSS-SDR require to have at least 2 MHz of bandwidth in 1.57542 GHz. (remember to enable the DC bias with the daughter board jumper). + 1. The signal file can be easily recorded using the GNU Radio file sink in ```gr_complex``` mode. + 2. You will need a GPS active antenna, a [USRP](http://www.ettus.com/product) and a suitable USRP daughter board to receive GPS L1 C/A signals. GNSS-SDR require to have at least 2 MHz of bandwidth in 1.57542 GHz. (remember to enable the DC bias with the daughter board jumper). We use a [DBSRX2](https://www.ettus.com/product/details/DBSRX2) to do the task, but you can try the newer Ettus' daughter boards as well. - 3. The easiest way to capture a signal file is to use the GNU Radio Companion GUI. Only two blocks are needed: a USRP signal source connected to complex float file sink. You need to tune the USRP central frequency and decimation factor using USRP signal source properties box. We suggest using a decimation factor of 20 if you use the USRP2. This will give you 100/20 = 5 MSPS which will be enough to receive GPS L1 C/A signals. The front-end gain should also be configured. In our test with the DBSRX2 we obtained good results with ```G=50```. - 4. Capture at least 80 seconds of signal in open sky conditions. During the process, be aware of USRP driver buffer underuns messages. If your hard disk is not fast enough to write data at this speed you can capture to a virtual RAM drive. 80 seconds of signal at 5 MSPS occupies less than 3 Gbytes using ```gr_complex```. - 5. If you have no access to a RF front-end, you can download a sample raw data file (that contains GPS and Galileo signals) from [here](http://sourceforge.net/projects/gnss-sdr/files/data/). + 3. The easiest way to capture a signal file is to use the GNU Radio Companion GUI. Only two blocks are needed: a USRP signal source connected to complex float file sink. You need to tune the USRP central frequency and decimation factor using USRP signal source properties box. We suggest using a decimation factor of 20 if you use the USRP2. This will give you 100/20 = 5 MSPS which will be enough to receive GPS L1 C/A signals. The front-end gain should also be configured. In our test with the DBSRX2 we obtained good results with ```G=50```. + 4. Capture at least 80 seconds of signal in open sky conditions. During the process, be aware of USRP driver buffer underuns messages. If your hard disk is not fast enough to write data at this speed you can capture to a virtual RAM drive. 80 seconds of signal at 5 MSPS occupies less than 3 Gbytes using ```gr_complex```. + 5. If you have no access to a RF front-end, you can download a sample raw data file (that contains GPS and Galileo signals) from [here](http://sourceforge.net/projects/gnss-sdr/files/data/). 3. You are ready to configure the receiver to use your captured file among other parameters: - 1. The default configuration file resides at [./conf/gnss-sdr.conf](./conf/gnss-sdr.conf). - 2. You need to review/modify at least the following settings: - * ```SignalSource.filename=``` (absolute or relative route to your GNSS signal captured file) - * ```GNSS-SDR.internal_fs_hz=``` (captured file sampling rate in Hz) - * ```SignalSource.sampling_frequency=``` (captured file sampling rate in Hz) - * ```SignalConditioner.sample_freq_in=``` (captured file sampling rate in Hz) - * ```SignalConditioner.sample_freq_out=``` (captured file sampling rate in Hz) - * ```TelemetryDecoder.fs_in=``` (captured file sampling rate in Hz) - 3. The configuration file has in-line documentation, you can try to tune the number of channels and several receiver parameters. + 1. The default configuration file resides at [./conf/gnss-sdr.conf](./conf/gnss-sdr.conf). + 2. You need to review/modify at least the following settings: + * ```SignalSource.filename=``` (absolute or relative route to your GNSS signal captured file) + * ```GNSS-SDR.internal_fs_hz=``` (captured file sampling rate in Hz) + * ```SignalSource.sampling_frequency=``` (captured file sampling rate in Hz) + * ```SignalConditioner.sample_freq_in=``` (captured file sampling rate in Hz) + * ```SignalConditioner.sample_freq_out=``` (captured file sampling rate in Hz) + * ```TelemetryDecoder.fs_in=``` (captured file sampling rate in Hz) + 3. The configuration file has in-line documentation, you can try to tune the number of channels and several receiver parameters. 4. Run the receiver from the install directory. The program reports the current status in text mode, directly to the terminal window. If all goes well, and GNSS-SDR is able to successfully track an decode at least 4 satellites, you will get PVT fixes. The program will write a .kml file and RINEX (yet experimental) files in the install directory. In addition to the console output, GNSS-SDR also writes log files at /tmp/ (configurable with the commandline flag ```./gnss-sdr --log_dir=/path/to/log```). From be1403082d4b5edc36292e7c842bd90e5b4d2f61 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 23 Apr 2014 20:52:50 +0200 Subject: [PATCH 15/18] Markdown that looks nice at SourceForge and at GitHub --- README.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index df387ecf4..212deb60b 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Tested distributions: Ubuntu 12.04, 12.10, 13.04, 13.10 and 14.04 (32 and 64 bit ### Install GNU Radio: -- Downloading, building and installing [GNU Radio](http://gnuradio.org/redmine/projects/gnuradio/wiki "GNU Radio's Homepage") and all its dependencies is not a simple task. We recommend to use [PyBOMBS](http://gnuradio.org/redmine/projects/pybombs/wiki) (Python Build Overlay Managed Bundle System), the GNU Radio install management system that automatically does all the work for you. In a terminal, type: +Downloading, building and installing [GNU Radio](http://gnuradio.org/redmine/projects/gnuradio/wiki "GNU Radio's Homepage") and all its dependencies is not a simple task. We recommend to use [PyBOMBS](http://gnuradio.org/redmine/projects/pybombs/wiki) (Python Build Overlay Managed Bundle System), the GNU Radio install management system that automatically does all the work for you. In a terminal, type: ~~~~~~ @@ -153,7 +153,7 @@ Cloning the GNSS-SDR repository as in the line above will create a folder named ###### Build GN3S V2 Custom firmware and driver (OPTIONAL): -- Go to GR-GN3S root directory, compile and install the driver (read the drivers/gr-gn3s/README for more information): +Go to GR-GN3S root directory, compile and install the driver (read the drivers/gr-gn3s/README for more information): ~~~~~~ @@ -166,7 +166,7 @@ $ sudo ldconfig ~~~~~~ -- Set the environment variable ```GN3S_DRIVER=1``` in order to enable the GN3S_Signal_Source in GNSS-SDR: +Set the environment variable ```GN3S_DRIVER=1``` in order to enable the GN3S_Signal_Source in GNSS-SDR: ~~~~~~ @@ -180,7 +180,7 @@ GNSS-SDR comes with a pre-compiled custom GN3S firmware available at gnss-sdr/fi ###### Build RTL-SDR support (OPTIONAL): -- Install the [OsmoSDR](http://sdr.osmocom.org/trac/ "OsmoSDR's Homepage") library and GNU Radio's source block: +Install the [OsmoSDR](http://sdr.osmocom.org/trac/ "OsmoSDR's Homepage") library and GNU Radio's source block: ~~~~~~ @@ -204,7 +204,7 @@ $ sudo ldconfig ~~~~~~ -- Set the environment variable ```RTLSDR_DRIVER=1``` in order to enable the Rtlsdr_Signal_Source in GNSS-SDR: +Set the environment variable ```RTLSDR_DRIVER=1``` in order to enable the Rtlsdr_Signal_Source in GNSS-SDR: ~~~~~~ @@ -212,7 +212,7 @@ $ export RTLSDR_DRIVER=1 ~~~~~~ -- In order to compile the RTLSDR adapter you should also provide the path to the gr-osmosdr source code using: +In order to compile the RTLSDR adapter you should also provide the path to the gr-osmosdr source code using: ~~~~~~ @@ -226,13 +226,13 @@ The default will be ```OSMOSDR_ROOT=/usr/local``` ### Build GNSS-SDR -- Go to GNSS-SDR's build directory: +Go to GNSS-SDR's build directory: ~~~~~~ $ cd gnss-sdr/build ~~~~~~ -- Configure and build the application: +Configure and build the application: ~~~~~~ $ cmake ../ @@ -245,15 +245,15 @@ By default, CMake is configured to build the release version. If you want to bui $ cmake ../ -DCMAKE_BUILD_TYPE=Debug ~~~~~~ -- Move the executables to the install folder: +Move the executables to the install folder: ~~~~~~ $ make install ~~~~~~ -- If everything goes well, two new executables will be created at gnss-sdr/install, namely ```gnss-sdr``` and ```run_tests```. +If everything goes well, two new executables will be created at gnss-sdr/install, namely ```gnss-sdr``` and ```run_tests```. -- You can create the documentation by doing: +You can create the documentation by doing: ~~~~~~ $ make doc @@ -280,7 +280,7 @@ $ make doc-clean will remove the content of previously-generated documentation. -- By default, CMake will build the Release version, meaning that the compiler will generate a faster, optimized executable. This is the recommended build type when using a RF front-end and you need to attain real time. If you are working with a file (and thus without real-time constraints), you may want to obtain more information about the internals of the receiver, as well as more fine-grained logging. This can be done by building the Debug version, by doing: +By default, CMake will build the Release version, meaning that the compiler will generate a faster, optimized executable. This is the recommended build type when using a RF front-end and you need to attain real time. If you are working with a file (and thus without real-time constraints), you may want to obtain more information about the internals of the receiver, as well as more fine-grained logging. This can be done by building the Debug version, by doing: ~~~~~~ $ cd gnss-sdr/build @@ -289,7 +289,7 @@ $ make $ make install ~~~~~~ -- If you are using Eclipse as your development environment, CMake can create the project for you. Type: +If you are using Eclipse as your development environment, CMake can create the project for you. Type: ~~~~~~ $ cmake -G "Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DECLIPSE_CDT4_GENERATE_SOURCE_PROJECT=TRUE -DCMAKE_ECLIPSE_VERSION=3.7 -DCMAKE_ECLIPSE_MAKE_ARGUMENTS=-j8 ../ From 274a4f2a78fdaae3ee6bb6b9c420075ac6b1dd1c Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 23 Apr 2014 20:59:46 +0200 Subject: [PATCH 16/18] Adding logo --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 212deb60b..5abb6fb97 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +![GNSS-SDR logo](./docs/doxygen/images/gnss-sdr_logo.png) + **Welcome to GNSS-SDR!** Check [gnss-sdr.org](http://gnss-sdr.org "GNSS-SDR's Homepage") for more information about this open source GNSS software defined receiver. From 50a900afbfe1a1b770b8835b4db89931cc4ce558 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 23 Apr 2014 21:08:15 +0200 Subject: [PATCH 17/18] Adding logo --- README.md | 4 ++-- docs/doxygen/images/gnss-sdr_logo.gif | Bin 0 -> 2201 bytes 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 docs/doxygen/images/gnss-sdr_logo.gif diff --git a/README.md b/README.md index 5abb6fb97..e36e7f194 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -![GNSS-SDR logo](./docs/doxygen/images/gnss-sdr_logo.png) +![GNSS-SDR logo](./docs/doxygen/images/gnss-sdr_logo.gif) **Welcome to GNSS-SDR!** -Check [gnss-sdr.org](http://gnss-sdr.org "GNSS-SDR's Homepage") for more information about this open source GNSS software defined receiver. +Visit [gnss-sdr.org](http://gnss-sdr.org "GNSS-SDR's Homepage") for more information about this open source GNSS software defined receiver. If you have questions about GNSS-SDR, please [subscribe to the gnss-sdr-developers mailing list](http://lists.sourceforge.net/lists/listinfo/gnss-sdr-developers "Subscribe to the gnss-sdr-developers mailing list" ) and post your questions there. diff --git a/docs/doxygen/images/gnss-sdr_logo.gif b/docs/doxygen/images/gnss-sdr_logo.gif new file mode 100644 index 0000000000000000000000000000000000000000..cc9ac860fb507f951d2376e35ea63bb7b3b0ae69 GIT binary patch literal 2201 zcmV;K2xj+3Nk%w1VT=Gy0K@~*OQVju<;FL8ETf!7cE}PHCYMA?r5)M?Wh@o9K zT;TNs&F}k*2}=nM4+={LP)vIPYF7aUO%H`j5h4&x2o8Y+3V)uTeM~KliGm`e0eKE{ zOK<@LOHT_-ptZI}aw)U{Zc90+O)|TAEw4+fx5>%@xgxv0VvM;JgaphYrr8aUYKpv@sBO786lgGfe5CJ_MtUR*iEN`p0}3PhkL&OshZIvQ}Jrjn&k zUH2S5lOj~44hK7*$k4>3ZQ)U)D-M!Uqs zQCe-x;EK35_UtJL5eC%RB49v-0^aQ5i)+=*lm&a;8qH>Pmxy(~kg z+$cdh_5j*NdJU+08|&O$Y&qS0;_yJ#F)J4c45I*WkWGgQRNayi$%6GbV~$)5pTKb7 zZ`KJ>KxO}!2-SO9u?7T<@e#qmPH#Y0ghm|Mm=i}ta)bnsMH1Nu zj)x#IUW`XTBY=-UxCYxB9qRDmWeS`y1dFmMkfjk!f_Ma&RC>6V03`+h!IfJm;G;gV z39twdMagzRU`13lB^f)Zc;;SE2GLxd(9tQIpwh^;#+X5Dn5GL3K+wY$ZLYZ2eJP-z z=w)ms97Eprg9pZsZCUr=cuj-ffy5vGQy*y z{>hp`b^=s%tQ7?$FrqpXuJM=uOs?vh=Kv){JFS_9wiUzz=<$k48R$7U!Ws$?lwDIY z=%Zp5VVJcPd3eI6t{1Pe#$UY=@bD@R^(CO}u*WQ0FKdTZb56oXtr1vJjBaT!5P<@* z<#mzxzPvdcY%BHn3 zkwX}R>5%oq-2_q8U@qswvX;ck&BV^u1Ve<=1l&nPcE7ffdI8=YDUkH4|Ll9eInQQVtYYGHf?4X~mWfE)nR3?snK)jHOTN zihnIR5F6g^P|IE~RW28+MozjA*-f&AQ+RSz*Y9=*f6CrLFzzPmGLU9?<8ZgR)1)d8 zTYTMRU|%Za!n5A#8UT@|Lxei4pWooa6VVo~To_+;hW5VXbxnREC?4tZ@HrMyPbdd~ zfCCV~BkBcVAxGdwC!U2FApyaCk27H2I<-FPv1l+SF5Yjc`7Q!%|ZYgk5l@T3>M!Z$gXr1EG zgwP{K_5lHdLpX^Y&ta<<$!1Jvj9(gm<*2bO;3gAdVhWtbD2G_Eb%y++V`T7xJQ9F5 zk))ys|Hy_diUW-EYXWVUWWyBL&j?yfw&IKV4bPNIj)m2T^NwQ=TD0Uyx66)-c4V178Q~_Ga$3>MIRn@T&2$AU zX8#JwI+=0*Ds*gIiZH!cgzV@_2;;$3I=Klxfo61)+)Ls{aTdPK3Bi*_nBfnPfHUnu z6QfZa=r1>VI{A&qa5`O89e62(6`m<-KDC|W+Ue5~f>M4g+Sj`vl{+FFNLJz_OfwN5EtMyn=X6bCe zdXOke>l}-*#Ni7^LwU1Q(bnC zf;}A_%k%~aYrH_kunMFQKk( zGNqj`>!<+;3A}WxT@%?uhF&oB2+e`4ttPX~%n;#U&N0BGm^5N?-Xy?8fChcXg-J4? zC~7idNpl3y-~%@K3oK5uPqu_1Tt2wK`uL=jE%JcMaLfo*88TT$)Y~n8L$OcP(b=># zA~~7aE_4z=1k?tm7(HOOB+2ia!NJfqzzQ&RDcWV8vu7zYg_SgHa-mtm00U$fSq5+x b;i65n0uIuU!IRGPko@V-2Xq(-Apih7UH{6_ literal 0 HcmV?d00001 From 697ef54b419dbe9968ddc12a310bcb2e964d25d3 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 23 Apr 2014 21:12:01 +0200 Subject: [PATCH 18/18] Sourceforge does not show the logo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e36e7f194..875190bb0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![GNSS-SDR logo](./docs/doxygen/images/gnss-sdr_logo.gif) +![](./docs/doxygen/images/gnss-sdr_logo.png) **Welcome to GNSS-SDR!**