From 46bc52ce9e8ea5dc7f7bb304fbfc8b788c4ac872 Mon Sep 17 00:00:00 2001 From: Antonio Ramos Date: Wed, 4 Apr 2018 11:16:35 +0200 Subject: [PATCH] Sample counter now accepts any data type --- .../libs/gnss_sdr_sample_counter.cc | 12 +++---- src/algorithms/libs/gnss_sdr_sample_counter.h | 6 ++-- src/algorithms/libs/pass_through.h | 1 - src/core/receiver/gnss_flowgraph.cc | 36 +++++++++---------- 4 files changed, 26 insertions(+), 29 deletions(-) diff --git a/src/algorithms/libs/gnss_sdr_sample_counter.cc b/src/algorithms/libs/gnss_sdr_sample_counter.cc index ac4ac67cc..bfe53f6af 100644 --- a/src/algorithms/libs/gnss_sdr_sample_counter.cc +++ b/src/algorithms/libs/gnss_sdr_sample_counter.cc @@ -36,10 +36,10 @@ #include #include -gnss_sdr_sample_counter::gnss_sdr_sample_counter(double _fs) : gr::sync_decimator("sample_counter", - gr::io_signature::make(1, 1, sizeof(gr_complex)), - gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), - static_cast(std::floor(_fs * 0.001))) +gnss_sdr_sample_counter::gnss_sdr_sample_counter(double _fs, size_t _size) : gr::sync_decimator("sample_counter", + gr::io_signature::make(1, 1, _size), + gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), + static_cast(std::floor(_fs * 0.001))) { message_port_register_out(pmt::mp("sample_counter")); set_max_noutput_items(1); @@ -56,9 +56,9 @@ gnss_sdr_sample_counter::gnss_sdr_sample_counter(double _fs) : gr::sync_decimato } -gnss_sdr_sample_counter_sptr gnss_sdr_make_sample_counter(double _fs) +gnss_sdr_sample_counter_sptr gnss_sdr_make_sample_counter(double _fs, size_t _size) { - gnss_sdr_sample_counter_sptr sample_counter_(new gnss_sdr_sample_counter(_fs)); + gnss_sdr_sample_counter_sptr sample_counter_(new gnss_sdr_sample_counter(_fs, _size)); return sample_counter_; } diff --git a/src/algorithms/libs/gnss_sdr_sample_counter.h b/src/algorithms/libs/gnss_sdr_sample_counter.h index 579222ef3..761894855 100644 --- a/src/algorithms/libs/gnss_sdr_sample_counter.h +++ b/src/algorithms/libs/gnss_sdr_sample_counter.h @@ -39,12 +39,12 @@ class gnss_sdr_sample_counter; typedef boost::shared_ptr gnss_sdr_sample_counter_sptr; -gnss_sdr_sample_counter_sptr gnss_sdr_make_sample_counter(double _fs); +gnss_sdr_sample_counter_sptr gnss_sdr_make_sample_counter(double _fs, size_t _size); class gnss_sdr_sample_counter : public gr::sync_decimator { private: - gnss_sdr_sample_counter(double _fs); + gnss_sdr_sample_counter(double _fs, size_t _size); long long int current_T_rx_ms; // Receiver time in ms since the beginning of the run unsigned int current_s; // Receiver time in seconds, modulo 60 bool flag_m; // True if the receiver has been running for at least 1 minute @@ -57,7 +57,7 @@ private: bool flag_enable_send_msg; public: - friend gnss_sdr_sample_counter_sptr gnss_sdr_make_sample_counter(double _fs); + friend gnss_sdr_sample_counter_sptr gnss_sdr_make_sample_counter(double _fs, size_t _size); int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); diff --git a/src/algorithms/libs/pass_through.h b/src/algorithms/libs/pass_through.h index 1a9538ae4..f1d8c5f72 100644 --- a/src/algorithms/libs/pass_through.h +++ b/src/algorithms/libs/pass_through.h @@ -88,7 +88,6 @@ private: std::string role_; unsigned int in_streams_; unsigned int out_streams_; - //gr_kludge_copy_sptr kludge_copy_; gr::blocks::copy::sptr kludge_copy_; size_t item_size_; conjugate_cc_sptr conjugate_cc_; diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index a1fa6855f..eec75d2f0 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -61,8 +61,6 @@ GNSSFlowgraph::GNSSFlowgraph(std::shared_ptr configurati GNSSFlowgraph::~GNSSFlowgraph() {} - - void GNSSFlowgraph::start() { if (running_) @@ -249,25 +247,25 @@ void GNSSFlowgraph::connect() //connect the signal source to sample counter //connect the sample counter to Observables try - { - double fs = static_cast(configuration_->property("GNSS-SDR.internal_fs_sps", 0)); - if(fs == 0.0) { - LOG(WARNING) << "Set GNSS-SDR.internal_fs_sps in configuration file"; - std::cout << "Set GNSS-SDR.internal_fs_sps in configuration file" << std::endl; - throw(std::invalid_argument("Set GNSS-SDR.internal_fs_sps in configuration")); + double fs = static_cast(configuration_->property("GNSS-SDR.internal_fs_sps", 0)); + if (fs == 0.0) + { + LOG(WARNING) << "Set GNSS-SDR.internal_fs_sps in configuration file"; + std::cout << "Set GNSS-SDR.internal_fs_sps in configuration file" << std::endl; + throw(std::invalid_argument("Set GNSS-SDR.internal_fs_sps in configuration")); + } + ch_out_sample_counter = gnss_sdr_make_sample_counter(fs, sig_conditioner_.at(0)->get_right_block()->output_signature()->sizeof_stream_item(0)); + top_block_->connect(sig_conditioner_.at(0)->get_right_block(), 0, ch_out_sample_counter, 0); + top_block_->connect(ch_out_sample_counter, 0, observables_->get_left_block(), channels_count_); //extra port for the sample counter pulse + } + catch (const std::exception& e) + { + LOG(WARNING) << "Can't connect sample counter"; + LOG(ERROR) << e.what(); + top_block_->disconnect_all(); + return; } - ch_out_sample_counter = gnss_sdr_make_sample_counter(fs); - top_block_->connect(sig_conditioner_.at(0)->get_right_block(), 0, ch_out_sample_counter, 0); - top_block_->connect(ch_out_sample_counter, 0, observables_->get_left_block(), channels_count_); //extra port for the sample counter pulse - } - catch (const std::exception & e) - { - LOG(WARNING) << "Can't connect sample counter"; - LOG(ERROR) << e.what(); - top_block_->disconnect_all(); - return; - } // Signal conditioner (selected_signal_source) >> channels (i) (dependent of their associated SignalSource_ID)