mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-02-04 13:19:19 +00:00
code cleaning
git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@191 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
parent
0d6462e52a
commit
7081c4fe8d
@ -41,126 +41,142 @@
|
|||||||
using google::LogMessage;
|
using google::LogMessage;
|
||||||
|
|
||||||
FirFilter::FirFilter(ConfigurationInterface* configuration, std::string role,
|
FirFilter::FirFilter(ConfigurationInterface* configuration, std::string role,
|
||||||
unsigned int in_streams, unsigned int out_streams,
|
unsigned int in_streams, unsigned int out_streams,
|
||||||
gr_msg_queue_sptr queue) :
|
gr_msg_queue_sptr queue) :
|
||||||
config_(configuration), role_(role), in_streams_(in_streams), out_streams_(
|
config_(configuration), role_(role), in_streams_(in_streams),
|
||||||
out_streams), queue_(queue) {
|
out_streams_(out_streams), queue_(queue)
|
||||||
|
{
|
||||||
|
|
||||||
size_t item_size;
|
size_t item_size;
|
||||||
(*this).init();
|
(*this).init();
|
||||||
|
|
||||||
if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare(
|
if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare(
|
||||||
"gr_complex") == 0) && (output_item_type_.compare("gr_complex")
|
"gr_complex") == 0) && (output_item_type_.compare("gr_complex")
|
||||||
== 0)) {
|
== 0))
|
||||||
item_size = sizeof(gr_complex);
|
{
|
||||||
fir_filter_ccf_ = gr_make_fir_filter_ccf(1, taps_);
|
item_size = sizeof(gr_complex);
|
||||||
DLOG(INFO) << "input_filter(" << fir_filter_ccf_->unique_id() << ")";
|
fir_filter_ccf_ = gr_make_fir_filter_ccf(1, taps_);
|
||||||
|
DLOG(INFO) << "input_filter(" << fir_filter_ccf_->unique_id() << ")";
|
||||||
|
|
||||||
} else {
|
}
|
||||||
LOG_AT_LEVEL(ERROR) << taps_item_type_
|
else
|
||||||
<< " unknown input filter item type";
|
{
|
||||||
}
|
LOG_AT_LEVEL(ERROR) << taps_item_type_
|
||||||
if (dump_) {
|
<< " unknown input filter item type";
|
||||||
DLOG(INFO) << "Dumping output into file " << dump_filename_;
|
}
|
||||||
file_sink_ = gr_make_file_sink(item_size, dump_filename_.c_str());
|
if (dump_)
|
||||||
}
|
{
|
||||||
|
DLOG(INFO) << "Dumping output into file " << dump_filename_;
|
||||||
|
file_sink_ = gr_make_file_sink(item_size, dump_filename_.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FirFilter::~FirFilter() {
|
FirFilter::~FirFilter()
|
||||||
|
{}
|
||||||
|
|
||||||
|
void FirFilter::connect(gr_top_block_sptr top_block)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (dump_)
|
||||||
|
{
|
||||||
|
top_block->connect(fir_filter_ccf_, 0, file_sink_, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DLOG(INFO) << "Nothing to connect internally";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FirFilter::connect(gr_top_block_sptr top_block) {
|
void FirFilter::disconnect(gr_top_block_sptr top_block)
|
||||||
|
{
|
||||||
|
|
||||||
if (dump_) {
|
if (dump_)
|
||||||
top_block->connect(fir_filter_ccf_, 0, file_sink_, 0);
|
{
|
||||||
} else {
|
top_block->connect(fir_filter_ccf_, 0, file_sink_, 0);
|
||||||
DLOG(INFO) << "Nothing to connect internally";
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FirFilter::disconnect(gr_top_block_sptr top_block) {
|
|
||||||
|
|
||||||
if (dump_) {
|
|
||||||
top_block->connect(fir_filter_ccf_, 0, file_sink_, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gr_basic_block_sptr FirFilter::get_left_block() {
|
gr_basic_block_sptr FirFilter::get_left_block()
|
||||||
return fir_filter_ccf_;
|
{
|
||||||
|
return fir_filter_ccf_;
|
||||||
}
|
}
|
||||||
|
|
||||||
gr_basic_block_sptr FirFilter::get_right_block() {
|
gr_basic_block_sptr FirFilter::get_right_block()
|
||||||
return fir_filter_ccf_;
|
{
|
||||||
|
return fir_filter_ccf_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FirFilter::init() {
|
void FirFilter::init()
|
||||||
std::string default_input_item_type = "gr_complex";
|
{
|
||||||
std::string default_output_item_type = "gr_complex";
|
std::string default_input_item_type = "gr_complex";
|
||||||
std::string default_taps_item_type = "float";
|
std::string default_output_item_type = "gr_complex";
|
||||||
std::string default_dump_filename = "../data/input_filter.dat";
|
std::string default_taps_item_type = "float";
|
||||||
int default_number_of_taps = 6;
|
std::string default_dump_filename = "../data/input_filter.dat";
|
||||||
unsigned int default_number_of_bands = 2;
|
int default_number_of_taps = 6;
|
||||||
std::vector<double> default_bands = { 0.0, 0.4, 0.6, 1.0 };
|
unsigned int default_number_of_bands = 2;
|
||||||
std::vector<double> default_ampl = { 1.0, 1.0, 0.0, 0.0 };
|
std::vector<double> default_bands = { 0.0, 0.4, 0.6, 1.0 };
|
||||||
std::vector<double> default_error_w = { 1.0, 1.0 };
|
std::vector<double> default_ampl = { 1.0, 1.0, 0.0, 0.0 };
|
||||||
std::string default_filter_type = "bandpass";
|
std::vector<double> default_error_w = { 1.0, 1.0 };
|
||||||
int default_grid_density = 16;
|
std::string default_filter_type = "bandpass";
|
||||||
|
int default_grid_density = 16;
|
||||||
|
|
||||||
DLOG(INFO) << "role " << role_;
|
DLOG(INFO) << "role " << role_;
|
||||||
|
|
||||||
input_item_type_ = config_->property(role_ + ".input_item_type",
|
input_item_type_ = config_->property(role_ + ".input_item_type",
|
||||||
default_input_item_type);
|
default_input_item_type);
|
||||||
output_item_type_ = config_->property(role_ + ".output_item_type",
|
output_item_type_ = config_->property(role_ + ".output_item_type",
|
||||||
default_output_item_type);
|
default_output_item_type);
|
||||||
taps_item_type_ = config_->property(role_ + ".taps_item_type",
|
taps_item_type_ = config_->property(role_ + ".taps_item_type",
|
||||||
default_taps_item_type);
|
default_taps_item_type);
|
||||||
|
|
||||||
dump_ = config_->property(role_ + ".dump", false);
|
dump_ = config_->property(role_ + ".dump", false);
|
||||||
dump_filename_ = config_->property(role_ + ".dump_filename",
|
dump_filename_ = config_->property(role_ + ".dump_filename",
|
||||||
default_dump_filename);
|
default_dump_filename);
|
||||||
int number_of_taps = config_->property(role_ + ".number_of_taps",
|
int number_of_taps = config_->property(role_ + ".number_of_taps",
|
||||||
default_number_of_taps);
|
default_number_of_taps);
|
||||||
unsigned int number_of_bands = config_->property(role_ + ".number_of_bands",
|
unsigned int number_of_bands = config_->property(role_ + ".number_of_bands",
|
||||||
default_number_of_bands);
|
default_number_of_bands);
|
||||||
|
|
||||||
std::vector<double> bands;
|
std::vector<double> bands;
|
||||||
std::vector<double> ampl;
|
std::vector<double> ampl;
|
||||||
std::vector<double> error_w;
|
std::vector<double> error_w;
|
||||||
std::string option;
|
std::string option;
|
||||||
double option_value;
|
double option_value;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < number_of_bands; i++) {
|
for (unsigned int i = 0; i < number_of_bands; i++)
|
||||||
|
{
|
||||||
|
|
||||||
option = ".band" + boost::lexical_cast<std::string>(i + 1) + "_begin";
|
option = ".band" + boost::lexical_cast<std::string>(i + 1) + "_begin";
|
||||||
option_value = config_->property(role_ + option, default_bands[i]);
|
option_value = config_->property(role_ + option, default_bands[i]);
|
||||||
bands.push_back(option_value);
|
bands.push_back(option_value);
|
||||||
|
|
||||||
option = ".band" + boost::lexical_cast<std::string>(i + 1) + "_end";
|
option = ".band" + boost::lexical_cast<std::string>(i + 1) + "_end";
|
||||||
option_value = config_->property(role_ + option, default_bands[i]);
|
option_value = config_->property(role_ + option, default_bands[i]);
|
||||||
bands.push_back(option_value);
|
bands.push_back(option_value);
|
||||||
|
|
||||||
option = ".ampl" + boost::lexical_cast<std::string>(i + 1) + "_begin";
|
option = ".ampl" + boost::lexical_cast<std::string>(i + 1) + "_begin";
|
||||||
option_value = config_->property(role_ + option, default_bands[i]);
|
option_value = config_->property(role_ + option, default_bands[i]);
|
||||||
ampl.push_back(option_value);
|
ampl.push_back(option_value);
|
||||||
|
|
||||||
option = ".ampl" + boost::lexical_cast<std::string>(i + 1) + "_end";
|
option = ".ampl" + boost::lexical_cast<std::string>(i + 1) + "_end";
|
||||||
option_value = config_->property(role_ + option, default_bands[i]);
|
option_value = config_->property(role_ + option, default_bands[i]);
|
||||||
ampl.push_back(option_value);
|
ampl.push_back(option_value);
|
||||||
|
|
||||||
option = ".band" + boost::lexical_cast<std::string>(i + 1) + "_error";
|
option = ".band" + boost::lexical_cast<std::string>(i + 1) + "_error";
|
||||||
option_value = config_->property(role_ + option, default_bands[i]);
|
option_value = config_->property(role_ + option, default_bands[i]);
|
||||||
error_w.push_back(option_value);
|
error_w.push_back(option_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string filter_type = config_->property(role_ + ".filter_type", default_filter_type);
|
std::string filter_type = config_->property(role_ + ".filter_type", default_filter_type);
|
||||||
int grid_density = config_->property(role_ + ".grid_density", default_grid_density);
|
int grid_density = config_->property(role_ + ".grid_density", default_grid_density);
|
||||||
|
|
||||||
std::vector<double> taps_d = gr_remez(number_of_taps - 1, bands, ampl,
|
std::vector<double> taps_d = gr_remez(number_of_taps - 1, bands, ampl,
|
||||||
error_w, filter_type, grid_density);
|
error_w, filter_type, grid_density);
|
||||||
taps_.reserve(taps_d.size());
|
taps_.reserve(taps_d.size());
|
||||||
for (std::vector<double>::iterator it = taps_d.begin(); it != taps_d.end(); it++) {
|
for (std::vector<double>::iterator it = taps_d.begin(); it != taps_d.end(); it++)
|
||||||
taps_.push_back(float(*it));
|
{
|
||||||
}
|
taps_.push_back(float(*it));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
* -------------------------------------------------------------------------
|
* -------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FIR_FILTER_H_
|
#ifndef GNSS_SDR_FIR_FILTER_H_
|
||||||
#define FIR_FILTER_H_
|
#define GNSS_SDR_FIR_FILTER_H_
|
||||||
|
|
||||||
#include "gnss_synchro.h"
|
#include "gnss_synchro.h"
|
||||||
#include "gnss_block_interface.h"
|
#include "gnss_block_interface.h"
|
||||||
@ -50,7 +50,7 @@ class FirFilter: public GNSSBlockInterface
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FirFilter(ConfigurationInterface* configuration,
|
FirFilter(ConfigurationInterface* configuration,
|
||||||
std::string role, unsigned int in_streams,
|
std::string role, unsigned int in_streams,
|
||||||
unsigned int out_streams, gr_msg_queue_sptr queue);
|
unsigned int out_streams, gr_msg_queue_sptr queue);
|
||||||
|
|
||||||
@ -75,28 +75,22 @@ public:
|
|||||||
gr_basic_block_sptr get_right_block();
|
gr_basic_block_sptr get_right_block();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
gr_fir_filter_ccf_sptr fir_filter_ccf_;
|
gr_fir_filter_ccf_sptr fir_filter_ccf_;
|
||||||
ConfigurationInterface* config_;
|
ConfigurationInterface* config_;
|
||||||
bool dump_;
|
bool dump_;
|
||||||
std::string dump_filename_;
|
std::string dump_filename_;
|
||||||
|
|
||||||
std::string input_item_type_;
|
std::string input_item_type_;
|
||||||
std::string output_item_type_;
|
std::string output_item_type_;
|
||||||
std::string taps_item_type_;
|
std::string taps_item_type_;
|
||||||
std::vector <float> taps_;
|
std::vector <float> taps_;
|
||||||
|
|
||||||
std::string role_;
|
std::string role_;
|
||||||
unsigned int in_streams_;
|
unsigned int in_streams_;
|
||||||
unsigned int out_streams_;
|
unsigned int out_streams_;
|
||||||
gr_msg_queue_sptr queue_;
|
gr_msg_queue_sptr queue_;
|
||||||
gr_block_sptr file_sink_;
|
gr_block_sptr file_sink_;
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* GNSS_SDR_GPS_L1_CA_PCPS_ACQUISITION_H_ */
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user