From 845385861dd84dfa89baa03887e751980a0bc53a Mon Sep 17 00:00:00 2001 From: Javier Arribas Date: Sat, 22 Aug 2020 16:46:21 +0200 Subject: [PATCH] Adding throttle support in LabSat file signal source --- .../adapters/labsat_signal_source.cc | 53 ++++++++++++++++--- .../adapters/labsat_signal_source.h | 7 +++ 2 files changed, 52 insertions(+), 8 deletions(-) diff --git a/src/algorithms/signal_source/adapters/labsat_signal_source.cc b/src/algorithms/signal_source/adapters/labsat_signal_source.cc index 1b59feae4..c8f4af983 100644 --- a/src/algorithms/signal_source/adapters/labsat_signal_source.cc +++ b/src/algorithms/signal_source/adapters/labsat_signal_source.cc @@ -34,6 +34,9 @@ LabsatSignalSource::LabsatSignalSource(const ConfigurationInterface* configurati dump_ = configuration->property(role + ".dump", false); dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file); + sampling_frequency_ = configuration->property(role + ".sampling_frequency", static_cast(0)); + enable_throttle_control_ = configuration->property(role + ".enable_throttle_control", false); + const int channel_selector = configuration->property(role + ".selected_channel", 1); const std::string default_filename("./example_capture.LS3"); @@ -54,12 +57,15 @@ LabsatSignalSource::LabsatSignalSource(const ConfigurationInterface* configurati if (dump_) { DLOG(INFO) << "Dumping output into file " << dump_filename_; + DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")"; file_sink_ = gr::blocks::file_sink::make(item_size_, dump_filename_.c_str()); } - if (dump_) + + if (enable_throttle_control_) { - DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")"; + throttle_ = gr::blocks::throttle::make(item_size_, sampling_frequency_); } + if (in_stream_ > 0) { LOG(ERROR) << "A signal source does not have an input stream"; @@ -73,23 +79,50 @@ LabsatSignalSource::LabsatSignalSource(const ConfigurationInterface* configurati void LabsatSignalSource::connect(gr::top_block_sptr top_block) { - if (dump_) + if (enable_throttle_control_ == true) { - top_block->connect(labsat23_source_, 0, file_sink_, 0); - DLOG(INFO) << "connected labsat23_source_ to file sink"; + top_block->connect(labsat23_source_, 0, throttle_, 0); + DLOG(INFO) << "connected labsat23_source_ to throttle"; + if (dump_) + { + top_block->connect(labsat23_source_, 0, file_sink_, 0); + DLOG(INFO) << "connected labsat23_source_to sink"; + } } else { - DLOG(INFO) << "nothing to connect internally"; + if (dump_) + { + top_block->connect(labsat23_source_, 0, file_sink_, 0); + DLOG(INFO) << "connected labsat23_source_ to sink"; + } + else + { + DLOG(INFO) << "nothing to connect internally"; + } } } void LabsatSignalSource::disconnect(gr::top_block_sptr top_block) { - if (dump_) + if (enable_throttle_control_ == true) { - top_block->disconnect(labsat23_source_, 0, file_sink_, 0); + top_block->disconnect(labsat23_source_, 0, throttle_, 0); + DLOG(INFO) << "disconnected labsat23_source_ to throttle"; + if (dump_) + { + top_block->disconnect(labsat23_source_, 0, file_sink_, 0); + DLOG(INFO) << "disconnected labsat23_source_ to sink"; + } + } + else + { + if (dump_) + { + top_block->disconnect(labsat23_source_, 0, file_sink_, 0); + DLOG(INFO) << "disconnected labsat23_source_ to sink"; + } } } @@ -103,5 +136,9 @@ gr::basic_block_sptr LabsatSignalSource::get_left_block() gr::basic_block_sptr LabsatSignalSource::get_right_block() { + if (enable_throttle_control_ == true) + { + return throttle_; + } return labsat23_source_; } diff --git a/src/algorithms/signal_source/adapters/labsat_signal_source.h b/src/algorithms/signal_source/adapters/labsat_signal_source.h index 6f1d109e5..83b331e94 100644 --- a/src/algorithms/signal_source/adapters/labsat_signal_source.h +++ b/src/algorithms/signal_source/adapters/labsat_signal_source.h @@ -24,6 +24,7 @@ #include "concurrent_queue.h" #include "gnss_block_interface.h" #include +#include #include #include #include @@ -73,6 +74,12 @@ private: std::string item_type_; std::string filename_; std::string dump_filename_; + + + int64_t sampling_frequency_; + bool enable_throttle_control_; + gr::blocks::throttle::sptr throttle_; + unsigned int in_stream_; unsigned int out_stream_; size_t item_size_;