1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-14 04:00:34 +00:00

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.
This commit is contained in:
Jim Melton 2021-02-09 15:47:34 -07:00
parent 8407acb7a7
commit 78362e7cba
48 changed files with 948 additions and 1142 deletions

View File

@ -586,14 +586,14 @@ endif()
################################################################################ ################################################################################
# Log4cpp - http://log4cpp.sourceforge.net/ # Log4cpp - http://log4cpp.sourceforge.net/
################################################################################ ################################################################################
#find_package(LOG4CPP) find_package(LOG4CPP)
#set_package_properties(LOG4CPP PROPERTIES set_package_properties(LOG4CPP PROPERTIES
# PURPOSE "Required by GNU Radio." PURPOSE "Required by GNU Radio."
# TYPE REQUIRED TYPE REQUIRED
#) )
#if(NOT LOG4CPP_FOUND) if(NOT LOG4CPP_FOUND)
# message(FATAL_ERROR "*** Log4cpp is required to build gnss-sdr") message(FATAL_ERROR "*** Log4cpp is required to build gnss-sdr")
#endif() endif()

View File

@ -92,6 +92,7 @@ endif()
set(SIGNAL_SOURCE_ADAPTER_SOURCES set(SIGNAL_SOURCE_ADAPTER_SOURCES
signal_source_base.cc
file_signal_source.cc file_signal_source.cc
multichannel_file_signal_source.cc multichannel_file_signal_source.cc
gen_signal_source.cc gen_signal_source.cc
@ -106,6 +107,7 @@ set(SIGNAL_SOURCE_ADAPTER_SOURCES
) )
set(SIGNAL_SOURCE_ADAPTER_HEADERS set(SIGNAL_SOURCE_ADAPTER_HEADERS
signal_source_base.h
file_signal_source.h file_signal_source.h
multichannel_file_signal_source.h multichannel_file_signal_source.h
gen_signal_source.h gen_signal_source.h

View File

@ -42,9 +42,12 @@
#include <vector> #include <vector>
using namespace std::string_literals;
Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(const ConfigurationInterface *configuration, Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(const ConfigurationInterface *configuration,
const std::string &role, unsigned int in_stream, unsigned int out_stream, const std::string &role, unsigned int in_stream, unsigned int out_stream,
Concurrent_Queue<pmt::pmt_t> *queue __attribute__((unused))) : role_(role), in_stream_(in_stream), out_stream_(out_stream) Concurrent_Queue<pmt::pmt_t> *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 std::string default_gain_mode("slow_attack");
const double default_tx_attenuation_db = -10.0; const double default_tx_attenuation_db = -10.0;

View File

@ -18,7 +18,7 @@
#ifndef GNSS_SDR_AD9361_FPGA_SIGNAL_SOURCE_H #ifndef GNSS_SDR_AD9361_FPGA_SIGNAL_SOURCE_H
#define 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 "concurrent_queue.h"
#include "fpga_dynamic_bit_selection.h" #include "fpga_dynamic_bit_selection.h"
@ -40,7 +40,7 @@
class ConfigurationInterface; class ConfigurationInterface;
class Ad9361FpgaSignalSource : public SignalSourceInterface class Ad9361FpgaSignalSource : public SignalSourceBase
{ {
public: public:
Ad9361FpgaSignalSource(const ConfigurationInterface *configuration, Ad9361FpgaSignalSource(const ConfigurationInterface *configuration,
@ -51,17 +51,12 @@ public:
void start() override; void start() override;
inline std::string role() override
{
return role_;
}
/*! /*!
* \brief Returns "Ad9361_Fpga_Signal_Source" * \brief Returns "Ad9361_Fpga_Signal_Source"
*/ */
inline std::string implementation() override inline std::string implementation() override
{ {
return "Ad9361_Fpga_Signal_Source"; return ;
} }
inline size_t item_size() override inline size_t item_size() override
@ -93,8 +88,6 @@ private:
std::shared_ptr<Fpga_Switch> switch_fpga; std::shared_ptr<Fpga_Switch> switch_fpga;
std::shared_ptr<Fpga_dynamic_bit_selection> dynamic_bit_selection_fpga; std::shared_ptr<Fpga_dynamic_bit_selection> dynamic_bit_selection_fpga;
std::string role_;
// Front-end settings // Front-end settings
std::string gain_mode_rx1_; std::string gain_mode_rx1_;
std::string gain_mode_rx2_; std::string gain_mode_rx2_;

View File

@ -21,9 +21,13 @@
#include <iostream> #include <iostream>
using namespace std::string_literals;
CustomUDPSignalSource::CustomUDPSignalSource(const ConfigurationInterface* configuration, CustomUDPSignalSource::CustomUDPSignalSource(const ConfigurationInterface* configuration,
const std::string& role, unsigned int in_stream, unsigned int out_stream, const std::string& role, unsigned int in_stream, unsigned int out_stream,
Concurrent_Queue<pmt::pmt_t>* queue __attribute__((unused))) : role_(role), in_stream_(in_stream), out_stream_(out_stream) Concurrent_Queue<pmt::pmt_t>* queue __attribute__((unused)))
: SignalSourceBase(configuration, role, "Custom_UDP_Signal_Source"s)
, in_stream_(in_stream), out_stream_(out_stream)
{ {
// DUMP PARAMETERS // DUMP PARAMETERS
const std::string default_dump_file("./data/signal_source.dat"); const std::string default_dump_file("./data/signal_source.dat");

View File

@ -18,10 +18,9 @@
#ifndef GNSS_SDR_CUSTOM_UDP_SIGNAL_SOURCE_H #ifndef GNSS_SDR_CUSTOM_UDP_SIGNAL_SOURCE_H
#define 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 "concurrent_queue.h"
#include "gnss_block_interface.h"
#include "gr_complex_ip_packet_source.h" #include "gr_complex_ip_packet_source.h"
#include <gnuradio/blocks/file_sink.h> #include <gnuradio/blocks/file_sink.h>
#include <gnuradio/blocks/null_sink.h> #include <gnuradio/blocks/null_sink.h>
@ -42,29 +41,15 @@ class ConfigurationInterface;
* \brief This class reads from UDP packets, which streams interleaved * \brief This class reads from UDP packets, which streams interleaved
* I/Q samples over a network. * I/Q samples over a network.
*/ */
class CustomUDPSignalSource : public SignalSourceInterface class CustomUDPSignalSource : public SignalSourceBase
{ {
public: public:
void fixme() final {}
CustomUDPSignalSource(const ConfigurationInterface* configuration, CustomUDPSignalSource(const ConfigurationInterface* configuration,
const std::string& role, unsigned int in_stream, const std::string& role, unsigned int in_stream,
unsigned int out_stream, Concurrent_Queue<pmt::pmt_t>* queue); unsigned int out_stream, Concurrent_Queue<pmt::pmt_t>* queue);
~CustomUDPSignalSource() = default; ~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 inline size_t item_size() override
{ {
return item_size_; return item_size_;
@ -81,7 +66,6 @@ private:
std::vector<gnss_shared_ptr<gr::block>> null_sinks_; std::vector<gnss_shared_ptr<gr::block>> null_sinks_;
std::vector<gnss_shared_ptr<gr::block>> file_sink_; std::vector<gnss_shared_ptr<gr::block>> file_sink_;
std::string role_;
std::string item_type_; std::string item_type_;
std::string dump_filename_; std::string dump_filename_;

View File

@ -27,10 +27,13 @@
#include <iostream> // for std::cerr #include <iostream> // for std::cerr
#include <utility> #include <utility>
using namespace std::string_literals;
FileSignalSource::FileSignalSource(const ConfigurationInterface* configuration, FileSignalSource::FileSignalSource(ConfigurationInterface const* configuration,
const std::string& role, unsigned int in_streams, unsigned int out_streams, std::string const& role, unsigned int in_streams, unsigned int out_streams,
Concurrent_Queue<pmt::pmt_t>* queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams) Concurrent_Queue<pmt::pmt_t>* 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_filename("./example_capture.dat");
const std::string default_item_type("short"); const std::string default_item_type("short");

View File

@ -21,10 +21,9 @@
#ifndef GNSS_SDR_FILE_SIGNAL_SOURCE_H #ifndef GNSS_SDR_FILE_SIGNAL_SOURCE_H
#define 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 "concurrent_queue.h"
#include "gnss_block_interface.h"
#include <gnuradio/blocks/file_sink.h> #include <gnuradio/blocks/file_sink.h>
#include <gnuradio/blocks/file_source.h> #include <gnuradio/blocks/file_source.h>
#include <gnuradio/blocks/throttle.h> #include <gnuradio/blocks/throttle.h>
@ -47,29 +46,15 @@ class ConfigurationInterface;
* \brief Class that reads signals samples from a file * \brief Class that reads signals samples from a file
* and adapts it to a SignalSourceInterface * and adapts it to a SignalSourceInterface
*/ */
class FileSignalSource : public SignalSourceInterface class FileSignalSource : public SignalSourceBase
{ {
public: public:
void fixme() final {} FileSignalSource(ConfigurationInterface const* configuration, std::string const& role,
FileSignalSource(const ConfigurationInterface* configuration, const std::string& role,
unsigned int in_streams, unsigned int out_streams, unsigned int in_streams, unsigned int out_streams,
Concurrent_Queue<pmt::pmt_t>* queue); Concurrent_Queue<pmt::pmt_t>* queue);
~FileSignalSource() = default; ~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 inline size_t item_size() override
{ {
return item_size_; return item_size_;
@ -111,7 +96,6 @@ private:
gr::blocks::file_sink::sptr sink_; gr::blocks::file_sink::sptr sink_;
gr::blocks::throttle::sptr throttle_; gr::blocks::throttle::sptr throttle_;
std::string role_;
std::string item_type_; std::string item_type_;
std::string filename_; std::string filename_;
std::string dump_filename_; std::string dump_filename_;

View File

@ -23,12 +23,15 @@
#include <teleorbit/frontend.h> #include <teleorbit/frontend.h>
#include <utility> #include <utility>
using namespace std::string_literals;
FlexibandSignalSource::FlexibandSignalSource(const ConfigurationInterface* configuration, FlexibandSignalSource::FlexibandSignalSource(const ConfigurationInterface* configuration,
const std::string& role, const std::string& role,
unsigned int in_stream, unsigned int in_stream,
unsigned int out_stream, unsigned int out_stream,
Concurrent_Queue<pmt::pmt_t>* queue __attribute__((unused))) : role_(role), in_stream_(in_stream), out_stream_(out_stream) Concurrent_Queue<pmt::pmt_t>* 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"); const std::string default_item_type("byte");
item_type_ = configuration->property(role + ".item_type", default_item_type); item_type_ = configuration->property(role + ".item_type", default_item_type);

View File

@ -20,10 +20,9 @@
#ifndef GNSS_SDR_FLEXIBAND_SIGNAL_SOURCE_H #ifndef GNSS_SDR_FLEXIBAND_SIGNAL_SOURCE_H
#define 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 "concurrent_queue.h"
#include "gnss_block_interface.h"
#include <gnuradio/blocks/char_to_float.h> #include <gnuradio/blocks/char_to_float.h>
#include <gnuradio/blocks/file_sink.h> #include <gnuradio/blocks/file_sink.h>
#include <gnuradio/blocks/float_to_complex.h> #include <gnuradio/blocks/float_to_complex.h>
@ -47,7 +46,7 @@ class ConfigurationInterface;
* \brief This class configures and reads samples from Teleorbit Flexiband front-end. * \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). * This software requires a Flexiband GNU Radio driver installed (not included with GNSS-SDR).
*/ */
class FlexibandSignalSource : public SignalSourceInterface class FlexibandSignalSource : public SignalSourceBase
{ {
public: public:
FlexibandSignalSource(const ConfigurationInterface* configuration, FlexibandSignalSource(const ConfigurationInterface* configuration,
@ -56,19 +55,6 @@ public:
~FlexibandSignalSource() = default; ~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 inline size_t item_size() override
{ {
return item_size_; return item_size_;
@ -87,7 +73,6 @@ private:
std::vector<boost::shared_ptr<gr::block>> float_to_complex_; std::vector<boost::shared_ptr<gr::block>> float_to_complex_;
std::vector<gr::blocks::null_sink::sptr> null_sinks_; std::vector<gr::blocks::null_sink::sptr> null_sinks_;
std::string role_;
std::string item_type_; std::string item_type_;
std::string firmware_filename_; std::string firmware_filename_;
std::string signal_file; std::string signal_file;

View File

@ -29,10 +29,12 @@
#include <iostream> #include <iostream>
#include <utility> #include <utility>
using namespace std::string_literals;
Fmcomms2SignalSource::Fmcomms2SignalSource(const ConfigurationInterface *configuration, Fmcomms2SignalSource::Fmcomms2SignalSource(const ConfigurationInterface *configuration,
const std::string &role, unsigned int in_stream, unsigned int out_stream, const std::string &role, unsigned int in_stream, unsigned int out_stream,
Concurrent_Queue<pmt::pmt_t> *queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream) Concurrent_Queue<pmt::pmt_t> *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_item_type("gr_complex");
const std::string default_dump_file("./data/signal_source.dat"); const std::string default_dump_file("./data/signal_source.dat");

View File

@ -20,9 +20,8 @@
#ifndef GNSS_SDR_FMCOMMS2_SIGNAL_SOURCE_H #ifndef GNSS_SDR_FMCOMMS2_SIGNAL_SOURCE_H
#define 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 <gnuradio/blocks/file_sink.h> #include <gnuradio/blocks/file_sink.h>
#if GRIIO_INCLUDE_HAS_GNURADIO #if GRIIO_INCLUDE_HAS_GNURADIO
#include <gnuradio/iio/fmcomms2_source.h> #include <gnuradio/iio/fmcomms2_source.h>
@ -43,7 +42,7 @@
class ConfigurationInterface; class ConfigurationInterface;
class Fmcomms2SignalSource : public SignalSourceInterface class Fmcomms2SignalSource : public SignalSourceBase
{ {
public: public:
Fmcomms2SignalSource(const ConfigurationInterface* configuration, Fmcomms2SignalSource(const ConfigurationInterface* configuration,
@ -52,19 +51,6 @@ public:
~Fmcomms2SignalSource(); ~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 inline size_t item_size() override
{ {
return item_size_; return item_size_;
@ -80,7 +66,6 @@ private:
gnss_shared_ptr<gr::block> valve_; gnss_shared_ptr<gr::block> valve_;
gr::blocks::file_sink::sptr file_sink_; gr::blocks::file_sink::sptr file_sink_;
std::string role_;
std::string item_type_; std::string item_type_;
std::string dump_filename_; std::string dump_filename_;

View File

@ -55,6 +55,8 @@ public:
//! Returns "Signal Source" //! Returns "Signal Source"
inline std::string implementation() override { return "Signal Source"; } inline std::string implementation() override { return "Signal Source"; }
inline size_t item_size() override { return 0; } inline size_t item_size() override { return 0; }
inline size_t getRfChannels() const final { return 0; }
inline std::shared_ptr<GNSSBlockInterface> signal_generator() const { return signal_generator_; } inline std::shared_ptr<GNSSBlockInterface> signal_generator() const { return signal_generator_; }
private: private:

View File

@ -20,12 +20,15 @@
#include <gnuradio/blocks/file_sink.h> #include <gnuradio/blocks/file_sink.h>
#include <gn3s/gn3s_source_cc.h> #include <gn3s/gn3s_source_cc.h>
using namespace std::string_literals;
Gn3sSignalSource::Gn3sSignalSource(const ConfigurationInterface* configuration, Gn3sSignalSource::Gn3sSignalSource(const ConfigurationInterface* configuration,
std::string role, std::string role,
unsigned int in_stream, unsigned int in_stream,
unsigned int out_stream, unsigned int out_stream,
Concurrent_Queue<pmt::pmt_t>* queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream) Concurrent_Queue<pmt::pmt_t>* 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_item_type("short");
const std::string default_dump_file("./data/gn3s_source.dat"); const std::string default_dump_file("./data/gn3s_source.dat");

View File

@ -18,10 +18,9 @@
#ifndef GNSS_SDR_GN3S_SIGNAL_SOURCE_H #ifndef GNSS_SDR_GN3S_SIGNAL_SOURCE_H
#define 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 "concurrent_queue.h"
#include "gnss_block_interface.h"
#include <gnuradio/blocks/file_sink.h> #include <gnuradio/blocks/file_sink.h>
#include <gnuradio/hier_block2.h> #include <gnuradio/hier_block2.h>
#include <pmt/pmt.h> #include <pmt/pmt.h>
@ -40,7 +39,7 @@ class ConfigurationInterface;
/*! /*!
* \brief This class reads samples from a GN3S USB dongle, a RF front-end signal sampler * \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: public:
Gn3sSignalSource(const ConfigurationInterface* configuration, Gn3sSignalSource(const ConfigurationInterface* configuration,
@ -49,19 +48,6 @@ public:
~Gn3sSignalSource() = default; ~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 inline size_t item_size() override
{ {
return item_size_; return item_size_;
@ -75,11 +61,10 @@ public:
private: private:
gr::block_sptr gn3s_source_; gr::block_sptr gn3s_source_;
gr::blocks::file_sink::sptr file_sink_; gr::blocks::file_sink::sptr file_sink_;
std::string role_;
std::string item_type_; std::string item_type_;
std::string dump_filename_; std::string dump_filename_;
size_t item_size_; size_t item_size_;
int64_t samples_; [[maybe_unused]] int64_t samples_;
unsigned int in_stream_; unsigned int in_stream_;
unsigned int out_stream_; unsigned int out_stream_;
bool dump_; bool dump_;

View File

@ -18,12 +18,13 @@
#include "configuration_interface.h" #include "configuration_interface.h"
#include "labsat23_source.h" #include "labsat23_source.h"
#include <glog/logging.h> #include <glog/logging.h>
#include <cstdint>
#include <utility>
using namespace std::string_literals;
LabsatSignalSource::LabsatSignalSource(const ConfigurationInterface* configuration, LabsatSignalSource::LabsatSignalSource(const ConfigurationInterface* configuration,
const std::string& role, unsigned int in_stream, unsigned int out_stream, Concurrent_Queue<pmt::pmt_t>* 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<pmt::pmt_t>* 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_item_type("gr_complex");
const std::string default_dump_file("./labsat_output.dat"); const std::string default_dump_file("./labsat_output.dat");

View File

@ -18,7 +18,7 @@
#ifndef GNSS_SDR_LABSAT_SIGNAL_SOURCE_H #ifndef GNSS_SDR_LABSAT_SIGNAL_SOURCE_H
#define 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 "concurrent_queue.h"
#include "gnss_block_interface.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 * \brief This class reads samples stored by a LabSat 2 or LabSat 3 device
*/ */
class LabsatSignalSource : public SignalSourceInterface class LabsatSignalSource : public SignalSourceBase
{ {
public: public:
void fixme() final {}
LabsatSignalSource(const ConfigurationInterface* configuration, LabsatSignalSource(const ConfigurationInterface* configuration,
const std::string& role, unsigned int in_stream, const std::string& role, unsigned int in_stream,
unsigned int out_stream, Concurrent_Queue<pmt::pmt_t>* queue); unsigned int out_stream, Concurrent_Queue<pmt::pmt_t>* queue);
~LabsatSignalSource() = default; ~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 inline size_t item_size() override
{ {
return item_size_; return item_size_;
@ -78,7 +64,6 @@ private:
gr::blocks::file_sink::sptr file_sink_; gr::blocks::file_sink::sptr file_sink_;
gr::blocks::throttle::sptr throttle_; gr::blocks::throttle::sptr throttle_;
std::string role_;
std::string item_type_; std::string item_type_;
std::string filename_; std::string filename_;
std::string dump_filename_; std::string dump_filename_;

View File

@ -27,18 +27,22 @@
#include <utility> #include <utility>
using namespace std::string_literals;
MultichannelFileSignalSource::MultichannelFileSignalSource(const ConfigurationInterface* configuration, MultichannelFileSignalSource::MultichannelFileSignalSource(const ConfigurationInterface* configuration,
const std::string& role, unsigned int in_streams, unsigned int out_streams, const std::string& role, unsigned int in_streams, unsigned int out_streams,
Concurrent_Queue<pmt::pmt_t>* queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams) Concurrent_Queue<pmt::pmt_t>* 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_filename("./example_capture.dat"s);
const std::string default_item_type("short"); const std::string default_item_type("short"s);
const std::string default_dump_filename("./my_capture.dat"); const std::string default_dump_filename("./my_capture.dat"s);
const double default_seconds_to_skip = 0.0; const double default_seconds_to_skip = 0.0;
samples_ = configuration->property(role + ".samples", static_cast<uint64_t>(0)); samples_ = configuration->property(role + ".samples"s, static_cast<uint64_t>(0));
sampling_frequency_ = configuration->property(role + ".sampling_frequency", static_cast<int64_t>(0)); sampling_frequency_ = configuration->property(role + ".sampling_frequency"s, static_cast<int64_t>(0));
n_channels_ = configuration->property(role + ".total_channels", 1); n_channels_ = configuration->property(role + ".total_channels"s, 1);
for (int32_t n = 0; n < n_channels_; n++) for (int32_t n = 0; n < n_channels_; n++)
{ {

View File

@ -21,7 +21,7 @@
#ifndef GNSS_SDR_MULTICHANNEL_FILE_SIGNAL_SOURCE_H #ifndef GNSS_SDR_MULTICHANNEL_FILE_SIGNAL_SOURCE_H
#define 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 "concurrent_queue.h"
#include "gnss_block_interface.h" #include "gnss_block_interface.h"
@ -47,29 +47,15 @@ class ConfigurationInterface;
* \brief Class that reads signals samples from files at different frequency bands * \brief Class that reads signals samples from files at different frequency bands
* and adapts it to a SignalSourceInterface * and adapts it to a SignalSourceInterface
*/ */
class MultichannelFileSignalSource : public SignalSourceInterface class MultichannelFileSignalSource : public SignalSourceBase
{ {
public: public:
void fixme() final {}
MultichannelFileSignalSource(const ConfigurationInterface* configuration, const std::string& role, MultichannelFileSignalSource(const ConfigurationInterface* configuration, const std::string& role,
unsigned int in_streams, unsigned int out_streams, unsigned int in_streams, unsigned int out_streams,
Concurrent_Queue<pmt::pmt_t>* queue); Concurrent_Queue<pmt::pmt_t>* queue);
~MultichannelFileSignalSource() = default; ~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 inline size_t item_size() override
{ {
return item_size_; return item_size_;
@ -112,7 +98,6 @@ private:
std::vector<gr::blocks::throttle::sptr> throttle_vec_; std::vector<gr::blocks::throttle::sptr> throttle_vec_;
std::vector<std::string> filename_vec_; std::vector<std::string> filename_vec_;
std::string item_type_; std::string item_type_;
std::string role_;
uint64_t samples_; uint64_t samples_;
int64_t sampling_frequency_; int64_t sampling_frequency_;
size_t item_size_; size_t item_size_;

View File

@ -27,10 +27,13 @@
#include <iostream> #include <iostream>
#include <utility> #include <utility>
using namespace std::string_literals;
NsrFileSignalSource::NsrFileSignalSource(const ConfigurationInterface* configuration, NsrFileSignalSource::NsrFileSignalSource(const ConfigurationInterface* configuration,
const std::string& role, unsigned int in_streams, unsigned int out_streams, const std::string& role, unsigned int in_streams, unsigned int out_streams,
Concurrent_Queue<pmt::pmt_t>* queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams) Concurrent_Queue<pmt::pmt_t>* 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_filename("../data/my_capture.dat");
const std::string default_item_type("byte"); 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" << "The receiver was configured to work with a file signal source\n"
<< "but the specified file is unreachable by GNSS-SDR.\n" << "but the specified file is unreachable by GNSS-SDR.\n"
<< "Please modify your configuration file\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" << "$ gnss-sdr --config_file=/path/to/my_GNSS_SDR_configuration.conf\n"
<< "Examples of configuration files available at:\n" << "Examples of configuration files available at:\n"
<< GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/\n"; << GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/\n";
LOG(WARNING) << "file_signal_source: Unable to open the samples file " LOG(WARNING) << "nsr_file_signal_source: Unable to open the samples file "
<< filename_.c_str() << ", exiting the program."; << filename_ << ", exiting the program.";
throw(e); throw;
} }
DLOG(INFO) << "file_source(" << file_source_->unique_id() << ")"; DLOG(INFO) << "file_source(" << file_source_->unique_id() << ")";

View File

@ -21,7 +21,7 @@
#ifndef GNSS_SDR_NSR_FILE_SIGNAL_SOURCE_H #ifndef GNSS_SDR_NSR_FILE_SIGNAL_SOURCE_H
#define 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 "concurrent_queue.h"
#include "gnss_block_interface.h" #include "gnss_block_interface.h"
@ -44,27 +44,14 @@ class ConfigurationInterface;
* \brief Class that reads signals samples from a file * \brief Class that reads signals samples from a file
* and adapts it to a SignalSourceInterface * and adapts it to a SignalSourceInterface
*/ */
class NsrFileSignalSource : public SignalSourceInterface class NsrFileSignalSource : public SignalSourceBase
{ {
public: public:
void fixme() final {}
NsrFileSignalSource(const ConfigurationInterface* configuration, const std::string& role, NsrFileSignalSource(const ConfigurationInterface* configuration, const std::string& role,
unsigned int in_streams, unsigned int out_streams, unsigned int in_streams, unsigned int out_streams,
Concurrent_Queue<pmt::pmt_t>* queue); Concurrent_Queue<pmt::pmt_t>* queue);
~NsrFileSignalSource() = default; ~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 inline size_t item_size() override
{ {
@ -113,7 +100,6 @@ private:
std::string filename_; std::string filename_;
std::string item_type_; std::string item_type_;
std::string dump_filename_; std::string dump_filename_;
std::string role_;
uint32_t in_streams_; uint32_t in_streams_;
uint32_t out_streams_; uint32_t out_streams_;
bool repeat_; bool repeat_;

View File

@ -25,9 +25,13 @@
#include <utility> #include <utility>
using namespace std::string_literals;
OsmosdrSignalSource::OsmosdrSignalSource(const ConfigurationInterface* configuration, OsmosdrSignalSource::OsmosdrSignalSource(const ConfigurationInterface* configuration,
const std::string& role, unsigned int in_stream, unsigned int out_stream, const std::string& role, unsigned int in_stream, unsigned int out_stream,
Concurrent_Queue<pmt::pmt_t>* queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream) Concurrent_Queue<pmt::pmt_t>* queue)
: SignalSourceBase(configuration, role, "Osmosdr_Signal_Source"s), in_stream_(in_stream), out_stream_(out_stream)
{ {
// DUMP PARAMETERS // DUMP PARAMETERS
const std::string empty; const std::string empty;

View File

@ -19,10 +19,9 @@
#ifndef GNSS_SDR_OSMOSDR_SIGNAL_SOURCE_H #ifndef GNSS_SDR_OSMOSDR_SIGNAL_SOURCE_H
#define 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 "concurrent_queue.h"
#include "gnss_block_interface.h"
#include <gnuradio/blocks/file_sink.h> #include <gnuradio/blocks/file_sink.h>
#include <pmt/pmt.h> #include <pmt/pmt.h>
#include <cstdint> #include <cstdint>
@ -44,7 +43,7 @@ class ConfigurationInterface;
* HackRF or Realtek's RTL2832U-based USB dongle DVB-T receivers * HackRF or Realtek's RTL2832U-based USB dongle DVB-T receivers
* (see https://osmocom.org/projects/rtl-sdr/wiki) * (see https://osmocom.org/projects/rtl-sdr/wiki)
*/ */
class OsmosdrSignalSource : public SignalSourceInterface class OsmosdrSignalSource : public SignalSourceBase
{ {
public: public:
OsmosdrSignalSource(const ConfigurationInterface* configuration, OsmosdrSignalSource(const ConfigurationInterface* configuration,
@ -53,19 +52,6 @@ public:
~OsmosdrSignalSource() = default; ~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 inline size_t item_size() override
{ {
return item_size_; return item_size_;
@ -83,7 +69,6 @@ private:
gnss_shared_ptr<gr::block> valve_; gnss_shared_ptr<gr::block> valve_;
gr::blocks::file_sink::sptr file_sink_; gr::blocks::file_sink::sptr file_sink_;
std::string role_;
std::string item_type_; std::string item_type_;
std::string dump_filename_; std::string dump_filename_;
std::string osmosdr_args_; std::string osmosdr_args_;

View File

@ -24,9 +24,13 @@
#include <utility> #include <utility>
using namespace std::string_literals;
PlutosdrSignalSource::PlutosdrSignalSource(const ConfigurationInterface* configuration, PlutosdrSignalSource::PlutosdrSignalSource(const ConfigurationInterface* configuration,
const std::string& role, unsigned int in_stream, unsigned int out_stream, const std::string& role, unsigned int in_stream, unsigned int out_stream,
Concurrent_Queue<pmt::pmt_t>* queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream) Concurrent_Queue<pmt::pmt_t>* 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_item_type("gr_complex");
const std::string default_dump_file("./data/signal_source.dat"); const std::string default_dump_file("./data/signal_source.dat");

View File

@ -19,9 +19,8 @@
#ifndef GNSS_SDR_PLUTOSDR_SIGNAL_SOURCE_H #ifndef GNSS_SDR_PLUTOSDR_SIGNAL_SOURCE_H
#define 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 <gnuradio/blocks/file_sink.h> #include <gnuradio/blocks/file_sink.h>
#if GRIIO_INCLUDE_HAS_GNURADIO #if GRIIO_INCLUDE_HAS_GNURADIO
#include <gnuradio/iio/pluto_source.h> #include <gnuradio/iio/pluto_source.h>
@ -44,7 +43,7 @@ class ConfigurationInterface;
/*! /*!
*/ */
class PlutosdrSignalSource : public SignalSourceInterface class PlutosdrSignalSource : public SignalSourceBase
{ {
public: public:
PlutosdrSignalSource(const ConfigurationInterface* configuration, PlutosdrSignalSource(const ConfigurationInterface* configuration,
@ -53,18 +52,6 @@ public:
~PlutosdrSignalSource() = default; ~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 size_t item_size() override
{ {
return item_size_; return item_size_;
@ -81,7 +68,6 @@ private:
gnss_shared_ptr<gr::block> valve_; gnss_shared_ptr<gr::block> valve_;
gr::blocks::file_sink::sptr file_sink_; gr::blocks::file_sink::sptr file_sink_;
std::string role_;
std::string dump_filename_; std::string dump_filename_;
// Front-end settings // Front-end settings

View File

@ -23,8 +23,11 @@
#include <dbfcttc/raw_array.h> #include <dbfcttc/raw_array.h>
using namespace std::string_literals;
RawArraySignalSource::RawArraySignalSource(const ConfigurationInterface* configuration, RawArraySignalSource::RawArraySignalSource(const ConfigurationInterface* configuration,
std::string role, unsigned int in_stream, unsigned int out_stream, Concurrent_Queue<pmt::pmt_t>* queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream) std::string role, unsigned int in_stream, unsigned int out_stream, Concurrent_Queue<pmt::pmt_t>* 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_item_type("gr_complex");
const std::string default_dump_file("./data/raw_array_source.dat"); const std::string default_dump_file("./data/raw_array_source.dat");

View File

@ -18,10 +18,9 @@
#ifndef GNSS_SDR_RAW_ARRAY_SIGNAL_SOURCE_H #ifndef GNSS_SDR_RAW_ARRAY_SIGNAL_SOURCE_H
#define 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 "concurrent_queue.h"
#include "gnss_block_interface.h"
#include <gnuradio/blocks/file_sink.h> #include <gnuradio/blocks/file_sink.h>
#include <gnuradio/hier_block2.h> #include <gnuradio/hier_block2.h>
#include <pmt/pmt.h> #include <pmt/pmt.h>
@ -41,7 +40,7 @@ class ConfigurationInterface;
/*! /*!
* \brief This class reads samples from a GN3S USB dongle, a RF front-end signal sampler * \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: public:
RawArraySignalSource(const ConfigurationInterface* configuration, RawArraySignalSource(const ConfigurationInterface* configuration,
@ -50,19 +49,6 @@ public:
~RawArraySignalSource() = default; ~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 inline size_t item_size() override
{ {
return item_size_; return item_size_;
@ -76,12 +62,11 @@ public:
private: private:
gr::block_sptr raw_array_source_; gr::block_sptr raw_array_source_;
gr::blocks::file_sink::sptr file_sink_; gr::blocks::file_sink::sptr file_sink_;
std::string role_;
std::string item_type_; std::string item_type_;
std::string dump_filename_; std::string dump_filename_;
std::string eth_device_; std::string eth_device_;
size_t item_size_; size_t item_size_;
int64_t samples_; [[maybe_unused]] int64_t samples_;
unsigned int in_stream_; unsigned int in_stream_;
unsigned int out_stream_; unsigned int out_stream_;
bool dump_; bool dump_;

View File

@ -25,14 +25,15 @@
#include <iostream> #include <iostream>
#include <utility> #include <utility>
using namespace std::string_literals;
RtlTcpSignalSource::RtlTcpSignalSource(const ConfigurationInterface* configuration, RtlTcpSignalSource::RtlTcpSignalSource(const ConfigurationInterface* configuration,
const std::string& role, const std::string& role,
unsigned int in_stream, unsigned int in_stream,
unsigned int out_stream, unsigned int out_stream,
Concurrent_Queue<pmt::pmt_t>* queue) : role_(role), Concurrent_Queue<pmt::pmt_t>* queue)
in_stream_(in_stream), : SignalSourceBase(configuration, role, "RtlTcp_Signal_Source"s)
out_stream_(out_stream) , in_stream_(in_stream), out_stream_(out_stream)
{ {
// DUMP PARAMETERS // DUMP PARAMETERS
const std::string default_dump_file("./data/signal_source.dat"); const std::string default_dump_file("./data/signal_source.dat");

View File

@ -18,10 +18,9 @@
#ifndef GNSS_SDR_RTL_TCP_SIGNAL_SOURCE_H #ifndef GNSS_SDR_RTL_TCP_SIGNAL_SOURCE_H
#define 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 "concurrent_queue.h"
#include "gnss_block_interface.h"
#include "rtl_tcp_signal_source_c.h" #include "rtl_tcp_signal_source_c.h"
#include <gnuradio/blocks/deinterleave.h> #include <gnuradio/blocks/deinterleave.h>
#include <gnuradio/blocks/file_sink.h> #include <gnuradio/blocks/file_sink.h>
@ -44,10 +43,9 @@ class ConfigurationInterface;
* I/Q samples over TCP. * I/Q samples over TCP.
* (see https://osmocom.org/projects/rtl-sdr/wiki) * (see https://osmocom.org/projects/rtl-sdr/wiki)
*/ */
class RtlTcpSignalSource : public SignalSourceInterface class RtlTcpSignalSource : public SignalSourceBase
{ {
public: public:
void fixme() final {}
RtlTcpSignalSource(const ConfigurationInterface* configuration, RtlTcpSignalSource(const ConfigurationInterface* configuration,
const std::string& role, const std::string& role,
unsigned int in_stream, unsigned int in_stream,
@ -56,19 +54,6 @@ public:
~RtlTcpSignalSource() = default; ~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 inline size_t item_size() override
{ {
return item_size_; return item_size_;
@ -87,7 +72,6 @@ private:
gnss_shared_ptr<gr::block> valve_; gnss_shared_ptr<gr::block> valve_;
gr::blocks::file_sink::sptr file_sink_; gr::blocks::file_sink::sptr file_sink_;
std::string role_;
std::string item_type_; std::string item_type_;
std::string dump_filename_; std::string dump_filename_;

View File

@ -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))
{
}

View File

@ -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 <cstddef>
#include <string>
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

View File

@ -28,9 +28,13 @@
#include <utility> #include <utility>
using namespace std::string_literals;
SpirFileSignalSource::SpirFileSignalSource(const ConfigurationInterface* configuration, SpirFileSignalSource::SpirFileSignalSource(const ConfigurationInterface* configuration,
const std::string& role, unsigned int in_streams, unsigned int out_streams, const std::string& role, unsigned int in_streams, unsigned int out_streams,
Concurrent_Queue<pmt::pmt_t>* queue) : role_(role), in_streams_(in_streams), out_streams_(out_streams) Concurrent_Queue<pmt::pmt_t>* 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_filename("../data/my_capture.dat");
const std::string default_item_type("int"); const std::string default_item_type("int");

View File

@ -21,7 +21,7 @@
#ifndef GNSS_SDR_SPIR_FILE_SIGNAL_SOURCE_H #ifndef GNSS_SDR_SPIR_FILE_SIGNAL_SOURCE_H
#define 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 "concurrent_queue.h"
#include "gnss_block_interface.h" #include "gnss_block_interface.h"
@ -47,28 +47,15 @@ class ConfigurationInterface;
* \brief Class that reads signals samples from a file * \brief Class that reads signals samples from a file
* and adapts it to a SignalSourceInterface * and adapts it to a SignalSourceInterface
*/ */
class SpirFileSignalSource : public SignalSourceInterface class SpirFileSignalSource : public SignalSourceBase
{ {
public: public:
void fixme() final {}
SpirFileSignalSource(const ConfigurationInterface* configuration, const std::string& role, SpirFileSignalSource(const ConfigurationInterface* configuration, const std::string& role,
unsigned int in_streams, unsigned int out_streams, unsigned int in_streams, unsigned int out_streams,
Concurrent_Queue<pmt::pmt_t>* queue); Concurrent_Queue<pmt::pmt_t>* queue);
~SpirFileSignalSource() = default; ~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 inline size_t item_size() override
{ {
@ -114,7 +101,6 @@ private:
std::string filename_; std::string filename_;
std::string item_type_; std::string item_type_;
std::string dump_filename_; std::string dump_filename_;
std::string role_;
uint64_t samples_; uint64_t samples_;
int64_t sampling_frequency_; int64_t sampling_frequency_;

View File

@ -25,9 +25,12 @@
#include <iostream> #include <iostream>
#include <utility> #include <utility>
using namespace std::string_literals;
SpirGSS6450FileSignalSource::SpirGSS6450FileSignalSource(const ConfigurationInterface* configuration, SpirGSS6450FileSignalSource::SpirGSS6450FileSignalSource(const ConfigurationInterface* configuration,
const std::string& role, uint32_t in_streams, uint32_t out_streams, Concurrent_Queue<pmt::pmt_t>* 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<pmt::pmt_t>* 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_filename("../data/my_capture.dat");
const std::string default_dump_filename("../data/my_capture_dump.dat"); const std::string default_dump_filename("../data/my_capture_dump.dat");

View File

@ -21,7 +21,7 @@
#ifndef GNSS_SDR_SPIR_GSS6450_FILE_SIGNAL_SOURCE_H #ifndef GNSS_SDR_SPIR_GSS6450_FILE_SIGNAL_SOURCE_H
#define 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 "concurrent_queue.h"
#include "gnss_sdr_valve.h" #include "gnss_sdr_valve.h"
@ -51,23 +51,12 @@ class ConfigurationInterface;
* \brief Class that reads signals samples from a file * \brief Class that reads signals samples from a file
* and adapts it to a SignalSourceInterface * and adapts it to a SignalSourceInterface
*/ */
class SpirGSS6450FileSignalSource : public SignalSourceInterface class SpirGSS6450FileSignalSource : public SignalSourceBase
{ {
public: public:
void fixme() final {}
SpirGSS6450FileSignalSource(const ConfigurationInterface* configuration, const std::string& role, SpirGSS6450FileSignalSource(const ConfigurationInterface* configuration, const std::string& role,
uint32_t in_streams, uint32_t out_streams, Concurrent_Queue<pmt::pmt_t>* queue); uint32_t in_streams, uint32_t out_streams, Concurrent_Queue<pmt::pmt_t>* 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 inline size_t item_size() override
{ {
return item_size_; return item_size_;
@ -115,7 +104,6 @@ private:
std::vector<gr::blocks::throttle::sptr> throttle_vec_; std::vector<gr::blocks::throttle::sptr> throttle_vec_;
std::string filename_; std::string filename_;
std::string dump_filename_; std::string dump_filename_;
std::string role_;
std::string item_type_; std::string item_type_;
uint64_t samples_; uint64_t samples_;
int64_t sampling_frequency_; int64_t sampling_frequency_;

View File

@ -26,15 +26,16 @@
#include <iostream> #include <iostream>
#include <utility> #include <utility>
using namespace std::string_literals;
TwoBitCpxFileSignalSource::TwoBitCpxFileSignalSource( TwoBitCpxFileSignalSource::TwoBitCpxFileSignalSource(
const ConfigurationInterface* configuration, const ConfigurationInterface* configuration,
const std::string& role, const std::string& role,
unsigned int in_streams, unsigned int in_streams,
unsigned int out_streams, unsigned int out_streams,
Concurrent_Queue<pmt::pmt_t>* queue) : role_(role), Concurrent_Queue<pmt::pmt_t>* queue)
in_streams_(in_streams), : SignalSourceBase(configuration, role, "Two_Bit_Cpx_File_Signal_Source"s), in_streams_(in_streams), out_streams_(out_streams)
out_streams_(out_streams)
{ {
const std::string default_filename("../data/my_capture.dat"); const std::string default_filename("../data/my_capture.dat");
const std::string default_item_type("byte"); const std::string default_item_type("byte");

View File

@ -20,7 +20,7 @@
#ifndef GNSS_SDR_TWO_BIT_CPX_FILE_SIGNAL_SOURCE_H #ifndef GNSS_SDR_TWO_BIT_CPX_FILE_SIGNAL_SOURCE_H
#define 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 "concurrent_queue.h"
#include "unpack_byte_2bit_cpx_samples.h" #include "unpack_byte_2bit_cpx_samples.h"
@ -45,10 +45,9 @@ class ConfigurationInterface;
* \brief Class that reads signals samples from a file * \brief Class that reads signals samples from a file
* and adapts it to a SignalSourceInterface * and adapts it to a SignalSourceInterface
*/ */
class TwoBitCpxFileSignalSource : public SignalSourceInterface class TwoBitCpxFileSignalSource : public SignalSourceBase
{ {
public: public:
void fixme() final {}
TwoBitCpxFileSignalSource(const ConfigurationInterface* configuration, TwoBitCpxFileSignalSource(const ConfigurationInterface* configuration,
const std::string& role, const std::string& role,
unsigned int in_streams, unsigned int in_streams,
@ -56,18 +55,6 @@ public:
Concurrent_Queue<pmt::pmt_t>* queue); Concurrent_Queue<pmt::pmt_t>* queue);
~TwoBitCpxFileSignalSource() = default; ~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 inline size_t item_size() override
{ {
@ -114,7 +101,6 @@ private:
std::string filename_; std::string filename_;
std::string item_type_; std::string item_type_;
std::string dump_filename_; std::string dump_filename_;
std::string role_;
size_t item_size_; size_t item_size_;
uint64_t samples_; uint64_t samples_;
int64_t sampling_frequency_; int64_t sampling_frequency_;

View File

@ -28,15 +28,17 @@
#include <iostream> #include <iostream>
#include <utility> #include <utility>
using namespace std::string_literals;
TwoBitPackedFileSignalSource::TwoBitPackedFileSignalSource( TwoBitPackedFileSignalSource::TwoBitPackedFileSignalSource(
const ConfigurationInterface* configuration, const ConfigurationInterface* configuration,
const std::string& role, const std::string& role,
unsigned int in_streams, unsigned int in_streams,
unsigned int out_streams, unsigned int out_streams,
Concurrent_Queue<pmt::pmt_t>* queue) : role_(role), Concurrent_Queue<pmt::pmt_t>* queue)
in_streams_(in_streams), : SignalSourceBase(configuration, role, "Two_Bit_Packed_File_Signal_Source"s)
out_streams_(out_streams) , in_streams_(in_streams)
, out_streams_(out_streams)
{ {
const std::string default_filename("../data/my_capture.dat"); const std::string default_filename("../data/my_capture.dat");
const std::string default_item_type("byte"); const std::string default_item_type("byte");

View File

@ -21,7 +21,7 @@
#ifndef GNSS_SDR_TWO_BIT_PACKED_FILE_SIGNAL_SOURCE_H #ifndef GNSS_SDR_TWO_BIT_PACKED_FILE_SIGNAL_SOURCE_H
#define 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 "concurrent_queue.h"
#include "unpack_2bit_samples.h" #include "unpack_2bit_samples.h"
@ -47,27 +47,14 @@ class ConfigurationInterface;
* \brief Class that reads signals samples from a file * \brief Class that reads signals samples from a file
* and adapts it to a SignalSourceInterface * and adapts it to a SignalSourceInterface
*/ */
class TwoBitPackedFileSignalSource : public SignalSourceInterface class TwoBitPackedFileSignalSource : public SignalSourceBase
{ {
public: public:
void fixme() final {}
TwoBitPackedFileSignalSource(const ConfigurationInterface* configuration, const std::string& role, TwoBitPackedFileSignalSource(const ConfigurationInterface* configuration, const std::string& role,
unsigned int in_streams, unsigned int out_streams, unsigned int in_streams, unsigned int out_streams,
Concurrent_Queue<pmt::pmt_t>* queue); Concurrent_Queue<pmt::pmt_t>* queue);
~TwoBitPackedFileSignalSource() = default; ~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 inline size_t item_size() override
{ {
@ -134,7 +121,6 @@ private:
std::string filename_; std::string filename_;
std::string item_type_; std::string item_type_;
std::string dump_filename_; std::string dump_filename_;
std::string role_;
std::string sample_type_; std::string sample_type_;
uint64_t samples_; uint64_t samples_;
int64_t sampling_frequency_; int64_t sampling_frequency_;

View File

@ -25,10 +25,13 @@
#include <iostream> #include <iostream>
#include <utility> #include <utility>
using namespace std::string_literals;
UhdSignalSource::UhdSignalSource(const ConfigurationInterface* configuration, UhdSignalSource::UhdSignalSource(const ConfigurationInterface* configuration,
const std::string& role, unsigned int in_stream, unsigned int out_stream, const std::string& role, unsigned int in_stream, unsigned int out_stream,
Concurrent_Queue<pmt::pmt_t>* queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream) Concurrent_Queue<pmt::pmt_t>* queue)
: SignalSourceBase(configuration, role, "UHD_Signal_Source"s), in_stream_(in_stream), out_stream_(out_stream)
{ {
// DUMP PARAMETERS // DUMP PARAMETERS
const std::string empty; const std::string empty;

View File

@ -17,7 +17,7 @@
#ifndef GNSS_SDR_UHD_SIGNAL_SOURCE_H #ifndef GNSS_SDR_UHD_SIGNAL_SOURCE_H
#define 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 "concurrent_queue.h"
#include <gnuradio/blocks/file_sink.h> #include <gnuradio/blocks/file_sink.h>
@ -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) * \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: public:
UhdSignalSource(const ConfigurationInterface* configuration, UhdSignalSource(const ConfigurationInterface* configuration,
@ -48,19 +48,6 @@ public:
~UhdSignalSource() = default; ~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 inline size_t item_size() override
{ {
return item_size_; return item_size_;
@ -90,7 +77,6 @@ private:
std::string item_type_; std::string item_type_;
std::string subdevice_; std::string subdevice_;
std::string clock_source_; std::string clock_source_;
std::string role_;
double sample_rate_; double sample_rate_;
size_t item_size_; size_t item_size_;

View File

@ -42,18 +42,19 @@
* implemented by that class or a parent class. * implemented by that class or a parent class.
*/ */
#include <glog/logging.h>
class SignalSourceInterface : public GNSSBlockInterface class SignalSourceInterface : public GNSSBlockInterface
{ {
virtual std::string role() = 0; public:
virtual std::string implementation() = 0; virtual size_t getRfChannels() const = 0;
virtual size_t item_size() = 0; protected:
virtual void connect(gr::top_block_sptr top_block) = 0; SignalSourceInterface() {
virtual void disconnect(gr::top_block_sptr top_block) = 0; VLOG(1) << "SignalSourceInterface: " << this << " ctor";
}
virtual gr::basic_block_sptr get_left_block() = 0; public: // required for polymorphic destruction
virtual gr::basic_block_sptr get_right_block() = 0; ~SignalSourceInterface() {
VLOG(1) << "SignalSourceInterface: " << this << " dtor";
virtual void fixme() = 0; }
}; };

File diff suppressed because it is too large Load Diff

View File

@ -38,6 +38,7 @@
class ConfigurationInterface; class ConfigurationInterface;
class GNSSBlockInterface; class GNSSBlockInterface;
class SignalSourceInterface;
class AcquisitionInterface; class AcquisitionInterface;
class TrackingInterface; class TrackingInterface;
class TelemetryDecoderInterface; class TelemetryDecoderInterface;
@ -51,7 +52,7 @@ public:
GNSSBlockFactory() = default; GNSSBlockFactory() = default;
~GNSSBlockFactory() = default; ~GNSSBlockFactory() = default;
std::unique_ptr<GNSSBlockInterface> GetSignalSource(const ConfigurationInterface* configuration, std::unique_ptr<SignalSourceInterface> GetSignalSource(const ConfigurationInterface* configuration,
Concurrent_Queue<pmt::pmt_t>* queue, int ID = -1); Concurrent_Queue<pmt::pmt_t>* queue, int ID = -1);
std::unique_ptr<GNSSBlockInterface> GetSignalConditioner(const ConfigurationInterface* configuration, int ID = -1); std::unique_ptr<GNSSBlockInterface> GetSignalConditioner(const ConfigurationInterface* configuration, int ID = -1);

View File

@ -36,6 +36,7 @@
#include "gnss_satellite.h" #include "gnss_satellite.h"
#include "gnss_sdr_make_unique.h" #include "gnss_sdr_make_unique.h"
#include "gnss_synchro_monitor.h" #include "gnss_synchro_monitor.h"
#include "signal_source_interface.h"
#include <boost/lexical_cast.hpp> // for boost::lexical_cast #include <boost/lexical_cast.hpp> // for boost::lexical_cast
#include <boost/tokenizer.hpp> // for boost::tokenizer #include <boost/tokenizer.hpp> // for boost::tokenizer
#include <glog/logging.h> // for LOG #include <glog/logging.h> // 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) // 1. read the number of RF front-ends available (one file_source per RF front-end)
sources_count_ = configuration_->property("Receiver.sources_count", 1); sources_count_ = configuration_->property("Receiver.sources_count", 1);
int RF_Channels = 0;
int signal_conditioner_ID = 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_conditioner_.push_back(block_factory->GetSignalConditioner(configuration_.get(), signal_conditioner_ID));
sig_source_.push_back(block_factory->GetSignalSource(configuration_.get(), queue_.get(), i)); signal_conditioner_ID++;
// 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));
} }
} }
@ -1028,42 +998,40 @@ int GNSSFlowgraph::disconnect_fpga_sample_counter()
int GNSSFlowgraph::connect_signal_sources_to_signal_conditioners() int GNSSFlowgraph::connect_signal_sources_to_signal_conditioners()
{ {
int RF_Channels = 0;
unsigned int signal_conditioner_ID = 0; unsigned int signal_conditioner_ID = 0;
for (int i = 0; i < sources_count_; i++) for (int i = 0; i < sources_count_; i++)
{ {
try try
{ {
auto& src = sig_source_.at(i);
// TODO: Remove this array implementation and create generic multistream connector // 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 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 // Multichannel Array
std::cout << "ARRAY MODE\n"; std::cout << "ARRAY MODE\n";
for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++)
{ {
std::cout << "connecting ch " << j << '\n'; 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 else
{ {
// TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. auto RF_Channels = src->getRfChannels();
// 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);
for (int j = 0; j < RF_Channels; j++) for (int j = 0; j < RF_Channels; j++)
{ {
// Connect the multichannel signal source to multiple signal conditioners // Connect the multichannel signal source to multiple signal conditioners
// GNURADIO max_streams=-1 means infinite ports! // 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); size_t input_size = sig_conditioner_.at(signal_conditioner_ID)->get_left_block()->input_signature()->sizeof_stream_item(0);
// Check configuration inconsistencies // Check configuration inconsistencies
if (output_size != input_size) if (output_size != input_size)
{ {
help_hint_ += " * The Signal Source implementation " + sig_source_.at(i)->implementation() + " has an output with a "; help_hint_ += " * The Signal Source implementation " + src->implementation() + " has an output with a ";
help_hint_ += sig_source_.at(i)->role() + ".item_size of " + std::to_string(output_size); 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_ += " 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_ += 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"; 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; 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) if (sig_conditioner_.size() > signal_conditioner_ID)
{ {
LOG(INFO) << "connecting sig_source_ " << i << " stream " << j << " to conditioner " << j; LOG(INFO) << "connecting sig_source_ " << i << " stream " << j << " to conditioner " << signal_conditioner_ID;
top_block_->connect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); top_block_->connect(src->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0);
} }
} }
else else
@ -1084,14 +1052,14 @@ int GNSSFlowgraph::connect_signal_sources_to_signal_conditioners()
if (j == 0) if (j == 0)
{ {
// RF_channel 0 backward compatibility with single channel sources // RF_channel 0 backward compatibility with single channel sources
LOG(INFO) << "connecting sig_source_ " << i << " stream " << 0 << " to conditioner " << j; LOG(INFO) << "connecting sig_source_ " << i << " stream " << 0 << " to conditioner " << signal_conditioner_ID;
top_block_->connect(sig_source_.at(i)->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); top_block_->connect(src->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0);
} }
else else
{ {
// Multiple channel sources using multiple output blocks of single channel (requires RF_channel selector in call) // 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; LOG(INFO) << "connecting sig_source_ " << i << " stream " << j << " to conditioner " << signal_conditioner_ID;
top_block_->connect(sig_source_.at(i)->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); top_block_->connect(src->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0);
} }
} }
signal_conditioner_ID++; signal_conditioner_ID++;
@ -1127,46 +1095,44 @@ int GNSSFlowgraph::connect_signal_sources_to_signal_conditioners()
int GNSSFlowgraph::disconnect_signal_sources_from_signal_conditioners() int GNSSFlowgraph::disconnect_signal_sources_from_signal_conditioners()
{ {
int RF_Channels = 0;
int signal_conditioner_ID = 0; int signal_conditioner_ID = 0;
for (int i = 0; i < sources_count_; i++) for (int i = 0; i < sources_count_; i++)
{ {
try try
{ {
auto& src = sig_source_.at(i);
// TODO: Remove this array implementation and create generic multistream connector // 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 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 // Multichannel Array
for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) 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 else
{ {
// TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. auto RF_Channels = src->getRfChannels();
// 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);
for (int j = 0; j < RF_Channels; j++) 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 else
{ {
if (j == 0) if (j == 0)
{ {
// RF_channel 0 backward compatibility with single channel sources // 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 else
{ {
// Multiple channel sources using multiple output blocks of single channel (requires RF_channel selector in call) // 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++; signal_conditioner_ID++;

View File

@ -53,6 +53,7 @@ class ChannelInterface;
class ConfigurationInterface; class ConfigurationInterface;
class GNSSBlockInterface; class GNSSBlockInterface;
class Gnss_Satellite; class Gnss_Satellite;
class SignalSourceInterface;
/*! \brief This class represents a GNSS flow graph. /*! \brief This class represents a GNSS flow graph.
* *
@ -230,7 +231,7 @@ private:
std::shared_ptr<ConfigurationInterface> configuration_; std::shared_ptr<ConfigurationInterface> configuration_;
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue_; std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue_;
std::vector<std::shared_ptr<GNSSBlockInterface>> sig_source_; std::vector<std::shared_ptr<SignalSourceInterface>> sig_source_;
std::vector<std::shared_ptr<GNSSBlockInterface>> sig_conditioner_; std::vector<std::shared_ptr<GNSSBlockInterface>> sig_conditioner_;
std::vector<std::shared_ptr<ChannelInterface>> channels_; std::vector<std::shared_ptr<ChannelInterface>> channels_;
std::shared_ptr<GNSSBlockInterface> observables_; std::shared_ptr<GNSSBlockInterface> observables_;

View File

@ -24,6 +24,7 @@
#include "concurrent_queue.h" #include "concurrent_queue.h"
#include "gnss_block_factory.h" #include "gnss_block_factory.h"
#include "gnss_block_interface.h" #include "gnss_block_interface.h"
#include "signal_source_interface.h"
#include "gnss_sdr_make_unique.h" #include "gnss_sdr_make_unique.h"
#include "in_memory_configuration.h" #include "in_memory_configuration.h"
#include "observables_interface.h" #include "observables_interface.h"
@ -45,7 +46,7 @@ TEST(GNSSBlockFactoryTest, InstantiateFileSignalSource)
// Example of a factory as a shared_ptr // Example of a factory as a shared_ptr
std::shared_ptr<GNSSBlockFactory> factory = std::make_shared<GNSSBlockFactory>(); std::shared_ptr<GNSSBlockFactory> factory = std::make_shared<GNSSBlockFactory>();
// Example of a block as a shared_ptr // Example of a block as a shared_ptr
std::shared_ptr<GNSSBlockInterface> 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("SignalSource", signal_source->role().c_str());
EXPECT_STREQ("File_Signal_Source", signal_source->implementation().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 // Example of a factory as a unique_ptr
std::unique_ptr<GNSSBlockFactory> factory = std::make_unique<GNSSBlockFactory>(); std::unique_ptr<GNSSBlockFactory> factory = std::make_unique<GNSSBlockFactory>();
// Example of a block as a unique_ptr // Example of a block as a unique_ptr
std::unique_ptr<GNSSBlockInterface> signal_source = factory->GetSignalSource(configuration.get(), queue.get()); auto signal_source = factory->GetSignalSource(configuration.get(), queue.get());
EXPECT_EQ(nullptr, signal_source); EXPECT_EQ(nullptr, signal_source);
} }

View File

@ -36,7 +36,8 @@
#include "gps_iono.h" #include "gps_iono.h"
#include "gps_l1_ca_pcps_acquisition_fine_doppler.h" #include "gps_l1_ca_pcps_acquisition_fine_doppler.h"
#include "gps_utc_model.h" #include "gps_utc_model.h"
#include <boost/any.hpp> // for bad_any_cast #include "signal_source_interface.h" // for SignalSourceInterface
#include <boost/any.hpp> // for bad_any_cast
#include <boost/exception/exception.hpp> #include <boost/exception/exception.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <gflags/gflags.h> #include <gflags/gflags.h>
@ -181,6 +182,10 @@ void wait_message()
bool front_end_capture(const std::shared_ptr<ConfigurationInterface>& configuration) bool front_end_capture(const std::shared_ptr<ConfigurationInterface>& configuration)
{ {
auto success = false;
std::string trace_step;
gr::top_block_sptr top_block; gr::top_block_sptr top_block;
GNSSBlockFactory block_factory; GNSSBlockFactory block_factory;
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue; std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue;
@ -188,43 +193,37 @@ bool front_end_capture(const std::shared_ptr<ConfigurationInterface>& configurat
queue = std::make_shared<Concurrent_Queue<pmt::pmt_t>>(); queue = std::make_shared<Concurrent_Queue<pmt::pmt_t>>();
top_block = gr::make_top_block("Acquisition test"); top_block = gr::make_top_block("Acquisition test");
std::shared_ptr<GNSSBlockInterface> source;
try 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<SignalSourceInterface> source;
std::shared_ptr<GNSSBlockInterface> conditioner;
trace_step = "creating source";
source = block_factory.GetSignalSource(configuration.get(), queue.get()); 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<GNSSBlockInterface> conditioner; trace_step = "creating signal conditioner";
try
{
conditioner = block_factory.GetSignalConditioner(configuration.get()); 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 --- trace_step = "unexpected in setup 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;
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); source->connect(top_block);
conditioner->connect(top_block); conditioner->connect(top_block);
top_block->connect(source->get_right_block(), 0, conditioner->get_left_block(), 0); 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<ConfigurationInterface>& configurat
top_block->connect(skiphead, 0, head, 0); top_block->connect(skiphead, 0, head, 0);
top_block->connect(head, 0, sink, 0); top_block->connect(head, 0, sink, 0);
top_block->run(); 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'; std::cout << "Exception caught " << trace_step << ": " << e.what() << std::endl;
return false;
} }
return true; return success;
} }