1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-08 16:30:35 +00:00

Code cleaning

git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@272 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
Carles Fernandez 2012-11-01 16:47:10 +00:00
parent 268b4ab566
commit 2c700a49a2

View File

@ -50,7 +50,6 @@ RtlsdrSignalSource::RtlsdrSignalSource(ConfigurationInterface* configuration,
role_(role), in_stream_(in_stream), out_stream_(out_stream), role_(role), in_stream_(in_stream), out_stream_(out_stream),
queue_(queue) queue_(queue)
{ {
// DUMP PARAMETERS // DUMP PARAMETERS
std::string empty = ""; std::string empty = "";
std::string default_dump_file = "./data/signal_source.dat"; std::string default_dump_file = "./data/signal_source.dat";
@ -61,14 +60,12 @@ RtlsdrSignalSource::RtlsdrSignalSource(ConfigurationInterface* configuration,
default_dump_file); default_dump_file);
// RTLSDR Driver parameters // RTLSDR Driver parameters
AGC_enabled_=configuration->property(role + ".AGC_enabled",true); AGC_enabled_ = configuration->property(role + ".AGC_enabled",true);
freq_ = configuration->property(role + ".freq", GPS_L1_FREQ_HZ); freq_ = configuration->property(role + ".freq", GPS_L1_FREQ_HZ);
gain_ = configuration->property(role + ".gain", (double)50.0); gain_ = configuration->property(role + ".gain", (double)50.0);
sample_rate_ = configuration->property(role + ".sampling_frequency", (double)2.0e6); sample_rate_ = configuration->property(role + ".sampling_frequency", (double)2.0e6);
item_type_ = configuration->property(role + ".item_type", default_item_type);
item_type_ = configuration->property(role + ".item_type",
default_item_type);
if (item_type_.compare("short") == 0) if (item_type_.compare("short") == 0)
{ {
item_size_ = sizeof(short); item_size_ = sizeof(short);
@ -82,34 +79,35 @@ RtlsdrSignalSource::RtlsdrSignalSource(ConfigurationInterface* configuration,
// 2 set sampling rate // 2 set sampling rate
rtlsdr_source_->set_sample_rate(sample_rate_); rtlsdr_source_->set_sample_rate(sample_rate_);
std::cout << boost::format("Actual RX Rate: %f [SPS]...") % (rtlsdr_source_->get_sample_rate()) << std::endl ; std::cout << boost::format("Actual RX Rate: %f [SPS]...") % (rtlsdr_source_->get_sample_rate()) << std::endl ;
DLOG(INFO) << boost::format("Actual RX Rate: %f [SPS]...") % (rtlsdr_source_->get_sample_rate()) << std::endl; LOG(INFO) << boost::format("Actual RX Rate: %f [SPS]...") % (rtlsdr_source_->get_sample_rate());
// 3. set rx frequency // 3. set rx frequency
rtlsdr_source_->set_center_freq(freq_); rtlsdr_source_->set_center_freq(freq_);
std::cout << boost::format("Actual RX Freq: %f [Hz]...") % (rtlsdr_source_->get_center_freq()) << std::endl ; std::cout << boost::format("Actual RX Freq: %f [Hz]...") % (rtlsdr_source_->get_center_freq()) << std::endl ;
DLOG(INFO) << boost::format("Actual RX Freq: %f [Hz]...") % (rtlsdr_source_->get_center_freq()) << std::endl ; LOG(INFO) << boost::format("Actual RX Freq: %f [Hz]...") % (rtlsdr_source_->get_center_freq());
// TODO: Asign the remanent IF from the PLL tune error // TODO: Assign the remnant IF from the PLL tune error
std::cout << boost::format("PLL Frequency tune error %f [Hz]...") % (rtlsdr_source_->get_center_freq()-freq_) ; std::cout << boost::format("PLL Frequency tune error %f [Hz]...") % (rtlsdr_source_->get_center_freq() - freq_) ;
DLOG(INFO) << boost::format("PLL Frequency tune error %f [Hz]...") % (rtlsdr_source_->get_center_freq()-freq_) ; LOG(INFO) << boost::format("PLL Frequency tune error %f [Hz]...") % (rtlsdr_source_->get_center_freq() - freq_) ;
// 4. set rx gain // 4. set rx gain
if (this->AGC_enabled_==true) if (this->AGC_enabled_ == true)
{ {
rtlsdr_source_->set_gain_mode(true); rtlsdr_source_->set_gain_mode(true);
std::cout << "AGC enabled"<< std::endl; std::cout << "AGC enabled" << std::endl;
DLOG(INFO)<< "AGC enabled"<< std::endl; LOG(INFO) << "AGC enabled";
}else{ }
else
{
rtlsdr_source_->set_gain_mode(false); rtlsdr_source_->set_gain_mode(false);
rtlsdr_source_->set_gain(gain_); rtlsdr_source_->set_gain(gain_);
std::cout << boost::format("Actual RX Gain: %f dB...") % rtlsdr_source_->get_gain() << std::endl; std::cout << boost::format("Actual RX Gain: %f dB...") % rtlsdr_source_->get_gain() << std::endl;
DLOG(INFO) << boost::format("Actual RX Gain: %f dB...") % rtlsdr_source_->get_gain() << std::endl; LOG(INFO) << boost::format("Actual RX Gain: %f dB...") % rtlsdr_source_->get_gain();
} }
} }
else else
{ {
LOG_AT_LEVEL(WARNING) << item_type_ LOG_AT_LEVEL(WARNING) << item_type_ << " unrecognized item type. Using short.";
<< " unrecognized item type. Using short.";
item_size_ = sizeof(short); item_size_ = sizeof(short);
} }
@ -126,21 +124,21 @@ RtlsdrSignalSource::RtlsdrSignalSource(ConfigurationInterface* configuration,
file_sink_ = gr_make_file_sink(item_size_, dump_filename_.c_str()); file_sink_ = gr_make_file_sink(item_size_, dump_filename_.c_str());
DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")"; DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")";
} }
} }
RtlsdrSignalSource::~RtlsdrSignalSource() RtlsdrSignalSource::~RtlsdrSignalSource()
{ {}
}
void RtlsdrSignalSource::connect(gr_top_block_sptr top_block) void RtlsdrSignalSource::connect(gr_top_block_sptr top_block)
{ {
if (samples_ != 0) if (samples_ != 0)
{ {
top_block->connect(rtlsdr_source_, 0, valve_, 0); top_block->connect(rtlsdr_source_, 0, valve_, 0);
DLOG(INFO) << "connected rtlsdr source to valve"; DLOG(INFO) << "connected rtlsdr source to valve";
if (dump_) if (dump_)
{ {
top_block->connect(valve_, 0, file_sink_, 0); top_block->connect(valve_, 0, file_sink_, 0);
@ -157,13 +155,13 @@ void RtlsdrSignalSource::connect(gr_top_block_sptr top_block)
} }
} }
void RtlsdrSignalSource::disconnect(gr_top_block_sptr top_block) void RtlsdrSignalSource::disconnect(gr_top_block_sptr top_block)
{ {
if (samples_ != 0) if (samples_ != 0)
{ {
top_block->disconnect(rtlsdr_source_, 0, valve_, 0); top_block->disconnect(rtlsdr_source_, 0, valve_, 0);
if (dump_) if (dump_)
{ {
top_block->disconnect(valve_, 0, file_sink_, 0); top_block->disconnect(valve_, 0, file_sink_, 0);
@ -178,12 +176,16 @@ void RtlsdrSignalSource::disconnect(gr_top_block_sptr top_block)
} }
} }
gr_basic_block_sptr RtlsdrSignalSource::get_left_block() gr_basic_block_sptr RtlsdrSignalSource::get_left_block()
{ {
LOG_AT_LEVEL(WARNING) << "Trying to get signal source left block."; LOG_AT_LEVEL(WARNING) << "Trying to get signal source left block.";
return gr_basic_block_sptr(); return gr_basic_block_sptr();
} }
gr_basic_block_sptr RtlsdrSignalSource::get_right_block() gr_basic_block_sptr RtlsdrSignalSource::get_right_block()
{ {
if (samples_ != 0) if (samples_ != 0)