diff --git a/src/core/libs/CMakeLists.txt b/src/core/libs/CMakeLists.txt index 5de16002d..cc95de249 100644 --- a/src/core/libs/CMakeLists.txt +++ b/src/core/libs/CMakeLists.txt @@ -85,18 +85,18 @@ target_link_libraries(core_libs Gnuradio::runtime Gnuradio::pmt protobuf::libprotobuf - algorithms_libs core_libs_supl core_system_parameters pvt_libs PRIVATE + algorithms_libs Boost::serialization Gflags::gflags Glog::glog Pugixml::pugixml ) -if(NOT USE_GENERIC_LAMBDAS) +if(USE_GENERIC_LAMBDAS AND NOT GNURADIO_USES_STD_POINTERS) target_link_libraries(core_libs PUBLIC Boost::headers) else() target_link_libraries(core_libs PRIVATE Boost::headers) @@ -117,20 +117,20 @@ if(USE_GENERIC_LAMBDAS) set(has_generic_lambdas HAS_GENERIC_LAMBDA=1) set(no_has_generic_lambdas HAS_GENERIC_LAMBDA=0) target_compile_definitions(core_libs - PUBLIC + PRIVATE "$<$:${has_generic_lambdas}>" "$<$>:${no_has_generic_lambdas}>" ) else() target_compile_definitions(core_libs - PUBLIC + PRIVATE -DHAS_GENERIC_LAMBDA=0 ) endif() if(USE_BOOST_BIND_PLACEHOLDERS) target_compile_definitions(core_libs - PUBLIC + PRIVATE -DUSE_BOOST_BIND_PLACEHOLDERS=1 ) endif() diff --git a/src/core/libs/galileo_e6_has_msg_receiver.cc b/src/core/libs/galileo_e6_has_msg_receiver.cc index 710ee0f1c..3d26612b1 100644 --- a/src/core/libs/galileo_e6_has_msg_receiver.cc +++ b/src/core/libs/galileo_e6_has_msg_receiver.cc @@ -19,15 +19,24 @@ #include "galileo_e6_has_msg_receiver.h" -#include "display.h" // for colors in terminal -#include // for boost::any_cast -#include // for DLOG -#include // for std::find, std::count -#include // for size_t -#include // for std::back_inserter -#include // for std::stringstream -#include // for std::out_of_range -#include // for typeid +#include "display.h" // for colors in terminal +#include "galileo_has_page.h" // for Galileo_HAS_page +#include "gnss_sdr_make_unique.h" // for std::make_unique in C++11 +#include "reed_solomon.h" // for ReedSolomon +#include // for boost::any_cast +#include // for DLOG +#include // for gr::io_signature::make +#include // for std::find, std::count +#include // for size_t +#include // for std::back_inserter +#include // for std::stringstream +#include // for std::out_of_range +#include // for typeid + +#if HAS_GENERIC_LAMBDA +#else +#include +#endif galileo_e6_has_msg_receiver_sptr galileo_e6_has_msg_receiver_make() @@ -36,6 +45,52 @@ galileo_e6_has_msg_receiver_sptr galileo_e6_has_msg_receiver_make() } +galileo_e6_has_msg_receiver::galileo_e6_has_msg_receiver() : gr::block("galileo_e6_has_msg_receiver", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) +{ + // register Gal E6 HAS input message port from telemetry blocks + this->message_port_register_in(pmt::mp("E6_HAS_from_TLM")); + // register nav message monitor out + this->message_port_register_out(pmt::mp("Nav_msg_from_TLM")); + this->set_msg_handler(pmt::mp("E6_HAS_from_TLM"), +#if HAS_GENERIC_LAMBDA + [this](auto&& PH1) { msg_handler_galileo_e6_has(PH1); }); +#else +#if USE_BOOST_BIND_PLACEHOLDERS + boost::bind(&galileo_e6_has_msg_receiver::msg_handler_galileo_e6_has, this, boost::placeholders::_1)); +#else + boost::bind(&galileo_e6_has_msg_receiver::msg_handler_galileo_e6_has, this, _1)); +#endif +#endif + + // register Gal E6 processed HAS async output message port towards PVT + this->message_port_register_out(pmt::mp("E6_HAS_to_PVT")); + + // initialize Reed-Solomon decoder + d_rs = std::make_unique(); + + // Reserve memory for decoding matrices and received PIDs + d_C_matrix = std::vector>>(GALILEO_CNAV_INFORMATION_VECTOR_LENGTH, std::vector>(GALILEO_CNAV_MAX_NUMBER_SYMBOLS_ENCODED_BLOCK, std::vector(GALILEO_CNAV_OCTETS_IN_SUBPAGE))); // 32 x 255 x 53 + d_M_matrix = std::vector>(GALILEO_CNAV_INFORMATION_VECTOR_LENGTH, std::vector(GALILEO_CNAV_OCTETS_IN_SUBPAGE)); // HAS message matrix 32 x 53 + d_received_pids = std::vector>(HAS_MSG_NUMBER_MESSAGE_IDS, std::vector()); + + // Reserve memory to store masks + d_nsat_in_mask_id = std::vector(HAS_MSG_NUMBER_MASK_IDS); + d_gnss_id_in_mask = std::vector>(HAS_MSG_NUMBER_MASK_IDS, std::vector(HAS_MSG_NUMBER_GNSS_IDS)); + d_satellite_mask = std::vector>(HAS_MSG_NUMBER_MASK_IDS, std::vector(HAS_MSG_NUMBER_GNSS_IDS)); + d_signal_mask = std::vector>(HAS_MSG_NUMBER_MASK_IDS, std::vector(HAS_MSG_NUMBER_GNSS_IDS)); + d_cell_mask_availability_flag = std::vector>(HAS_MSG_NUMBER_MASK_IDS, std::vector(HAS_MSG_NUMBER_GNSS_IDS)); + d_cell_mask = std::vector>>>(HAS_MSG_NUMBER_MASK_IDS, {HAS_MSG_NUMBER_GNSS_IDS, {HAS_MSG_NUMBER_SATELLITE_IDS, std::vector(HAS_MSG_NUMBER_SIGNAL_MASKS)}}); + d_nsys_in_mask = std::vector(HAS_MSG_NUMBER_MASK_IDS); + d_nav_message_mask = std::vector>(HAS_MSG_NUMBER_MASK_IDS, std::vector(HAS_MSG_NUMBER_GNSS_IDS)); + + // Initialize values for d_nav_msg_packet + d_nav_msg_packet.system = std::string("E"); + d_nav_msg_packet.signal = std::string("E6"); + d_nav_msg_packet.prn = 0; + d_nav_msg_packet.tow_at_current_symbol_ms = 0; +} + + void galileo_e6_has_msg_receiver::set_enable_navdata_monitor(bool enable) { d_enable_navdata_monitor = enable; @@ -429,12 +484,12 @@ void galileo_e6_has_msg_receiver::read_MT1_body(const std::string& message_body) d_HAS_data.delta_cross_track = std::vector(Nsat); for (int i = 0; i < Nsat; i++) { - if (d_HAS_data.gnss_id_mask[i] == HAS_MSG_GPS_SYSTEM) + if (d_HAS_data.get_gnss_id(i) == HAS_MSG_GPS_SYSTEM) { d_HAS_data.gnss_iod[i] = read_has_message_body_uint16(message.substr(0, HAS_MSG_IOD_GPS_LENGTH)); message = std::string(message.begin() + HAS_MSG_IOD_GPS_LENGTH, message.end()); } - if (d_HAS_data.gnss_id_mask[i] == HAS_MSG_GALILEO_SYSTEM) + if (d_HAS_data.get_gnss_id(i) == HAS_MSG_GALILEO_SYSTEM) { d_HAS_data.gnss_iod[i] = read_has_message_body_uint16(message.substr(0, HAS_MSG_IOD_GAL_LENGTH)); message = std::string(message.begin() + HAS_MSG_IOD_GAL_LENGTH, message.end()); diff --git a/src/core/libs/galileo_e6_has_msg_receiver.h b/src/core/libs/galileo_e6_has_msg_receiver.h index f3e704fbd..dd26b1e34 100644 --- a/src/core/libs/galileo_e6_has_msg_receiver.h +++ b/src/core/libs/galileo_e6_has_msg_receiver.h @@ -20,33 +20,26 @@ #ifndef GNSS_SDR_GALILEO_E6_HAS_MSG_RECEIVER_H #define GNSS_SDR_GALILEO_E6_HAS_MSG_RECEIVER_H -#include "Galileo_CNAV.h" // for GALILEO_CNAV_* and HAS_MSG_* constants -#include "galileo_has_data.h" // for Galileo_HAS_data -#include "galileo_has_page.h" // for Galileo_HAS_page -#include "gnss_block_interface.h" // for gnss_shared_ptr -#include "gnss_sdr_make_unique.h" // for std::make_unique in C++11 -#include "nav_message_packet.h" // for Nav_Message_Packet -#include "reed_solomon.h" // for ReedSolomon -#include // for gr::block -#include // for gr::io_signature::make -#include // for pmt::mp -#include // for std::bitset -#include // for uint8_t, ... -#include // for std::unique_ptr -#include // for std::string -#include // std::pair -#include // for std::vector - -#if HAS_GENERIC_LAMBDA -#else -#include // for boost::bind -#endif +#include "Galileo_CNAV.h" // for GALILEO_CNAV_* constants +#include "galileo_has_data.h" // for Galileo_HAS_data +#include "gnss_block_interface.h" // for gnss_shared_ptr +#include "nav_message_packet.h" // for Nav_Message_Packet +#include // for gr::block +#include // for pmt::pmt_t +#include +#include +#include // for std::unique_ptr +#include +#include // std::pair +#include /** \addtogroup Core * \{ */ /** \addtogroup Core_Receiver_Library * \{ */ +class Galileo_HAS_page; +class ReedSolomon; class galileo_e6_has_msg_receiver; using galileo_e6_has_msg_receiver_sptr = gnss_shared_ptr; @@ -67,51 +60,7 @@ public: private: friend galileo_e6_has_msg_receiver_sptr galileo_e6_has_msg_receiver_make(); - - inline galileo_e6_has_msg_receiver() : gr::block("galileo_e6_has_msg_receiver", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) - { - // register Gal E6 HAS input message port from telemetry blocks - this->message_port_register_in(pmt::mp("E6_HAS_from_TLM")); - // register nav message monitor out - this->message_port_register_out(pmt::mp("Nav_msg_from_TLM")); - this->set_msg_handler(pmt::mp("E6_HAS_from_TLM"), -#if HAS_GENERIC_LAMBDA - [this](auto&& PH1) { msg_handler_galileo_e6_has(PH1); }); -#else -#if USE_BOOST_BIND_PLACEHOLDERS - boost::bind(&galileo_e6_has_msg_receiver::msg_handler_galileo_e6_has, this, boost::placeholders::_1)); -#else - boost::bind(&galileo_e6_has_msg_receiver::msg_handler_galileo_e6_has, this, _1)); -#endif -#endif - - // register Gal E6 processed HAS async output message port towards PVT - this->message_port_register_out(pmt::mp("E6_HAS_to_PVT")); - - // initialize Reed-Solomon decoder - d_rs = std::make_unique(); - - // Reserve memory for decoding matrices and received PIDs - d_C_matrix = std::vector>>(GALILEO_CNAV_INFORMATION_VECTOR_LENGTH, std::vector>(GALILEO_CNAV_MAX_NUMBER_SYMBOLS_ENCODED_BLOCK, std::vector(GALILEO_CNAV_OCTETS_IN_SUBPAGE))); // 32 x 255 x 53 - d_M_matrix = std::vector>(GALILEO_CNAV_INFORMATION_VECTOR_LENGTH, std::vector(GALILEO_CNAV_OCTETS_IN_SUBPAGE)); // HAS message matrix 32 x 53 - d_received_pids = std::vector>(HAS_MSG_NUMBER_MESSAGE_IDS, std::vector()); - - // Reserve memory to store masks - d_nsat_in_mask_id = std::vector(HAS_MSG_NUMBER_MASK_IDS); - d_gnss_id_in_mask = std::vector>(HAS_MSG_NUMBER_MASK_IDS, std::vector(HAS_MSG_NUMBER_GNSS_IDS)); - d_satellite_mask = std::vector>(HAS_MSG_NUMBER_MASK_IDS, std::vector(HAS_MSG_NUMBER_GNSS_IDS)); - d_signal_mask = std::vector>(HAS_MSG_NUMBER_MASK_IDS, std::vector(HAS_MSG_NUMBER_GNSS_IDS)); - d_cell_mask_availability_flag = std::vector>(HAS_MSG_NUMBER_MASK_IDS, std::vector(HAS_MSG_NUMBER_GNSS_IDS)); - d_cell_mask = std::vector>>>(HAS_MSG_NUMBER_MASK_IDS, {HAS_MSG_NUMBER_GNSS_IDS, {HAS_MSG_NUMBER_SATELLITE_IDS, std::vector(HAS_MSG_NUMBER_SIGNAL_MASKS)}}); - d_nsys_in_mask = std::vector(HAS_MSG_NUMBER_MASK_IDS); - d_nav_message_mask = std::vector>(HAS_MSG_NUMBER_MASK_IDS, std::vector(HAS_MSG_NUMBER_GNSS_IDS)); - - // Initialize values for d_nav_msg_packet - d_nav_msg_packet.system = std::string("E"); - d_nav_msg_packet.signal = std::string("E6"); - d_nav_msg_packet.prn = 0; - d_nav_msg_packet.tow_at_current_symbol_ms = 0; - }; + galileo_e6_has_msg_receiver(); void msg_handler_galileo_e6_has(const pmt::pmt_t& msg); void process_HAS_page(const Galileo_HAS_page& has_page); @@ -137,7 +86,7 @@ private: std::unique_ptr d_rs; Galileo_HAS_data d_HAS_data{}; - Nav_Message_Packet d_nav_msg_packet{}; + Nav_Message_Packet d_nav_msg_packet; // Store decoding matrices and received PIDs std::vector>> d_C_matrix; diff --git a/src/core/system_parameters/galileo_has_data.cc b/src/core/system_parameters/galileo_has_data.cc index 0e7c61d74..ca51d652f 100644 --- a/src/core/system_parameters/galileo_has_data.cc +++ b/src/core/system_parameters/galileo_has_data.cc @@ -382,3 +382,20 @@ std::vector Galileo_HAS_data::get_signals_in_mask(uint8_t nsys) con } return signals_in_mask; } + + +uint8_t Galileo_HAS_data::get_gnss_id(int nsat) const +{ + uint8_t gnss_id_ = 0; + int number_sats = 0; + for (uint8_t i = 0; i < Nsys; i++) + { + number_sats += static_cast(get_PRNs_in_mask(i).size()); + if (nsat < number_sats) + { + return gnss_id_mask[i]; + } + } + + return gnss_id_; +} diff --git a/src/core/system_parameters/galileo_has_data.h b/src/core/system_parameters/galileo_has_data.h index 41381767b..4d524f15b 100644 --- a/src/core/system_parameters/galileo_has_data.h +++ b/src/core/system_parameters/galileo_has_data.h @@ -54,6 +54,7 @@ public: std::vector get_PRNs_in_mask(uint8_t nsys) const; std::vector get_PRNs_in_submask(uint8_t nsys) const; std::vector get_signals_in_mask(uint8_t nsys) const; + uint8_t get_gnss_id(int nsat) const; mt1_header header; uint8_t has_status;