mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-31 15:23:04 +00:00 
			
		
		
		
	Code cleaning
This commit is contained in:
		| @@ -51,50 +51,52 @@ UhdSignalSource::UhdSignalSource(ConfigurationInterface* configuration, | ||||
|     std::string default_dump_file = "./data/signal_source.dat"; | ||||
|     std::string default_item_type = "cshort"; | ||||
|  | ||||
| 	// UHD COMMON PARAMETERS | ||||
| 	uhd::device_addr_t dev_addr; | ||||
| 	device_address_= configuration->property(role + ".device_address", empty); | ||||
| 	// When left empty, the device discovery routines will search all | ||||
| 	// available transports on the system (ethernet, usb...). | ||||
| 	// To narrow down the discovery process to a particular device, | ||||
| 	// specify a transport key/value pair specific to your device. | ||||
| 	if (empty.compare(device_address_) != 0) // if not empty | ||||
| 		{ | ||||
| 			dev_addr["addr"] = device_address_; | ||||
| 		} | ||||
|     // UHD COMMON PARAMETERS | ||||
|     uhd::device_addr_t dev_addr; | ||||
|     device_address_ = configuration->property(role + ".device_address", empty); | ||||
|     // When left empty, the device discovery routines will search all | ||||
|     // available transports on the system (ethernet, usb...). | ||||
|     // To narrow down the discovery process to a particular device, | ||||
|     // specify a transport key/value pair specific to your device. | ||||
|     if (empty.compare(device_address_) != 0) // if not empty | ||||
|         { | ||||
|             dev_addr["addr"] = device_address_; | ||||
|         } | ||||
|  | ||||
| 	subdevice_=configuration->property(role + ".subdevice", empty); | ||||
|     RF_channels_=configuration->property(role + ".RF_channels", 1); | ||||
| 	sample_rate_ = configuration->property(role + ".sampling_frequency", (double)4.0e6); | ||||
| 	item_type_ = configuration->property(role + ".item_type", default_item_type); | ||||
|     subdevice_ = configuration->property(role + ".subdevice", empty); | ||||
|     RF_channels_ = configuration->property(role + ".RF_channels", 1); | ||||
|     sample_rate_ = configuration->property(role + ".sampling_frequency", (double)4.0e6); | ||||
|     item_type_ = configuration->property(role + ".item_type", default_item_type); | ||||
|  | ||||
|     if (RF_channels_==1) | ||||
|     { | ||||
|     	// Single RF channel UHD operation (backward compatible config file format) | ||||
| 		samples_.push_back(configuration->property(role + ".samples", 0)); | ||||
| 		dump_.push_back(configuration->property(role + ".dump", false)); | ||||
| 		dump_filename_.push_back(configuration->property(role + ".dump_filename", default_dump_file)); | ||||
|     if (RF_channels_ == 1) | ||||
|         { | ||||
|             // Single RF channel UHD operation (backward compatible config file format) | ||||
|             samples_.push_back(configuration->property(role + ".samples", 0)); | ||||
|             dump_.push_back(configuration->property(role + ".dump", false)); | ||||
|             dump_filename_.push_back(configuration->property(role + ".dump_filename", default_dump_file)); | ||||
|  | ||||
| 		freq_.push_back(configuration->property(role + ".freq", GPS_L1_FREQ_HZ)); | ||||
| 		gain_.push_back(configuration->property(role + ".gain", (double)50.0)); | ||||
|             freq_.push_back(configuration->property(role + ".freq", GPS_L1_FREQ_HZ)); | ||||
|             gain_.push_back(configuration->property(role + ".gain", (double)50.0)); | ||||
|  | ||||
| 		IF_bandwidth_hz_.push_back(configuration->property(role + ".IF_bandwidth_hz", sample_rate_/2)); | ||||
|             IF_bandwidth_hz_.push_back(configuration->property(role + ".IF_bandwidth_hz", sample_rate_/2)); | ||||
|  | ||||
|     }else{ | ||||
|     	// multiple RF channels selected | ||||
|     	for (int i=0;i<RF_channels_;i++) | ||||
|     	{ | ||||
|         	// Single RF channel UHD operation (backward compatible config file format) | ||||
|     		samples_.push_back(configuration->property(role + ".samples" + boost::lexical_cast<std::string>(i), 0)); | ||||
|     		dump_.push_back(configuration->property(role + ".dump" + boost::lexical_cast<std::string>(i), false)); | ||||
|     		dump_filename_.push_back(configuration->property(role + ".dump_filename" + boost::lexical_cast<std::string>(i), default_dump_file)); | ||||
|         } | ||||
|     else | ||||
|         { | ||||
|             // multiple RF channels selected | ||||
|             for (int i = 0; i < RF_channels_; i++) | ||||
|                 { | ||||
|                     // Single RF channel UHD operation (backward compatible config file format) | ||||
|                     samples_.push_back(configuration->property(role + ".samples" + boost::lexical_cast<std::string>(i), 0)); | ||||
|                     dump_.push_back(configuration->property(role + ".dump" + boost::lexical_cast<std::string>(i), false)); | ||||
|                     dump_filename_.push_back(configuration->property(role + ".dump_filename" + boost::lexical_cast<std::string>(i), default_dump_file)); | ||||
|  | ||||
|     		freq_.push_back(configuration->property(role + ".freq" + boost::lexical_cast<std::string>(i), GPS_L1_FREQ_HZ)); | ||||
|     		gain_.push_back(configuration->property(role + ".gain" + boost::lexical_cast<std::string>(i), (double)50.0)); | ||||
|                     freq_.push_back(configuration->property(role + ".freq" + boost::lexical_cast<std::string>(i), GPS_L1_FREQ_HZ)); | ||||
|                     gain_.push_back(configuration->property(role + ".gain" + boost::lexical_cast<std::string>(i), (double)50.0)); | ||||
|  | ||||
|     		IF_bandwidth_hz_.push_back(configuration->property(role + ".IF_bandwidth_hz" + boost::lexical_cast<std::string>(i), sample_rate_/2)); | ||||
|     	} | ||||
|     } | ||||
|                     IF_bandwidth_hz_.push_back(configuration->property(role + ".IF_bandwidth_hz" + boost::lexical_cast<std::string>(i), sample_rate_/2)); | ||||
|                 } | ||||
|         } | ||||
|     // 1. Make the uhd driver instance | ||||
|     //uhd_source_= uhd::usrp::multi_usrp::make(dev_addr); | ||||
|  | ||||
| @@ -108,44 +110,44 @@ UhdSignalSource::UhdSignalSource(ConfigurationInterface* configuration, | ||||
|     if (item_type_.compare("cbyte") == 0) | ||||
|         { | ||||
|             item_size_ = sizeof(lv_8sc_t); | ||||
|             uhd_stream_args_=uhd::stream_args_t("sc8"); | ||||
|             uhd_stream_args_ = uhd::stream_args_t("sc8"); | ||||
|         } | ||||
|     else if (item_type_.compare("cshort") == 0) | ||||
|         { | ||||
|             item_size_ = sizeof(lv_16sc_t); | ||||
|             uhd_stream_args_=uhd::stream_args_t("sc16"); | ||||
|             uhd_stream_args_ = uhd::stream_args_t("sc16"); | ||||
|         } | ||||
|     else if (item_type_.compare("gr_complex") == 0) | ||||
|         { | ||||
|             item_size_ = sizeof(gr_complex); | ||||
|             uhd_stream_args_=uhd::stream_args_t("fc32"); | ||||
|             uhd_stream_args_ = uhd::stream_args_t("fc32"); | ||||
|         } | ||||
|     else | ||||
|         { | ||||
|             LOG(WARNING) << item_type_ << " unrecognized item type. Using cshort."; | ||||
|             item_size_ = sizeof(lv_16sc_t); | ||||
|             uhd_stream_args_=uhd::stream_args_t("sc16"); | ||||
|             uhd_stream_args_ = uhd::stream_args_t("sc16"); | ||||
|         } | ||||
|  | ||||
|     // select the number of channels and the subdevice specifications | ||||
| 	for (int i=0;i<RF_channels_;i++) | ||||
| 	{ | ||||
| 		uhd_stream_args_.channels.push_back(i); | ||||
| 	} | ||||
|     for (int i = 0; i< RF_channels_; i++) | ||||
|         { | ||||
|             uhd_stream_args_.channels.push_back(i); | ||||
|         } | ||||
|  | ||||
|     // 1.2 Make the UHD source object | ||||
|     uhd_source_ = gr::uhd::usrp_source::make(dev_addr, uhd_stream_args_); | ||||
|  | ||||
| 	// Set subdevice specification string for USRP family devices. It is composed of: | ||||
| 	// <motherboard slot name>:<daughterboard frontend name> | ||||
| 	// For motherboards: All USRP family motherboards have a first slot named A:. | ||||
| 	//       The USRP1 has two daughterboard subdevice slots, known as A: and B:. | ||||
| 	// For daughterboards, see http://files.ettus.com/uhd_docs/manual/html/dboards.html | ||||
| 	// "0" is valid for DBSRX, DBSRX2, WBX Series | ||||
|     // Set subdevice specification string for USRP family devices. It is composed of: | ||||
|     // <motherboard slot name>:<daughterboard frontend name> | ||||
|     // For motherboards: All USRP family motherboards have a first slot named A:. | ||||
|     //       The USRP1 has two daughterboard subdevice slots, known as A: and B:. | ||||
|     // For daughterboards, see http://files.ettus.com/uhd_docs/manual/html/dboards.html | ||||
|     // "0" is valid for DBSRX, DBSRX2, WBX Series | ||||
|     // Dual channel example: "A:0 B:0" | ||||
|     // TODO: Add support for multiple motherboards (i.e. four channels "A:0 B:0 A:1 B1") | ||||
|  | ||||
| 	uhd_source_->set_subdev_spec(subdevice_, 0); | ||||
|     uhd_source_->set_subdev_spec(subdevice_, 0); | ||||
|  | ||||
|     // 2.1 set sampling clock reference | ||||
|     // Set the clock source for the usrp device. | ||||
| @@ -159,70 +161,69 @@ UhdSignalSource::UhdSignalSource(ConfigurationInterface* configuration, | ||||
|     std::cout << boost::format("Sampling Rate for the USRP device: %f [sps]...") % (uhd_source_->get_samp_rate()) << std::endl; | ||||
|     LOG(INFO) << boost::format("Sampling Rate for the USRP device: %f [sps]...") % (uhd_source_->get_samp_rate()); | ||||
|  | ||||
| 	std::vector<std::string> sensor_names; | ||||
|     std::vector<std::string> sensor_names; | ||||
|  | ||||
| 	for (int i=0;i<RF_channels_;i++) | ||||
| 	{ | ||||
| 		// 3. Tune the usrp device to the desired center frequency | ||||
| 		uhd_source_->set_center_freq(freq_.at(i),i); | ||||
| 		std::cout << boost::format("Actual USRP center freq.: %f [Hz]...") % (uhd_source_->get_center_freq(i)) << std::endl << std::endl; | ||||
| 		LOG(INFO) << boost::format("Actual USRP center freq. set to: %f [Hz]...") % (uhd_source_->get_center_freq(i)); | ||||
|     for (int i = 0; i < RF_channels_; i++) | ||||
|         { | ||||
|             // 3. Tune the usrp device to the desired center frequency | ||||
|             uhd_source_->set_center_freq(freq_.at(i),i); | ||||
|             std::cout << boost::format("Actual USRP center freq.: %f [Hz]...") % (uhd_source_->get_center_freq(i)) << std::endl << std::endl; | ||||
|             LOG(INFO) << boost::format("Actual USRP center freq. set to: %f [Hz]...") % (uhd_source_->get_center_freq(i)); | ||||
|  | ||||
| 		// TODO: Assign the remnant IF from the PLL tune error | ||||
| 		std::cout << boost::format("PLL Frequency tune error %f [Hz]...") % (uhd_source_->get_center_freq(i) - freq_.at(i)) << std::endl; | ||||
| 		LOG(INFO) << boost::format("PLL Frequency tune error %f [Hz]...") % (uhd_source_->get_center_freq(i) - freq_.at(i)); | ||||
|             // TODO: Assign the remnant IF from the PLL tune error | ||||
|             std::cout << boost::format("PLL Frequency tune error %f [Hz]...") % (uhd_source_->get_center_freq(i) - freq_.at(i)) << std::endl; | ||||
|             LOG(INFO) << boost::format("PLL Frequency tune error %f [Hz]...") % (uhd_source_->get_center_freq(i) - freq_.at(i)); | ||||
|  | ||||
| 		// 4. set the gain for the daughterboard | ||||
| 		uhd_source_->set_gain(gain_.at(i),i); | ||||
| 		std::cout << boost::format("Actual daughterboard gain set to: %f dB...") % uhd_source_->get_gain(i) << std::endl; | ||||
| 		LOG(INFO) << boost::format("Actual daughterboard gain set to: %f dB...") % uhd_source_->get_gain(i); | ||||
|             // 4. set the gain for the daughterboard | ||||
|             uhd_source_->set_gain(gain_.at(i),i); | ||||
|             std::cout << boost::format("Actual daughterboard gain set to: %f dB...") % uhd_source_->get_gain(i) << std::endl; | ||||
|             LOG(INFO) << boost::format("Actual daughterboard gain set to: %f dB...") % uhd_source_->get_gain(i); | ||||
|  | ||||
| 		//5.  Set the bandpass filter on the RF frontend | ||||
| 		std::cout << boost::format("Setting RF bandpass filter bandwidth to: %f [Hz]...") % IF_bandwidth_hz_.at(i) << std::endl; | ||||
| 		uhd_source_->set_bandwidth(IF_bandwidth_hz_.at(i),i); | ||||
|             //5.  Set the bandpass filter on the RF frontend | ||||
|             std::cout << boost::format("Setting RF bandpass filter bandwidth to: %f [Hz]...") % IF_bandwidth_hz_.at(i) << std::endl; | ||||
|             uhd_source_->set_bandwidth(IF_bandwidth_hz_.at(i),i); | ||||
|  | ||||
| 		//set the antenna (optional) | ||||
| 		//uhd_source_->set_antenna(ant); | ||||
|             //set the antenna (optional) | ||||
|             //uhd_source_->set_antenna(ant); | ||||
|  | ||||
| 		// We should wait? #include <boost/thread.hpp> | ||||
| 		// boost::this_thread::sleep(boost::posix_time::seconds(1)); | ||||
|             // We should wait? #include <boost/thread.hpp> | ||||
|             // boost::this_thread::sleep(boost::posix_time::seconds(1)); | ||||
|  | ||||
| 		// Check out the status of the lo_locked sensor (boolean for LO lock state) | ||||
| 		sensor_names = uhd_source_->get_sensor_names(i); | ||||
| 		if (std::find(sensor_names.begin(), sensor_names.end(), "lo_locked") != sensor_names.end()) | ||||
| 			{ | ||||
| 				uhd::sensor_value_t lo_locked = uhd_source_->get_sensor("lo_locked", i); | ||||
| 				std::cout << boost::format("Check for front-end %s ...") % lo_locked.to_pp_string() << " is "; | ||||
| 				if (lo_locked.to_bool() == true) | ||||
| 					{ | ||||
| 						std::cout << "Locked" << std::endl; | ||||
| 					} | ||||
| 				else | ||||
| 					{ | ||||
| 						std::cout << "UNLOCKED!" <<std::endl; | ||||
| 					} | ||||
| 				//UHD_ASSERT_THROW(lo_locked.to_bool()); | ||||
| 			} | ||||
| 	} | ||||
|             // Check out the status of the lo_locked sensor (boolean for LO lock state) | ||||
|             sensor_names = uhd_source_->get_sensor_names(i); | ||||
|             if (std::find(sensor_names.begin(), sensor_names.end(), "lo_locked") != sensor_names.end()) | ||||
|                 { | ||||
|                     uhd::sensor_value_t lo_locked = uhd_source_->get_sensor("lo_locked", i); | ||||
|                     std::cout << boost::format("Check for front-end %s ...") % lo_locked.to_pp_string() << " is "; | ||||
|                     if (lo_locked.to_bool() == true) | ||||
|                         { | ||||
|                             std::cout << "Locked" << std::endl; | ||||
|                         } | ||||
|                     else | ||||
|                         { | ||||
|                             std::cout << "UNLOCKED!" <<std::endl; | ||||
|                         } | ||||
|                     //UHD_ASSERT_THROW(lo_locked.to_bool()); | ||||
|                 } | ||||
|         } | ||||
|  | ||||
|  | ||||
| 	for (int i=0;i<RF_channels_;i++) | ||||
| 	{ | ||||
| 	    if (samples_.at(i) != 0) | ||||
| 	        { | ||||
| 	            LOG(INFO) << "RF_channel "<<i<<" Send STOP signal after " << samples_.at(i) << " samples"; | ||||
| 	            valve_.push_back(gnss_sdr_make_valve(item_size_, samples_.at(i), queue_)); | ||||
| 	            DLOG(INFO) << "valve(" << valve_.at(i)->unique_id() << ")"; | ||||
| 	        } | ||||
|  | ||||
| 	    if (dump_.at(i)) | ||||
| 	        { | ||||
| 	            LOG(INFO) << "RF_channel "<<i<< "Dumping output into file " << dump_filename_.at(i); | ||||
| 	            file_sink_.push_back(gr::blocks::file_sink::make(item_size_, dump_filename_.at(i).c_str())); | ||||
| 	            DLOG(INFO) << "file_sink(" << file_sink_.at(i)->unique_id() << ")"; | ||||
| 	        } | ||||
| 	} | ||||
|     for (int i = 0; i < RF_channels_; i++) | ||||
|         { | ||||
|             if (samples_.at(i) != 0) | ||||
|                 { | ||||
|                     LOG(INFO) << "RF_channel "<<i<<" Send STOP signal after " << samples_.at(i) << " samples"; | ||||
|                     valve_.push_back(gnss_sdr_make_valve(item_size_, samples_.at(i), queue_)); | ||||
|                     DLOG(INFO) << "valve(" << valve_.at(i)->unique_id() << ")"; | ||||
|                 } | ||||
|  | ||||
|             if (dump_.at(i)) | ||||
|                 { | ||||
|                     LOG(INFO) << "RF_channel "<<i<< "Dumping output into file " << dump_filename_.at(i); | ||||
|                     file_sink_.push_back(gr::blocks::file_sink::make(item_size_, dump_filename_.at(i).c_str())); | ||||
|                     DLOG(INFO) << "file_sink(" << file_sink_.at(i)->unique_id() << ")"; | ||||
|                 } | ||||
|         } | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -230,56 +231,55 @@ UhdSignalSource::UhdSignalSource(ConfigurationInterface* configuration, | ||||
| UhdSignalSource::~UhdSignalSource() | ||||
| {} | ||||
|  | ||||
|  | ||||
| void UhdSignalSource::connect(gr::top_block_sptr top_block) | ||||
| { | ||||
|  | ||||
| 	for (int i=0;i<RF_channels_;i++) | ||||
| 	{ | ||||
|  | ||||
| 		if (samples_.at(i) != 0) | ||||
| 			{ | ||||
| 				top_block->connect(uhd_source_, i, valve_.at(i), 0); | ||||
| 				DLOG(INFO) << "connected usrp source to valve RF Channel "<< i; | ||||
| 				if (dump_.at(i)) | ||||
| 					{ | ||||
| 						top_block->connect(valve_.at(i), 0, file_sink_.at(i), 0); | ||||
| 						DLOG(INFO) << "connected valve to file sink RF Channel "<< i; | ||||
| 					} | ||||
| 			} | ||||
| 		else | ||||
| 			{ | ||||
| 				if (dump_.at(i)) | ||||
| 					{ | ||||
| 						top_block->connect(uhd_source_, i, file_sink_.at(i), 0); | ||||
| 						DLOG(INFO) << "connected usrp source to file sink RF Channel "<< i; | ||||
| 					} | ||||
| 			} | ||||
| 	} | ||||
|     for (int i = 0; i < RF_channels_; i++) | ||||
|         { | ||||
|             if (samples_.at(i) != 0) | ||||
|                 { | ||||
|                     top_block->connect(uhd_source_, i, valve_.at(i), 0); | ||||
|                     DLOG(INFO) << "connected usrp source to valve RF Channel "<< i; | ||||
|                     if (dump_.at(i)) | ||||
|                         { | ||||
|                             top_block->connect(valve_.at(i), 0, file_sink_.at(i), 0); | ||||
|                             DLOG(INFO) << "connected valve to file sink RF Channel "<< i; | ||||
|                         } | ||||
|                 } | ||||
|             else | ||||
|                 { | ||||
|                     if (dump_.at(i)) | ||||
|                         { | ||||
|                             top_block->connect(uhd_source_, i, file_sink_.at(i), 0); | ||||
|                             DLOG(INFO) << "connected usrp source to file sink RF Channel "<< i; | ||||
|                         } | ||||
|                 } | ||||
|         } | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| void UhdSignalSource::disconnect(gr::top_block_sptr top_block) | ||||
| { | ||||
| 	for (int i=0;i<RF_channels_;i++) | ||||
| 	{ | ||||
| 		if (samples_.at(i) != 0) | ||||
| 			{ | ||||
| 				top_block->disconnect(uhd_source_, i, valve_.at(i), 0); | ||||
| 				LOG(INFO) << "UHD source disconnected"; | ||||
| 				if (dump_.at(i)) | ||||
| 					{ | ||||
| 						top_block->disconnect(valve_.at(i), 0, file_sink_.at(i), 0); | ||||
| 					} | ||||
| 			} | ||||
| 		else | ||||
| 			{ | ||||
| 				if (dump_.at(i)) | ||||
| 					{ | ||||
| 						top_block->disconnect(uhd_source_, i, file_sink_.at(i), 0); | ||||
| 					} | ||||
| 			} | ||||
| 	} | ||||
|     for (int i = 0; i < RF_channels_; i++) | ||||
|         { | ||||
|             if (samples_.at(i) != 0) | ||||
|                 { | ||||
|                     top_block->disconnect(uhd_source_, i, valve_.at(i), 0); | ||||
|                     LOG(INFO) << "UHD source disconnected"; | ||||
|                     if (dump_.at(i)) | ||||
|                         { | ||||
|                             top_block->disconnect(valve_.at(i), 0, file_sink_.at(i), 0); | ||||
|                         } | ||||
|                 } | ||||
|             else | ||||
|                 { | ||||
|                     if (dump_.at(i)) | ||||
|                         { | ||||
|                             top_block->disconnect(uhd_source_, i, file_sink_.at(i), 0); | ||||
|                         } | ||||
|                 } | ||||
|         } | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -294,9 +294,10 @@ gr::basic_block_sptr UhdSignalSource::get_left_block() | ||||
|  | ||||
| gr::basic_block_sptr UhdSignalSource::get_right_block() | ||||
| { | ||||
| 	return get_right_block(0); | ||||
|     return get_right_block(0); | ||||
| } | ||||
|  | ||||
|  | ||||
| gr::basic_block_sptr UhdSignalSource::get_right_block(int RF_channel) | ||||
| { | ||||
|     if (samples_.at(RF_channel) != 0) | ||||
|   | ||||
| @@ -128,11 +128,11 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetSignalSource( | ||||
|         std::shared_ptr<ConfigurationInterface> configuration, boost::shared_ptr<gr::msg_queue> queue, int ID) | ||||
| { | ||||
|     std::string default_implementation = "File_Signal_Source"; | ||||
|     std::string role="SignalSource";//backwards compatibility for old conf files | ||||
|     if (ID!=-1) | ||||
|     { | ||||
|     	role="SignalSource"+ boost::lexical_cast<std::string>(ID); | ||||
|     } | ||||
|     std::string role = "SignalSource"; //backwards compatibility for old conf files | ||||
|     if (ID != -1) | ||||
|         { | ||||
|             role = "SignalSource" + boost::lexical_cast<std::string>(ID); | ||||
|         } | ||||
|     std::string implementation = configuration->property(role + ".implementation", default_implementation); | ||||
|     LOG(INFO) << "Getting SignalSource with implementation " << implementation; | ||||
|     return GetBlock(configuration, role, implementation, 0, 1, queue); | ||||
| @@ -145,21 +145,21 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetSignalConditioner( | ||||
| { | ||||
|     std::string default_implementation = "Pass_Through"; | ||||
|     //backwards compatibility for old conf files | ||||
| 	std::string role_conditioner="SignalConditioner" ; | ||||
| 	std::string role_datatypeadapter="DataTypeAdapter"; | ||||
| 	std::string role_inputfilter="InputFilter"; | ||||
| 	std::string role_resampler="Resampler"; | ||||
|     std::string role_conditioner = "SignalConditioner" ; | ||||
|     std::string role_datatypeadapter = "DataTypeAdapter"; | ||||
|     std::string role_inputfilter = "InputFilter"; | ||||
|     std::string role_resampler = "Resampler"; | ||||
|  | ||||
|     if (ID!=-1) | ||||
|     { | ||||
| 		role_conditioner="SignalConditioner" + boost::lexical_cast<std::string>(ID); | ||||
| 		role_datatypeadapter="DataTypeAdapter" + boost::lexical_cast<std::string>(ID); | ||||
| 		role_inputfilter="InputFilter" + boost::lexical_cast<std::string>(ID); | ||||
| 		role_resampler="Resampler" + boost::lexical_cast<std::string>(ID); | ||||
|     } | ||||
|     if (ID != -1) | ||||
|         { | ||||
|             role_conditioner = "SignalConditioner" + boost::lexical_cast<std::string>(ID); | ||||
|             role_datatypeadapter = "DataTypeAdapter" + boost::lexical_cast<std::string>(ID); | ||||
|             role_inputfilter = "InputFilter" + boost::lexical_cast<std::string>(ID); | ||||
|             role_resampler = "Resampler" + boost::lexical_cast<std::string>(ID); | ||||
|         } | ||||
|  | ||||
|     std::string signal_conditioner = configuration->property( | ||||
|     		role_conditioner+".implementation", default_implementation); | ||||
|             role_conditioner + ".implementation", default_implementation); | ||||
|  | ||||
|     std::string data_type_adapter; | ||||
|     std::string input_filter; | ||||
| @@ -173,11 +173,11 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetSignalConditioner( | ||||
|     else | ||||
|         { | ||||
|             data_type_adapter = configuration->property( | ||||
|             		role_datatypeadapter + ".implementation", default_implementation); | ||||
|                     role_datatypeadapter + ".implementation", default_implementation); | ||||
|             input_filter = configuration->property( | ||||
|             		role_inputfilter + ".implementation", default_implementation); | ||||
|                     role_inputfilter + ".implementation", default_implementation); | ||||
|             resampler = configuration->property( | ||||
|             		role_resampler + ".implementation", default_implementation); | ||||
|                     role_resampler + ".implementation", default_implementation); | ||||
|         } | ||||
|  | ||||
|     LOG(INFO) << "Getting SignalConditioner with DataTypeAdapter implementation: " | ||||
| @@ -189,7 +189,7 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetSignalConditioner( | ||||
|         { | ||||
|             //instantiate the array version | ||||
|             std::unique_ptr<GNSSBlockInterface> conditioner_(new ArraySignalConditioner(configuration.get(), GetBlock(configuration, | ||||
|             		role_datatypeadapter, data_type_adapter, 1, 1, queue).release(), GetBlock( | ||||
|                     role_datatypeadapter, data_type_adapter, 1, 1, queue).release(), GetBlock( | ||||
|                             configuration,role_inputfilter, input_filter, 1, 1, queue).release(), | ||||
|                             GetBlock(configuration,role_resampler, resampler, 1, 1, queue).release(), | ||||
|                             role_conditioner, "Signal_Conditioner", queue)); | ||||
| @@ -199,7 +199,7 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetSignalConditioner( | ||||
|         { | ||||
|             //single-antenna version | ||||
|             std::unique_ptr<GNSSBlockInterface> conditioner_(new SignalConditioner(configuration.get(), GetBlock(configuration, | ||||
|             		role_datatypeadapter, data_type_adapter, 1, 1, queue).release(), GetBlock( | ||||
|                     role_datatypeadapter, data_type_adapter, 1, 1, queue).release(), GetBlock( | ||||
|                             configuration,role_inputfilter, input_filter, 1, 1, queue).release(), | ||||
|                             GetBlock(configuration,role_resampler, resampler, 1, 1, queue).release(), | ||||
|                             role_conditioner, "Signal_Conditioner", queue)); | ||||
|   | ||||
| @@ -57,10 +57,10 @@ public: | ||||
|     GNSSBlockFactory(); | ||||
|     virtual ~GNSSBlockFactory(); | ||||
|     std::unique_ptr<GNSSBlockInterface> GetSignalSource(std::shared_ptr<ConfigurationInterface> configuration, | ||||
|             boost::shared_ptr<gr::msg_queue> queue, int ID=-1); | ||||
|             boost::shared_ptr<gr::msg_queue> queue, int ID = -1); | ||||
|  | ||||
|     std::unique_ptr<GNSSBlockInterface> GetSignalConditioner(std::shared_ptr<ConfigurationInterface> configuration, | ||||
|             boost::shared_ptr<gr::msg_queue> queue, int ID=-1); | ||||
|             boost::shared_ptr<gr::msg_queue> queue, int ID = -1); | ||||
|  | ||||
|     std::unique_ptr<GNSSBlockInterface> GetPVT(std::shared_ptr<ConfigurationInterface> configuration, | ||||
|             boost::shared_ptr<gr::msg_queue> queue); | ||||
|   | ||||
| @@ -54,16 +54,13 @@ GNSSFlowgraph::GNSSFlowgraph(std::shared_ptr<ConfigurationInterface> configurati | ||||
|     connected_ = false; | ||||
|     running_ = false; | ||||
|     configuration_ = configuration; | ||||
|     //std::shared_ptr<std::vector<std::shared_ptr<GNSSBlockInterface>>> blocks_ = std::make_shared<std::vector<std::shared_ptr<GNSSBlockInterface>>>(); | ||||
|     queue_ = queue; | ||||
|     init(); | ||||
| } | ||||
|  | ||||
|  | ||||
| GNSSFlowgraph::~GNSSFlowgraph() | ||||
| { | ||||
|     //blocks_->clear(); | ||||
| } | ||||
| {} | ||||
|  | ||||
| void GNSSFlowgraph::start() | ||||
| { | ||||
| @@ -87,6 +84,7 @@ void GNSSFlowgraph::start() | ||||
|     running_ = true; | ||||
| } | ||||
|  | ||||
|  | ||||
| void GNSSFlowgraph::stop() | ||||
| { | ||||
|     for (unsigned int i = 0; i < channels_count_; i++) | ||||
| @@ -113,45 +111,41 @@ void GNSSFlowgraph::connect() | ||||
|             return; | ||||
|         } | ||||
|  | ||||
| 		for (int i = 0; i < sources_count_; i++) | ||||
| 		{ | ||||
| 			try | ||||
| 			{ | ||||
| 				sig_source_.at(i)->connect(top_block_); | ||||
| 			} | ||||
| 			catch (std::exception& e) | ||||
| 			{ | ||||
| 				LOG(INFO) << "Can't connect signal source block " << i << " internally"; | ||||
| 				LOG(ERROR) << e.what(); | ||||
| 				top_block_->disconnect_all(); | ||||
| 				return; | ||||
| 			} | ||||
| 		} | ||||
|     for (int i = 0; i < sources_count_; i++) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                     sig_source_.at(i)->connect(top_block_); | ||||
|             } | ||||
|             catch (std::exception& e) | ||||
|             { | ||||
|                     LOG(INFO) << "Can't connect signal source block " << i << " internally"; | ||||
|                     LOG(ERROR) << e.what(); | ||||
|                     top_block_->disconnect_all(); | ||||
|                     return; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|     // Signal Source > Signal conditioner > | ||||
|  | ||||
| 		for (int i = 0; i < sources_count_; i++) | ||||
| 		{ | ||||
| 			try | ||||
| 			{ | ||||
| 				sig_conditioner_.at(i)->connect(top_block_); | ||||
| 			} | ||||
| 			catch (std::exception& e) | ||||
| 			{ | ||||
| 				LOG(INFO) << "Can't connect signal conditioner block " << i << " internally"; | ||||
| 				LOG(ERROR) << e.what(); | ||||
| 				top_block_->disconnect_all(); | ||||
| 				return; | ||||
| 			} | ||||
| 		} | ||||
|     for (int i = 0; i < sources_count_; i++) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                     sig_conditioner_.at(i)->connect(top_block_); | ||||
|             } | ||||
|             catch (std::exception& e) | ||||
|             { | ||||
|                     LOG(INFO) << "Can't connect signal conditioner block " << i << " internally"; | ||||
|                     LOG(ERROR) << e.what(); | ||||
|                     top_block_->disconnect_all(); | ||||
|                     return; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|     for (unsigned int i = 0; i < channels_count_; i++) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                     //auto chan_ = std::move(blocks_->at(i)); | ||||
|                     //std::shared_ptr<ChannelInterface> chan = std::dynamic_pointer_cast<ChannelInterface>(chan_); | ||||
|                     //channels_.push_back(chan); | ||||
|                     channels_.at(i)->connect(top_block_); | ||||
|             } | ||||
|             catch (std::exception& e) | ||||
| @@ -165,7 +159,6 @@ void GNSSFlowgraph::connect() | ||||
|  | ||||
|     try | ||||
|     { | ||||
|             //observables_ = std::move(blocks_->at(2)); | ||||
|             observables_->connect(top_block_); | ||||
|     } | ||||
|     catch (std::exception& e) | ||||
| @@ -179,7 +172,6 @@ void GNSSFlowgraph::connect() | ||||
|     // Signal Source > Signal conditioner >> Channels >> Observables > PVT | ||||
|     try | ||||
|     { | ||||
|             //pvt_ = std::move(blocks_->at(3)); | ||||
|             pvt_->connect(top_block_); | ||||
|     } | ||||
|     catch (std::exception& e) | ||||
| @@ -193,7 +185,6 @@ void GNSSFlowgraph::connect() | ||||
|     // Signal Source > Signal conditioner >> Channels >> Observables > PVT > Output Filter | ||||
|     try | ||||
|     { | ||||
|             //output_filter_ = std::move(blocks_->at(4)); | ||||
|             output_filter_->connect(top_block_); | ||||
|     } | ||||
|     catch (std::exception& e) | ||||
| @@ -207,39 +198,37 @@ void GNSSFlowgraph::connect() | ||||
|     DLOG(INFO) << "blocks connected internally"; | ||||
|  | ||||
|     // Signal Source (i) >  Signal conditioner (i) > | ||||
|     for (int i = 0; i < sources_count_; i++) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                     //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(sig_source_.at(i)->implementation().compare("Raw_Array_Signal_Source") == 0) | ||||
|                         { | ||||
|                             //Multichannel Array | ||||
|                             std::cout << "ARRAY MODE" << std::endl; | ||||
|                             for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) | ||||
|                                 { | ||||
|                                     std::cout << "connecting ch "<< j << std::endl; | ||||
|                                     top_block_->connect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j); | ||||
|                                 } | ||||
|                         } | ||||
|                     else | ||||
|                         { | ||||
|                             //single channel | ||||
|                             top_block_->connect(sig_source_.at(i)->get_right_block(), 0, sig_conditioner_.at(i)->get_left_block(), 0); | ||||
|                         } | ||||
|  | ||||
| 	for (int i = 0; i < sources_count_; i++) | ||||
| 	{ | ||||
|  | ||||
| 			try | ||||
| 			{ | ||||
| 					//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(sig_source_.at(i)->implementation().compare("Raw_Array_Signal_Source") == 0) | ||||
| 						{ | ||||
| 							//Multichannel Array | ||||
| 							std::cout << "ARRAY MODE" << std::endl; | ||||
| 							for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) | ||||
| 								{ | ||||
| 									std::cout << "connecting ch "<< j << std::endl; | ||||
| 									top_block_->connect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j); | ||||
| 								} | ||||
| 						} | ||||
| 					else | ||||
| 						{ | ||||
| 							//single channel | ||||
| 							top_block_->connect(sig_source_.at(i)->get_right_block(), 0, sig_conditioner_.at(i)->get_left_block(), 0); | ||||
| 						} | ||||
|  | ||||
| 			} | ||||
| 			catch (std::exception& e) | ||||
| 			{ | ||||
| 					LOG(WARNING) << "Can't connect signal source " << i << " to signal conditioner " << i; | ||||
| 					LOG(ERROR) << e.what(); | ||||
| 					top_block_->disconnect_all(); | ||||
| 					return; | ||||
| 			} | ||||
|     } | ||||
|             } | ||||
|             catch (std::exception& e) | ||||
|             { | ||||
|                     LOG(WARNING) << "Can't connect signal source " << i << " to signal conditioner " << i; | ||||
|                     LOG(ERROR) << e.what(); | ||||
|                     top_block_->disconnect_all(); | ||||
|                     return; | ||||
|             } | ||||
|         } | ||||
|     DLOG(INFO) << "Signal source connected to signal conditioner"; | ||||
|  | ||||
|     // Signal conditioner (selected_signal_source) >> channels (i) (dependent of their associated SignalSource_ID) | ||||
| @@ -247,21 +236,21 @@ void GNSSFlowgraph::connect() | ||||
|     for (unsigned int i = 0; i < channels_count_; i++) | ||||
|         { | ||||
|  | ||||
|             selected_signal_source = configuration_->property("Channel" + boost::lexical_cast<std::string>(i) +".SignalSource_ID", 0); | ||||
| 			try | ||||
| 			{ | ||||
| 			top_block_->connect(sig_conditioner_.at(selected_signal_source)->get_right_block(), 0, | ||||
| 					channels_.at(i)->get_left_block(), 0); | ||||
|             selected_signal_source = configuration_->property("Channel" + boost::lexical_cast<std::string>(i) + ".SignalSource_ID", 0); | ||||
|             try | ||||
|             { | ||||
|                     top_block_->connect(sig_conditioner_.at(selected_signal_source)->get_right_block(), 0, | ||||
|                             channels_.at(i)->get_left_block(), 0); | ||||
|             } | ||||
|             catch (std::exception& e) | ||||
|             { | ||||
|                     LOG(WARNING) << "Can't connect signal conditioner "<<selected_signal_source<<" to channel " << i; | ||||
|                     LOG(WARNING) << "Can't connect signal conditioner " << selected_signal_source << " to channel " << i; | ||||
|                     LOG(ERROR) << e.what(); | ||||
|                     top_block_->disconnect_all(); | ||||
|                     return; | ||||
|             } | ||||
|  | ||||
|             DLOG(INFO) << "signal conditioner "<<selected_signal_source<<" connected to channel " << i; | ||||
|             DLOG(INFO) << "signal conditioner " << selected_signal_source << " connected to channel " << i; | ||||
|  | ||||
|             // Signal Source > Signal conditioner >> Channels >> Observables | ||||
|             try | ||||
| @@ -279,7 +268,7 @@ void GNSSFlowgraph::connect() | ||||
|  | ||||
|             //discriminate between systems | ||||
|             //TODO: add a specific string member to the channel template, and not re-use the implementation field! | ||||
|             while (channels_.at(i)->implementation()!= available_GNSS_signals_.front().get_satellite().get_system()) | ||||
|             while (channels_.at(i)->implementation() != available_GNSS_signals_.front().get_satellite().get_system()) | ||||
|                 { | ||||
|                     available_GNSS_signals_.push_back(available_GNSS_signals_.front()); | ||||
|                     available_GNSS_signals_.pop_front(); | ||||
| @@ -300,8 +289,8 @@ void GNSSFlowgraph::connect() | ||||
|                     LOG(INFO) << "Channel " << i | ||||
|                               << " connected to observables in standby mode"; | ||||
|                 } | ||||
|  | ||||
|         } | ||||
|  | ||||
|     /* | ||||
|      * Connect the observables output of each channel to the PVT block | ||||
|      */ | ||||
| @@ -461,19 +450,21 @@ void GNSSFlowgraph::init() | ||||
|     // 1. read the number of RF front-ends available (one file_source per RF front-end) | ||||
|     sources_count_ = configuration_->property("Receiver.sources_count", 1); | ||||
|  | ||||
|     if (sources_count_>1) | ||||
|     { | ||||
| 		for (int i = 0; i < sources_count_; i++) | ||||
| 			{ | ||||
| 			std::cout<<"creating source "<<i<<std::endl; | ||||
| 				sig_source_.push_back(block_factory_->GetSignalSource(configuration_, queue_,i)); | ||||
| 				sig_conditioner_.push_back(block_factory_->GetSignalConditioner(configuration_, queue_, i)); | ||||
| 			} | ||||
|     }else{ | ||||
|     	//backwards compatibility for old config files | ||||
| 		sig_source_.push_back(block_factory_->GetSignalSource(configuration_, queue_,-1)); | ||||
| 		sig_conditioner_.push_back(block_factory_->GetSignalConditioner(configuration_, queue_, -1)); | ||||
| 	} | ||||
|     if (sources_count_ > 1) | ||||
|         { | ||||
|             for (int i = 0; i < sources_count_; i++) | ||||
|                 { | ||||
|                     std::cout << "Creating signal source " << i << std::endl; | ||||
|                     sig_source_.push_back(block_factory_->GetSignalSource(configuration_, queue_, i)); | ||||
|                     sig_conditioner_.push_back(block_factory_->GetSignalConditioner(configuration_, queue_, i)); | ||||
|                 } | ||||
|         } | ||||
|     else | ||||
|         { | ||||
|             //backwards compatibility for old config files | ||||
|             sig_source_.push_back(block_factory_->GetSignalSource(configuration_, queue_, -1)); | ||||
|             sig_conditioner_.push_back(block_factory_->GetSignalConditioner(configuration_, queue_, -1)); | ||||
|         } | ||||
|  | ||||
|     observables_ = block_factory_->GetObservables(configuration_, queue_); | ||||
|     pvt_ = block_factory_->GetPVT(configuration_, queue_); | ||||
| @@ -484,7 +475,7 @@ void GNSSFlowgraph::init() | ||||
|     channels_count_ = channels->size(); | ||||
|     for (unsigned int i = 0; i < channels_count_; i++) | ||||
|         { | ||||
|         	std::shared_ptr<GNSSBlockInterface> chan_ = std::move(channels->at(i)); | ||||
|             std::shared_ptr<GNSSBlockInterface> chan_ = std::move(channels->at(i)); | ||||
|             channels_.push_back(std::dynamic_pointer_cast<ChannelInterface>(chan_)); | ||||
|         } | ||||
|  | ||||
| @@ -498,6 +489,7 @@ void GNSSFlowgraph::init() | ||||
|     DLOG(INFO) << "Blocks instantiated. " << channels_count_ << " channels."; | ||||
| } | ||||
|  | ||||
|  | ||||
| void GNSSFlowgraph::set_signals_list() | ||||
| { | ||||
|     /* | ||||
| @@ -569,8 +561,8 @@ void GNSSFlowgraph::set_signals_list() | ||||
|                     available_gnss_prn_iter != available_galileo_prn.end(); | ||||
|                     available_gnss_prn_iter++) | ||||
|                 { | ||||
| //                    available_GNSS_signals_.push_back(Gnss_Signal(Gnss_Satellite(std::string("Galileo"), | ||||
| //                            *available_gnss_prn_iter), std::string("1B"))); | ||||
|                     //  available_GNSS_signals_.push_back(Gnss_Signal(Gnss_Satellite(std::string("Galileo"), | ||||
|                     //      *available_gnss_prn_iter), std::string("1B"))); | ||||
|                     available_GNSS_signals_.push_back(Gnss_Signal(Gnss_Satellite(std::string("Galileo"), | ||||
|                             *available_gnss_prn_iter), default_signal)); | ||||
|                 } | ||||
| @@ -611,17 +603,16 @@ void GNSSFlowgraph::set_signals_list() | ||||
|         } | ||||
|  | ||||
|  | ||||
| //    **** FOR DEBUGGING THE LIST OF GNSS SIGNALS **** | ||||
|  | ||||
| //    std::cout<<"default_system="<<default_system<<std::endl; | ||||
| //    std::cout<<"default_signal="<<default_signal<<std::endl; | ||||
| //        std::list<Gnss_Signal>::iterator available_gnss_list_iter; | ||||
| //        for (available_gnss_list_iter = available_GNSS_signals_.begin(); available_gnss_list_iter | ||||
| //        != available_GNSS_signals_.end(); available_gnss_list_iter++) | ||||
| //        { | ||||
| //          std::cout << *available_gnss_list_iter << std::endl; | ||||
| //        } | ||||
|     //    **** FOR DEBUGGING THE LIST OF GNSS SIGNALS **** | ||||
|  | ||||
|     //    std::cout<<"default_system="<<default_system<<std::endl; | ||||
|     //    std::cout<<"default_signal="<<default_signal<<std::endl; | ||||
|     //        std::list<Gnss_Signal>::iterator available_gnss_list_iter; | ||||
|     //        for (available_gnss_list_iter = available_GNSS_signals_.begin(); available_gnss_list_iter | ||||
|     //        != available_GNSS_signals_.end(); available_gnss_list_iter++) | ||||
|     //        { | ||||
|     //          std::cout << *available_gnss_list_iter << std::endl; | ||||
|     //        } | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -124,7 +124,6 @@ private: | ||||
|     std::string config_file_; | ||||
|     std::shared_ptr<ConfigurationInterface> configuration_; | ||||
|     std::shared_ptr<GNSSBlockFactory> block_factory_; | ||||
|     //std::shared_ptr<std::vector<std::shared_ptr<GNSSBlockInterface>>> blocks_ = std::make_shared<std::vector<std::shared_ptr<GNSSBlockInterface>>>(); | ||||
|  | ||||
|     std::vector<std::shared_ptr<GNSSBlockInterface>> sig_source_; | ||||
|     std::vector<std::shared_ptr<GNSSBlockInterface>> sig_conditioner_; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Carles Fernandez
					Carles Fernandez