mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-31 15:23:04 +00:00 
			
		
		
		
	Sample counter now accepts any data type
This commit is contained in:
		| @@ -36,10 +36,10 @@ | |||||||
| #include <iostream> | #include <iostream> | ||||||
| #include <string> | #include <string> | ||||||
|  |  | ||||||
| gnss_sdr_sample_counter::gnss_sdr_sample_counter(double _fs) : gr::sync_decimator("sample_counter", | gnss_sdr_sample_counter::gnss_sdr_sample_counter(double _fs, size_t _size) : gr::sync_decimator("sample_counter", | ||||||
|                                                                    gr::io_signature::make(1, 1, sizeof(gr_complex)), |                                                                                  gr::io_signature::make(1, 1, _size), | ||||||
|                                                                    gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), |                                                                                  gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), | ||||||
|                                                                    static_cast<unsigned int>(std::floor(_fs * 0.001))) |                                                                                  static_cast<unsigned int>(std::floor(_fs * 0.001))) | ||||||
| { | { | ||||||
|     message_port_register_out(pmt::mp("sample_counter")); |     message_port_register_out(pmt::mp("sample_counter")); | ||||||
|     set_max_noutput_items(1); |     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_; |     return sample_counter_; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -39,12 +39,12 @@ class gnss_sdr_sample_counter; | |||||||
|  |  | ||||||
| typedef boost::shared_ptr<gnss_sdr_sample_counter> gnss_sdr_sample_counter_sptr; | typedef boost::shared_ptr<gnss_sdr_sample_counter> 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 | class gnss_sdr_sample_counter : public gr::sync_decimator | ||||||
| { | { | ||||||
| private: | 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 |     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 |     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 |     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; |     bool flag_enable_send_msg; | ||||||
|  |  | ||||||
| public: | 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, |     int work(int noutput_items, | ||||||
|         gr_vector_const_void_star &input_items, |         gr_vector_const_void_star &input_items, | ||||||
|         gr_vector_void_star &output_items); |         gr_vector_void_star &output_items); | ||||||
|   | |||||||
| @@ -88,7 +88,6 @@ private: | |||||||
|     std::string role_; |     std::string role_; | ||||||
|     unsigned int in_streams_; |     unsigned int in_streams_; | ||||||
|     unsigned int out_streams_; |     unsigned int out_streams_; | ||||||
|     //gr_kludge_copy_sptr kludge_copy_; |  | ||||||
|     gr::blocks::copy::sptr kludge_copy_; |     gr::blocks::copy::sptr kludge_copy_; | ||||||
|     size_t item_size_; |     size_t item_size_; | ||||||
|     conjugate_cc_sptr conjugate_cc_; |     conjugate_cc_sptr conjugate_cc_; | ||||||
|   | |||||||
| @@ -61,8 +61,6 @@ GNSSFlowgraph::GNSSFlowgraph(std::shared_ptr<ConfigurationInterface> configurati | |||||||
|  |  | ||||||
|  |  | ||||||
| GNSSFlowgraph::~GNSSFlowgraph() {} | GNSSFlowgraph::~GNSSFlowgraph() {} | ||||||
|  |  | ||||||
|  |  | ||||||
| void GNSSFlowgraph::start() | void GNSSFlowgraph::start() | ||||||
| { | { | ||||||
|     if (running_) |     if (running_) | ||||||
| @@ -249,25 +247,25 @@ void GNSSFlowgraph::connect() | |||||||
|     //connect the signal source to sample counter |     //connect the signal source to sample counter | ||||||
|     //connect the sample counter to Observables |     //connect the sample counter to Observables | ||||||
|     try |     try | ||||||
|     { |  | ||||||
|         double fs = static_cast<double>(configuration_->property("GNSS-SDR.internal_fs_sps", 0)); |  | ||||||
|         if(fs == 0.0) |  | ||||||
|         { |         { | ||||||
|             LOG(WARNING) << "Set GNSS-SDR.internal_fs_sps in configuration file"; |             double fs = static_cast<double>(configuration_->property("GNSS-SDR.internal_fs_sps", 0)); | ||||||
|             std::cout << "Set GNSS-SDR.internal_fs_sps in configuration file" << std::endl; |             if (fs == 0.0) | ||||||
|             throw(std::invalid_argument("Set GNSS-SDR.internal_fs_sps in configuration")); |                 { | ||||||
|  |                     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) |     // Signal conditioner (selected_signal_source) >> channels (i) (dependent of their associated SignalSource_ID) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Antonio Ramos
					Antonio Ramos