From 57a01809cbad6e8f87bd3176a10fc4f6b93e8204 Mon Sep 17 00:00:00 2001 From: Javier Date: Sun, 11 Nov 2018 20:25:14 +0100 Subject: [PATCH] Improving spir signal source --- .../spir_gss6450_file_signal_source.cc | 153 ++++++++++-------- .../spir_gss6450_file_signal_source.h | 11 +- .../unpack_spir_gss6450_samples.cc | 2 +- 3 files changed, 95 insertions(+), 71 deletions(-) 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 25473ce2f..8b124a3fd 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 @@ -59,7 +59,7 @@ SpirGSS6450FileSignalSource::SpirGSS6450FileSignalSource(ConfigurationInterface* adc_bits_ = configuration->property(role + ".adc_bits", 4); n_channels_ = configuration->property(role + ".total_channels", 1); sel_ch_ = configuration->property(role + ".sel_ch", 1); - item_size_ = sizeof(int); + item_size_ = sizeof(int32_t); int64_t bytes_seek = configuration->property(role + ".bytes_to_skip", 65536); double sample_size_byte = static_cast(adc_bits_) / 4.0; @@ -69,17 +69,22 @@ SpirGSS6450FileSignalSource::SpirGSS6450FileSignalSource(ConfigurationInterface* } if (n_channels_ > 1) { - for (uint32_t i = 0; i < (n_channels_ - 1); i++) + for (uint32_t i = 0; i < n_channels_; i++) { - null_sinks_.push_back(gr::blocks::null_sink::make(item_size_)); + null_sinks_.push_back(gr::blocks::null_sink::make(sizeof(gr_complex))); + unpack_spir_vec_.push_back(make_unpack_spir_gss6450_samples(adc_bits_)); + if (endian_swap_) + { + endian_vec_.push_back(gr::blocks::endian_swap::make(item_size_)); + } } - DLOG(INFO) << "NUMBER OF NULL SINKS = " << null_sinks_.size(); } try { file_source_ = gr::blocks::file_source::make(item_size_, filename_.c_str(), repeat_); file_source_->seek(bytes_seek / item_size_, SEEK_SET); - unpack_spir_ = make_unpack_spir_gss6450_samples(adc_bits_); + + deint_ = gr::blocks::deinterleave::make(item_size_); } catch (const std::exception& e) @@ -143,22 +148,19 @@ SpirGSS6450FileSignalSource::SpirGSS6450FileSignalSource(ConfigurationInterface* LOG(INFO) << "Total number samples to be processed= " << samples_ << " GNSS signal duration= " << signal_duration_s << " [s]"; std::cout << "GNSS signal recorded time to be processed: " << signal_duration_s << " [s]" << std::endl; - valve_ = gnss_sdr_make_valve(sizeof(gr_complex), samples_, queue_); - DLOG(INFO) << "valve(" << valve_->unique_id() << ")"; + for (uint32_t i = 0; i < (n_channels_); i++) + { + valve_vec_.push_back(gnss_sdr_make_valve(sizeof(gr_complex), samples_, queue_)); + if (dump_) + { + sink_vec_.push_back(gr::blocks::file_sink::make(sizeof(gr_complex), dump_filename_.c_str())); + } + if (enable_throttle_control_) + { + throttle_vec_.push_back(gr::blocks::throttle::make(sizeof(gr_complex), sampling_frequency_)); + } + } - if (dump_) - { - sink_ = gr::blocks::file_sink::make(sizeof(gr_complex), dump_filename_.c_str()); - DLOG(INFO) << "file_sink(" << sink_->unique_id() << ")"; - } - if (enable_throttle_control_) - { - throttle_ = gr::blocks::throttle::make(sizeof(gr_complex), sampling_frequency_); - } - if (endian_swap_) - { - endian_ = gr::blocks::endian_swap::make(item_size_); - } DLOG(INFO) << "File source filename " << filename_; DLOG(INFO) << "Samples " << samples_; DLOG(INFO) << "Sampling frequency " << sampling_frequency_; @@ -188,15 +190,17 @@ void SpirGSS6450FileSignalSource::connect(gr::top_block_sptr top_block) if (samples_ > 0) { top_block->connect(file_source_, 0, deint_, 0); + if (endian_swap_) { - top_block->connect(deint_, sel_ch_ - 1, endian_, 0); - top_block->connect(endian_, 0, unpack_spir_, 0); + top_block->connect(deint_, sel_ch_ - 1, endian_vec_.at(sel_ch_ - 1), 0); + top_block->connect(endian_vec_.at(sel_ch_ - 1), 0, unpack_spir_vec_.at(sel_ch_ - 1), 0); } else { - top_block->connect(deint_, sel_ch_ - 1, unpack_spir_, 0); + top_block->connect(deint_, sel_ch_ - 1, unpack_spir_vec_.at(sel_ch_ - 1), 0); } + if (n_channels_ > 1) { uint32_t aux = 0; @@ -204,23 +208,37 @@ void SpirGSS6450FileSignalSource::connect(gr::top_block_sptr top_block) { if (i != (sel_ch_ - 1)) { - top_block->connect(deint_, i, null_sinks_.at(aux), 0); + if (endian_swap_) + { + top_block->connect(deint_, i, endian_vec_.at(i), 0); + top_block->connect(endian_vec_.at(i), 0, unpack_spir_vec_.at(i), 0); + } + else + { + top_block->connect(deint_, i, unpack_spir_vec_.at(i), 0); + } + aux++; } } } - if (enable_throttle_control_) + for (uint32_t i = 0; i < n_channels_; i++) { - top_block->connect(unpack_spir_, 0, throttle_, 0); - top_block->connect(throttle_, 0, valve_, 0); - } - else - { - top_block->connect(unpack_spir_, 0, valve_, 0); - } - if (dump_) - { - top_block->connect(valve_, 0, sink_, 0); + if (enable_throttle_control_) + { + top_block->connect(unpack_spir_vec_.at(i), 0, throttle_vec_.at(i), 0); + top_block->connect(throttle_vec_.at(i), 0, valve_vec_.at(i), 0); + } + else + { + top_block->connect(unpack_spir_vec_.at(i), 0, valve_vec_.at(i), 0); + } + if (dump_) + { + top_block->connect(valve_vec_.at(i), 0, sink_vec_.at(i), 0); + } + + top_block->connect(valve_vec_.at(i), 0, null_sinks_.at(i), 0); } } else @@ -237,12 +255,12 @@ void SpirGSS6450FileSignalSource::disconnect(gr::top_block_sptr top_block) top_block->disconnect(file_source_, 0, deint_, 0); if (endian_swap_) { - top_block->disconnect(deint_, sel_ch_ - 1, endian_, 0); - top_block->disconnect(endian_, 0, unpack_spir_, 0); + top_block->disconnect(deint_, sel_ch_ - 1, endian_vec_.at(sel_ch_ - 1), 0); + top_block->disconnect(endian_vec_.at(sel_ch_ - 1), 0, unpack_spir_vec_.at(sel_ch_ - 1), 0); } else { - top_block->disconnect(deint_, sel_ch_ - 1, unpack_spir_, 0); + top_block->disconnect(deint_, sel_ch_ - 1, unpack_spir_vec_.at(sel_ch_ - 1), 0); } if (n_channels_ > 1) { @@ -251,23 +269,38 @@ void SpirGSS6450FileSignalSource::disconnect(gr::top_block_sptr top_block) { if (i != (sel_ch_ - 1)) { - top_block->disconnect(deint_, i, null_sinks_.at(aux), 0); + if (endian_swap_) + { + top_block->disconnect(deint_, i, endian_vec_.at(i), 0); + top_block->disconnect(endian_vec_.at(i), 0, unpack_spir_vec_.at(i), 0); + } + else + { + top_block->disconnect(deint_, i, unpack_spir_vec_.at(i), 0); + } + aux++; } } } - if (enable_throttle_control_) + + for (uint32_t i = 0; i < (n_channels_); i++) { - top_block->disconnect(unpack_spir_, 0, throttle_, 0); - top_block->disconnect(throttle_, 0, valve_, 0); - } - else - { - top_block->disconnect(unpack_spir_, 0, valve_, 0); - } - if (dump_) - { - top_block->disconnect(valve_, 0, sink_, 0); + if (enable_throttle_control_) + { + top_block->disconnect(unpack_spir_vec_.at(i), 0, throttle_vec_.at(i), 0); + top_block->disconnect(throttle_vec_.at(i), 0, valve_vec_.at(i), 0); + } + else + { + top_block->disconnect(unpack_spir_vec_.at(i), 0, valve_vec_.at(i), 0); + } + if (dump_) + { + top_block->disconnect(valve_vec_.at(i), 0, sink_vec_.at(i), 0); + } + + top_block->disconnect(valve_vec_.at(i), 0, null_sinks_.at(i), 0); } } else @@ -283,22 +316,12 @@ gr::basic_block_sptr SpirGSS6450FileSignalSource::get_left_block() return gr::blocks::file_source::sptr(); } +gr::basic_block_sptr SpirGSS6450FileSignalSource::get_right_block(int RF_channel) +{ + return valve_vec_.at(RF_channel); +} gr::basic_block_sptr SpirGSS6450FileSignalSource::get_right_block() { - if (samples_ > 0) - { - return valve_; - } - else - { - if (enable_throttle_control_) - { - return throttle_; - } - else - { - return unpack_spir_; - } - } + return valve_vec_.at(0); } 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 d09f0356b..a37a4fe7f 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 @@ -79,6 +79,7 @@ public: void connect(gr::top_block_sptr top_block) override; void disconnect(gr::top_block_sptr top_block) override; gr::basic_block_sptr get_left_block() override; + gr::basic_block_sptr get_right_block(int RF_channel) override; gr::basic_block_sptr get_right_block() override; inline std::string filename() const @@ -124,12 +125,12 @@ private: uint32_t sel_ch_; gr::blocks::file_source::sptr file_source_; gr::blocks::deinterleave::sptr deint_; - gr::blocks::endian_swap::sptr endian_; + std::vector endian_vec_; std::vector null_sinks_; - unpack_spir_gss6450_samples_sptr unpack_spir_; - boost::shared_ptr valve_; - gr::blocks::file_sink::sptr sink_; - gr::blocks::throttle::sptr throttle_; + std::vector unpack_spir_vec_; + std::vector> valve_vec_; + std::vector sink_vec_; + std::vector throttle_vec_; gr::msg_queue::sptr queue_; size_t item_size_; }; diff --git a/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.cc b/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.cc index bca448c20..84d7ad0fc 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.cc @@ -40,7 +40,7 @@ unpack_spir_gss6450_samples_sptr make_unpack_spir_gss6450_samples(unsigned int a unpack_spir_gss6450_samples::unpack_spir_gss6450_samples(unsigned int adc_nbit) : gr::sync_interpolator("unpack_spir_gss6450_samples", - gr::io_signature::make(1, 1, sizeof(int)), + gr::io_signature::make(1, 1, sizeof(int32_t)), gr::io_signature::make(1, 1, sizeof(gr_complex)), 16 / adc_nbit) { adc_bits = adc_nbit;