From 78362e7cba815cda4addc5b0e4f568bd300163a9 Mon Sep 17 00:00:00 2001 From: Jim Melton Date: Tue, 9 Feb 2021 15:47:34 -0700 Subject: [PATCH] add signal_source_interface also adds a base implementation that most signal sources should inherit from. The gen_signal_source is inexplicably different (probably as a test fixture, commonality was not valued). Only the file_signal_source has been tested; all the sources are modified in the same way, but we all know the only proof of correctness is testing. The block factory was simplified a bit. Handling for legacy config files was pulled out of the flowgraph; now when the "0" instance of a component (Foo0) is created, if there is no config for it, then the legacy version (Foo) will be tried. This is different from passing -1 for the item number (which is still supported). Theoretically, all existing config files should still work. --- CMakeLists.txt | 16 +- .../signal_source/adapters/CMakeLists.txt | 2 + .../adapters/ad9361_fpga_signal_source.cc | 5 +- .../adapters/ad9361_fpga_signal_source.h | 13 +- .../adapters/custom_udp_signal_source.cc | 6 +- .../adapters/custom_udp_signal_source.h | 20 +- .../adapters/file_signal_source.cc | 9 +- .../adapters/file_signal_source.h | 22 +- .../adapters/flexiband_signal_source.cc | 5 +- .../adapters/flexiband_signal_source.h | 19 +- .../adapters/fmcomms2_signal_source.cc | 4 +- .../adapters/fmcomms2_signal_source.h | 19 +- .../adapters/gen_signal_source.h | 2 + .../adapters/gn3s_signal_source.cc | 5 +- .../adapters/gn3s_signal_source.h | 21 +- .../adapters/labsat_signal_source.cc | 7 +- .../adapters/labsat_signal_source.h | 19 +- .../multichannel_file_signal_source.cc | 18 +- .../multichannel_file_signal_source.h | 19 +- .../adapters/nsr_file_signal_source.cc | 13 +- .../adapters/nsr_file_signal_source.h | 18 +- .../adapters/osmosdr_signal_source.cc | 6 +- .../adapters/osmosdr_signal_source.h | 19 +- .../adapters/plutosdr_signal_source.cc | 6 +- .../adapters/plutosdr_signal_source.h | 18 +- .../adapters/raw_array_signal_source.cc | 5 +- .../adapters/raw_array_signal_source.h | 21 +- .../adapters/rtl_tcp_signal_source.cc | 7 +- .../adapters/rtl_tcp_signal_source.h | 20 +- .../adapters/signal_source_base.cc | 46 + .../adapters/signal_source_base.h | 52 + .../adapters/spir_file_signal_source.cc | 6 +- .../adapters/spir_file_signal_source.h | 18 +- .../spir_gss6450_file_signal_source.cc | 5 +- .../spir_gss6450_file_signal_source.h | 16 +- .../two_bit_cpx_file_signal_source.cc | 7 +- .../adapters/two_bit_cpx_file_signal_source.h | 18 +- .../two_bit_packed_file_signal_source.cc | 8 +- .../two_bit_packed_file_signal_source.h | 18 +- .../adapters/uhd_signal_source.cc | 5 +- .../adapters/uhd_signal_source.h | 18 +- src/core/interfaces/signal_source_interface.h | 21 +- src/core/receiver/gnss_block_factory.cc | 1311 ++++++++--------- src/core/receiver/gnss_block_factory.h | 3 +- src/core/receiver/gnss_flowgraph.cc | 102 +- src/core/receiver/gnss_flowgraph.h | 3 +- .../control-plane/gnss_block_factory_test.cc | 5 +- src/utils/front-end-cal/main.cc | 64 +- 48 files changed, 948 insertions(+), 1142 deletions(-) create mode 100644 src/algorithms/signal_source/adapters/signal_source_base.cc create mode 100644 src/algorithms/signal_source/adapters/signal_source_base.h diff --git a/CMakeLists.txt b/CMakeLists.txt index fe0f20d8f..e9523274c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -586,14 +586,14 @@ endif() ################################################################################ # Log4cpp - http://log4cpp.sourceforge.net/ ################################################################################ -#find_package(LOG4CPP) -#set_package_properties(LOG4CPP PROPERTIES -# PURPOSE "Required by GNU Radio." -# TYPE REQUIRED -#) -#if(NOT LOG4CPP_FOUND) -# message(FATAL_ERROR "*** Log4cpp is required to build gnss-sdr") -#endif() +find_package(LOG4CPP) +set_package_properties(LOG4CPP PROPERTIES + PURPOSE "Required by GNU Radio." + TYPE REQUIRED +) +if(NOT LOG4CPP_FOUND) + message(FATAL_ERROR "*** Log4cpp is required to build gnss-sdr") +endif() diff --git a/src/algorithms/signal_source/adapters/CMakeLists.txt b/src/algorithms/signal_source/adapters/CMakeLists.txt index 3bd766ff1..93377a6ad 100644 --- a/src/algorithms/signal_source/adapters/CMakeLists.txt +++ b/src/algorithms/signal_source/adapters/CMakeLists.txt @@ -92,6 +92,7 @@ endif() set(SIGNAL_SOURCE_ADAPTER_SOURCES + signal_source_base.cc file_signal_source.cc multichannel_file_signal_source.cc gen_signal_source.cc @@ -106,6 +107,7 @@ set(SIGNAL_SOURCE_ADAPTER_SOURCES ) set(SIGNAL_SOURCE_ADAPTER_HEADERS + signal_source_base.h file_signal_source.h multichannel_file_signal_source.h gen_signal_source.h diff --git a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc index 613e981b8..c95f3838e 100644 --- a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc +++ b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc @@ -42,9 +42,12 @@ #include +using namespace std::string_literals; + Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(const ConfigurationInterface *configuration, const std::string &role, unsigned int in_stream, unsigned int out_stream, - Concurrent_Queue *queue __attribute__((unused))) : role_(role), in_stream_(in_stream), out_stream_(out_stream) + Concurrent_Queue *queue __attribute__((unused))) + : SignalSourceBase(configuration, role, "Ad9361_Fpga_Signal_Source"s), in_stream_(in_stream), out_stream_(out_stream) { const std::string default_gain_mode("slow_attack"); const double default_tx_attenuation_db = -10.0; diff --git a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.h b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.h index 6ac364fe0..aba363509 100644 --- a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.h +++ b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.h @@ -18,7 +18,7 @@ #ifndef GNSS_SDR_AD9361_FPGA_SIGNAL_SOURCE_H #define GNSS_SDR_AD9361_FPGA_SIGNAL_SOURCE_H -#include "signal_source_interface.h" +#include "signal_source_base.h" #include "concurrent_queue.h" #include "fpga_dynamic_bit_selection.h" @@ -40,7 +40,7 @@ class ConfigurationInterface; -class Ad9361FpgaSignalSource : public SignalSourceInterface +class Ad9361FpgaSignalSource : public SignalSourceBase { public: Ad9361FpgaSignalSource(const ConfigurationInterface *configuration, @@ -51,17 +51,12 @@ public: void start() override; - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "Ad9361_Fpga_Signal_Source" */ inline std::string implementation() override { - return "Ad9361_Fpga_Signal_Source"; + return ; } inline size_t item_size() override @@ -93,8 +88,6 @@ private: std::shared_ptr switch_fpga; std::shared_ptr dynamic_bit_selection_fpga; - std::string role_; - // Front-end settings std::string gain_mode_rx1_; std::string gain_mode_rx2_; diff --git a/src/algorithms/signal_source/adapters/custom_udp_signal_source.cc b/src/algorithms/signal_source/adapters/custom_udp_signal_source.cc index efacc52cd..aeb91711a 100644 --- a/src/algorithms/signal_source/adapters/custom_udp_signal_source.cc +++ b/src/algorithms/signal_source/adapters/custom_udp_signal_source.cc @@ -21,9 +21,13 @@ #include +using namespace std::string_literals; + CustomUDPSignalSource::CustomUDPSignalSource(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_stream, unsigned int out_stream, - Concurrent_Queue* queue __attribute__((unused))) : role_(role), in_stream_(in_stream), out_stream_(out_stream) + Concurrent_Queue* queue __attribute__((unused))) + : SignalSourceBase(configuration, role, "Custom_UDP_Signal_Source"s) + , in_stream_(in_stream), out_stream_(out_stream) { // DUMP PARAMETERS const std::string default_dump_file("./data/signal_source.dat"); diff --git a/src/algorithms/signal_source/adapters/custom_udp_signal_source.h b/src/algorithms/signal_source/adapters/custom_udp_signal_source.h index af85a4696..0f66a4611 100644 --- a/src/algorithms/signal_source/adapters/custom_udp_signal_source.h +++ b/src/algorithms/signal_source/adapters/custom_udp_signal_source.h @@ -18,10 +18,9 @@ #ifndef GNSS_SDR_CUSTOM_UDP_SIGNAL_SOURCE_H #define GNSS_SDR_CUSTOM_UDP_SIGNAL_SOURCE_H -#include "signal_source_interface.h" +#include "signal_source_base.h" #include "concurrent_queue.h" -#include "gnss_block_interface.h" #include "gr_complex_ip_packet_source.h" #include #include @@ -42,29 +41,15 @@ class ConfigurationInterface; * \brief This class reads from UDP packets, which streams interleaved * I/Q samples over a network. */ -class CustomUDPSignalSource : public SignalSourceInterface +class CustomUDPSignalSource : public SignalSourceBase { public: - void fixme() final {} CustomUDPSignalSource(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_stream, unsigned int out_stream, Concurrent_Queue* queue); ~CustomUDPSignalSource() = default; - inline std::string role() override - { - return role_; - } - - /*! - * \brief Returns "Custom_UDP_Signal_Source" - */ - inline std::string implementation() override - { - return "Custom_UDP_Signal_Source"; - } - inline size_t item_size() override { return item_size_; @@ -81,7 +66,6 @@ private: std::vector> null_sinks_; std::vector> file_sink_; - std::string role_; std::string item_type_; std::string dump_filename_; diff --git a/src/algorithms/signal_source/adapters/file_signal_source.cc b/src/algorithms/signal_source/adapters/file_signal_source.cc index e41596689..120bda664 100644 --- a/src/algorithms/signal_source/adapters/file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/file_signal_source.cc @@ -27,10 +27,13 @@ #include // for std::cerr #include +using namespace std::string_literals; -FileSignalSource::FileSignalSource(const ConfigurationInterface* configuration, - const std::string& role, unsigned int in_streams, unsigned int out_streams, - Concurrent_Queue* queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams) +FileSignalSource::FileSignalSource(ConfigurationInterface const* configuration, + std::string const& role, unsigned int in_streams, unsigned int out_streams, + Concurrent_Queue* queue) + : SignalSourceBase(configuration, role, "File_Signal_Source"s) +, in_streams_(in_streams), out_streams_(out_streams) { const std::string default_filename("./example_capture.dat"); const std::string default_item_type("short"); diff --git a/src/algorithms/signal_source/adapters/file_signal_source.h b/src/algorithms/signal_source/adapters/file_signal_source.h index ab4a234fa..754698446 100644 --- a/src/algorithms/signal_source/adapters/file_signal_source.h +++ b/src/algorithms/signal_source/adapters/file_signal_source.h @@ -21,10 +21,9 @@ #ifndef GNSS_SDR_FILE_SIGNAL_SOURCE_H #define GNSS_SDR_FILE_SIGNAL_SOURCE_H -#include "signal_source_interface.h" +#include "signal_source_base.h" #include "concurrent_queue.h" -#include "gnss_block_interface.h" #include #include #include @@ -47,29 +46,15 @@ class ConfigurationInterface; * \brief Class that reads signals samples from a file * and adapts it to a SignalSourceInterface */ -class FileSignalSource : public SignalSourceInterface +class FileSignalSource : public SignalSourceBase { public: - void fixme() final {} - FileSignalSource(const ConfigurationInterface* configuration, const std::string& role, + FileSignalSource(ConfigurationInterface const* configuration, std::string const& role, unsigned int in_streams, unsigned int out_streams, Concurrent_Queue* queue); ~FileSignalSource() = default; - inline std::string role() override - { - return role_; - } - - /*! - * \brief Returns "File_Signal_Source". - */ - inline std::string implementation() override - { - return "File_Signal_Source"; - } - inline size_t item_size() override { return item_size_; @@ -111,7 +96,6 @@ private: gr::blocks::file_sink::sptr sink_; gr::blocks::throttle::sptr throttle_; - std::string role_; std::string item_type_; std::string filename_; std::string dump_filename_; diff --git a/src/algorithms/signal_source/adapters/flexiband_signal_source.cc b/src/algorithms/signal_source/adapters/flexiband_signal_source.cc index 4b3996b9e..39f79ffe1 100644 --- a/src/algorithms/signal_source/adapters/flexiband_signal_source.cc +++ b/src/algorithms/signal_source/adapters/flexiband_signal_source.cc @@ -23,12 +23,15 @@ #include #include +using namespace std::string_literals; + FlexibandSignalSource::FlexibandSignalSource(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_stream, unsigned int out_stream, - Concurrent_Queue* queue __attribute__((unused))) : role_(role), in_stream_(in_stream), out_stream_(out_stream) + Concurrent_Queue* queue __attribute__((unused))) + : SignalSourceBase(configuration, role, "Flexiband_Signal_Source"s), in_stream_(in_stream), out_stream_(out_stream) { const std::string default_item_type("byte"); item_type_ = configuration->property(role + ".item_type", default_item_type); diff --git a/src/algorithms/signal_source/adapters/flexiband_signal_source.h b/src/algorithms/signal_source/adapters/flexiband_signal_source.h index a63fc1de1..ae22d82d7 100644 --- a/src/algorithms/signal_source/adapters/flexiband_signal_source.h +++ b/src/algorithms/signal_source/adapters/flexiband_signal_source.h @@ -20,10 +20,9 @@ #ifndef GNSS_SDR_FLEXIBAND_SIGNAL_SOURCE_H #define GNSS_SDR_FLEXIBAND_SIGNAL_SOURCE_H -#include "signal_source_interface.h" +#include "signal_source_base.h" #include "concurrent_queue.h" -#include "gnss_block_interface.h" #include #include #include @@ -47,7 +46,7 @@ class ConfigurationInterface; * \brief This class configures and reads samples from Teleorbit Flexiband front-end. * This software requires a Flexiband GNU Radio driver installed (not included with GNSS-SDR). */ -class FlexibandSignalSource : public SignalSourceInterface +class FlexibandSignalSource : public SignalSourceBase { public: FlexibandSignalSource(const ConfigurationInterface* configuration, @@ -56,19 +55,6 @@ public: ~FlexibandSignalSource() = default; - inline std::string role() override - { - return role_; - } - - /*! - * \brief Returns "Flexiband_Signal_Source". - */ - inline std::string implementation() override - { - return "Flexiband_Signal_Source"; - } - inline size_t item_size() override { return item_size_; @@ -87,7 +73,6 @@ private: std::vector> float_to_complex_; std::vector null_sinks_; - std::string role_; std::string item_type_; std::string firmware_filename_; std::string signal_file; diff --git a/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc b/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc index c685cae28..b48e240a0 100644 --- a/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc +++ b/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc @@ -29,10 +29,12 @@ #include #include +using namespace std::string_literals; Fmcomms2SignalSource::Fmcomms2SignalSource(const ConfigurationInterface *configuration, const std::string &role, unsigned int in_stream, unsigned int out_stream, - Concurrent_Queue *queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream) + Concurrent_Queue *queue) + : SignalSourceBase(configuration, role, "Fmcomms2_Signal_Source"s), in_stream_(in_stream), out_stream_(out_stream) { const std::string default_item_type("gr_complex"); const std::string default_dump_file("./data/signal_source.dat"); diff --git a/src/algorithms/signal_source/adapters/fmcomms2_signal_source.h b/src/algorithms/signal_source/adapters/fmcomms2_signal_source.h index 7d35629c5..9b62c715f 100644 --- a/src/algorithms/signal_source/adapters/fmcomms2_signal_source.h +++ b/src/algorithms/signal_source/adapters/fmcomms2_signal_source.h @@ -20,9 +20,8 @@ #ifndef GNSS_SDR_FMCOMMS2_SIGNAL_SOURCE_H #define GNSS_SDR_FMCOMMS2_SIGNAL_SOURCE_H -#include "signal_source_interface.h" +#include "signal_source_base.h" -#include "gnss_block_interface.h" #include #if GRIIO_INCLUDE_HAS_GNURADIO #include @@ -43,7 +42,7 @@ class ConfigurationInterface; -class Fmcomms2SignalSource : public SignalSourceInterface +class Fmcomms2SignalSource : public SignalSourceBase { public: Fmcomms2SignalSource(const ConfigurationInterface* configuration, @@ -52,19 +51,6 @@ public: ~Fmcomms2SignalSource(); - inline std::string role() override - { - return role_; - } - - /*! - * \brief Returns "Fmcomms2_Signal_Source" - */ - inline std::string implementation() override - { - return "Fmcomms2_Signal_Source"; - } - inline size_t item_size() override { return item_size_; @@ -80,7 +66,6 @@ private: gnss_shared_ptr valve_; gr::blocks::file_sink::sptr file_sink_; - std::string role_; std::string item_type_; std::string dump_filename_; diff --git a/src/algorithms/signal_source/adapters/gen_signal_source.h b/src/algorithms/signal_source/adapters/gen_signal_source.h index c75d02526..bc2a55ba6 100644 --- a/src/algorithms/signal_source/adapters/gen_signal_source.h +++ b/src/algorithms/signal_source/adapters/gen_signal_source.h @@ -55,6 +55,8 @@ public: //! Returns "Signal Source" inline std::string implementation() override { return "Signal Source"; } inline size_t item_size() override { return 0; } + inline size_t getRfChannels() const final { return 0; } + inline std::shared_ptr signal_generator() const { return signal_generator_; } private: diff --git a/src/algorithms/signal_source/adapters/gn3s_signal_source.cc b/src/algorithms/signal_source/adapters/gn3s_signal_source.cc index abc0dc58a..d6cf9ea76 100644 --- a/src/algorithms/signal_source/adapters/gn3s_signal_source.cc +++ b/src/algorithms/signal_source/adapters/gn3s_signal_source.cc @@ -20,12 +20,15 @@ #include #include +using namespace std::string_literals; + Gn3sSignalSource::Gn3sSignalSource(const ConfigurationInterface* configuration, std::string role, unsigned int in_stream, unsigned int out_stream, - Concurrent_Queue* queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream) + Concurrent_Queue* queue) + : SignalSourceBase(configuration, role, "Gn3s_Signal_Source"s), in_stream_(in_stream), out_stream_(out_stream) { const std::string default_item_type("short"); const std::string default_dump_file("./data/gn3s_source.dat"); diff --git a/src/algorithms/signal_source/adapters/gn3s_signal_source.h b/src/algorithms/signal_source/adapters/gn3s_signal_source.h index 2081b9da5..dd26b8ff8 100644 --- a/src/algorithms/signal_source/adapters/gn3s_signal_source.h +++ b/src/algorithms/signal_source/adapters/gn3s_signal_source.h @@ -18,10 +18,9 @@ #ifndef GNSS_SDR_GN3S_SIGNAL_SOURCE_H #define GNSS_SDR_GN3S_SIGNAL_SOURCE_H -#include "signal_source_interface.h" +#include "signal_source_base.h" #include "concurrent_queue.h" -#include "gnss_block_interface.h" #include #include #include @@ -40,7 +39,7 @@ class ConfigurationInterface; /*! * \brief This class reads samples from a GN3S USB dongle, a RF front-end signal sampler */ -class Gn3sSignalSource : public SignalSourceInterface +class Gn3sSignalSource : public SignalSourceBase { public: Gn3sSignalSource(const ConfigurationInterface* configuration, @@ -49,19 +48,6 @@ public: ~Gn3sSignalSource() = default; - inline std::string role() override - { - return role_; - } - - /*! - * \brief Returns "Gn3s_Signal_Source". - */ - inline std::string implementation() override - { - return "Gn3s_Signal_Source"; - } - inline size_t item_size() override { return item_size_; @@ -75,11 +61,10 @@ public: private: gr::block_sptr gn3s_source_; gr::blocks::file_sink::sptr file_sink_; - std::string role_; std::string item_type_; std::string dump_filename_; size_t item_size_; - int64_t samples_; + [[maybe_unused]] int64_t samples_; unsigned int in_stream_; unsigned int out_stream_; bool dump_; diff --git a/src/algorithms/signal_source/adapters/labsat_signal_source.cc b/src/algorithms/signal_source/adapters/labsat_signal_source.cc index c02559e57..a73980891 100644 --- a/src/algorithms/signal_source/adapters/labsat_signal_source.cc +++ b/src/algorithms/signal_source/adapters/labsat_signal_source.cc @@ -18,12 +18,13 @@ #include "configuration_interface.h" #include "labsat23_source.h" #include -#include -#include +using namespace std::string_literals; LabsatSignalSource::LabsatSignalSource(const ConfigurationInterface* configuration, - const std::string& role, unsigned int in_stream, unsigned int out_stream, Concurrent_Queue* queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream) + const std::string& role, unsigned int in_stream, unsigned int out_stream, Concurrent_Queue* queue) + : SignalSourceBase(configuration, role, "Labsat_Signal_Source"s) + , in_stream_(in_stream), out_stream_(out_stream) { const std::string default_item_type("gr_complex"); const std::string default_dump_file("./labsat_output.dat"); diff --git a/src/algorithms/signal_source/adapters/labsat_signal_source.h b/src/algorithms/signal_source/adapters/labsat_signal_source.h index b2ab00161..365d2c79a 100644 --- a/src/algorithms/signal_source/adapters/labsat_signal_source.h +++ b/src/algorithms/signal_source/adapters/labsat_signal_source.h @@ -18,7 +18,7 @@ #ifndef GNSS_SDR_LABSAT_SIGNAL_SOURCE_H #define GNSS_SDR_LABSAT_SIGNAL_SOURCE_H -#include "signal_source_interface.h" +#include "signal_source_base.h" #include "concurrent_queue.h" #include "gnss_block_interface.h" @@ -40,29 +40,15 @@ class ConfigurationInterface; /*! * \brief This class reads samples stored by a LabSat 2 or LabSat 3 device */ -class LabsatSignalSource : public SignalSourceInterface +class LabsatSignalSource : public SignalSourceBase { public: - void fixme() final {} LabsatSignalSource(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_stream, unsigned int out_stream, Concurrent_Queue* queue); ~LabsatSignalSource() = default; - inline std::string role() override - { - return role_; - } - - /*! - * \brief Returns "Labsat_Signal_Source". - */ - inline std::string implementation() override - { - return "Labsat_Signal_Source"; - } - inline size_t item_size() override { return item_size_; @@ -78,7 +64,6 @@ private: gr::blocks::file_sink::sptr file_sink_; gr::blocks::throttle::sptr throttle_; - std::string role_; std::string item_type_; std::string filename_; std::string dump_filename_; diff --git a/src/algorithms/signal_source/adapters/multichannel_file_signal_source.cc b/src/algorithms/signal_source/adapters/multichannel_file_signal_source.cc index 335458660..906c47e0b 100644 --- a/src/algorithms/signal_source/adapters/multichannel_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/multichannel_file_signal_source.cc @@ -27,18 +27,22 @@ #include +using namespace std::string_literals; + MultichannelFileSignalSource::MultichannelFileSignalSource(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams, - Concurrent_Queue* queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams) + Concurrent_Queue* queue) + : SignalSourceBase(configuration, role, "Multichannel_File_Signal_Source"s) +, in_streams_(in_streams), out_streams_(out_streams) { - const std::string default_filename("./example_capture.dat"); - const std::string default_item_type("short"); - const std::string default_dump_filename("./my_capture.dat"); + const std::string default_filename("./example_capture.dat"s); + const std::string default_item_type("short"s); + const std::string default_dump_filename("./my_capture.dat"s); const double default_seconds_to_skip = 0.0; - samples_ = configuration->property(role + ".samples", static_cast(0)); - sampling_frequency_ = configuration->property(role + ".sampling_frequency", static_cast(0)); - n_channels_ = configuration->property(role + ".total_channels", 1); + samples_ = configuration->property(role + ".samples"s, static_cast(0)); + sampling_frequency_ = configuration->property(role + ".sampling_frequency"s, static_cast(0)); + n_channels_ = configuration->property(role + ".total_channels"s, 1); for (int32_t n = 0; n < n_channels_; n++) { diff --git a/src/algorithms/signal_source/adapters/multichannel_file_signal_source.h b/src/algorithms/signal_source/adapters/multichannel_file_signal_source.h index caf467df0..94049b37d 100644 --- a/src/algorithms/signal_source/adapters/multichannel_file_signal_source.h +++ b/src/algorithms/signal_source/adapters/multichannel_file_signal_source.h @@ -21,7 +21,7 @@ #ifndef GNSS_SDR_MULTICHANNEL_FILE_SIGNAL_SOURCE_H #define GNSS_SDR_MULTICHANNEL_FILE_SIGNAL_SOURCE_H -#include "signal_source_interface.h" +#include "signal_source_base.h" #include "concurrent_queue.h" #include "gnss_block_interface.h" @@ -47,29 +47,15 @@ class ConfigurationInterface; * \brief Class that reads signals samples from files at different frequency bands * and adapts it to a SignalSourceInterface */ -class MultichannelFileSignalSource : public SignalSourceInterface +class MultichannelFileSignalSource : public SignalSourceBase { public: - void fixme() final {} MultichannelFileSignalSource(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams, Concurrent_Queue* queue); ~MultichannelFileSignalSource() = default; - inline std::string role() override - { - return role_; - } - - /*! - * \brief Returns "Multichannel_File_Signal_Source". - */ - inline std::string implementation() override - { - return "Multichannel_File_Signal_Source"; - } - inline size_t item_size() override { return item_size_; @@ -112,7 +98,6 @@ private: std::vector throttle_vec_; std::vector filename_vec_; std::string item_type_; - std::string role_; uint64_t samples_; int64_t sampling_frequency_; size_t item_size_; diff --git a/src/algorithms/signal_source/adapters/nsr_file_signal_source.cc b/src/algorithms/signal_source/adapters/nsr_file_signal_source.cc index ad2bc1502..8501a8df5 100644 --- a/src/algorithms/signal_source/adapters/nsr_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/nsr_file_signal_source.cc @@ -27,10 +27,13 @@ #include #include +using namespace std::string_literals; NsrFileSignalSource::NsrFileSignalSource(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams, - Concurrent_Queue* queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams) + Concurrent_Queue* queue) + : SignalSourceBase(configuration, role, "Nsr_File_Signal_Source"s) + , in_streams_(in_streams), out_streams_(out_streams) { const std::string default_filename("../data/my_capture.dat"); const std::string default_item_type("byte"); @@ -76,14 +79,14 @@ NsrFileSignalSource::NsrFileSignalSource(const ConfigurationInterface* configura << "The receiver was configured to work with a file signal source\n" << "but the specified file is unreachable by GNSS-SDR.\n" << "Please modify your configuration file\n" - << "and point SignalSource.filename to a valid raw data file. Then:\n" + << "and point " << role << ".filename to a valid raw data file. Then:\n" << "$ gnss-sdr --config_file=/path/to/my_GNSS_SDR_configuration.conf\n" << "Examples of configuration files available at:\n" << GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/\n"; - LOG(WARNING) << "file_signal_source: Unable to open the samples file " - << filename_.c_str() << ", exiting the program."; - throw(e); + LOG(WARNING) << "nsr_file_signal_source: Unable to open the samples file " + << filename_ << ", exiting the program."; + throw; } DLOG(INFO) << "file_source(" << file_source_->unique_id() << ")"; diff --git a/src/algorithms/signal_source/adapters/nsr_file_signal_source.h b/src/algorithms/signal_source/adapters/nsr_file_signal_source.h index afe7a1c99..d3dbabe71 100644 --- a/src/algorithms/signal_source/adapters/nsr_file_signal_source.h +++ b/src/algorithms/signal_source/adapters/nsr_file_signal_source.h @@ -21,7 +21,7 @@ #ifndef GNSS_SDR_NSR_FILE_SIGNAL_SOURCE_H #define GNSS_SDR_NSR_FILE_SIGNAL_SOURCE_H -#include "signal_source_interface.h" +#include "signal_source_base.h" #include "concurrent_queue.h" #include "gnss_block_interface.h" @@ -44,27 +44,14 @@ class ConfigurationInterface; * \brief Class that reads signals samples from a file * and adapts it to a SignalSourceInterface */ -class NsrFileSignalSource : public SignalSourceInterface +class NsrFileSignalSource : public SignalSourceBase { public: - void fixme() final {} NsrFileSignalSource(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams, Concurrent_Queue* queue); ~NsrFileSignalSource() = default; - inline std::string role() override - { - return role_; - } - - /*! - * \brief Returns "Nsr_File_Signal_Source". - */ - inline std::string implementation() override - { - return "Nsr_File_Signal_Source"; - } inline size_t item_size() override { @@ -113,7 +100,6 @@ private: std::string filename_; std::string item_type_; std::string dump_filename_; - std::string role_; uint32_t in_streams_; uint32_t out_streams_; bool repeat_; diff --git a/src/algorithms/signal_source/adapters/osmosdr_signal_source.cc b/src/algorithms/signal_source/adapters/osmosdr_signal_source.cc index c776ad74b..a648a589a 100644 --- a/src/algorithms/signal_source/adapters/osmosdr_signal_source.cc +++ b/src/algorithms/signal_source/adapters/osmosdr_signal_source.cc @@ -25,9 +25,13 @@ #include +using namespace std::string_literals; + + OsmosdrSignalSource::OsmosdrSignalSource(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_stream, unsigned int out_stream, - Concurrent_Queue* queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream) + Concurrent_Queue* queue) + : SignalSourceBase(configuration, role, "Osmosdr_Signal_Source"s), in_stream_(in_stream), out_stream_(out_stream) { // DUMP PARAMETERS const std::string empty; diff --git a/src/algorithms/signal_source/adapters/osmosdr_signal_source.h b/src/algorithms/signal_source/adapters/osmosdr_signal_source.h index 442de26d0..b97a00fb8 100644 --- a/src/algorithms/signal_source/adapters/osmosdr_signal_source.h +++ b/src/algorithms/signal_source/adapters/osmosdr_signal_source.h @@ -19,10 +19,9 @@ #ifndef GNSS_SDR_OSMOSDR_SIGNAL_SOURCE_H #define GNSS_SDR_OSMOSDR_SIGNAL_SOURCE_H -#include "signal_source_interface.h" +#include "signal_source_base.h" #include "concurrent_queue.h" -#include "gnss_block_interface.h" #include #include #include @@ -44,7 +43,7 @@ class ConfigurationInterface; * HackRF or Realtek's RTL2832U-based USB dongle DVB-T receivers * (see https://osmocom.org/projects/rtl-sdr/wiki) */ -class OsmosdrSignalSource : public SignalSourceInterface +class OsmosdrSignalSource : public SignalSourceBase { public: OsmosdrSignalSource(const ConfigurationInterface* configuration, @@ -53,19 +52,6 @@ public: ~OsmosdrSignalSource() = default; - inline std::string role() override - { - return role_; - } - - /*! - * \brief Returns "Osmosdr_Signal_Source" - */ - inline std::string implementation() override - { - return "Osmosdr_Signal_Source"; - } - inline size_t item_size() override { return item_size_; @@ -83,7 +69,6 @@ private: gnss_shared_ptr valve_; gr::blocks::file_sink::sptr file_sink_; - std::string role_; std::string item_type_; std::string dump_filename_; std::string osmosdr_args_; diff --git a/src/algorithms/signal_source/adapters/plutosdr_signal_source.cc b/src/algorithms/signal_source/adapters/plutosdr_signal_source.cc index e415e2b2a..fb4ac8fc6 100644 --- a/src/algorithms/signal_source/adapters/plutosdr_signal_source.cc +++ b/src/algorithms/signal_source/adapters/plutosdr_signal_source.cc @@ -24,9 +24,13 @@ #include +using namespace std::string_literals; + + PlutosdrSignalSource::PlutosdrSignalSource(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_stream, unsigned int out_stream, - Concurrent_Queue* queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream) + Concurrent_Queue* queue) + : SignalSourceBase(configuration, role, "Plutosdr_Signal_Source"s), in_stream_(in_stream), out_stream_(out_stream) { const std::string default_item_type("gr_complex"); const std::string default_dump_file("./data/signal_source.dat"); diff --git a/src/algorithms/signal_source/adapters/plutosdr_signal_source.h b/src/algorithms/signal_source/adapters/plutosdr_signal_source.h index 07534923d..27de2a622 100644 --- a/src/algorithms/signal_source/adapters/plutosdr_signal_source.h +++ b/src/algorithms/signal_source/adapters/plutosdr_signal_source.h @@ -19,9 +19,8 @@ #ifndef GNSS_SDR_PLUTOSDR_SIGNAL_SOURCE_H #define GNSS_SDR_PLUTOSDR_SIGNAL_SOURCE_H -#include "signal_source_interface.h" +#include "signal_source_base.h" -#include "gnss_block_interface.h" #include #if GRIIO_INCLUDE_HAS_GNURADIO #include @@ -44,7 +43,7 @@ class ConfigurationInterface; /*! */ -class PlutosdrSignalSource : public SignalSourceInterface +class PlutosdrSignalSource : public SignalSourceBase { public: PlutosdrSignalSource(const ConfigurationInterface* configuration, @@ -53,18 +52,6 @@ public: ~PlutosdrSignalSource() = default; - std::string role() override - { - return role_; - } - - /*! - * \brief Returns "Plutosdr_Signal_Source" - */ - std::string implementation() override - { - return "Plutosdr_Signal_Source"; - } size_t item_size() override { return item_size_; @@ -81,7 +68,6 @@ private: gnss_shared_ptr valve_; gr::blocks::file_sink::sptr file_sink_; - std::string role_; std::string dump_filename_; // Front-end settings diff --git a/src/algorithms/signal_source/adapters/raw_array_signal_source.cc b/src/algorithms/signal_source/adapters/raw_array_signal_source.cc index bdc4d7352..e4e0d4e85 100644 --- a/src/algorithms/signal_source/adapters/raw_array_signal_source.cc +++ b/src/algorithms/signal_source/adapters/raw_array_signal_source.cc @@ -23,8 +23,11 @@ #include +using namespace std::string_literals; + RawArraySignalSource::RawArraySignalSource(const ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, unsigned int out_stream, Concurrent_Queue* queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream) + std::string role, unsigned int in_stream, unsigned int out_stream, Concurrent_Queue* queue) +: SignalSourceBase(configuration, role, "Raw_Array_Signal_Source"s), in_stream_(in_stream), out_stream_(out_stream) { const std::string default_item_type("gr_complex"); const std::string default_dump_file("./data/raw_array_source.dat"); diff --git a/src/algorithms/signal_source/adapters/raw_array_signal_source.h b/src/algorithms/signal_source/adapters/raw_array_signal_source.h index 8fe4be6a4..a3da5fa50 100644 --- a/src/algorithms/signal_source/adapters/raw_array_signal_source.h +++ b/src/algorithms/signal_source/adapters/raw_array_signal_source.h @@ -18,10 +18,9 @@ #ifndef GNSS_SDR_RAW_ARRAY_SIGNAL_SOURCE_H #define GNSS_SDR_RAW_ARRAY_SIGNAL_SOURCE_H -#include "signal_source_interface.h" +#include "signal_source_base.h" #include "concurrent_queue.h" -#include "gnss_block_interface.h" #include #include #include @@ -41,7 +40,7 @@ class ConfigurationInterface; /*! * \brief This class reads samples from a GN3S USB dongle, a RF front-end signal sampler */ -class RawArraySignalSource : public SignalSourceInterface +class RawArraySignalSource : public SignalSourceBase { public: RawArraySignalSource(const ConfigurationInterface* configuration, @@ -50,19 +49,6 @@ public: ~RawArraySignalSource() = default; - inline std::string role() override - { - return role_; - } - - /*! - * \brief Returns "RawArraySignalSource". - */ - inline std::string implementation() override - { - return "Raw_Array_Signal_Source"; - } - inline size_t item_size() override { return item_size_; @@ -76,12 +62,11 @@ public: private: gr::block_sptr raw_array_source_; gr::blocks::file_sink::sptr file_sink_; - std::string role_; std::string item_type_; std::string dump_filename_; std::string eth_device_; size_t item_size_; - int64_t samples_; + [[maybe_unused]] int64_t samples_; unsigned int in_stream_; unsigned int out_stream_; bool dump_; diff --git a/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.cc b/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.cc index 1e0a738c4..740437e49 100644 --- a/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.cc +++ b/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.cc @@ -25,14 +25,15 @@ #include #include +using namespace std::string_literals; RtlTcpSignalSource::RtlTcpSignalSource(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_stream, unsigned int out_stream, - Concurrent_Queue* queue) : role_(role), - in_stream_(in_stream), - out_stream_(out_stream) + Concurrent_Queue* queue) + : SignalSourceBase(configuration, role, "RtlTcp_Signal_Source"s) + , in_stream_(in_stream), out_stream_(out_stream) { // DUMP PARAMETERS const std::string default_dump_file("./data/signal_source.dat"); diff --git a/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.h b/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.h index 6dc5889c3..ddb8f3456 100644 --- a/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.h +++ b/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.h @@ -18,10 +18,9 @@ #ifndef GNSS_SDR_RTL_TCP_SIGNAL_SOURCE_H #define GNSS_SDR_RTL_TCP_SIGNAL_SOURCE_H -#include "signal_source_interface.h" +#include "signal_source_base.h" #include "concurrent_queue.h" -#include "gnss_block_interface.h" #include "rtl_tcp_signal_source_c.h" #include #include @@ -44,10 +43,9 @@ class ConfigurationInterface; * I/Q samples over TCP. * (see https://osmocom.org/projects/rtl-sdr/wiki) */ -class RtlTcpSignalSource : public SignalSourceInterface +class RtlTcpSignalSource : public SignalSourceBase { public: - void fixme() final {} RtlTcpSignalSource(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_stream, @@ -56,19 +54,6 @@ public: ~RtlTcpSignalSource() = default; - inline std::string role() override - { - return role_; - } - - /*! - * \brief Returns "RtlTcp_Signal_Source" - */ - inline std::string implementation() override - { - return "RtlTcp_Signal_Source"; - } - inline size_t item_size() override { return item_size_; @@ -87,7 +72,6 @@ private: gnss_shared_ptr valve_; gr::blocks::file_sink::sptr file_sink_; - std::string role_; std::string item_type_; std::string dump_filename_; diff --git a/src/algorithms/signal_source/adapters/signal_source_base.cc b/src/algorithms/signal_source/adapters/signal_source_base.cc new file mode 100644 index 000000000..650bc150f --- /dev/null +++ b/src/algorithms/signal_source/adapters/signal_source_base.cc @@ -0,0 +1,46 @@ +/*! + * \file signal_source_base.cc + * \brief Base class for signal sources + * \author Jim Melton, 2020. jim.melton(at)sncorp.com + * + * + * ----------------------------------------------------------------------------- + * + * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + * ----------------------------------------------------------------------------- + */ + +#include "signal_source_base.h" + +#include "configuration_interface.h" + +using namespace std::string_literals; + +std::string SignalSourceBase::role() +{ + return role_; +} + +std::string SignalSourceBase::implementation() +{ + return implementation_; +} + +size_t SignalSourceBase::getRfChannels() const +{ + return rfChannels_; +} + +SignalSourceBase::SignalSourceBase(ConfigurationInterface const* configuration, std::string role, std::string impl) + : SignalSourceInterface(), role_(role), implementation_(impl), connected_(false), rfChannels_(configuration->property(role + ".RF_channels"s, 1u)) +{ +} + diff --git a/src/algorithms/signal_source/adapters/signal_source_base.h b/src/algorithms/signal_source/adapters/signal_source_base.h new file mode 100644 index 000000000..ea8a397da --- /dev/null +++ b/src/algorithms/signal_source/adapters/signal_source_base.h @@ -0,0 +1,52 @@ +/*! + * \file signal_source_base.h + * \brief Header file of the base class to signal_source GNSS blocks. + * \author Jim Melton, 2020. jim.melton(at)sncorp.com + * + * + * ----------------------------------------------------------------------------- + * + * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + * ----------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_SIGNAL_SOURCE_BASE_H +#define GNSS_SDR_SIGNAL_SOURCE_BASE_H + +#include "signal_source_interface.h" + +#include +#include + + +class ConfigurationInterface; + +class SignalSourceBase : public SignalSourceInterface +{ +public: + std::string role() final; + std::string implementation() final; + + size_t getRfChannels() const override; + +protected: + //! Constructor + SignalSourceBase(ConfigurationInterface const* configuration, std::string role, std::string impl); + +private: + std::string const role_; + std::string const implementation_; + bool connected_; + size_t rfChannels_; +}; + + +#endif diff --git a/src/algorithms/signal_source/adapters/spir_file_signal_source.cc b/src/algorithms/signal_source/adapters/spir_file_signal_source.cc index e30f1b5ba..2c8841c34 100644 --- a/src/algorithms/signal_source/adapters/spir_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/spir_file_signal_source.cc @@ -28,9 +28,13 @@ #include +using namespace std::string_literals; + SpirFileSignalSource::SpirFileSignalSource(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams, - Concurrent_Queue* queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams) + Concurrent_Queue* queue) + : SignalSourceBase(configuration, role, "Spir_File_Signal_Source"s) + , in_streams_(in_streams), out_streams_(out_streams) { const std::string default_filename("../data/my_capture.dat"); const std::string default_item_type("int"); diff --git a/src/algorithms/signal_source/adapters/spir_file_signal_source.h b/src/algorithms/signal_source/adapters/spir_file_signal_source.h index 565b53ede..a7287ec4e 100644 --- a/src/algorithms/signal_source/adapters/spir_file_signal_source.h +++ b/src/algorithms/signal_source/adapters/spir_file_signal_source.h @@ -21,7 +21,7 @@ #ifndef GNSS_SDR_SPIR_FILE_SIGNAL_SOURCE_H #define GNSS_SDR_SPIR_FILE_SIGNAL_SOURCE_H -#include "signal_source_interface.h" +#include "signal_source_base.h" #include "concurrent_queue.h" #include "gnss_block_interface.h" @@ -47,28 +47,15 @@ class ConfigurationInterface; * \brief Class that reads signals samples from a file * and adapts it to a SignalSourceInterface */ -class SpirFileSignalSource : public SignalSourceInterface +class SpirFileSignalSource : public SignalSourceBase { public: - void fixme() final {} SpirFileSignalSource(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams, Concurrent_Queue* queue); ~SpirFileSignalSource() = default; - inline std::string role() override - { - return role_; - } - - /*! - * \brief Returns "Spir_File_Signal_Source". - */ - inline std::string implementation() override - { - return "Spir_File_Signal_Source"; - } inline size_t item_size() override { @@ -114,7 +101,6 @@ private: std::string filename_; std::string item_type_; std::string dump_filename_; - std::string role_; uint64_t samples_; int64_t sampling_frequency_; diff --git a/src/algorithms/signal_source/adapters/spir_gss6450_file_signal_source.cc b/src/algorithms/signal_source/adapters/spir_gss6450_file_signal_source.cc index 430e44e64..54a7c7197 100644 --- a/src/algorithms/signal_source/adapters/spir_gss6450_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/spir_gss6450_file_signal_source.cc @@ -25,9 +25,12 @@ #include #include +using namespace std::string_literals; SpirGSS6450FileSignalSource::SpirGSS6450FileSignalSource(const ConfigurationInterface* configuration, - const std::string& role, uint32_t in_streams, uint32_t out_streams, Concurrent_Queue* queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams) + const std::string& role, uint32_t in_streams, uint32_t out_streams, Concurrent_Queue* queue) + : SignalSourceBase(configuration, role, "Spir_GSS6450_File_Signal_Source"s) + , in_streams_(in_streams), out_streams_(out_streams) { const std::string default_filename("../data/my_capture.dat"); const std::string default_dump_filename("../data/my_capture_dump.dat"); diff --git a/src/algorithms/signal_source/adapters/spir_gss6450_file_signal_source.h b/src/algorithms/signal_source/adapters/spir_gss6450_file_signal_source.h index 00d9c0333..85e91dc15 100644 --- a/src/algorithms/signal_source/adapters/spir_gss6450_file_signal_source.h +++ b/src/algorithms/signal_source/adapters/spir_gss6450_file_signal_source.h @@ -21,7 +21,7 @@ #ifndef GNSS_SDR_SPIR_GSS6450_FILE_SIGNAL_SOURCE_H #define GNSS_SDR_SPIR_GSS6450_FILE_SIGNAL_SOURCE_H -#include "signal_source_interface.h" +#include "signal_source_base.h" #include "concurrent_queue.h" #include "gnss_sdr_valve.h" @@ -51,23 +51,12 @@ class ConfigurationInterface; * \brief Class that reads signals samples from a file * and adapts it to a SignalSourceInterface */ -class SpirGSS6450FileSignalSource : public SignalSourceInterface +class SpirGSS6450FileSignalSource : public SignalSourceBase { public: - void fixme() final {} SpirGSS6450FileSignalSource(const ConfigurationInterface* configuration, const std::string& role, uint32_t in_streams, uint32_t out_streams, Concurrent_Queue* queue); - inline std::string role() override - { - return role_; - } - - inline std::string implementation() override - { - return "Spir_GSS6450_File_Signal_Source"; - } - inline size_t item_size() override { return item_size_; @@ -115,7 +104,6 @@ private: std::vector throttle_vec_; std::string filename_; std::string dump_filename_; - std::string role_; std::string item_type_; uint64_t samples_; int64_t sampling_frequency_; diff --git a/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.cc b/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.cc index f496f11df..b968793d7 100644 --- a/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.cc @@ -26,15 +26,16 @@ #include #include +using namespace std::string_literals; + TwoBitCpxFileSignalSource::TwoBitCpxFileSignalSource( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams, - Concurrent_Queue* queue) : role_(role), - in_streams_(in_streams), - out_streams_(out_streams) + Concurrent_Queue* queue) + : SignalSourceBase(configuration, role, "Two_Bit_Cpx_File_Signal_Source"s), in_streams_(in_streams), out_streams_(out_streams) { const std::string default_filename("../data/my_capture.dat"); const std::string default_item_type("byte"); diff --git a/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.h b/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.h index 25ba669ef..eabdc22cf 100644 --- a/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.h +++ b/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.h @@ -20,7 +20,7 @@ #ifndef GNSS_SDR_TWO_BIT_CPX_FILE_SIGNAL_SOURCE_H #define GNSS_SDR_TWO_BIT_CPX_FILE_SIGNAL_SOURCE_H -#include "signal_source_interface.h" +#include "signal_source_base.h" #include "concurrent_queue.h" #include "unpack_byte_2bit_cpx_samples.h" @@ -45,10 +45,9 @@ class ConfigurationInterface; * \brief Class that reads signals samples from a file * and adapts it to a SignalSourceInterface */ -class TwoBitCpxFileSignalSource : public SignalSourceInterface +class TwoBitCpxFileSignalSource : public SignalSourceBase { public: - void fixme() final {} TwoBitCpxFileSignalSource(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, @@ -56,18 +55,6 @@ public: Concurrent_Queue* queue); ~TwoBitCpxFileSignalSource() = default; - inline std::string role() override - { - return role_; - } - - /*! - * \brief Returns "Two_Bit_Cpx_File_Signal_Source". - */ - inline std::string implementation() override - { - return "Two_Bit_Cpx_File_Signal_Source"; - } inline size_t item_size() override { @@ -114,7 +101,6 @@ private: std::string filename_; std::string item_type_; std::string dump_filename_; - std::string role_; size_t item_size_; uint64_t samples_; int64_t sampling_frequency_; diff --git a/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc b/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc index c31bf3390..fffd1c773 100644 --- a/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc @@ -28,15 +28,17 @@ #include #include +using namespace std::string_literals; TwoBitPackedFileSignalSource::TwoBitPackedFileSignalSource( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams, - Concurrent_Queue* queue) : role_(role), - in_streams_(in_streams), - out_streams_(out_streams) + Concurrent_Queue* queue) + : SignalSourceBase(configuration, role, "Two_Bit_Packed_File_Signal_Source"s) + , in_streams_(in_streams) + , out_streams_(out_streams) { const std::string default_filename("../data/my_capture.dat"); const std::string default_item_type("byte"); diff --git a/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.h b/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.h index 2be63790f..672fc99f1 100644 --- a/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.h +++ b/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.h @@ -21,7 +21,7 @@ #ifndef GNSS_SDR_TWO_BIT_PACKED_FILE_SIGNAL_SOURCE_H #define GNSS_SDR_TWO_BIT_PACKED_FILE_SIGNAL_SOURCE_H -#include "signal_source_interface.h" +#include "signal_source_base.h" #include "concurrent_queue.h" #include "unpack_2bit_samples.h" @@ -47,27 +47,14 @@ class ConfigurationInterface; * \brief Class that reads signals samples from a file * and adapts it to a SignalSourceInterface */ -class TwoBitPackedFileSignalSource : public SignalSourceInterface +class TwoBitPackedFileSignalSource : public SignalSourceBase { public: - void fixme() final {} TwoBitPackedFileSignalSource(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams, Concurrent_Queue* queue); ~TwoBitPackedFileSignalSource() = default; - inline std::string role() override - { - return role_; - } - - /*! - * \brief Returns "Two_Bit_Packed_File_Signal_Source". - */ - inline std::string implementation() override - { - return "Two_Bit_Packed_File_Signal_Source"; - } inline size_t item_size() override { @@ -134,7 +121,6 @@ private: std::string filename_; std::string item_type_; std::string dump_filename_; - std::string role_; std::string sample_type_; uint64_t samples_; int64_t sampling_frequency_; diff --git a/src/algorithms/signal_source/adapters/uhd_signal_source.cc b/src/algorithms/signal_source/adapters/uhd_signal_source.cc index 81ed5e75b..0311b349e 100644 --- a/src/algorithms/signal_source/adapters/uhd_signal_source.cc +++ b/src/algorithms/signal_source/adapters/uhd_signal_source.cc @@ -25,10 +25,13 @@ #include #include +using namespace std::string_literals; + UhdSignalSource::UhdSignalSource(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_stream, unsigned int out_stream, - Concurrent_Queue* queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream) + Concurrent_Queue* queue) + : SignalSourceBase(configuration, role, "UHD_Signal_Source"s), in_stream_(in_stream), out_stream_(out_stream) { // DUMP PARAMETERS const std::string empty; diff --git a/src/algorithms/signal_source/adapters/uhd_signal_source.h b/src/algorithms/signal_source/adapters/uhd_signal_source.h index 6394cbcc2..d861be682 100644 --- a/src/algorithms/signal_source/adapters/uhd_signal_source.h +++ b/src/algorithms/signal_source/adapters/uhd_signal_source.h @@ -17,7 +17,7 @@ #ifndef GNSS_SDR_UHD_SIGNAL_SOURCE_H #define GNSS_SDR_UHD_SIGNAL_SOURCE_H -#include "signal_source_interface.h" +#include "signal_source_base.h" #include "concurrent_queue.h" #include @@ -39,7 +39,7 @@ class ConfigurationInterface; /*! * \brief This class reads samples from a UHD device (see http://code.ettus.com/redmine/ettus/projects/uhd/wiki) */ -class UhdSignalSource : public SignalSourceInterface +class UhdSignalSource : public SignalSourceBase { public: UhdSignalSource(const ConfigurationInterface* configuration, @@ -48,19 +48,6 @@ public: ~UhdSignalSource() = default; - inline std::string role() override - { - return role_; - } - - /*! - * \brief Returns "UHD_Signal_Source" - */ - inline std::string implementation() override - { - return "UHD_Signal_Source"; - } - inline size_t item_size() override { return item_size_; @@ -90,7 +77,6 @@ private: std::string item_type_; std::string subdevice_; std::string clock_source_; - std::string role_; double sample_rate_; size_t item_size_; diff --git a/src/core/interfaces/signal_source_interface.h b/src/core/interfaces/signal_source_interface.h index c6ba1b079..46b6d4ad5 100644 --- a/src/core/interfaces/signal_source_interface.h +++ b/src/core/interfaces/signal_source_interface.h @@ -42,18 +42,19 @@ * implemented by that class or a parent class. */ +#include class SignalSourceInterface : public GNSSBlockInterface { - virtual std::string role() = 0; - virtual std::string implementation() = 0; - virtual size_t item_size() = 0; - virtual void connect(gr::top_block_sptr top_block) = 0; - virtual void disconnect(gr::top_block_sptr top_block) = 0; - - virtual gr::basic_block_sptr get_left_block() = 0; - virtual gr::basic_block_sptr get_right_block() = 0; - - virtual void fixme() = 0; +public: + virtual size_t getRfChannels() const = 0; + protected: + SignalSourceInterface() { + VLOG(1) << "SignalSourceInterface: " << this << " ctor"; + } + public: // required for polymorphic destruction + ~SignalSourceInterface() { + VLOG(1) << "SignalSourceInterface: " << this << " dtor"; + } }; diff --git a/src/core/receiver/gnss_block_factory.cc b/src/core/receiver/gnss_block_factory.cc index 581ac7771..7b7453bf7 100644 --- a/src/core/receiver/gnss_block_factory.cc +++ b/src/core/receiver/gnss_block_factory.cc @@ -170,26 +170,53 @@ #include "gps_l1_ca_dll_pll_tracking_gpu.h" #endif +using namespace std::string_literals; -std::unique_ptr GNSSBlockFactory::GetSignalSource( +namespace +{ +auto const impl_prop = ".implementation"s; // "implementation" property; used nearly universally +auto const item_prop = ".item_type"s; // "item_type" property + +// unique_ptr dynamic cast from https://stackoverflow.com/a/26377517/9220132 +template +std::unique_ptr dynamic_unique_cast(std::unique_ptr&& p) +{ + std::unique_ptr result; + + if (To* cast = dynamic_cast(p.get())) + { + result.reset(cast); + p.release(); + } + return result; +} + +auto findRole(ConfigurationInterface const* configuration, std::string base, int ID) -> std::string +{ + auto role = base + std::to_string(ID); + + // Legacy behavior: pass -1 for unadorned property. + // Current behavior: if there is no "Tag0" use "Tag" instead + if (ID < 1) + { + auto stub = configuration->property(role + impl_prop, ""s); + if (stub.empty()) role = base; // legacy format + } + return role; +}; + + +} // namespace + + +std::unique_ptr GNSSBlockFactory::GetSignalSource( const ConfigurationInterface* configuration, Concurrent_Queue* queue, int ID) { - const std::string empty_implementation; - std::string role = "SignalSource"; // backwards compatibility for old conf files - try - { - if (ID != -1) - { - role = "SignalSource" + std::to_string(ID); - } - } - catch (const std::exception& e) - { - LOG(WARNING) << e.what(); - } - std::string implementation = configuration->property(role + ".implementation", empty_implementation); - LOG(INFO) << "Getting SignalSource with implementation " << implementation; - return GetBlock(configuration, role, 0, 1, queue); + auto role = findRole(configuration, "SignalSource"s, ID); + auto implementation = configuration->property(role + impl_prop, ""s); + LOG(INFO) << "Getting SignalSource " << role << " with implementation " << implementation; + + return dynamic_unique_cast(GetBlock(configuration, role, 0, 1, queue)); } @@ -197,51 +224,40 @@ std::unique_ptr GNSSBlockFactory::GetSignalConditioner( const ConfigurationInterface* configuration, int ID) { const std::string empty_implementation; - // backwards compatibility for old conf files - std::string role_conditioner = "SignalConditioner"; - std::string role_datatypeadapter = "DataTypeAdapter"; - std::string role_inputfilter = "InputFilter"; - std::string role_resampler = "Resampler"; - try - { - if (ID != -1) - { - role_conditioner = "SignalConditioner" + std::to_string(ID); - role_datatypeadapter = "DataTypeAdapter" + std::to_string(ID); - role_inputfilter = "InputFilter" + std::to_string(ID); - role_resampler = "Resampler" + std::to_string(ID); - } - } - catch (const std::exception& e) - { - LOG(WARNING) << e.what(); - } - const std::string signal_conditioner = configuration->property(role_conditioner + ".implementation", empty_implementation); - const std::string data_type_adapter = configuration->property(role_datatypeadapter + ".implementation", empty_implementation); - const std::string input_filter = configuration->property(role_inputfilter + ".implementation", empty_implementation); - const std::string resampler = configuration->property(role_resampler + ".implementation", empty_implementation); + auto role_conditioner = findRole(configuration, "SignalConditioner"s, ID); + auto role_datatypeadapter = findRole(configuration, "DataTypeAdapter"s, ID); + auto role_inputfilter = findRole(configuration, "InputFilter"s, ID); + auto role_resampler = findRole(configuration, "Resampler"s, ID); + + DLOG(INFO) << "role: " << role_conditioner << " (ID=" << ID << ")"; + + const std::string signal_conditioner = configuration->property(role_conditioner + impl_prop, ""s); + + const std::string data_type_adapter = configuration->property(role_datatypeadapter + impl_prop, ""s); + const std::string input_filter = configuration->property(role_inputfilter + impl_prop, ""s); + const std::string resampler = configuration->property(role_resampler + impl_prop, ""s); if (signal_conditioner == "Pass_Through") { if (!data_type_adapter.empty() and (data_type_adapter != "Pass_Through")) { - LOG(WARNING) << "Configuration warning: if " << role_conditioner << ".implementation\n" - << "is set to Pass_Through, then the " << role_datatypeadapter << ".implementation\n" + LOG(WARNING) << "Configuration warning: if " << role_conditioner << impl_prop << "\n" + << "is set to Pass_Through, then the " << role_datatypeadapter << impl_prop << "\n" << "parameter should be either not set or set to Pass_Through.\n" << role_datatypeadapter << " configuration parameters will be ignored."; } if (!input_filter.empty() and (input_filter != "Pass_Through")) { - LOG(WARNING) << "Configuration warning: if " << role_conditioner << ".implementation\n" - << "is set to Pass_Through, then the " << role_inputfilter << ".implementation\n" + LOG(WARNING) << "Configuration warning: if " << role_conditioner << impl_prop << "\n" + << "is set to Pass_Through, then the " << role_inputfilter << impl_prop << "\n" << "parameter should be either not set or set to Pass_Through.\n" << role_inputfilter << " configuration parameters will be ignored."; } if (!resampler.empty() and (resampler != "Pass_Through")) { - LOG(WARNING) << "Configuration warning: if " << role_conditioner << ".implementation\n" - << "is set to Pass_Through, then the " << role_resampler << ".implementation\n" + LOG(WARNING) << "Configuration warning: if " << role_conditioner << impl_prop << "\n" + << "is set to Pass_Through, then the " << role_resampler << impl_prop << "\n" << "parameter should be either not set or set to Pass_Through.\n" << role_resampler << " configuration parameters will be ignored."; } @@ -346,21 +362,21 @@ std::unique_ptr GNSSBlockFactory::GetChannel( { // "appendix" is added to the "role" with the aim of Acquisition, Tracking and Telemetry Decoder adapters // can find their specific configurations for channels - std::string aux = configuration->property("Acquisition_" + signal + std::to_string(channel) + ".implementation", std::string("W")); + std::string aux = configuration->property("Acquisition_" + signal + std::to_string(channel) + impl_prop, std::string("W")); std::string appendix1; if (aux != "W") { appendix1 = std::to_string(channel); } - aux = configuration->property("Tracking_" + signal + std::to_string(channel) + ".implementation", std::string("W")); + aux = configuration->property("Tracking_" + signal + std::to_string(channel) + impl_prop, std::string("W")); std::string appendix2; if (aux != "W") { appendix2 = std::to_string(channel); } - aux = configuration->property("TelemetryDecoder_" + signal + std::to_string(channel) + ".implementation", std::string("W")); + aux = configuration->property("TelemetryDecoder_" + signal + std::to_string(channel) + impl_prop, std::string("W")); std::string appendix3; if (aux != "W") { @@ -369,8 +385,8 @@ std::unique_ptr GNSSBlockFactory::GetChannel( // Automatically detect input data type const std::string default_item_type("gr_complex"); - std::string acq_item_type = configuration->property("Acquisition_" + signal + appendix1 + ".item_type", default_item_type); - std::string trk_item_type = configuration->property("Tracking_" + signal + appendix2 + ".item_type", default_item_type); + std::string acq_item_type = configuration->property("Acquisition_" + signal + appendix1 + item_prop, default_item_type); + std::string trk_item_type = configuration->property("Tracking_" + signal + appendix2 + item_prop, default_item_type); if (acq_item_type != trk_item_type) { LOG(ERROR) << "Acquisition and Tracking blocks must have the same input data type!"; @@ -379,11 +395,11 @@ std::unique_ptr GNSSBlockFactory::GetChannel( LOG(INFO) << "Instantiating Channel " << channel << " with Acquisition Implementation: " - << configuration->property("Acquisition_" + signal + appendix1 + ".implementation", std::string("W")) + << configuration->property("Acquisition_" + signal + appendix1 + impl_prop, std::string("W")) << ", Tracking Implementation: " - << configuration->property("Tracking_" + signal + appendix2 + ".implementation", std::string("W")) + << configuration->property("Tracking_" + signal + appendix2 + impl_prop, std::string("W")) << ", Telemetry Decoder implementation: " - << configuration->property("TelemetryDecoder_" + signal + appendix3 + ".implementation", std::string("W")); + << configuration->property("TelemetryDecoder_" + signal + appendix3 + impl_prop, std::string("W")); std::unique_ptr acq_ = GetAcqBlock(configuration, "Acquisition_" + signal + appendix1, 1, 0); std::unique_ptr trk_ = GetTrkBlock(configuration, "Tracking_" + signal + appendix2, 1, 1); @@ -395,7 +411,7 @@ std::unique_ptr GNSSBlockFactory::GetChannel( } if (trk_->item_size() == 0) { - LOG(ERROR) << trk_->role() << ".item_type=" << acq_item_type << " is not defined for implementation " << trk_->implementation(); + LOG(ERROR) << trk_->role() << item_prop << "=" << acq_item_type << " is not defined for implementation " << trk_->implementation(); return nullptr; } @@ -611,727 +627,652 @@ std::unique_ptr GNSSBlockFactory::GetBlock( Concurrent_Queue* queue) { std::unique_ptr block; - const std::string defaut_implementation("Pass_Through"); - const std::string implementation = configuration->property(role + ".implementation", defaut_implementation); + const std::string implementation = configuration->property(role + impl_prop, "Pass_Through"s); - // PASS THROUGH ------------------------------------------------------------ - if (implementation == "Pass_Through") + try { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, out_streams); - block = std::move(block_); - } + // PASS THROUGH ------------------------------------------------------------ + if (implementation == "Pass_Through") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, out_streams); + block = std::move(block_); + } - // SIGNAL SOURCES ---------------------------------------------------------- - else if (implementation == "File_Signal_Source") - { - try + // SIGNAL SOURCES ---------------------------------------------------------- + else if (implementation == "File_Signal_Source") { std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, out_streams, queue); block = std::move(block_); } - - catch (const std::exception& e) - { - std::cout << "GNSS-SDR program ended.\n"; - exit(1); - } - } - else if (implementation == "Multichannel_File_Signal_Source") - { - try + else if (implementation == "Multichannel_File_Signal_Source") { std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, out_streams, queue); block = std::move(block_); } - - catch (const std::exception& e) - { - std::cout << "GNSS-SDR program ended.\n"; - exit(1); - } - } #if RAW_UDP - else if (implementation == "Custom_UDP_Signal_Source") - { - try + else if (implementation == "Custom_UDP_Signal_Source") { std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, out_streams, queue); block = std::move(block_); } - - catch (const std::exception& e) - { - std::cout << "GNSS-SDR program ended.\n"; - exit(1); - } - } #endif - else if (implementation == "Nsr_File_Signal_Source") - { - try + else if (implementation == "Nsr_File_Signal_Source") { std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, out_streams, queue); block = std::move(block_); } - catch (const std::exception& e) - { - std::cout << "GNSS-SDR program ended.\n"; - exit(1); - } - } - else if (implementation == "Two_Bit_Cpx_File_Signal_Source") - { - try + else if (implementation == "Two_Bit_Cpx_File_Signal_Source") { std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, out_streams, queue); block = std::move(block_); } - catch (const std::exception& e) - { - std::cout << "GNSS-SDR program ended.\n"; - exit(1); - } - } - else if (implementation == "Two_Bit_Packed_File_Signal_Source") - { - try + else if (implementation == "Two_Bit_Packed_File_Signal_Source") { std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, out_streams, queue); block = std::move(block_); } - catch (const std::exception& e) - { - std::cout << "GNSS-SDR program ended.\n"; - exit(1); - } - } - else if (implementation == "Spir_File_Signal_Source") - { - try + else if (implementation == "Spir_File_Signal_Source") { std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, out_streams, queue); block = std::move(block_); } - catch (const std::exception& e) - { - std::cout << "GNSS-SDR program ended.\n"; - exit(1); - } - } - else if (implementation == "Spir_GSS6450_File_Signal_Source") - { - try + else if (implementation == "Spir_GSS6450_File_Signal_Source") { std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, out_streams, queue); block = std::move(block_); } - catch (const std::exception& e) - { - std::cout << "GNSS-SDR program ended.\n"; - exit(1); - } - } - else if (implementation == "RtlTcp_Signal_Source") - { - try + else if (implementation == "RtlTcp_Signal_Source") { std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, out_streams, queue); block = std::move(block_); } - catch (const std::exception& e) - { - std::cout << "GNSS-SDR program ended.\n"; - exit(1); - } - } - else if (implementation == "Labsat_Signal_Source") - { - try + else if (implementation == "Labsat_Signal_Source") { std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, out_streams, queue); block = std::move(block_); } - - catch (const std::exception& e) - { - std::cout << "GNSS-SDR program ended.\n"; - exit(1); - } - } #if UHD_DRIVER - else if (implementation == "UHD_Signal_Source") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams, queue); - block = std::move(block_); - } + else if (implementation == "UHD_Signal_Source") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams, queue); + block = std::move(block_); + } #endif + #if GN3S_DRIVER - else if (implementation == "GN3S_Signal_Source") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams, queue); - block = std::move(block_); - } + else if (implementation == "GN3S_Signal_Source") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams, queue); + block = std::move(block_); + } #endif #if RAW_ARRAY_DRIVER - else if (implementation == "Raw_Array_Signal_Source") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams, queue); - block = std::move(block_); - } + else if (implementation == "Raw_Array_Signal_Source") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams, queue); + block = std::move(block_); + } #endif #if OSMOSDR_DRIVER - else if (implementation == "Osmosdr_Signal_Source") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams, queue); - block = std::move(block_); - } + else if (implementation == "Osmosdr_Signal_Source") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams, queue); + block = std::move(block_); + } #endif #if PLUTOSDR_DRIVER - else if (implementation == "Plutosdr_Signal_Source") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams, queue); - block = std::move(block_); - } + else if (implementation == "Plutosdr_Signal_Source") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams, queue); + block = std::move(block_); + } #endif #if FMCOMMS2_DRIVER - else if (implementation == "Fmcomms2_Signal_Source") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams, queue); - block = std::move(block_); - } + else if (implementation == "Fmcomms2_Signal_Source") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams, queue); + block = std::move(block_); + } #endif #if FLEXIBAND_DRIVER - else if (implementation == "Flexiband_Signal_Source") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams, queue); - block = std::move(block_); - } + else if (implementation == "Flexiband_Signal_Source") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams, queue); + block = std::move(block_); + } #endif #if AD9361_DRIVER - // The AD9361_DRIVER Driver must be instantiated last. In this way, when using the FPGA, and when using the GNSS receiver - // in post-processing mode, the receiver is configured and ready when the DMA starts sending samples to the receiver. - else if (implementation == "Ad9361_Fpga_Signal_Source") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams, queue); - block = std::move(block_); - } + // The AD9361_DRIVER Driver must be instantiated last. In this way, when using the FPGA, and when using the GNSS receiver + // in post-processing mode, the receiver is configured and ready when the DMA starts sending samples to the receiver. + else if (implementation == "Ad9361_Fpga_Signal_Source") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams, queue); + block = std::move(block_); + } #endif - // DATA TYPE ADAPTER ----------------------------------------------------------- - else if (implementation == "Byte_To_Short") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Ibyte_To_Cbyte") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Ibyte_To_Cshort") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Ibyte_To_Complex") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Ishort_To_Cshort") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Ishort_To_Complex") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } + // DATA TYPE ADAPTER ----------------------------------------------------------- + else if (implementation == "Byte_To_Short") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Ibyte_To_Cbyte") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Ibyte_To_Cshort") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Ibyte_To_Complex") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Ishort_To_Cshort") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Ishort_To_Complex") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } - // INPUT FILTER ------------------------------------------------------------ - else if (implementation == "Fir_Filter") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Freq_Xlating_Fir_Filter") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Beamformer_Filter") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Pulse_Blanking_Filter") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Notch_Filter") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Notch_Filter_Lite") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } + // INPUT FILTER ------------------------------------------------------------ + else if (implementation == "Fir_Filter") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Freq_Xlating_Fir_Filter") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Beamformer_Filter") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Pulse_Blanking_Filter") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Notch_Filter") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Notch_Filter_Lite") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } - // RESAMPLER --------------------------------------------------------------- - else if (implementation == "Direct_Resampler") - { - std::unique_ptr block_ = std::make_unique(configuration, role, - in_streams, out_streams); - block = std::move(block_); - } + // RESAMPLER --------------------------------------------------------------- + else if (implementation == "Direct_Resampler") + { + std::unique_ptr block_ = std::make_unique(configuration, role, + in_streams, out_streams); + block = std::move(block_); + } - else if ((implementation == "Fractional_Resampler") || (implementation == "Mmse_Resampler")) - { - std::unique_ptr block_ = std::make_unique(configuration, role, - in_streams, out_streams); - block = std::move(block_); - } + else if ((implementation == "Fractional_Resampler") || (implementation == "Mmse_Resampler")) + { + std::unique_ptr block_ = std::make_unique(configuration, role, + in_streams, out_streams); + block = std::move(block_); + } - // ACQUISITION BLOCKS ------------------------------------------------------ - else if (implementation == "GPS_L1_CA_PCPS_Acquisition") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "GPS_L1_CA_PCPS_Assisted_Acquisition") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "GPS_L1_CA_PCPS_Tong_Acquisition") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "GPS_L1_CA_PCPS_Acquisition_Fine_Doppler") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "GPS_L1_CA_PCPS_QuickSync_Acquisition") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "GPS_L2_M_PCPS_Acquisition") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "GPS_L5i_PCPS_Acquisition") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Galileo_E1_PCPS_Ambiguous_Acquisition") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Galileo_E1_PCPS_8ms_Ambiguous_Acquisition") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Galileo_E1_PCPS_Tong_Ambiguous_Acquisition") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Galileo_E1_PCPS_CCCWSR_Ambiguous_Acquisition") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Galileo_E1_PCPS_QuickSync_Ambiguous_Acquisition") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Galileo_E5a_Noncoherent_IQ_Acquisition_CAF") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Galileo_E5a_Pcps_Acquisition") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Galileo_E5b_PCPS_Acquisition") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Galileo_E6_PCPS_Acquisition") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "GLONASS_L1_CA_PCPS_Acquisition") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "GLONASS_L2_CA_PCPS_Acquisition") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "BEIDOU_B1I_PCPS_Acquisition") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "BEIDOU_B3I_PCPS_Acquisition") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } + // ACQUISITION BLOCKS ------------------------------------------------------ + else if (implementation == "GPS_L1_CA_PCPS_Acquisition") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "GPS_L1_CA_PCPS_Assisted_Acquisition") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "GPS_L1_CA_PCPS_Tong_Acquisition") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "GPS_L1_CA_PCPS_Acquisition_Fine_Doppler") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "GPS_L1_CA_PCPS_QuickSync_Acquisition") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "GPS_L2_M_PCPS_Acquisition") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "GPS_L5i_PCPS_Acquisition") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Galileo_E1_PCPS_Ambiguous_Acquisition") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Galileo_E1_PCPS_8ms_Ambiguous_Acquisition") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Galileo_E1_PCPS_Tong_Ambiguous_Acquisition") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Galileo_E1_PCPS_CCCWSR_Ambiguous_Acquisition") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Galileo_E1_PCPS_QuickSync_Ambiguous_Acquisition") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Galileo_E5a_Noncoherent_IQ_Acquisition_CAF") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Galileo_E5a_Pcps_Acquisition") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Galileo_E5b_PCPS_Acquisition") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Galileo_E6_PCPS_Acquisition") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "GLONASS_L1_CA_PCPS_Acquisition") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "GLONASS_L2_CA_PCPS_Acquisition") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "BEIDOU_B1I_PCPS_Acquisition") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "BEIDOU_B3I_PCPS_Acquisition") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } #if OPENCL_BLOCKS - else if (implementation == "GPS_L1_CA_PCPS_OpenCl_Acquisition") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } + else if (implementation == "GPS_L1_CA_PCPS_OpenCl_Acquisition") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } #endif #if ENABLE_FPGA - else if (implementation == "GPS_L1_CA_PCPS_Acquisition_Fpga") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Galileo_E1_PCPS_Ambiguous_Acquisition_Fpga") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "GPS_L2_M_PCPS_Acquisition_Fpga") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "GPS_L5i_PCPS_Acquisition_Fpga") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Galileo_E5a_Pcps_Acquisition_Fpga") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Galileo_E5b_PCPS_Acquisition_FPGA") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } + else if (implementation == "GPS_L1_CA_PCPS_Acquisition_Fpga") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Galileo_E1_PCPS_Ambiguous_Acquisition_Fpga") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "GPS_L2_M_PCPS_Acquisition_Fpga") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "GPS_L5i_PCPS_Acquisition_Fpga") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Galileo_E5a_Pcps_Acquisition_Fpga") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Galileo_E5b_PCPS_Acquisition_FPGA") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } #endif - // TRACKING BLOCKS --------------------------------------------------------- - else if (implementation == "GPS_L1_CA_DLL_PLL_Tracking") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "GPS_L1_CA_KF_Tracking") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "GPS_L1_CA_TCP_CONNECTOR_Tracking") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "GPS_L2_M_DLL_PLL_Tracking") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if ((implementation == "GPS_L5i_DLL_PLL_Tracking") or (implementation == "GPS_L5_DLL_PLL_Tracking")) - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Galileo_E1_DLL_PLL_VEML_Tracking") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Galileo_E1_TCP_CONNECTOR_Tracking") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Galileo_E5a_DLL_PLL_Tracking") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Galileo_E5b_DLL_PLL_Tracking") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Galileo_E6_DLL_PLL_Tracking") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "GLONASS_L1_CA_DLL_PLL_Tracking") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "GLONASS_L1_CA_DLL_PLL_C_Aid_Tracking") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "GLONASS_L2_CA_DLL_PLL_Tracking") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "GLONASS_L2_CA_DLL_PLL_C_Aid_Tracking") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "BEIDOU_B1I_DLL_PLL_Tracking") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "BEIDOU_B3I_DLL_PLL_Tracking") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } + // TRACKING BLOCKS --------------------------------------------------------- + else if (implementation == "GPS_L1_CA_DLL_PLL_Tracking") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "GPS_L1_CA_KF_Tracking") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "GPS_L1_CA_TCP_CONNECTOR_Tracking") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "GPS_L2_M_DLL_PLL_Tracking") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if ((implementation == "GPS_L5i_DLL_PLL_Tracking") or (implementation == "GPS_L5_DLL_PLL_Tracking")) + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Galileo_E1_DLL_PLL_VEML_Tracking") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Galileo_E1_TCP_CONNECTOR_Tracking") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Galileo_E5a_DLL_PLL_Tracking") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Galileo_E5b_DLL_PLL_Tracking") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Galileo_E6_DLL_PLL_Tracking") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "GLONASS_L1_CA_DLL_PLL_Tracking") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "GLONASS_L1_CA_DLL_PLL_C_Aid_Tracking") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "GLONASS_L2_CA_DLL_PLL_Tracking") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "GLONASS_L2_CA_DLL_PLL_C_Aid_Tracking") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "BEIDOU_B1I_DLL_PLL_Tracking") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "BEIDOU_B3I_DLL_PLL_Tracking") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } #if CUDA_GPU_ACCEL - else if (implementation == "GPS_L1_CA_DLL_PLL_Tracking_GPU") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } + else if (implementation == "GPS_L1_CA_DLL_PLL_Tracking_GPU") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } #endif #if ENABLE_FPGA - else if (implementation == "GPS_L1_CA_DLL_PLL_Tracking_Fpga") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "GPS_L2_M_DLL_PLL_Tracking_Fpga") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if ((implementation == "GPS_L5i_DLL_PLL_Tracking_Fpga") or (implementation == "GPS_L5_DLL_PLL_Tracking_Fpga")) - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Galileo_E5a_DLL_PLL_Tracking_Fpga") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } + else if (implementation == "GPS_L1_CA_DLL_PLL_Tracking_Fpga") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "GPS_L2_M_DLL_PLL_Tracking_Fpga") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if ((implementation == "GPS_L5i_DLL_PLL_Tracking_Fpga") or (implementation == "GPS_L5_DLL_PLL_Tracking_Fpga")) + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Galileo_E5a_DLL_PLL_Tracking_Fpga") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } #endif - // TELEMETRY DECODERS ------------------------------------------------------ - else if (implementation == "GPS_L1_CA_Telemetry_Decoder") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "GPS_L2C_Telemetry_Decoder") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "GPS_L5_Telemetry_Decoder") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "SBAS_L1_Telemetry_Decoder") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Galileo_E1B_Telemetry_Decoder") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Galileo_E5a_Telemetry_Decoder") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Galileo_E5b_Telemetry_Decoder") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "Galileo_E6_Telemetry_Decoder") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "GLONASS_L1_CA_Telemetry_Decoder") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "GLONASS_L2_CA_Telemetry_Decoder") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "BEIDOU_B1I_Telemetry_Decoder") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } - else if (implementation == "BEIDOU_B3I_Telemetry_Decoder") - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } + // TELEMETRY DECODERS ------------------------------------------------------ + else if (implementation == "GPS_L1_CA_Telemetry_Decoder") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "GPS_L2C_Telemetry_Decoder") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "GPS_L5_Telemetry_Decoder") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "SBAS_L1_Telemetry_Decoder") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Galileo_E1B_Telemetry_Decoder") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Galileo_E5a_Telemetry_Decoder") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Galileo_E5b_Telemetry_Decoder") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "Galileo_E6_Telemetry_Decoder") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "GLONASS_L1_CA_Telemetry_Decoder") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "GLONASS_L2_CA_Telemetry_Decoder") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "BEIDOU_B1I_Telemetry_Decoder") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } + else if (implementation == "BEIDOU_B3I_Telemetry_Decoder") + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } - // OBSERVABLES ------------------------------------------------------------- - else if ((implementation == "Hybrid_Observables") || (implementation == "GPS_L1_CA_Observables") || (implementation == "GPS_L2C_Observables") || - (implementation == "Galileo_E5A_Observables")) - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } + // OBSERVABLES ------------------------------------------------------------- + else if ((implementation == "Hybrid_Observables") || (implementation == "GPS_L1_CA_Observables") || (implementation == "GPS_L2C_Observables") || + (implementation == "Galileo_E5A_Observables")) + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } - // PVT --------------------------------------------------------------------- - else if ((implementation == "RTKLIB_PVT") || (implementation == "GPS_L1_CA_PVT") || (implementation == "Galileo_E1_PVT") || (implementation == "Hybrid_PVT")) - { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, - out_streams); - block = std::move(block_); - } + // PVT --------------------------------------------------------------------- + else if ((implementation == "RTKLIB_PVT") || (implementation == "GPS_L1_CA_PVT") || (implementation == "Galileo_E1_PVT") || (implementation == "Hybrid_PVT")) + { + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + out_streams); + block = std::move(block_); + } - else + else + { + // Log fatal. This causes execution to stop. + LOG(FATAL) << role << "." << implementation << ": Undefined implementation for block"; + } + } + catch (const std::exception& e) { - LOG(ERROR) << role << " block: Undefined implementation " << implementation; + std::cout << "GNSS-SDR program ended.\n"; + exit(1); } return block; } @@ -1351,8 +1292,7 @@ std::unique_ptr GNSSBlockFactory::GetAcqBlock( unsigned int out_streams) { std::unique_ptr block; - const std::string default_impl("Wrong"); - const std::string implementation = configuration->property(role + ".implementation", default_impl); + const std::string implementation = configuration->property(role + impl_prop, "Wrong"s); // ACQUISITION BLOCKS ------------------------------------------------------ if (implementation == "GPS_L1_CA_PCPS_Acquisition") @@ -1538,8 +1478,7 @@ std::unique_ptr GNSSBlockFactory::GetTrkBlock( unsigned int out_streams) { std::unique_ptr block; - const std::string default_impl("Wrong"); - const std::string implementation = configuration->property(role + ".implementation", default_impl); + const std::string implementation = configuration->property(role + impl_prop, "Wrong"s); // TRACKING BLOCKS --------------------------------------------------------- if (implementation == "GPS_L1_CA_DLL_PLL_Tracking") @@ -1693,8 +1632,7 @@ std::unique_ptr GNSSBlockFactory::GetTlmBlock( unsigned int out_streams) { std::unique_ptr block; - const std::string default_impl("Wrong"); - const std::string implementation = configuration->property(role + ".implementation", default_impl); + const std::string implementation = configuration->property(role + impl_prop, "Wrong"s); // TELEMETRY DECODERS ------------------------------------------------------ if (implementation == "GPS_L1_CA_Telemetry_Decoder") @@ -1774,5 +1712,6 @@ std::unique_ptr GNSSBlockFactory::GetTlmBlock( { LOG(ERROR) << role << " block: Undefined implementation " << implementation; } + return block; } diff --git a/src/core/receiver/gnss_block_factory.h b/src/core/receiver/gnss_block_factory.h index 13ceeb937..6e22084e8 100644 --- a/src/core/receiver/gnss_block_factory.h +++ b/src/core/receiver/gnss_block_factory.h @@ -38,6 +38,7 @@ class ConfigurationInterface; class GNSSBlockInterface; +class SignalSourceInterface; class AcquisitionInterface; class TrackingInterface; class TelemetryDecoderInterface; @@ -51,7 +52,7 @@ public: GNSSBlockFactory() = default; ~GNSSBlockFactory() = default; - std::unique_ptr GetSignalSource(const ConfigurationInterface* configuration, + std::unique_ptr GetSignalSource(const ConfigurationInterface* configuration, Concurrent_Queue* queue, int ID = -1); std::unique_ptr GetSignalConditioner(const ConfigurationInterface* configuration, int ID = -1); diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index c6f684e83..28d8e7a43 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -36,6 +36,7 @@ #include "gnss_satellite.h" #include "gnss_sdr_make_unique.h" #include "gnss_synchro_monitor.h" +#include "signal_source_interface.h" #include // for boost::lexical_cast #include // for boost::tokenizer #include // for LOG @@ -100,50 +101,19 @@ void GNSSFlowgraph::init() // 1. read the number of RF front-ends available (one file_source per RF front-end) sources_count_ = configuration_->property("Receiver.sources_count", 1); - int RF_Channels = 0; int signal_conditioner_ID = 0; - if (sources_count_ > 1) + for (int i = 0; i < sources_count_; i++) { - for (int i = 0; i < sources_count_; i++) + std::cout << "Creating source " << i << '\n'; + sig_source_.push_back(block_factory->GetSignalSource(configuration_.get(), queue_.get(), i)); + auto& src = sig_source_.back(); + auto RF_Channels = src->getRfChannels(); + std::cout << "RF Channels " << RF_Channels << '\n'; + for (int j = 0; j < RF_Channels; j++) { - std::cout << "Creating source " << i << '\n'; - sig_source_.push_back(block_factory->GetSignalSource(configuration_.get(), queue_.get(), i)); - // TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. - // Include GetRFChannels in the interface to avoid read config parameters here - // read the number of RF channels for each front-end - RF_Channels = configuration_->property(sig_source_.at(i)->role() + ".RF_channels", 1); - std::cout << "RF Channels " << RF_Channels << '\n'; - for (int j = 0; j < RF_Channels; j++) - { - sig_conditioner_.push_back(block_factory->GetSignalConditioner(configuration_.get(), signal_conditioner_ID)); - signal_conditioner_ID++; - } - } - } - else - { - // backwards compatibility for old config files - sig_source_.push_back(block_factory->GetSignalSource(configuration_.get(), queue_.get(), -1)); - // TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. - // Include GetRFChannels in the interface to avoid read config parameters here - // read the number of RF channels for each front-end - if (sig_source_.at(0) != nullptr) - { - RF_Channels = configuration_->property(sig_source_.at(0)->role() + ".RF_channels", 0); - } - if (RF_Channels != 0) - { - for (int j = 0; j < RF_Channels; j++) - { - sig_conditioner_.push_back(block_factory->GetSignalConditioner(configuration_.get(), signal_conditioner_ID)); - signal_conditioner_ID++; - } - } - else - { - // old config file, single signal source and single channel, not specified - sig_conditioner_.push_back(block_factory->GetSignalConditioner(configuration_.get(), -1)); + sig_conditioner_.push_back(block_factory->GetSignalConditioner(configuration_.get(), signal_conditioner_ID)); + signal_conditioner_ID++; } } @@ -1028,42 +998,40 @@ int GNSSFlowgraph::disconnect_fpga_sample_counter() int GNSSFlowgraph::connect_signal_sources_to_signal_conditioners() { - int RF_Channels = 0; unsigned int signal_conditioner_ID = 0; for (int i = 0; i < sources_count_; i++) { try { + auto& src = sig_source_.at(i); + // TODO: Remove this array implementation and create generic multistream connector // (if a signal source has more than 1 stream, then connect it to the multistream signal conditioner) - if (sig_source_.at(i)->implementation() == "Raw_Array_Signal_Source") + if (src->implementation() == "Raw_Array_Signal_Source") { // Multichannel Array std::cout << "ARRAY MODE\n"; for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) { std::cout << "connecting ch " << j << '\n'; - top_block_->connect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j); + top_block_->connect(src->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j); } } else { - // TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. - // Include GetRFChannels in the interface to avoid read config parameters here - // read the number of RF channels for each front-end - RF_Channels = configuration_->property(sig_source_.at(i)->role() + ".RF_channels", 1); + auto RF_Channels = src->getRfChannels(); for (int j = 0; j < RF_Channels; j++) { // Connect the multichannel signal source to multiple signal conditioners // GNURADIO max_streams=-1 means infinite ports! - size_t output_size = sig_source_.at(i)->item_size(); + size_t output_size = src->item_size(); size_t input_size = sig_conditioner_.at(signal_conditioner_ID)->get_left_block()->input_signature()->sizeof_stream_item(0); // Check configuration inconsistencies if (output_size != input_size) { - help_hint_ += " * The Signal Source implementation " + sig_source_.at(i)->implementation() + " has an output with a "; - help_hint_ += sig_source_.at(i)->role() + ".item_size of " + std::to_string(output_size); + help_hint_ += " * The Signal Source implementation " + src->implementation() + " has an output with a "; + help_hint_ += src->role() + ".item_size of " + std::to_string(output_size); help_hint_ += " bytes, but it is connected to the Signal Conditioner implementation "; help_hint_ += sig_conditioner_.at(signal_conditioner_ID)->implementation() + " with input item size of " + std::to_string(input_size) + " bytes.\n"; help_hint_ += " Output ports must be connected to input ports with the same item size.\n"; @@ -1071,12 +1039,12 @@ int GNSSFlowgraph::connect_signal_sources_to_signal_conditioners() return 1; } - if (sig_source_.at(i)->get_right_block()->output_signature()->max_streams() > 1 or sig_source_.at(i)->get_right_block()->output_signature()->max_streams() == -1) + if (src->get_right_block()->output_signature()->max_streams() > 1 or src->get_right_block()->output_signature()->max_streams() == -1) { if (sig_conditioner_.size() > signal_conditioner_ID) { - LOG(INFO) << "connecting sig_source_ " << i << " stream " << j << " to conditioner " << j; - top_block_->connect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + LOG(INFO) << "connecting sig_source_ " << i << " stream " << j << " to conditioner " << signal_conditioner_ID; + top_block_->connect(src->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); } } else @@ -1084,14 +1052,14 @@ int GNSSFlowgraph::connect_signal_sources_to_signal_conditioners() if (j == 0) { // RF_channel 0 backward compatibility with single channel sources - LOG(INFO) << "connecting sig_source_ " << i << " stream " << 0 << " to conditioner " << j; - top_block_->connect(sig_source_.at(i)->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + LOG(INFO) << "connecting sig_source_ " << i << " stream " << 0 << " to conditioner " << signal_conditioner_ID; + top_block_->connect(src->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); } else { // Multiple channel sources using multiple output blocks of single channel (requires RF_channel selector in call) - LOG(INFO) << "connecting sig_source_ " << i << " stream " << j << " to conditioner " << j; - top_block_->connect(sig_source_.at(i)->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + LOG(INFO) << "connecting sig_source_ " << i << " stream " << j << " to conditioner " << signal_conditioner_ID; + top_block_->connect(src->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); } } signal_conditioner_ID++; @@ -1127,46 +1095,44 @@ int GNSSFlowgraph::connect_signal_sources_to_signal_conditioners() int GNSSFlowgraph::disconnect_signal_sources_from_signal_conditioners() { - int RF_Channels = 0; int signal_conditioner_ID = 0; for (int i = 0; i < sources_count_; i++) { try { + auto& src = sig_source_.at(i); + // TODO: Remove this array implementation and create generic multistream connector // (if a signal source has more than 1 stream, then connect it to the multistream signal conditioner) - if (sig_source_.at(i)->implementation() == "Raw_Array_Signal_Source") + if (src->implementation() == "Raw_Array_Signal_Source") { // Multichannel Array for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) { - top_block_->disconnect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j); + top_block_->disconnect(src->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j); } } else { - // TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. - // Include GetRFChannels in the interface to avoid read config parameters here - // read the number of RF channels for each front-end - RF_Channels = configuration_->property(sig_source_.at(i)->role() + ".RF_channels", 1); + auto RF_Channels = src->getRfChannels(); for (int j = 0; j < RF_Channels; j++) { - if (sig_source_.at(i)->get_right_block()->output_signature()->max_streams() > 1 or sig_source_.at(i)->get_right_block()->output_signature()->max_streams() == -1) + if (src->get_right_block()->output_signature()->max_streams() > 1 or src->get_right_block()->output_signature()->max_streams() == -1) { - top_block_->disconnect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + top_block_->disconnect(src->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); } else { if (j == 0) { // RF_channel 0 backward compatibility with single channel sources - top_block_->disconnect(sig_source_.at(i)->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + top_block_->disconnect(src->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); } else { // Multiple channel sources using multiple output blocks of single channel (requires RF_channel selector in call) - top_block_->disconnect(sig_source_.at(i)->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + top_block_->disconnect(src->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); } } signal_conditioner_ID++; diff --git a/src/core/receiver/gnss_flowgraph.h b/src/core/receiver/gnss_flowgraph.h index 8b71bb672..59086a366 100644 --- a/src/core/receiver/gnss_flowgraph.h +++ b/src/core/receiver/gnss_flowgraph.h @@ -53,6 +53,7 @@ class ChannelInterface; class ConfigurationInterface; class GNSSBlockInterface; class Gnss_Satellite; +class SignalSourceInterface; /*! \brief This class represents a GNSS flow graph. * @@ -230,7 +231,7 @@ private: std::shared_ptr configuration_; std::shared_ptr> queue_; - std::vector> sig_source_; + std::vector> sig_source_; std::vector> sig_conditioner_; std::vector> channels_; std::shared_ptr observables_; diff --git a/src/tests/unit-tests/control-plane/gnss_block_factory_test.cc b/src/tests/unit-tests/control-plane/gnss_block_factory_test.cc index 96e6051a7..be9709fb4 100644 --- a/src/tests/unit-tests/control-plane/gnss_block_factory_test.cc +++ b/src/tests/unit-tests/control-plane/gnss_block_factory_test.cc @@ -24,6 +24,7 @@ #include "concurrent_queue.h" #include "gnss_block_factory.h" #include "gnss_block_interface.h" +#include "signal_source_interface.h" #include "gnss_sdr_make_unique.h" #include "in_memory_configuration.h" #include "observables_interface.h" @@ -45,7 +46,7 @@ TEST(GNSSBlockFactoryTest, InstantiateFileSignalSource) // Example of a factory as a shared_ptr std::shared_ptr factory = std::make_shared(); // Example of a block as a shared_ptr - std::shared_ptr signal_source = factory->GetSignalSource(configuration.get(), queue.get()); + auto signal_source = factory->GetSignalSource(configuration.get(), queue.get()); EXPECT_STREQ("SignalSource", signal_source->role().c_str()); EXPECT_STREQ("File_Signal_Source", signal_source->implementation().c_str()); } @@ -59,7 +60,7 @@ TEST(GNSSBlockFactoryTest, InstantiateWrongSignalSource) // Example of a factory as a unique_ptr std::unique_ptr factory = std::make_unique(); // Example of a block as a unique_ptr - std::unique_ptr signal_source = factory->GetSignalSource(configuration.get(), queue.get()); + auto signal_source = factory->GetSignalSource(configuration.get(), queue.get()); EXPECT_EQ(nullptr, signal_source); } diff --git a/src/utils/front-end-cal/main.cc b/src/utils/front-end-cal/main.cc index d89478fb5..c62303eba 100644 --- a/src/utils/front-end-cal/main.cc +++ b/src/utils/front-end-cal/main.cc @@ -36,7 +36,8 @@ #include "gps_iono.h" #include "gps_l1_ca_pcps_acquisition_fine_doppler.h" #include "gps_utc_model.h" -#include // for bad_any_cast +#include "signal_source_interface.h" // for SignalSourceInterface +#include // for bad_any_cast #include #include #include @@ -181,6 +182,10 @@ void wait_message() bool front_end_capture(const std::shared_ptr& configuration) { + auto success = false; + + std::string trace_step; + gr::top_block_sptr top_block; GNSSBlockFactory block_factory; std::shared_ptr> queue; @@ -188,43 +193,37 @@ bool front_end_capture(const std::shared_ptr& configurat queue = std::make_shared>(); top_block = gr::make_top_block("Acquisition test"); - std::shared_ptr source; try { + // Note: the block_factory returns a unique_ptr (what you would get with an "auto" + // declaration), but the flowgraph uses shared_ptr. Without further understanding of why + // it should matter in this context, used shared_ptr throughout + std::shared_ptr source; + std::shared_ptr conditioner; + + trace_step = "creating source"; source = block_factory.GetSignalSource(configuration.get(), queue.get()); - } - catch (const boost::exception_ptr& e) - { - std::cout << "Exception caught in creating source " << e << '\n'; - return false; - } - std::shared_ptr conditioner; - try - { + trace_step = "creating signal conditioner"; conditioner = block_factory.GetSignalConditioner(configuration.get()); - } - catch (const boost::exception_ptr& e) - { - std::cout << "Exception caught in creating signal conditioner " << e << '\n'; - return false; - } - gr::block_sptr sink; - sink = gr::blocks::file_sink::make(sizeof(gr_complex), "tmp_capture.dat"); - // -- Find number of samples per spreading code --- - int64_t fs_in_ = configuration->property("GNSS-SDR.internal_fs_sps", 2048000); - int samples_per_code = round(fs_in_ / (GPS_L1_CA_CODE_RATE_CPS / GPS_L1_CA_CODE_LENGTH_CHIPS)); - int nsamples = samples_per_code * 50; + trace_step = "unexpected in setup code"; - int skip_samples = fs_in_ * 5; // skip 5 seconds + gr::block_sptr sink; + sink = gr::blocks::file_sink::make(sizeof(gr_complex), "tmp_capture.dat"); - gr::block_sptr head = gr::blocks::head::make(sizeof(gr_complex), nsamples); + // -- Find number of samples per spreading code --- + int64_t fs_in_ = configuration->property("GNSS-SDR.internal_fs_sps", 2048000); + int samples_per_code = round(fs_in_ / (GPS_L1_CA_CODE_RATE_CPS / GPS_L1_CA_CODE_LENGTH_CHIPS)); + int nsamples = samples_per_code * 50; - gr::block_sptr skiphead = gr::blocks::skiphead::make(sizeof(gr_complex), skip_samples); + int skip_samples = fs_in_ * 5; // skip 5 seconds - try - { + gr::block_sptr head = gr::blocks::head::make(sizeof(gr_complex), nsamples); + + gr::block_sptr skiphead = gr::blocks::skiphead::make(sizeof(gr_complex), skip_samples); + + trace_step = "connecting the GNU Radio blocks"; source->connect(top_block); conditioner->connect(top_block); top_block->connect(source->get_right_block(), 0, conditioner->get_left_block(), 0); @@ -232,14 +231,15 @@ bool front_end_capture(const std::shared_ptr& configurat top_block->connect(skiphead, 0, head, 0); top_block->connect(head, 0, sink, 0); top_block->run(); + + success = true; } - catch (const std::exception& e) + catch (std::exception const& e) { - std::cout << "Failure connecting the GNU Radio blocks " << e.what() << '\n'; - return false; + std::cout << "Exception caught " << trace_step << ": " << e.what() << std::endl; } - return true; + return success; }