diff --git a/src/algorithms/data_type_adapter/adapters/CMakeLists.txt b/src/algorithms/data_type_adapter/adapters/CMakeLists.txt index a88ffd3e9..d18c83b04 100644 --- a/src/algorithms/data_type_adapter/adapters/CMakeLists.txt +++ b/src/algorithms/data_type_adapter/adapters/CMakeLists.txt @@ -31,6 +31,7 @@ include_directories( ${CMAKE_SOURCE_DIR}/src/core/system_parameters ${CMAKE_SOURCE_DIR}/src/core/interfaces ${CMAKE_SOURCE_DIR}/src/algorithms/data_type_adapter/gnuradio_blocks + ${CMAKE_SOURCE_DIR}/src/algorithms/libs ${GLOG_INCLUDE_DIRS} ${GFlags_INCLUDE_DIRS} ${GNURADIO_RUNTIME_INCLUDE_DIRS} diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.cc b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.cc index 8dc47c8ad..e91455a23 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.cc +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.cc @@ -51,6 +51,7 @@ IbyteToCbyte::IbyteToCbyte(ConfigurationInterface* configuration, std::string ro dump_ = config_->property(role_ + ".dump", false); dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename); + inverted_spectrum = configuration->property(role + ".inverted_spectrum", false); size_t item_size = sizeof(lv_8sc_t); @@ -63,6 +64,10 @@ IbyteToCbyte::IbyteToCbyte(ConfigurationInterface* configuration, std::string ro DLOG(INFO) << "Dumping output into file " << dump_filename_; file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str()); } + if(inverted_spectrum) + { + conjugate_ic_ = make_conjugate_ic(); + } } @@ -74,7 +79,26 @@ void IbyteToCbyte::connect(gr::top_block_sptr top_block) { if (dump_) { - top_block->connect(ibyte_to_cbyte_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->connect(ibyte_to_cbyte_, 0, conjugate_ic_, 0); + top_block->connect(conjugate_ic_, 0, file_sink_, 0); + } + else + { + top_block->connect(ibyte_to_cbyte_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->connect(ibyte_to_cbyte_, 0, conjugate_ic_, 0); + } + else + { + DLOG(INFO) << "Nothing to connect internally"; + } } } @@ -83,21 +107,40 @@ void IbyteToCbyte::disconnect(gr::top_block_sptr top_block) { if (dump_) { - top_block->disconnect(ibyte_to_cbyte_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->disconnect(ibyte_to_cbyte_, 0, conjugate_ic_, 0); + top_block->disconnect(conjugate_ic_, 0, file_sink_, 0); + } + else + { + top_block->disconnect(ibyte_to_cbyte_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->disconnect(ibyte_to_cbyte_, 0, conjugate_ic_, 0); + } } } - gr::basic_block_sptr IbyteToCbyte::get_left_block() { return ibyte_to_cbyte_; } - gr::basic_block_sptr IbyteToCbyte::get_right_block() { - return ibyte_to_cbyte_; + if(inverted_spectrum) + { + return conjugate_ic_; + } + else + { + return ibyte_to_cbyte_; + } } - diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h index 2aa0d1197..c40d85286 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h @@ -34,6 +34,7 @@ #include #include +#include "conjugate_ic.h" #include "gnss_block_interface.h" #include "interleaved_byte_to_complex_byte.h" @@ -85,6 +86,8 @@ private: unsigned int in_streams_; unsigned int out_streams_; gr::blocks::file_sink::sptr file_sink_; + conjugate_ic_sptr conjugate_ic_; + bool inverted_spectrum; }; #endif diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.cc b/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.cc index 6119ebd9f..83b6fd6c5 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.cc +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.cc @@ -49,6 +49,7 @@ IbyteToComplex::IbyteToComplex(ConfigurationInterface* configuration, std::strin dump_ = config_->property(role_ + ".dump", false); dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename); + inverted_spectrum = configuration->property(role + ".inverted_spectrum", false); size_t item_size = sizeof(gr_complex); @@ -56,6 +57,10 @@ IbyteToComplex::IbyteToComplex(ConfigurationInterface* configuration, std::strin DLOG(INFO) << "data_type_adapter_(" << gr_interleaved_char_to_complex_->unique_id() << ")"; + if (inverted_spectrum) + { + conjugate_cc_ = make_conjugate_cc(); + } if (dump_) { DLOG(INFO) << "Dumping output into file " << dump_filename_; @@ -72,7 +77,26 @@ void IbyteToComplex::connect(gr::top_block_sptr top_block) { if (dump_) { - top_block->connect(gr_interleaved_char_to_complex_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->connect(gr_interleaved_char_to_complex_, 0, conjugate_cc_, 0); + top_block->connect(conjugate_cc_, 0, file_sink_, 0); + } + else + { + top_block->connect(gr_interleaved_char_to_complex_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->connect(gr_interleaved_char_to_complex_, 0, conjugate_cc_, 0); + } + else + { + DLOG(INFO) << "Nothing to connect internally"; + } } } @@ -81,22 +105,40 @@ void IbyteToComplex::disconnect(gr::top_block_sptr top_block) { if (dump_) { - top_block->disconnect(gr_interleaved_char_to_complex_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->disconnect(gr_interleaved_char_to_complex_, 0, conjugate_cc_, 0); + top_block->disconnect(conjugate_cc_, 0, file_sink_, 0); + } + else + { + top_block->disconnect(gr_interleaved_char_to_complex_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->disconnect(gr_interleaved_char_to_complex_, 0, conjugate_cc_, 0); + } } } - gr::basic_block_sptr IbyteToComplex::get_left_block() { return gr_interleaved_char_to_complex_; } - gr::basic_block_sptr IbyteToComplex::get_right_block() { - return gr_interleaved_char_to_complex_; + if(inverted_spectrum) + { + return conjugate_cc_; + } + else + { + return gr_interleaved_char_to_complex_; + } } - - diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.h b/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.h index 50b38f37e..3c379d7ba 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.h +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.h @@ -34,8 +34,9 @@ #include #include #include -#include "gnss_synchro.h" +#include "conjugate_cc.h" #include "gnss_block_interface.h" +#include "gnss_synchro.h" class ConfigurationInterface; @@ -85,6 +86,8 @@ private: unsigned int in_streams_; unsigned int out_streams_; gr::blocks::file_sink::sptr file_sink_; + conjugate_cc_sptr conjugate_cc_; + bool inverted_spectrum; }; #endif diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.cc b/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.cc index 206f824cc..59ac82042 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.cc +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.cc @@ -51,6 +51,7 @@ IbyteToCshort::IbyteToCshort(ConfigurationInterface* configuration, std::string dump_ = config_->property(role_ + ".dump", false); dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename); + inverted_spectrum = configuration->property(role + ".inverted_spectrum", false); size_t item_size = sizeof(lv_16sc_t); @@ -63,6 +64,10 @@ IbyteToCshort::IbyteToCshort(ConfigurationInterface* configuration, std::string DLOG(INFO) << "Dumping output into file " << dump_filename_; file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str()); } + if(inverted_spectrum) + { + conjugate_sc_ = make_conjugate_sc(); + } } @@ -74,7 +79,22 @@ void IbyteToCshort::connect(gr::top_block_sptr top_block) { if (dump_) { - top_block->connect(interleaved_byte_to_complex_short_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->connect(interleaved_byte_to_complex_short_, 0, conjugate_sc_, 0); + top_block->connect(conjugate_sc_, 0, file_sink_, 0); + } + else + { + top_block->connect(interleaved_byte_to_complex_short_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->connect(interleaved_byte_to_complex_short_, 0, conjugate_sc_, 0); + } } } @@ -83,22 +103,40 @@ void IbyteToCshort::disconnect(gr::top_block_sptr top_block) { if (dump_) { - top_block->disconnect(interleaved_byte_to_complex_short_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->disconnect(interleaved_byte_to_complex_short_, 0, conjugate_sc_, 0); + top_block->disconnect(conjugate_sc_, 0, file_sink_, 0); + } + else + { + top_block->disconnect(interleaved_byte_to_complex_short_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->disconnect(interleaved_byte_to_complex_short_, 0, conjugate_sc_, 0); + } } } - gr::basic_block_sptr IbyteToCshort::get_left_block() { return interleaved_byte_to_complex_short_; } - gr::basic_block_sptr IbyteToCshort::get_right_block() { - return interleaved_byte_to_complex_short_; + if(inverted_spectrum) + { + return conjugate_sc_; + } + else + { + return interleaved_byte_to_complex_short_; + } } - - diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.h b/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.h index 71829d6a3..2de7089ac 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.h +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.h @@ -34,6 +34,7 @@ #include #include #include "gnss_block_interface.h" +#include "conjugate_sc.h" #include "interleaved_byte_to_complex_short.h" @@ -85,6 +86,8 @@ private: unsigned int in_streams_; unsigned int out_streams_; gr::blocks::file_sink::sptr file_sink_; + conjugate_sc_sptr conjugate_sc_; + bool inverted_spectrum; }; #endif diff --git a/src/algorithms/data_type_adapter/adapters/ishort_to_complex.cc b/src/algorithms/data_type_adapter/adapters/ishort_to_complex.cc index e87dc1f59..cb9d3c6df 100644 --- a/src/algorithms/data_type_adapter/adapters/ishort_to_complex.cc +++ b/src/algorithms/data_type_adapter/adapters/ishort_to_complex.cc @@ -49,6 +49,7 @@ IshortToComplex::IshortToComplex(ConfigurationInterface* configuration, std::str dump_ = config_->property(role_ + ".dump", false); dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename); + inverted_spectrum = configuration->property(role + ".inverted_spectrum", false); size_t item_size = sizeof(gr_complex); @@ -56,6 +57,10 @@ IshortToComplex::IshortToComplex(ConfigurationInterface* configuration, std::str DLOG(INFO) << "data_type_adapter_(" << gr_interleaved_short_to_complex_->unique_id() << ")"; + if (inverted_spectrum) + { + conjugate_cc_ = make_conjugate_cc(); + } if (dump_) { DLOG(INFO) << "Dumping output into file " << dump_filename_; @@ -72,11 +77,26 @@ void IshortToComplex::connect(gr::top_block_sptr top_block) { if (dump_) { - top_block->connect(gr_interleaved_short_to_complex_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->connect(gr_interleaved_short_to_complex_, 0, conjugate_cc_, 0); + top_block->connect(conjugate_cc_, 0, file_sink_, 0); + } + else + { + top_block->connect(gr_interleaved_short_to_complex_, 0, file_sink_, 0); + } } else { - DLOG(INFO) << "Nothing to connect internally"; + if(inverted_spectrum) + { + top_block->connect(gr_interleaved_short_to_complex_, 0, conjugate_cc_, 0); + } + else + { + DLOG(INFO) << "Nothing to connect internally"; + } } } @@ -85,22 +105,40 @@ void IshortToComplex::disconnect(gr::top_block_sptr top_block) { if (dump_) { - top_block->disconnect(gr_interleaved_short_to_complex_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->disconnect(gr_interleaved_short_to_complex_, 0, conjugate_cc_, 0); + top_block->disconnect(conjugate_cc_, 0, file_sink_, 0); + } + else + { + top_block->disconnect(gr_interleaved_short_to_complex_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->disconnect(gr_interleaved_short_to_complex_, 0, conjugate_cc_, 0); + } } } - gr::basic_block_sptr IshortToComplex::get_left_block() { return gr_interleaved_short_to_complex_; } - gr::basic_block_sptr IshortToComplex::get_right_block() { - return gr_interleaved_short_to_complex_; + if(inverted_spectrum) + { + return conjugate_cc_; + } + else + { + return gr_interleaved_short_to_complex_; + } } - - diff --git a/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h b/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h index 79a2d7162..57cf7283e 100644 --- a/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h +++ b/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h @@ -34,6 +34,7 @@ #include #include #include +#include "conjugate_cc.h" #include "gnss_block_interface.h" @@ -84,6 +85,8 @@ private: unsigned int in_streams_; unsigned int out_streams_; gr::blocks::file_sink::sptr file_sink_; + conjugate_cc_sptr conjugate_cc_; + bool inverted_spectrum; }; #endif diff --git a/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.cc b/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.cc index 503341d08..96a87abe2 100644 --- a/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.cc +++ b/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.cc @@ -51,6 +51,7 @@ IshortToCshort::IshortToCshort(ConfigurationInterface* configuration, std::strin dump_ = config_->property(role_ + ".dump", false); dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename); + inverted_spectrum = configuration->property(role + ".inverted_spectrum", false); size_t item_size = sizeof(lv_16sc_t); @@ -63,6 +64,10 @@ IshortToCshort::IshortToCshort(ConfigurationInterface* configuration, std::strin DLOG(INFO) << "Dumping output into file " << dump_filename_; file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str()); } + if(inverted_spectrum) + { + conjugate_sc_ = make_conjugate_sc(); + } } @@ -74,11 +79,26 @@ void IshortToCshort::connect(gr::top_block_sptr top_block) { if (dump_) { - top_block->connect(interleaved_short_to_complex_short_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->connect(interleaved_short_to_complex_short_, 0, conjugate_sc_, 0); + top_block->connect(conjugate_sc_, 0, file_sink_, 0); + } + else + { + top_block->connect(interleaved_short_to_complex_short_, 0, file_sink_, 0); + } } else { - DLOG(INFO) << "Nothing to connect internally"; + if(inverted_spectrum) + { + top_block->connect(interleaved_short_to_complex_short_, 0, conjugate_sc_, 0); + } + else + { + DLOG(INFO) << "Nothing to connect internally"; + } } } @@ -87,22 +107,40 @@ void IshortToCshort::disconnect(gr::top_block_sptr top_block) { if (dump_) { - top_block->disconnect(interleaved_short_to_complex_short_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->disconnect(interleaved_short_to_complex_short_, 0, conjugate_sc_, 0); + top_block->disconnect(conjugate_sc_, 0, file_sink_, 0); + } + else + { + top_block->disconnect(interleaved_short_to_complex_short_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->disconnect(interleaved_short_to_complex_short_, 0, conjugate_sc_, 0); + } } } - gr::basic_block_sptr IshortToCshort::get_left_block() { return interleaved_short_to_complex_short_; } - gr::basic_block_sptr IshortToCshort::get_right_block() { - return interleaved_short_to_complex_short_; + if(inverted_spectrum) + { + return conjugate_sc_; + } + else + { + return interleaved_short_to_complex_short_; + } } - - diff --git a/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.h b/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.h index cb8080e40..685373a6a 100644 --- a/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.h +++ b/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.h @@ -33,6 +33,7 @@ #include #include +#include "conjugate_sc.h" #include "gnss_block_interface.h" #include "interleaved_short_to_complex_short.h" @@ -85,6 +86,8 @@ private: unsigned int in_streams_; unsigned int out_streams_; gr::blocks::file_sink::sptr file_sink_; + conjugate_sc_sptr conjugate_sc_; + bool inverted_spectrum; }; #endif diff --git a/src/algorithms/libs/CMakeLists.txt b/src/algorithms/libs/CMakeLists.txt index e7d8b60bd..cc085ae75 100644 --- a/src/algorithms/libs/CMakeLists.txt +++ b/src/algorithms/libs/CMakeLists.txt @@ -32,6 +32,9 @@ set(GNSS_SPLIBS_SOURCES cshort_to_float_x2.cc short_x2_to_cshort.cc complex_float_to_complex_byte.cc + conjugate_cc.cc + conjugate_sc.cc + conjugate_ic.cc ) diff --git a/src/algorithms/libs/conjugate_cc.cc b/src/algorithms/libs/conjugate_cc.cc new file mode 100644 index 000000000..60063473a --- /dev/null +++ b/src/algorithms/libs/conjugate_cc.cc @@ -0,0 +1,29 @@ +#include "conjugate_cc.h" +#include +#include + + +conjugate_cc_sptr make_conjugate_cc() +{ + return conjugate_cc_sptr(new conjugate_cc()); +} + + +conjugate_cc::conjugate_cc() : gr::sync_block("conjugate_cc", + gr::io_signature::make (1, 1, sizeof(gr_complex)), + gr::io_signature::make (1, 1, sizeof(gr_complex))) +{ + const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex); + set_alignment(std::max(1, alignment_multiple)); +} + + +int conjugate_cc::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const gr_complex *in = reinterpret_cast(input_items[0]); + gr_complex *out = reinterpret_cast(output_items[0]); + volk_32fc_conjugate_32fc(out, in, noutput_items); + return noutput_items; +} diff --git a/src/algorithms/libs/conjugate_cc.h b/src/algorithms/libs/conjugate_cc.h new file mode 100644 index 000000000..556f79c6d --- /dev/null +++ b/src/algorithms/libs/conjugate_cc.h @@ -0,0 +1,59 @@ +/*! + * \file conjugate_cc.h + * \brief Conjugate + * \author Carles Fernandez Prades, cfernandez(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_CONJUGATE_CC_H_ +#define GNSS_SDR_CONJUGATE_CC_H_ + +#include +#include + +class conjugate_cc; + +typedef boost::shared_ptr conjugate_cc_sptr; + +conjugate_cc_sptr make_conjugate_cc(); + +/*! + * \brief This class adapts a std::complex stream + * into two 32-bits (float) streams + */ +class conjugate_cc : public gr::sync_block +{ +private: + friend conjugate_cc_sptr make_conjugate_cc(); +public: + conjugate_cc(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif diff --git a/src/algorithms/libs/conjugate_ic.cc b/src/algorithms/libs/conjugate_ic.cc new file mode 100644 index 000000000..b1f85e39f --- /dev/null +++ b/src/algorithms/libs/conjugate_ic.cc @@ -0,0 +1,29 @@ +#include "conjugate_ic.h" +#include +#include + + +conjugate_ic_sptr make_conjugate_ic() +{ + return conjugate_ic_sptr(new conjugate_ic()); +} + + +conjugate_ic::conjugate_ic() : gr::sync_block("conjugate_ic", + gr::io_signature::make (1, 1, sizeof(lv_8sc_t)), + gr::io_signature::make (1, 1, sizeof(lv_8sc_t))) +{ + const int alignment_multiple = volk_gnsssdr_get_alignment() / sizeof(lv_8sc_t); + set_alignment(std::max(1, alignment_multiple)); +} + + +int conjugate_ic::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const lv_8sc_t *in = reinterpret_cast(input_items[0]); + lv_8sc_t *out = reinterpret_cast(output_items[0]); + volk_gnsssdr_8ic_conjugate_8ic(out, in, noutput_items); + return noutput_items; +} diff --git a/src/algorithms/libs/conjugate_ic.h b/src/algorithms/libs/conjugate_ic.h new file mode 100644 index 000000000..38eb21a35 --- /dev/null +++ b/src/algorithms/libs/conjugate_ic.h @@ -0,0 +1,59 @@ +/*! + * \file conjugate_ic.h + * \brief Adapts a std::complex stream into two float streams + * \author Carles Fernandez Prades, cfernandez(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_CONJUGATE_IC_H_ +#define GNSS_SDR_CONJUGATE_IC_H_ + +#include +#include + +class conjugate_ic; + +typedef boost::shared_ptr conjugate_ic_sptr; + +conjugate_ic_sptr make_conjugate_ic(); + +/*! + * \brief This class adapts a std::complex stream + * into two 32-bits (float) streams + */ +class conjugate_ic : public gr::sync_block +{ +private: + friend conjugate_ic_sptr make_conjugate_ic(); +public: + conjugate_ic(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif diff --git a/src/algorithms/libs/conjugate_sc.cc b/src/algorithms/libs/conjugate_sc.cc new file mode 100644 index 000000000..ac22d7723 --- /dev/null +++ b/src/algorithms/libs/conjugate_sc.cc @@ -0,0 +1,29 @@ +#include "conjugate_sc.h" +#include +#include + + +conjugate_sc_sptr make_conjugate_sc() +{ + return conjugate_sc_sptr(new conjugate_sc()); +} + + +conjugate_sc::conjugate_sc() : gr::sync_block("conjugate_sc", + gr::io_signature::make (1, 1, sizeof(lv_16sc_t)), + gr::io_signature::make (1, 1, sizeof(lv_16sc_t))) +{ + const int alignment_multiple = volk_gnsssdr_get_alignment() / sizeof(lv_16sc_t); + set_alignment(std::max(1, alignment_multiple)); +} + + +int conjugate_sc::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const lv_16sc_t *in = reinterpret_cast(input_items[0]); + lv_16sc_t *out = reinterpret_cast(output_items[0]); + volk_gnsssdr_16ic_conjugate_16ic(out, in, noutput_items); + return noutput_items; +} diff --git a/src/algorithms/libs/conjugate_sc.h b/src/algorithms/libs/conjugate_sc.h new file mode 100644 index 000000000..b26a66c79 --- /dev/null +++ b/src/algorithms/libs/conjugate_sc.h @@ -0,0 +1,59 @@ +/*! + * \file conjugate_sc.h + * \brief Adapts a std::complex stream into two float streams + * \author Carles Fernandez Prades, cfernandez(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_CONJUGATE_SC_H_ +#define GNSS_SDR_CONJUGATE_SC_H_ + +#include +#include + +class conjugate_sc; + +typedef boost::shared_ptr conjugate_sc_sptr; + +conjugate_sc_sptr make_conjugate_sc(); + +/*! + * \brief This class adapts a std::complex stream + * into two 32-bits (float) streams + */ +class conjugate_sc : public gr::sync_block +{ +private: + friend conjugate_sc_sptr make_conjugate_sc(); +public: + conjugate_sc(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif diff --git a/src/algorithms/libs/pass_through.cc b/src/algorithms/libs/pass_through.cc index 94394866e..87f2b1be6 100644 --- a/src/algorithms/libs/pass_through.cc +++ b/src/algorithms/libs/pass_through.cc @@ -57,7 +57,7 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro } item_type_ = configuration->property(role + ".item_type", input_type); - vector_size_ = configuration->property(role + ".vector_size", 1); + inverted_spectrum = configuration->property(role + ".inverted_spectrum", false); if(item_type_.compare("float") == 0) { @@ -66,6 +66,10 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro else if(item_type_.compare("gr_complex") == 0) { item_size_ = sizeof(gr_complex); + if(inverted_spectrum) + { + conjugate_cc_ = make_conjugate_cc(); + } } else if(item_type_.compare("short") == 0) { @@ -78,6 +82,10 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro else if(item_type_.compare("cshort") == 0) { item_size_ = sizeof(lv_16sc_t); + if(inverted_spectrum) + { + conjugate_sc_ = make_conjugate_sc(); + } } else if(item_type_.compare("byte") == 0) { @@ -90,12 +98,17 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro else if(item_type_.compare("cbyte") == 0) { item_size_ = sizeof(lv_8sc_t); + if(inverted_spectrum) + { + conjugate_ic_ = make_conjugate_ic(); + } } else { LOG(WARNING) << item_type_ << " unrecognized item type. Using float"; item_size_ = sizeof(float); } + kludge_copy_ = gr::blocks::copy::make(item_size_); DLOG(INFO) << "kludge_copy(" << kludge_copy_->unique_id() << ")"; } @@ -125,6 +138,27 @@ void Pass_Through::disconnect(gr::top_block_sptr top_block) gr::basic_block_sptr Pass_Through::get_left_block() { + if(inverted_spectrum) + { + if(item_type_.compare("gr_complex") == 0) + { + return conjugate_cc_; + } + else if(item_type_.compare("cshort") == 0) + { + return conjugate_sc_; + } + else if(item_type_.compare("cbyte") == 0) + { + return conjugate_ic_; + } + else + { + LOG(WARNING) << "Setting inverted_spectrum to true with item_type " + << item_type_ << " is not defined and has no effect."; + } + } + return kludge_copy_; } @@ -132,5 +166,26 @@ gr::basic_block_sptr Pass_Through::get_left_block() gr::basic_block_sptr Pass_Through::get_right_block() { + if(inverted_spectrum) + { + if(item_type_.compare("gr_complex") == 0) + { + return conjugate_cc_; + } + else if(item_type_.compare("cshort") == 0) + { + return conjugate_sc_; + } + else if(item_type_.compare("cbyte") == 0) + { + return conjugate_ic_; + } + else + { + DLOG(WARNING) << "Setting inverted_spectrum to true with item_type " + << item_type_ << " is not defined and has no effect."; + } + } + return kludge_copy_; } diff --git a/src/algorithms/libs/pass_through.h b/src/algorithms/libs/pass_through.h index 02cc1647f..39d4c5468 100644 --- a/src/algorithms/libs/pass_through.h +++ b/src/algorithms/libs/pass_through.h @@ -37,6 +37,10 @@ #include #include #include "gnss_block_interface.h" +#include "conjugate_cc.h" +#include "conjugate_sc.h" +#include "conjugate_ic.h" + class ConfigurationInterface; @@ -69,11 +73,6 @@ public: return item_type_; } - inline size_t vector_size() const - { - return vector_size_; - } - inline size_t item_size() override { return item_size_; @@ -86,13 +85,16 @@ public: private: std::string item_type_; - size_t vector_size_; 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_; + conjugate_sc_sptr conjugate_sc_; + conjugate_ic_sptr conjugate_ic_; + bool inverted_spectrum; }; #endif /*GNSS_SDR_PASS_THROUGH_H_*/ diff --git a/src/tests/unit-tests/signal-processing-blocks/adapter/pass_through_test.cc b/src/tests/unit-tests/signal-processing-blocks/adapter/pass_through_test.cc index 656a0d688..070196fe6 100644 --- a/src/tests/unit-tests/signal-processing-blocks/adapter/pass_through_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/adapter/pass_through_test.cc @@ -41,9 +41,6 @@ TEST(PassThroughTest, Instantiate) { std::shared_ptr config = std::make_shared(); config->set_property("Test.item_type", "gr_complex"); - config->set_property("Test.vector_size", "2"); std::shared_ptr signal_conditioner = std::make_shared(config.get(), "Test", 1, 1); EXPECT_STREQ("gr_complex", signal_conditioner->item_type().c_str()); - unsigned int expected2 = 2; - EXPECT_EQ(expected2, signal_conditioner->vector_size()); }