diff --git a/src/algorithms/PVT/libs/rinex_printer.h b/src/algorithms/PVT/libs/rinex_printer.h index 90724d0d9..98c11e4fc 100644 --- a/src/algorithms/PVT/libs/rinex_printer.h +++ b/src/algorithms/PVT/libs/rinex_printer.h @@ -157,7 +157,7 @@ public: /*! * \brief Generates the Mixed GPS L1,L5 + BDS B1I, B3I Navigation Data header */ - void rinex_nav_header(std::fstream& out, const Gps_Iono& gps_lnav_iono, const Gps_Utc_Model& gps_lnav_utc_model, const Gps_Ephemeris& eph, const Beidou_Dnav_Iono& bds_dnav_iono, const Beidou_Dnav_Utc_Model& bds_dnav_utc_model); + void rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono, const Gps_Utc_Model& gps_utc_model, const Gps_Ephemeris& eph, const Beidou_Dnav_Iono& bds_dnav_iono, const Beidou_Dnav_Utc_Model& bds_dnav_utc_model); /*! * \brief Generates the Mixed GPS L2C + BDS B1I, B3I Navigation Data header diff --git a/src/algorithms/channel/adapters/CMakeLists.txt b/src/algorithms/channel/adapters/CMakeLists.txt index 48f293df5..1019e526a 100644 --- a/src/algorithms/channel/adapters/CMakeLists.txt +++ b/src/algorithms/channel/adapters/CMakeLists.txt @@ -31,7 +31,6 @@ target_link_libraries(channel_adapters Gnuradio::runtime channel_libs core_system_parameters - core_receiver PRIVATE Gflags::gflags Glog::glog @@ -41,6 +40,7 @@ target_link_libraries(channel_adapters target_include_directories(channel_adapters PUBLIC ${CMAKE_SOURCE_DIR}/src/core/interfaces + ${CMAKE_SOURCE_DIR}/src/core/receiver ) if(ENABLE_CLANG_TIDY) diff --git a/src/algorithms/channel/libs/CMakeLists.txt b/src/algorithms/channel/libs/CMakeLists.txt index 1ab513f43..1411013a9 100644 --- a/src/algorithms/channel/libs/CMakeLists.txt +++ b/src/algorithms/channel/libs/CMakeLists.txt @@ -35,16 +35,21 @@ add_library(channel_libs ${CHANNEL_FSM_SOURCES} ${CHANNEL_FSM_HEADERS}) target_link_libraries(channel_libs PUBLIC - core_libs core_system_parameters Gnuradio::runtime Gnuradio::pmt PRIVATE + core_libs Boost::boost Gflags::gflags Glog::glog ) +target_include_directories(channel_libs + PUBLIC + ${CMAKE_SOURCE_DIR}/src/core/receiver +) + if(ENABLE_CLANG_TIDY) if(CLANG_TIDY_EXE) set_target_properties(channel_libs diff --git a/src/algorithms/libs/pass_through.cc b/src/algorithms/libs/pass_through.cc index 7b4144dd1..4ecf9edb4 100644 --- a/src/algorithms/libs/pass_through.cc +++ b/src/algorithms/libs/pass_through.cc @@ -109,7 +109,7 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, const std::str } kludge_copy_ = gr::blocks::copy::make(item_size_); - unsigned long int max_source_buffer_samples = configuration->property("GNSS-SDR.max_source_buffer_samples", 0); + uint64_t max_source_buffer_samples = configuration->property("GNSS-SDR.max_source_buffer_samples", 0ULL); if (max_source_buffer_samples > 0) { kludge_copy_->set_max_output_buffer(max_source_buffer_samples); diff --git a/src/algorithms/signal_generator/adapters/CMakeLists.txt b/src/algorithms/signal_generator/adapters/CMakeLists.txt index a519eaa3f..ed67e8674 100644 --- a/src/algorithms/signal_generator/adapters/CMakeLists.txt +++ b/src/algorithms/signal_generator/adapters/CMakeLists.txt @@ -34,12 +34,12 @@ target_link_libraries(signal_generator_adapters Gflags::gflags Glog::glog algorithms_libs - core_receiver ) target_include_directories(signal_generator_adapters PUBLIC ${CMAKE_SOURCE_DIR}/src/core/interfaces + ${CMAKE_SOURCE_DIR}/src/core/receiver ) if(ENABLE_CLANG_TIDY) diff --git a/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.h b/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.h index b0a8fb574..4a5af2e3a 100644 --- a/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.h +++ b/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.h @@ -148,7 +148,7 @@ private: std::vector> sampled_code_data_; std::vector> sampled_code_pilot_; std::vector complex_phase_; - unsigned int work_counter_; + unsigned int work_counter_{}; std::random_device r; std::default_random_engine e1; std::default_random_engine e2; diff --git a/src/algorithms/signal_source/gnuradio_blocks/CMakeLists.txt b/src/algorithms/signal_source/gnuradio_blocks/CMakeLists.txt index 4f05f3169..6a1ff6e62 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/signal_source/gnuradio_blocks/CMakeLists.txt @@ -60,15 +60,20 @@ add_library(signal_source_gr_blocks target_link_libraries(signal_source_gr_blocks PUBLIC + signal_source_libs Boost::thread Gnuradio::runtime - signal_source_libs PRIVATE - core_receiver + core_libs Gflags::gflags Glog::glog ) +target_include_directories(signal_source_gr_blocks + PUBLIC + ${CMAKE_SOURCE_DIR}/src/core/receiver +) + if(ENABLE_RAW_UDP AND PCAP_FOUND) target_link_libraries(signal_source_gr_blocks PUBLIC diff --git a/src/algorithms/signal_source/libs/CMakeLists.txt b/src/algorithms/signal_source/libs/CMakeLists.txt index 1045967b4..7e2f4f2f6 100644 --- a/src/algorithms/signal_source/libs/CMakeLists.txt +++ b/src/algorithms/signal_source/libs/CMakeLists.txt @@ -71,10 +71,15 @@ target_link_libraries(signal_source_libs PUBLIC Boost::boost Gnuradio::runtime - core_receiver PRIVATE Gflags::gflags Glog::glog + core_libs +) + +target_include_directories(signal_source_libs + PUBLIC + ${CMAKE_SOURCE_DIR}/src/core/receiver ) if(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2) diff --git a/src/core/libs/CMakeLists.txt b/src/core/libs/CMakeLists.txt index 6a074d5a7..a108368ae 100644 --- a/src/core/libs/CMakeLists.txt +++ b/src/core/libs/CMakeLists.txt @@ -26,6 +26,7 @@ set(CORE_LIBS_SOURCES gnss_sdr_sample_counter.cc channel_status_msg_receiver.cc channel_event.cc + command_event.cc ) set(CORE_LIBS_HEADERS @@ -36,6 +37,7 @@ set(CORE_LIBS_HEADERS gnss_sdr_sample_counter.h channel_status_msg_receiver.h channel_event.h + command_event.h ) if(ENABLE_FPGA) diff --git a/src/core/libs/channel_event.cc b/src/core/libs/channel_event.cc index 7c6862d76..c324d2fd5 100644 --- a/src/core/libs/channel_event.cc +++ b/src/core/libs/channel_event.cc @@ -32,10 +32,10 @@ channel_event_sptr channel_event_make(int channel_id, int event_type) { - return channel_event_sptr(new channel_event(channel_id, event_type)); + return channel_event_sptr(new Channel_Event(channel_id, event_type)); } -channel_event::channel_event(int channel_id_, int event_type_) +Channel_Event::Channel_Event(int channel_id_, int event_type_) { channel_id = channel_id_; event_type = event_type_; diff --git a/src/core/libs/channel_event.h b/src/core/libs/channel_event.h index 51c1a3a8f..1382c5b40 100644 --- a/src/core/libs/channel_event.h +++ b/src/core/libs/channel_event.h @@ -33,21 +33,21 @@ #include -class channel_event; +class Channel_Event; -using channel_event_sptr = std::shared_ptr; +using channel_event_sptr = std::shared_ptr; channel_event_sptr channel_event_make(int channel_id, int event_type); -class channel_event +class Channel_Event { public: int channel_id; int event_type; + private: friend channel_event_sptr channel_event_make(int channel_id, int event_type); - channel_event(int channel_id_, int event_type_); - + Channel_Event(int channel_id_, int event_type_); }; #endif diff --git a/src/core/libs/channel_status_msg_receiver.cc b/src/core/libs/channel_status_msg_receiver.cc index 2dd58bc4f..bed7f1ff2 100644 --- a/src/core/libs/channel_status_msg_receiver.cc +++ b/src/core/libs/channel_status_msg_receiver.cc @@ -1,11 +1,11 @@ /*! * \file channel_status_msg_receiver.cc * \brief GNU Radio block that receives asynchronous channel messages from acquisition and tracking blocks - * \author Javier Arribas, 2016. jarribas(at)cttc.es + * \author Javier Arribas, 2019. jarribas(at)cttc.es * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -75,12 +75,12 @@ void channel_status_msg_receiver::msg_handler_events(const pmt::pmt_t& msg) d_channel_status_map.erase(gnss_synchro_obj->Channel_ID); } - // std::cout << "-------- \n\n"; - // for (std::map>::iterator it = d_channel_status_map.begin(); it != d_channel_status_map.end(); ++it) - // { - // std::cout << " Channel: " << it->first << " => Doppler: " << it->second->Carrier_Doppler_hz << "[Hz] \n"; - // } - // std::cout << "-------- \n\n"; + // std::cout << "-------- " << std::endl << std::endl; + // for (std::map>::iterator it = d_channel_status_map.begin(); it != d_channel_status_map.end(); ++it) + // { + // std::cout << " Channel: " << it->first << " => Doppler: " << it->second->Carrier_Doppler_hz << "[Hz] " << std::endl; + // } + // std::cout << "-------- " << std::endl << std::endl; } else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) { @@ -88,10 +88,10 @@ void channel_status_msg_receiver::msg_handler_events(const pmt::pmt_t& msg) std::shared_ptr monitor_pvt_obj; monitor_pvt_obj = boost::any_cast>(pmt::any_ref(msg)); d_pvt_status = *monitor_pvt_obj.get(); - // - // std::cout << "-------- \n\n"; - // std::cout << "PVT TOW: " << d_pvt_status->TOW_at_current_symbol_ms << std::endl; - // std::cout << "-------- \n\n"; + + // std::cout << "-------- " << std::endl << std::endl; + // std::cout << "PVT TOW: " << d_pvt_status->TOW_at_current_symbol_ms << std::endl; + // std::cout << "-------- " << std::endl << std::endl; } else { @@ -104,11 +104,14 @@ void channel_status_msg_receiver::msg_handler_events(const pmt::pmt_t& msg) } } + std::map> channel_status_msg_receiver::get_current_status_map() { gr::thread::scoped_lock lock(d_setlock); // require mutex with msg_handler_events function called by the scheduler return d_channel_status_map; } + + Monitor_Pvt channel_status_msg_receiver::get_current_status_pvt() { gr::thread::scoped_lock lock(d_setlock); // require mutex with msg_handler_events function called by the scheduler diff --git a/src/core/libs/channel_status_msg_receiver.h b/src/core/libs/channel_status_msg_receiver.h index a4259834e..196484ed4 100644 --- a/src/core/libs/channel_status_msg_receiver.h +++ b/src/core/libs/channel_status_msg_receiver.h @@ -1,11 +1,11 @@ /*! * \file channel_msg_receiver_cc.h * \brief GNU Radio block that receives asynchronous channel messages from acquisition and tracking blocks - * \author Javier Arribas, 2016. jarribas(at)cttc.es + * \author Javier Arribas, 2019. jarribas(at)cttc.es * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -50,10 +50,12 @@ class channel_status_msg_receiver : public gr::block { public: ~channel_status_msg_receiver(); //!< Default destructor + /*! * \brief return the current status map of all channels with valid telemetry */ std::map> get_current_status_map(); + /*! * \brief return the current receiver PVT */ @@ -63,7 +65,6 @@ private: friend channel_status_msg_receiver_sptr channel_status_msg_receiver_make(); channel_status_msg_receiver(); std::map> d_channel_status_map; - Monitor_Pvt d_pvt_status{}; void msg_handler_events(const pmt::pmt_t& msg); }; diff --git a/src/core/receiver/command_event.cc b/src/core/libs/command_event.cc similarity index 91% rename from src/core/receiver/command_event.cc rename to src/core/libs/command_event.cc index 771061255..c3e8e8180 100644 --- a/src/core/receiver/command_event.cc +++ b/src/core/libs/command_event.cc @@ -32,10 +32,10 @@ command_event_sptr command_event_make(int command_id, int event_type) { - return command_event_sptr(new command_event(command_id, event_type)); + return command_event_sptr(new Command_Event(command_id, event_type)); } -command_event::command_event(int command_id_, int event_type_) +Command_Event::Command_Event(int command_id_, int event_type_) { command_id = command_id_; event_type = event_type_; diff --git a/src/core/receiver/command_event.h b/src/core/libs/command_event.h similarity index 86% rename from src/core/receiver/command_event.h rename to src/core/libs/command_event.h index 094281578..674e0ad57 100644 --- a/src/core/receiver/command_event.h +++ b/src/core/libs/command_event.h @@ -28,18 +28,18 @@ * ------------------------------------------------------------------------- */ -#ifndef GNSS_SDR_command_EVENT_H -#define GNSS_SDR_command_EVENT_H +#ifndef GNSS_SDR_COMMAND_EVENT_H +#define GNSS_SDR_COMMAND_EVENT_H #include -class command_event; +class Command_Event; -using command_event_sptr = std::shared_ptr; +using command_event_sptr = std::shared_ptr; command_event_sptr command_event_make(int command_id, int event_type); -class command_event +class Command_Event { public: int command_id; @@ -47,7 +47,7 @@ public: private: friend command_event_sptr command_event_make(int command_id, int event_type); - command_event(int command_id_, int event_type_); + Command_Event(int command_id_, int event_type_); }; #endif diff --git a/src/core/receiver/CMakeLists.txt b/src/core/receiver/CMakeLists.txt index cb709a7e4..08e8bec98 100644 --- a/src/core/receiver/CMakeLists.txt +++ b/src/core/receiver/CMakeLists.txt @@ -24,7 +24,6 @@ set(GNSS_RECEIVER_SOURCES gnss_flowgraph.cc in_memory_configuration.cc tcp_cmd_interface.cc - command_event.cc ) set(GNSS_RECEIVER_HEADERS @@ -36,7 +35,6 @@ set(GNSS_RECEIVER_HEADERS tcp_cmd_interface.h concurrent_map.h concurrent_queue.h - command_event.h ) list(SORT GNSS_RECEIVER_HEADERS) @@ -135,17 +133,11 @@ endif() target_link_libraries(core_receiver PUBLIC - Armadillo::armadillo - Boost::boost - Boost::thread - Gnuradio::runtime - channel_libs core_libs core_monitor + Boost::thread + Gnuradio::runtime PRIVATE - Boost::chrono - Gflags::gflags - Glog::glog signal_source_adapters data_type_adapters input_filter_adapters @@ -157,6 +149,11 @@ target_link_libraries(core_receiver telemetry_decoder_adapters obs_adapters pvt_adapters + Boost::boost + Boost::chrono + Gflags::gflags + Glog::glog + Armadillo::armadillo ) # Fix for Boost Asio < 1.70 diff --git a/src/core/receiver/concurrent_map.h b/src/core/receiver/concurrent_map.h index f3d20f181..08b059c98 100644 --- a/src/core/receiver/concurrent_map.h +++ b/src/core/receiver/concurrent_map.h @@ -31,8 +31,8 @@ #ifndef GNSS_SDR_CONCURRENT_MAP_H #define GNSS_SDR_CONCURRENT_MAP_H -#include #include +#include #include @@ -49,7 +49,7 @@ class Concurrent_Map public: void write(int key, Data const& data) { - boost::mutex::scoped_lock lock(the_mutex); + std::unique_lock lock(the_mutex); Data_iterator data_iter; data_iter = the_map.find(key); if (data_iter != the_map.end()) @@ -65,7 +65,7 @@ public: std::map get_map_copy() { - boost::mutex::scoped_lock lock(the_mutex); + std::unique_lock lock(the_mutex); std::map map_aux = the_map; lock.unlock(); return map_aux; @@ -73,7 +73,7 @@ public: size_t size() { - boost::mutex::scoped_lock lock(the_mutex); + std::unique_lock lock(the_mutex); size_t size_ = the_map.size(); lock.unlock(); return size_; @@ -81,7 +81,7 @@ public: bool read(int key, Data& p_data) { - boost::mutex::scoped_lock lock(the_mutex); + std::unique_lock lock(the_mutex); Data_iterator data_iter; data_iter = the_map.find(key); if (data_iter != the_map.end()) @@ -96,7 +96,7 @@ public: private: std::map the_map; - boost::mutex the_mutex; + mutable std::mutex the_mutex; }; #endif diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 919a658a7..629957959 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -60,6 +60,8 @@ #include "rtklib_conversions.h" // for alm_to_rtklib #include "rtklib_ephemeris.h" // for alm2pos, eph2pos #include "rtklib_rtkcmn.h" // for utc2gpst +#include // for interaction with geofunctions +#include // for steady_clock #include // for bad_lexical_cast #include // for LOG #include // for make_any @@ -67,7 +69,6 @@ #include // for array #include // for milliseconds #include // for floor, fmod, log -#include // for gmtime, strftime #include // for exception #include // for operator<<, endl #include // for numeric_limits @@ -225,6 +226,7 @@ void ControlThread::telecommand_listener() } } + void ControlThread::event_dispatcher(bool &valid_event, pmt::pmt_t &msg) { if (valid_event) @@ -270,6 +272,7 @@ void ControlThread::event_dispatcher(bool &valid_event, pmt::pmt_t &msg) } } + /* * Runs the control thread that manages the receiver control plane * @@ -813,9 +816,9 @@ void ControlThread::assist_GNSS() if ((agnss_ref_location_.valid == true) and ((enable_gps_supl_assistance == true) or (enable_agnss_xml == true))) { // Get the list of visible satellites - arma::vec ref_LLH = arma::zeros(3, 1); - ref_LLH(0) = agnss_ref_location_.lat; - ref_LLH(1) = agnss_ref_location_.lon; + std::array ref_LLH{}; + ref_LLH[0] = agnss_ref_location_.lat; + ref_LLH[1] = agnss_ref_location_.lon; time_t ref_rx_utc_time = 0; if (agnss_ref_time_.valid == true) { @@ -885,10 +888,10 @@ void ControlThread::apply_action(unsigned int what) } -std::vector> ControlThread::get_visible_sats(time_t rx_utc_time, const arma::vec &LLH) +std::vector> ControlThread::get_visible_sats(time_t rx_utc_time, const std::array &LLH) { // 1. Compute rx ECEF position from LLH WGS84 - arma::vec LLH_rad = arma::vec{degtorad(LLH(0)), degtorad(LLH(1)), LLH(2)}; + arma::vec LLH_rad = arma::vec{degtorad(LLH[0]), degtorad(LLH[1]), LLH[2]}; arma::mat C_tmp = arma::zeros(3, 3); arma::vec r_eb_e = arma::zeros(3, 1); arma::vec v_eb_e = arma::zeros(3, 1); @@ -912,7 +915,7 @@ std::vector> ControlThread::get_visible_sats(time strftime(buf, sizeof(buf), "%d/%m/%Y %H:%M:%S ", &tstruct); std::string str_time = std::string(buf); std::cout << "Get visible satellites at " << str_time - << "UTC, assuming RX position " << LLH(0) << " [deg], " << LLH(1) << " [deg], " << LLH(2) << " [m]" << std::endl; + << "UTC, assuming RX position " << LLH[0] << " [deg], " << LLH[1] << " [deg], " << LLH[2] << " [m]" << std::endl; std::map gps_eph_map = pvt_ptr->get_gps_ephemeris(); for (auto &it : gps_eph_map) diff --git a/src/core/receiver/control_thread.h b/src/core/receiver/control_thread.h index 5fa84f791..0459acd50 100644 --- a/src/core/receiver/control_thread.h +++ b/src/core/receiver/control_thread.h @@ -9,7 +9,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -35,15 +35,15 @@ #ifndef GNSS_SDR_CONTROL_THREAD_H_ #define GNSS_SDR_CONTROL_THREAD_H_ -#include "agnss_ref_location.h" // for Agnss_Ref_Location -#include "agnss_ref_time.h" // for Agnss_Ref_Time -#include "concurrent_queue.h" +#include "agnss_ref_location.h" // for Agnss_Ref_Location +#include "agnss_ref_time.h" // for Agnss_Ref_Time +#include "concurrent_queue.h" // for Concurrent_Queue #include "gnss_sdr_supl_client.h" // for Gnss_Sdr_Supl_Client #include "tcp_cmd_interface.h" // for TcpCmdInterface -#include // for arma::vec #include // for boost::thread #include -#include // for time_t +#include // for array +#include // for time_t (gmtime, strftime in implementation) #include // for shared_ptr #include // for string #include // for std::thread @@ -75,7 +75,9 @@ public: */ ControlThread(std::shared_ptr configuration); - //! \brief Destructor + /*! + * \brief Destructor + */ ~ControlThread(); /*! \brief Runs the control thread @@ -99,12 +101,12 @@ public: */ void set_control_queue(const std::shared_ptr> control_queue); // NOLINT(performance-unnecessary-value-param) - unsigned int processed_control_messages() + unsigned int processed_control_messages() const { return processed_control_messages_; } - unsigned int applied_actions() + unsigned int applied_actions() const { return applied_actions_; } @@ -120,15 +122,18 @@ public: } private: - //Telecommand TCP interface + // Telecommand TCP interface TcpCmdInterface cmd_interface_; void telecommand_listener(); + /* * New receiver event dispatcher */ void event_dispatcher(bool &valid_event, pmt::pmt_t &msg); + std::thread cmd_interface_thread_; - //SUPL assistance classes + + // SUPL assistance classes Gnss_Sdr_Supl_Client supl_client_acquisition_; Gnss_Sdr_Supl_Client supl_client_ephemeris_; int supl_mcc; // Current network MCC (Mobile country code), 3 digits. @@ -141,9 +146,6 @@ private: // Read {ephemeris, iono, utc, ref loc, ref time} assistance from a local XML file previously recorded bool read_assistance_from_XML(); - // Save {ephemeris, iono, utc, ref loc, ref time} assistance to a local XML file - //bool save_assistance_to_XML(); - /* * Blocking function that reads the GPS assistance queue */ @@ -153,7 +155,7 @@ private: * Compute elevations for the specified time and position for all the available satellites in ephemeris and almanac queues * returns a vector filled with the available satellites ordered from high elevation to low elevation angle. */ - std::vector> get_visible_sats(time_t rx_utc_time, const arma::vec &LLH); + std::vector> get_visible_sats(time_t rx_utc_time, const std::array &LLH); /* * Read initial GNSS assistance from SUPL server or local XML files diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 7f7558599..36ec45e61 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -64,7 +64,6 @@ #include // for set #include // for invalid_argument #include // for thread -#include // for move #ifdef GR_GREATER_38 #include #else @@ -1295,7 +1294,10 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) push_back_signal(gs); } channels_state_[who] = 0; - if (acq_channels_count_ > 0) acq_channels_count_--; + if (acq_channels_count_ > 0) + { + acq_channels_count_--; + } // call the acquisition manager to assign new satellite and start next acquisition (if required) acquisition_manager(who); break; @@ -1305,7 +1307,10 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) remove_signal(channels_[who]->get_signal()); channels_state_[who] = 2; - if (acq_channels_count_ > 0) acq_channels_count_--; + if (acq_channels_count_ > 0) + { + acq_channels_count_--; + } // call the acquisition manager to assign new satellite and start next acquisition (if required) acquisition_manager(who); break; @@ -1900,18 +1905,18 @@ Gnss_Signal GNSSFlowgraph::search_next_signal(const std::string& searched_signal std::map> current_channels_status = channels_status_->get_current_status_map(); // 2. search the currently tracked GPS L1 satellites and assist the GPS L2 acquisition if the satellite is not tracked on L2 bool found_signal = false; - for (std::map>::iterator it = current_channels_status.begin(); it != current_channels_status.end(); ++it) + for (auto& current_status : current_channels_status) { - if (std::string(it->second->Signal) == "1C") + if (std::string(current_status.second->Signal) == "1C") { std::list::iterator it2; it2 = std::find_if(std::begin(available_GPS_2S_signals_), std::end(available_GPS_2S_signals_), - [&](Gnss_Signal const& sig) { return sig.get_satellite().get_PRN() == it->second->PRN; }); + [&](Gnss_Signal const& sig) { return sig.get_satellite().get_PRN() == current_status.second->PRN; }); if (it2 != available_GPS_2S_signals_.end()) { - estimated_doppler = it->second->Carrier_Doppler_hz; - RX_time = it->second->RX_time; + estimated_doppler = current_status.second->Carrier_Doppler_hz; + RX_time = current_status.second->RX_time; // std::cout << " Channel: " << it->first << " => Doppler: " << estimated_doppler << "[Hz] \n"; // 3. return the GPS L2 satellite and remove it from list result = *it2; @@ -1953,18 +1958,18 @@ Gnss_Signal GNSSFlowgraph::search_next_signal(const std::string& searched_signal // 1. Get the current channel status map std::map> current_channels_status = channels_status_->get_current_status_map(); // 2. search the currently tracked GPS L1 satellites and assist the GPS L5 acquisition if the satellite is not tracked on L5 - for (std::map>::iterator it = current_channels_status.begin(); it != current_channels_status.end(); ++it) + for (auto& current_status : current_channels_status) { - if (std::string(it->second->Signal) == "1C") + if (std::string(current_status.second->Signal) == "1C") { std::list::iterator it2; it2 = std::find_if(std::begin(available_GPS_L5_signals_), std::end(available_GPS_L5_signals_), - [&](Gnss_Signal const& sig) { return sig.get_satellite().get_PRN() == it->second->PRN; }); + [&](Gnss_Signal const& sig) { return sig.get_satellite().get_PRN() == current_status.second->PRN; }); if (it2 != available_GPS_L5_signals_.end()) { - estimated_doppler = it->second->Carrier_Doppler_hz; - RX_time = it->second->RX_time; + estimated_doppler = current_status.second->Carrier_Doppler_hz; + RX_time = current_status.second->RX_time; // std::cout << " Channel: " << it->first << " => Doppler: " << estimated_doppler << "[Hz] \n"; // 3. return the GPS L5 satellite and remove it from list result = *it2; @@ -2007,18 +2012,18 @@ Gnss_Signal GNSSFlowgraph::search_next_signal(const std::string& searched_signal // 1. Get the current channel status map std::map> current_channels_status = channels_status_->get_current_status_map(); // 2. search the currently tracked Galileo E1 satellites and assist the Galileo E5 acquisition if the satellite is not tracked on E5 - for (std::map>::iterator it = current_channels_status.begin(); it != current_channels_status.end(); ++it) + for (auto& current_status : current_channels_status) { - if (std::string(it->second->Signal) == "1B") + if (std::string(current_status.second->Signal) == "1B") { std::list::iterator it2; it2 = std::find_if(std::begin(available_GAL_5X_signals_), std::end(available_GAL_5X_signals_), - [&](Gnss_Signal const& sig) { return sig.get_satellite().get_PRN() == it->second->PRN; }); + [&](Gnss_Signal const& sig) { return sig.get_satellite().get_PRN() == current_status.second->PRN; }); if (it2 != available_GAL_5X_signals_.end()) { - estimated_doppler = it->second->Carrier_Doppler_hz; - RX_time = it->second->RX_time; + estimated_doppler = current_status.second->Carrier_Doppler_hz; + RX_time = current_status.second->RX_time; // std::cout << " Channel: " << it->first << " => Doppler: " << estimated_doppler << "[Hz] \n"; // 3. return the Gal 5X satellite and remove it from list result = *it2; diff --git a/src/core/receiver/gnss_flowgraph.h b/src/core/receiver/gnss_flowgraph.h index d60995b36..6e52cff1f 100644 --- a/src/core/receiver/gnss_flowgraph.h +++ b/src/core/receiver/gnss_flowgraph.h @@ -11,7 +11,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -42,7 +42,7 @@ #include "gnss_sdr_sample_counter.h" #include "gnss_signal.h" #include "pvt_interface.h" -#include //for null_sink +#include // for null_sink #include // for basic_block_sptr, top_block_sptr #include // for pmt_t #include // for list @@ -79,10 +79,14 @@ public: */ ~GNSSFlowgraph(); - //! \brief Start the flow graph + /*! + * \brief Start the flow graph + */ void start(); - //! \brief Stop the flow graph + /*! + * \brief Stop the flow graph + */ void stop(); /*! @@ -92,16 +96,27 @@ public: */ void connect(); + /*! + * \brief Disconnect the blocks in the flow graph + */ void disconnect(); + /*! + * \brief Wait for a flowgraph to complete. + * + * Flowgraphs complete when either + * (1) all blocks indicate that they are done, or + * (2) after stop() has been called to request shutdown. + */ void wait(); -#ifdef ENABLE_FPGA - void start_acquisition_helper(); - - void perform_hw_reset(); -#endif + /*! + * \brief Manage satellite acquisition + * + * \param[in] who Channel ID + */ void acquisition_manager(unsigned int who); + /*! * \brief Applies an action to the flow graph * @@ -110,10 +125,9 @@ public: */ void apply_action(unsigned int who, unsigned int what); - - void push_back_signal(const Gnss_Signal& gs); - void remove_signal(const Gnss_Signal& gs); - + /*! + * \brief Set flow graph configuratiob + */ void set_configuration(std::shared_ptr configuration); bool connected() const @@ -127,7 +141,7 @@ public: } /*! - * \brief Sends a GNURadio asynchronous message from telemetry to PVT + * \brief Sends a GNU Radio asynchronous message from telemetry to PVT * * It is used to assist the receiver with external ephemeris data */ @@ -146,6 +160,12 @@ public: */ void priorize_satellites(const std::vector>& visible_satellites); +#ifdef ENABLE_FPGA + void start_acquisition_helper(); + + void perform_hw_reset(); +#endif + private: void init(); // Populates the SV PRN list available for acquisition and tracking void set_signals_list(); @@ -157,6 +177,10 @@ private: bool& assistance_available, float& estimated_doppler, double& RX_time); + + void push_back_signal(const Gnss_Signal& gs); + void remove_signal(const Gnss_Signal& gs); + bool connected_; bool running_; int sources_count_; @@ -209,7 +233,7 @@ private: std::map mapStringValues_; std::vector channels_state_; - channel_status_msg_receiver_sptr channels_status_; //class that receives and stores the current status of the receiver channels + channel_status_msg_receiver_sptr channels_status_; // class that receives and stores the current status of the receiver channels std::mutex signal_list_mutex; bool enable_monitor_; @@ -217,4 +241,4 @@ private: std::vector split_string(const std::string& s, char delim); }; -#endif /*GNSS_SDR_GNSS_FLOWGRAPH_H_*/ +#endif /* GNSS_SDR_GNSS_FLOWGRAPH_H_ */ diff --git a/src/core/receiver/tcp_cmd_interface.cc b/src/core/receiver/tcp_cmd_interface.cc index f274c82dc..20d3618a6 100644 --- a/src/core/receiver/tcp_cmd_interface.cc +++ b/src/core/receiver/tcp_cmd_interface.cc @@ -33,7 +33,6 @@ #include "command_event.h" #include "pvt_interface.h" #include -#include #include // for isnan #include // for exception #include // for setprecision @@ -51,9 +50,9 @@ TcpCmdInterface::TcpCmdInterface() register_functions(); keep_running_ = true; control_queue_ = nullptr; - rx_latitude_ = 0; - rx_longitude_ = 0; - rx_altitude_ = 0; + rx_latitude_ = 0.0; + rx_longitude_ = 0.0; + rx_altitude_ = 0.0; receiver_utc_time_ = 0; } @@ -85,9 +84,9 @@ time_t TcpCmdInterface::get_utc_time() } -arma::vec TcpCmdInterface::get_LLH() +std::array TcpCmdInterface::get_LLH() const { - return arma::vec{rx_latitude_, rx_longitude_, rx_altitude_}; + return std::array{rx_latitude_, rx_longitude_, rx_altitude_}; } @@ -192,9 +191,9 @@ std::string TcpCmdInterface::hotstart(const std::vector &commandLin receiver_utc_time_ = timegm(&tm); // Read latitude, longitude, and height - rx_latitude_ = std::stod(commandLine.at(3).c_str()); - rx_longitude_ = std::stod(commandLine.at(4).c_str()); - rx_altitude_ = std::stod(commandLine.at(5).c_str()); + rx_latitude_ = std::stof(commandLine.at(3).c_str()); + rx_longitude_ = std::stof(commandLine.at(4).c_str()); + rx_altitude_ = std::stof(commandLine.at(5).c_str()); if (std::isnan(rx_latitude_) || std::isnan(rx_longitude_) || std::isnan(rx_altitude_)) { diff --git a/src/core/receiver/tcp_cmd_interface.h b/src/core/receiver/tcp_cmd_interface.h index 0b6276e92..993a68312 100644 --- a/src/core/receiver/tcp_cmd_interface.h +++ b/src/core/receiver/tcp_cmd_interface.h @@ -33,8 +33,8 @@ #include "concurrent_queue.h" -#include #include +#include #include #include #include @@ -61,7 +61,7 @@ public: /*! * \brief gets the Latitude, Longitude and Altitude vector from the last TC command issued */ - arma::vec get_LLH(); + std::array get_LLH() const; void set_pvt(std::shared_ptr PVT_sptr); @@ -83,9 +83,9 @@ private: time_t receiver_utc_time_; - double rx_latitude_; - double rx_longitude_; - double rx_altitude_; + float rx_latitude_; + float rx_longitude_; + float rx_altitude_; std::shared_ptr PVT_sptr_; };