diff --git a/src/algorithms/signal_source/adapters/CMakeLists.txt b/src/algorithms/signal_source/adapters/CMakeLists.txt index ededc5dc7..a502b6e30 100644 --- a/src/algorithms/signal_source/adapters/CMakeLists.txt +++ b/src/algorithms/signal_source/adapters/CMakeLists.txt @@ -29,7 +29,7 @@ if(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2) message(STATUS " * libiio from https://github.com/analogdevicesinc/libiio") message(STATUS " * libad9361-iio from https://github.com/analogdevicesinc/libad9361-iio") message(STATUS " * gnuradio-iio from https://github.com/analogdevicesinc/gr-iio") - message(FATAL_ERROR "gnuradio-iio required for building gnss-sdr with this option enabled") + message(FATAL_ERROR "gnuradio-iio is required for building gnss-sdr with this option enabled.") endif(NOT IIO_FOUND) set(OPT_LIBRARIES ${OPT_LIBRARIES} ${IIO_LIBRARIES}) set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS}) @@ -38,12 +38,12 @@ endif(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2) if(ENABLE_AD9361) find_package(libiio REQUIRED) if(NOT LIBIIO_FOUND) - message(STATUS "gnuradio-iio not found, its installation is required.") + message(STATUS "libiio not found, its installation is required.") message(STATUS "Please build and install the following projects:") message(STATUS " * libiio from https://github.com/analogdevicesinc/libiio") message(STATUS " * libad9361-iio from https://github.com/analogdevicesinc/libad9361-iio") message(STATUS " * gnuradio-iio from https://github.com/analogdevicesinc/gr-iio") - message(FATAL_ERROR "gnuradio-iio required for building gnss-sdr with this option enabled") + message(FATAL_ERROR "libiio is required for building gnss-sdr with this option enabled.") endif(NOT LIBIIO_FOUND) set(OPT_LIBRARIES ${OPT_LIBRARIES} ${LIBIIO_LIBRARIES}) set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${LIBIIO_INCLUDE_DIRS}) diff --git a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc index cba4e5439..02be88152 100644 --- a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc +++ b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc @@ -35,10 +35,8 @@ #include "ad9361_manager.h" #include "GPS_L1_CA.h" #include "GPS_L2C.h" -#include -#include #include -#include +#include // for cout, endl #ifdef __APPLE__ #include @@ -47,10 +45,8 @@ #endif Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, unsigned int out_stream, - boost::shared_ptr queue) : - role_(role), in_stream_(in_stream), out_stream_(out_stream), - queue_(queue) + std::string role, unsigned int in_stream, unsigned int out_stream, + boost::shared_ptr queue) : role_(role), in_stream_(in_stream), out_stream_(out_stream), queue_(queue) { std::string default_item_type = "gr_complex"; std::string default_dump_file = "./data/signal_source.dat"; @@ -75,12 +71,12 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(ConfigurationInterface* configura dump_ = configuration->property(role + ".dump", false); dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file); - enable_dds_lo_=configuration->property(role + ".enable_dds_lo", false); - freq_rf_tx_hz_=configuration->property(role + ".freq_rf_tx_hz", GPS_L1_FREQ_HZ-GPS_L2_FREQ_HZ-1000); - freq_dds_tx_hz_=configuration->property(role + ".freq_dds_tx_hz", 1000); - scale_dds_dbfs_=configuration->property(role + ".scale_dds_dbfs", -3.0); - phase_dds_deg_=configuration->property(role + ".phase_dds_deg", 0.0); - tx_attenuation_db_=configuration->property(role + ".tx_attenuation_db", 0.0); + enable_dds_lo_ = configuration->property(role + ".enable_dds_lo", false); + freq_rf_tx_hz_ = configuration->property(role + ".freq_rf_tx_hz", GPS_L1_FREQ_HZ - GPS_L2_FREQ_HZ - 1000); + freq_dds_tx_hz_ = configuration->property(role + ".freq_dds_tx_hz", 1000); + scale_dds_dbfs_ = configuration->property(role + ".scale_dds_dbfs", -3.0); + phase_dds_deg_ = configuration->property(role + ".phase_dds_deg", 0.0); + tx_attenuation_db_ = configuration->property(role + ".tx_attenuation_db", 0.0); item_size_ = sizeof(gr_complex); @@ -89,30 +85,30 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(ConfigurationInterface* configura std::cout << "sample rate: " << sample_rate_ << " Hz" << std::endl; config_ad9361_rx_local(bandwidth_, - sample_rate_, - freq_, - rf_port_select_, - gain_mode_rx1_, - gain_mode_rx2_, - rf_gain_rx1_, - rf_gain_rx2_); + sample_rate_, + freq_, + rf_port_select_, + gain_mode_rx1_, + gain_mode_rx2_, + rf_gain_rx1_, + rf_gain_rx2_); //LOCAL OSCILLATOR DDS GENERATOR FOR DUAL FREQUENCY OPERATION - if (enable_dds_lo_==true) - { - config_ad9361_lo_local(bandwidth_, - sample_rate_, - freq_rf_tx_hz_, - tx_attenuation_db_, - freq_dds_tx_hz_, - scale_dds_dbfs_); - } + if (enable_dds_lo_ == true) + { + config_ad9361_lo_local(bandwidth_, + sample_rate_, + freq_rf_tx_hz_, + tx_attenuation_db_, + freq_dds_tx_hz_, + scale_dds_dbfs_); + } // turn switch to A/D position std::string default_device_name = "/dev/uio13"; std::string device_name = configuration->property(role + ".devicename", default_device_name); int switch_position = configuration->property(role + ".switch_position", 0); - switch_fpga = std::make_shared (device_name); + switch_fpga = std::make_shared(device_name); switch_fpga->set_switch_position(switch_position); } @@ -125,11 +121,11 @@ Ad9361FpgaSignalSource::~Ad9361FpgaSignalSource() //if (rx0_q) { iio_channel_disable(rx0_q); } if (enable_dds_lo_) - { - ad9361_disable_lo_local(); - } + { + ad9361_disable_lo_local(); + } - // std::cout<<"* AD9361 Destroying context\n"; + // std::cout<<"* AD9361 Destroying context\n"; //if (ctx) { iio_context_destroy(ctx); } } diff --git a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.h b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.h index 6110a63c3..2a98e3017 100644 --- a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.h +++ b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.h @@ -34,21 +34,20 @@ #include "gnss_block_interface.h" #include "fpga_switch.h" - #include #include #include class ConfigurationInterface; -class Ad9361FpgaSignalSource: public GNSSBlockInterface +class Ad9361FpgaSignalSource : public GNSSBlockInterface { public: Ad9361FpgaSignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_stream, - unsigned int out_stream, boost::shared_ptr queue); + std::string role, unsigned int in_stream, + unsigned int out_stream, boost::shared_ptr queue); - virtual ~Ad9361FpgaSignalSource(); + ~Ad9361FpgaSignalSource(); inline std::string role() override { @@ -77,11 +76,11 @@ private: std::string role_; // Front-end settings - std::string uri_;//device direction - unsigned long freq_; //frequency of local oscilator + std::string uri_; // device direction + unsigned long freq_; // frequency of local oscillator unsigned long sample_rate_; unsigned long bandwidth_; - unsigned long buffer_size_; //reception buffer + unsigned long buffer_size_; // reception buffer bool rx1_en_; bool rx2_en_; bool quadrature_; @@ -95,7 +94,7 @@ private: std::string filter_file_; bool filter_auto_; - //DDS configuration for LO generation for external mixer + // DDS configuration for LO generation for external mixer bool enable_dds_lo_; unsigned long freq_rf_tx_hz_; unsigned long freq_dds_tx_hz_; diff --git a/src/algorithms/signal_source/libs/CMakeLists.txt b/src/algorithms/signal_source/libs/CMakeLists.txt index 9cb569618..073cc343f 100644 --- a/src/algorithms/signal_source/libs/CMakeLists.txt +++ b/src/algorithms/signal_source/libs/CMakeLists.txt @@ -52,10 +52,10 @@ if(ENABLE_FMCOMMS2 OR ENABLE_AD9361) endif(LIBIIO_FOUND) endif(ENABLE_FMCOMMS2 OR ENABLE_AD9361) -if(ENABLE_FPGA) +if(ENABLE_FPGA OR ENABLE_AD9361) set(OPT_SIGNAL_SOURCE_LIB_SOURCES ${OPT_SIGNAL_SOURCE_LIB_SOURCES} fpga_switch.cc) set(OPT_SIGNAL_SOURCE_LIB_HEADERS ${OPT_SIGNAL_SOURCE_LIB_HEADERS} fpga_switch.h) -endif(ENABLE_FPGA) +endif(ENABLE_FPGA OR ENABLE_AD9361) include_directories( ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/src/algorithms/signal_source/libs/fpga_switch.cc b/src/algorithms/signal_source/libs/fpga_switch.cc index aae7da979..675c1c071 100644 --- a/src/algorithms/signal_source/libs/fpga_switch.cc +++ b/src/algorithms/signal_source/libs/fpga_switch.cc @@ -35,52 +35,33 @@ */ #include "fpga_switch.h" -#include - -// FPGA stuff -#include - -// libraries used by DMA test code and GIPO test code -#include -#include -#include -#include - -// libraries used by DMA test code -#include -#include -#include -#include - -// libraries used by GPIO test code -#include -#include -#include - -// logging #include +#include // for open, O_RDWR, O_SYNC +#include // for cout, endl +#include // for mmap -// string manipulation -#include // constants -#define PAGE_SIZE 0x10000 -#define TEST_REGISTER_TRACK_WRITEVAL 0x55AA +const size_t PAGE_SIZE = 0x10000; +const unsigned int TEST_REGISTER_TRACK_WRITEVAL = 0x55AA; fpga_switch::fpga_switch(std::string device_name) { if ((d_device_descriptor = open(device_name.c_str(), O_RDWR | O_SYNC)) == -1) { LOG(WARNING) << "Cannot open deviceio" << device_name; - printf("switch memory successfully mapped\n"); } - d_map_base = reinterpret_cast(mmap(NULL, PAGE_SIZE, + d_map_base = reinterpret_cast(mmap(nullptr, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, d_device_descriptor, 0)); if (d_map_base == reinterpret_cast(-1)) { LOG(WARNING) << "Cannot map the FPGA switch module into tracking memory"; - printf("could not map switch memory\n"); + std::cout << "Could not map switch memory." << std::endl; + } + else + { + std::cout << "Switch memory successfully mapped." << std::endl; } // sanity check : check test register @@ -130,7 +111,7 @@ void fpga_switch::close_device() unsigned *aux = const_cast(d_map_base); if (munmap(static_cast(aux), PAGE_SIZE) == -1) { - printf("Failed to unmap memory uio\n"); + std::cout << "Failed to unmap memory uio" << std::endl; } close(d_device_descriptor); diff --git a/src/algorithms/signal_source/libs/fpga_switch.h b/src/algorithms/signal_source/libs/fpga_switch.h index 395aff425..bf60a17fe 100644 --- a/src/algorithms/signal_source/libs/fpga_switch.h +++ b/src/algorithms/signal_source/libs/fpga_switch.h @@ -37,7 +37,7 @@ #ifndef GNSS_SDR_FPGA_SWITCH_H_ #define GNSS_SDR_FPGA_SWITCH_H_ -#include +#include #define MAX_LENGTH_DEVICEIO_NAME 50 diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 9121d7fa7..aba3c0272 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -110,7 +110,15 @@ ControlThread::~ControlThread() void ControlThread::run() { // Connect the flowgraph - flowgraph_->connect(); + try + { + flowgraph_->connect(); + } + catch (const std::exception e) + { + LOG(ERROR) << e.what(); + return; + } if (flowgraph_->connected()) { LOG(INFO) << "Flowgraph connected"; @@ -141,9 +149,9 @@ void ControlThread::run() bool enable_FPGA = configuration_->property("Channel.enable_FPGA", false); if (enable_FPGA == true) - { - flowgraph_->start_acquisition_helper(); - } + { + flowgraph_->start_acquisition_helper(); + } // Main loop to read and process the control messages while (flowgraph_->running() && !stop_) @@ -271,6 +279,7 @@ bool ControlThread::read_assistance_from_XML() return ret; } + void ControlThread::assist_GNSS() { //######### GNSS Assistance ################################# diff --git a/src/core/receiver/gnss_block_factory.cc b/src/core/receiver/gnss_block_factory.cc index 09d396b36..329f2e168 100644 --- a/src/core/receiver/gnss_block_factory.cc +++ b/src/core/receiver/gnss_block_factory.cc @@ -148,7 +148,6 @@ #include "gps_l1_ca_dll_pll_tracking_gpu.h" #endif -#include #include #include #include @@ -169,9 +168,16 @@ std::unique_ptr GNSSBlockFactory::GetSignalSource( { std::string default_implementation = "File_Signal_Source"; std::string role = "SignalSource"; //backwards compatibility for old conf files - if (ID != -1) + try { - role = "SignalSource" + boost::lexical_cast(ID); + if (ID != -1) + { + role = "SignalSource" + std::to_string(ID); + } + } + catch (const std::exception &e) + { + LOG(WARNING) << e.what(); } std::string implementation = configuration->property(role + ".implementation", default_implementation); LOG(INFO) << "Getting SignalSource with implementation " << implementation; @@ -188,15 +194,20 @@ std::unique_ptr GNSSBlockFactory::GetSignalConditioner( std::string role_datatypeadapter = "DataTypeAdapter"; std::string role_inputfilter = "InputFilter"; std::string role_resampler = "Resampler"; - - if (ID != -1) + try { - role_conditioner = "SignalConditioner" + boost::lexical_cast(ID); - role_datatypeadapter = "DataTypeAdapter" + boost::lexical_cast(ID); - role_inputfilter = "InputFilter" + boost::lexical_cast(ID); - role_resampler = "Resampler" + boost::lexical_cast(ID); + if (ID != -1) + { + role_conditioner = "SignalConditioner" + std::to_string(ID); + role_datatypeadapter = "DataTypeAdapter" + std::to_string(ID); + role_inputfilter = "InputFilter" + std::to_string(ID); + role_resampler = "Resampler" + std::to_string(ID); + } + } + catch (const std::exception &e) + { + LOG(WARNING) << e.what(); } - std::string signal_conditioner = configuration->property(role_conditioner + ".implementation", default_implementation); std::string data_type_adapter; @@ -293,31 +304,31 @@ std::unique_ptr GNSSBlockFactory::GetChannel_1C( LOG(INFO) << "Instantiating Channel " << channel << " with Acquisition Implementation: " << acq << ", Tracking Implementation: " << trk << ", Telemetry Decoder implementation: " << tlm; - std::string aux = configuration->property("Acquisition_1C" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + std::string aux = configuration->property("Acquisition_1C" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix1; if (aux.compare("W") != 0) { - appendix1 = boost::lexical_cast(channel); + appendix1 = std::to_string(channel); } else { appendix1 = ""; } - aux = configuration->property("Tracking_1C" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + aux = configuration->property("Tracking_1C" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix2; if (aux.compare("W") != 0) { - appendix2 = boost::lexical_cast(channel); + appendix2 = std::to_string(channel); } else { appendix2 = ""; } - aux = configuration->property("TelemetryDecoder_1C" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + aux = configuration->property("TelemetryDecoder_1C" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix3; if (aux.compare("W") != 0) { - appendix3 = boost::lexical_cast(channel); + appendix3 = std::to_string(channel); } else { @@ -358,31 +369,31 @@ std::unique_ptr GNSSBlockFactory::GetChannel_2S( { LOG(INFO) << "Instantiating Channel " << channel << " with Acquisition Implementation: " << acq << ", Tracking Implementation: " << trk << ", Telemetry Decoder implementation: " << tlm; - std::string aux = configuration->property("Acquisition_2S" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + std::string aux = configuration->property("Acquisition_2S" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix1; if (aux.compare("W") != 0) { - appendix1 = boost::lexical_cast(channel); + appendix1 = std::to_string(channel); } else { appendix1 = ""; } - aux = configuration->property("Tracking_2S" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + aux = configuration->property("Tracking_2S" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix2; if (aux.compare("W") != 0) { - appendix2 = boost::lexical_cast(channel); + appendix2 = std::to_string(channel); } else { appendix2 = ""; } - aux = configuration->property("TelemetryDecoder_2S" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + aux = configuration->property("TelemetryDecoder_2S" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix3; if (aux.compare("W") != 0) { - appendix3 = boost::lexical_cast(channel); + appendix3 = std::to_string(channel); } else { @@ -426,31 +437,31 @@ std::unique_ptr GNSSBlockFactory::GetChannel_1B( std::string id = stream.str(); LOG(INFO) << "Instantiating Channel " << id << " with Acquisition Implementation: " << acq << ", Tracking Implementation: " << trk << ", Telemetry Decoder implementation: " << tlm; - std::string aux = configuration->property("Acquisition_1B" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + std::string aux = configuration->property("Acquisition_1B" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix1; if (aux.compare("W") != 0) { - appendix1 = boost::lexical_cast(channel); + appendix1 = std::to_string(channel); } else { appendix1 = ""; } - aux = configuration->property("Tracking_1B" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + aux = configuration->property("Tracking_1B" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix2; if (aux.compare("W") != 0) { - appendix2 = boost::lexical_cast(channel); + appendix2 = std::to_string(channel); } else { appendix2 = ""; } - aux = configuration->property("TelemetryDecoder_1B" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + aux = configuration->property("TelemetryDecoder_1B" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix3; if (aux.compare("W") != 0) { - appendix3 = boost::lexical_cast(channel); + appendix3 = std::to_string(channel); } else { @@ -494,31 +505,31 @@ std::unique_ptr GNSSBlockFactory::GetChannel_5X( std::string id = stream.str(); LOG(INFO) << "Instantiating Channel " << id << " with Acquisition Implementation: " << acq << ", Tracking Implementation: " << trk << ", Telemetry Decoder implementation: " << tlm; - std::string aux = configuration->property("Acquisition_5X" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + std::string aux = configuration->property("Acquisition_5X" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix1; if (aux.compare("W") != 0) { - appendix1 = boost::lexical_cast(channel); + appendix1 = std::to_string(channel); } else { appendix1 = ""; } - aux = configuration->property("Tracking_5X" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + aux = configuration->property("Tracking_5X" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix2; if (aux.compare("W") != 0) { - appendix2 = boost::lexical_cast(channel); + appendix2 = std::to_string(channel); } else { appendix2 = ""; } - aux = configuration->property("TelemetryDecoder_5X" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + aux = configuration->property("TelemetryDecoder_5X" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix3; if (aux.compare("W") != 0) { - appendix3 = boost::lexical_cast(channel); + appendix3 = std::to_string(channel); } else { @@ -563,31 +574,31 @@ std::unique_ptr GNSSBlockFactory::GetChannel_1G( LOG(INFO) << "Instantiating Channel " << channel << " with Acquisition Implementation: " << acq << ", Tracking Implementation: " << trk << ", Telemetry Decoder Implementation: " << tlm; - std::string aux = configuration->property("Acquisition_1G" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + std::string aux = configuration->property("Acquisition_1G" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix1; if (aux.compare("W") != 0) { - appendix1 = boost::lexical_cast(channel); + appendix1 = std::to_string(channel); } else { appendix1 = ""; } - aux = configuration->property("Tracking_1G" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + aux = configuration->property("Tracking_1G" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix2; if (aux.compare("W") != 0) { - appendix2 = boost::lexical_cast(channel); + appendix2 = std::to_string(channel); } else { appendix2 = ""; } - aux = configuration->property("TelemetryDecoder_1G" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + aux = configuration->property("TelemetryDecoder_1G" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix3; if (aux.compare("W") != 0) { - appendix3 = boost::lexical_cast(channel); + appendix3 = std::to_string(channel); } else { @@ -632,31 +643,31 @@ std::unique_ptr GNSSBlockFactory::GetChannel_2G( LOG(INFO) << "Instantiating Channel " << channel << " with Acquisition Implementation: " << acq << ", Tracking Implementation: " << trk << ", Telemetry Decoder Implementation: " << tlm; - std::string aux = configuration->property("Acquisition_2G" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + std::string aux = configuration->property("Acquisition_2G" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix1; if (aux.compare("W") != 0) { - appendix1 = boost::lexical_cast(channel); + appendix1 = std::to_string(channel); } else { appendix1 = ""; } - aux = configuration->property("Tracking_2G" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + aux = configuration->property("Tracking_2G" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix2; if (aux.compare("W") != 0) { - appendix2 = boost::lexical_cast(channel); + appendix2 = std::to_string(channel); } else { appendix2 = ""; } - aux = configuration->property("TelemetryDecoder_2G" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + aux = configuration->property("TelemetryDecoder_2G" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix3; if (aux.compare("W") != 0) { - appendix3 = boost::lexical_cast(channel); + appendix3 = std::to_string(channel); } else { @@ -700,31 +711,31 @@ std::unique_ptr GNSSBlockFactory::GetChannel_L5( std::string id = stream.str(); LOG(INFO) << "Instantiating Channel " << id << " with Acquisition Implementation: " << acq << ", Tracking Implementation: " << trk << ", Telemetry Decoder implementation: " << tlm; - std::string aux = configuration->property("Acquisition_L5" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + std::string aux = configuration->property("Acquisition_L5" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix1; if (aux.compare("W") != 0) { - appendix1 = boost::lexical_cast(channel); + appendix1 = std::to_string(channel); } else { appendix1 = ""; } - aux = configuration->property("Tracking_L5" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + aux = configuration->property("Tracking_L5" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix2; if (aux.compare("W") != 0) { - appendix2 = boost::lexical_cast(channel); + appendix2 = std::to_string(channel); } else { appendix2 = ""; } - aux = configuration->property("TelemetryDecoder_L5" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + aux = configuration->property("TelemetryDecoder_L5" + std::to_string(channel) + ".implementation", std::string("W")); std::string appendix3; if (aux.compare("W") != 0) { - appendix3 = boost::lexical_cast(channel); + appendix3 = std::to_string(channel); } else { @@ -768,227 +779,233 @@ std::unique_ptr>> GNSSBlockFacto unsigned int channel_absolute_id = 0; unsigned int Channels_1C_count = configuration->property("Channels_1C.count", 0); - unsigned int Channels_2S_count = configuration->property("Channels_2S.count", 0); unsigned int Channels_1B_count = configuration->property("Channels_1B.count", 0); - unsigned int Channels_5X_count = configuration->property("Channels_5X.count", 0); unsigned int Channels_1G_count = configuration->property("Channels_1G.count", 0); unsigned int Channels_2G_count = configuration->property("Channels_2G.count", 0); + unsigned int Channels_2S_count = configuration->property("Channels_2S.count", 0); + unsigned int Channels_5X_count = configuration->property("Channels_5X.count", 0); unsigned int Channels_L5_count = configuration->property("Channels_L5.count", 0); unsigned int total_channels = Channels_1C_count + - Channels_2S_count + Channels_1B_count + - Channels_5X_count + Channels_1G_count + + Channels_2S_count + Channels_2G_count + + Channels_5X_count + Channels_L5_count; std::unique_ptr>> channels(new std::vector>(total_channels)); - - //**************** GPS L1 C/A CHANNELS ********************** - LOG(INFO) << "Getting " << Channels_1C_count << " GPS L1 C/A channels"; - acquisition_implementation = configuration->property("Acquisition_1C.implementation", default_implementation); - tracking_implementation = configuration->property("Tracking_1C.implementation", default_implementation); - telemetry_decoder_implementation = configuration->property("TelemetryDecoder_1C.implementation", default_implementation); - - for (unsigned int i = 0; i < Channels_1C_count; i++) + try { - //(i.e. Acquisition_1C0.implementation=xxxx) - std::string acquisition_implementation_specific = configuration->property( - "Acquisition_1C" + boost::lexical_cast(channel_absolute_id) + ".implementation", - acquisition_implementation); - //(i.e. Tracking_1C0.implementation=xxxx) - std::string tracking_implementation_specific = configuration->property( - "Tracking_1C" + boost::lexical_cast(channel_absolute_id) + ".implementation", - tracking_implementation); - std::string telemetry_decoder_implementation_specific = configuration->property( - "TelemetryDecoder_1C" + boost::lexical_cast(channel_absolute_id) + ".implementation", - telemetry_decoder_implementation); + //**************** GPS L1 C/A CHANNELS ********************** + LOG(INFO) << "Getting " << Channels_1C_count << " GPS L1 C/A channels"; + acquisition_implementation = configuration->property("Acquisition_1C.implementation", default_implementation); + tracking_implementation = configuration->property("Tracking_1C.implementation", default_implementation); + telemetry_decoder_implementation = configuration->property("TelemetryDecoder_1C.implementation", default_implementation); - // Push back the channel to the vector of channels - channels->at(channel_absolute_id) = std::move(GetChannel_1C(configuration, - acquisition_implementation_specific, - tracking_implementation_specific, - telemetry_decoder_implementation_specific, - channel_absolute_id, - queue)); - channel_absolute_id++; + for (unsigned int i = 0; i < Channels_1C_count; i++) + { + //(i.e. Acquisition_1C0.implementation=xxxx) + std::string acquisition_implementation_specific = configuration->property( + "Acquisition_1C" + std::to_string(channel_absolute_id) + ".implementation", + acquisition_implementation); + //(i.e. Tracking_1C0.implementation=xxxx) + std::string tracking_implementation_specific = configuration->property( + "Tracking_1C" + std::to_string(channel_absolute_id) + ".implementation", + tracking_implementation); + std::string telemetry_decoder_implementation_specific = configuration->property( + "TelemetryDecoder_1C" + std::to_string(channel_absolute_id) + ".implementation", + telemetry_decoder_implementation); + + // Push back the channel to the vector of channels + channels->at(channel_absolute_id) = std::move(GetChannel_1C(configuration, + acquisition_implementation_specific, + tracking_implementation_specific, + telemetry_decoder_implementation_specific, + channel_absolute_id, + queue)); + channel_absolute_id++; + } + + //**************** GPS L2C (M) CHANNELS ********************** + LOG(INFO) << "Getting " << Channels_2S_count << " GPS L2C (M) channels"; + tracking_implementation = configuration->property("Tracking_2S.implementation", default_implementation); + telemetry_decoder_implementation = configuration->property("TelemetryDecoder_2S.implementation", default_implementation); + acquisition_implementation = configuration->property("Acquisition_2S.implementation", default_implementation); + for (unsigned int i = 0; i < Channels_2S_count; i++) + { + //(i.e. Acquisition_1C0.implementation=xxxx) + std::string acquisition_implementation_specific = configuration->property( + "Acquisition_2S" + std::to_string(channel_absolute_id) + ".implementation", + acquisition_implementation); + //(i.e. Tracking_1C0.implementation=xxxx) + std::string tracking_implementation_specific = configuration->property( + "Tracking_2S" + std::to_string(channel_absolute_id) + ".implementation", + tracking_implementation); + std::string telemetry_decoder_implementation_specific = configuration->property( + "TelemetryDecoder_2S" + std::to_string(channel_absolute_id) + ".implementation", + telemetry_decoder_implementation); + + // Push back the channel to the vector of channels + channels->at(channel_absolute_id) = std::move(GetChannel_2S(configuration, + acquisition_implementation_specific, + tracking_implementation_specific, + telemetry_decoder_implementation_specific, + channel_absolute_id, + queue)); + channel_absolute_id++; + } + + //**************** GPS L5 CHANNELS ********************** + LOG(INFO) << "Getting " << Channels_L5_count << " GPS L5 channels"; + tracking_implementation = configuration->property("Tracking_L5.implementation", default_implementation); + telemetry_decoder_implementation = configuration->property("TelemetryDecoder_L5.implementation", default_implementation); + acquisition_implementation = configuration->property("Acquisition_L5.implementation", default_implementation); + for (unsigned int i = 0; i < Channels_L5_count; i++) + { + //(i.e. Acquisition_1C0.implementation=xxxx) + std::string acquisition_implementation_specific = configuration->property( + "Acquisition_L5" + std::to_string(channel_absolute_id) + ".implementation", + acquisition_implementation); + //(i.e. Tracking_1C0.implementation=xxxx) + std::string tracking_implementation_specific = configuration->property( + "Tracking_L5" + std::to_string(channel_absolute_id) + ".implementation", + tracking_implementation); + std::string telemetry_decoder_implementation_specific = configuration->property( + "TelemetryDecoder_L5" + std::to_string(channel_absolute_id) + ".implementation", + telemetry_decoder_implementation); + + // Push back the channel to the vector of channels + channels->at(channel_absolute_id) = std::move(GetChannel_L5(configuration, + acquisition_implementation_specific, + tracking_implementation_specific, + telemetry_decoder_implementation_specific, + channel_absolute_id, + queue)); + channel_absolute_id++; + } + + //**************** GALILEO E1 B (I/NAV OS) CHANNELS ********************** + LOG(INFO) << "Getting " << Channels_1B_count << " GALILEO E1 B (I/NAV OS) channels"; + tracking_implementation = configuration->property("Tracking_1B.implementation", default_implementation); + telemetry_decoder_implementation = configuration->property("TelemetryDecoder_1B.implementation", default_implementation); + acquisition_implementation = configuration->property("Acquisition_1B.implementation", default_implementation); + for (unsigned int i = 0; i < Channels_1B_count; i++) + { + //(i.e. Acquisition_1C0.implementation=xxxx) + std::string acquisition_implementation_specific = configuration->property( + "Acquisition_1B" + std::to_string(channel_absolute_id) + ".implementation", + acquisition_implementation); + //(i.e. Tracking_1C0.implementation=xxxx) + std::string tracking_implementation_specific = configuration->property( + "Tracking_1B" + std::to_string(channel_absolute_id) + ".implementation", + tracking_implementation); + std::string telemetry_decoder_implementation_specific = configuration->property( + "TelemetryDecoder_1B" + std::to_string(channel_absolute_id) + ".implementation", + telemetry_decoder_implementation); + + // Push back the channel to the vector of channels + channels->at(channel_absolute_id) = std::move(GetChannel_1B(configuration, + acquisition_implementation_specific, + tracking_implementation_specific, + telemetry_decoder_implementation_specific, + channel_absolute_id, + queue)); + channel_absolute_id++; + } + + //**************** GALILEO E5a I (F/NAV OS) CHANNELS ********************** + LOG(INFO) << "Getting " << Channels_5X_count << " GALILEO E5a I (F/NAV OS) channels"; + tracking_implementation = configuration->property("Tracking_5X.implementation", default_implementation); + telemetry_decoder_implementation = configuration->property("TelemetryDecoder_5X.implementation", default_implementation); + acquisition_implementation = configuration->property("Acquisition_5X.implementation", default_implementation); + for (unsigned int i = 0; i < Channels_5X_count; i++) + { + //(i.e. Acquisition_1C0.implementation=xxxx) + std::string acquisition_implementation_specific = configuration->property( + "Acquisition_5X" + std::to_string(channel_absolute_id) + ".implementation", + acquisition_implementation); + //(i.e. Tracking_1C0.implementation=xxxx) + std::string tracking_implementation_specific = configuration->property( + "Tracking_5X" + std::to_string(channel_absolute_id) + ".implementation", + tracking_implementation); + std::string telemetry_decoder_implementation_specific = configuration->property( + "TelemetryDecoder_5X" + std::to_string(channel_absolute_id) + ".implementation", + telemetry_decoder_implementation); + + // Push back the channel to the vector of channels + channels->at(channel_absolute_id) = std::move(GetChannel_5X(configuration, + acquisition_implementation_specific, + tracking_implementation_specific, + telemetry_decoder_implementation_specific, + channel_absolute_id, + queue)); + channel_absolute_id++; + } + + //**************** GLONASS L1 C/A CHANNELS ********************** + LOG(INFO) << "Getting " << Channels_1G_count << " GLONASS L1 C/A channels"; + acquisition_implementation = configuration->property("Acquisition_1G.implementation", default_implementation); + tracking_implementation = configuration->property("Tracking_1G.implementation", default_implementation); + telemetry_decoder_implementation = configuration->property("TelemetryDecoder_1G.implementation", default_implementation); + + for (unsigned int i = 0; i < Channels_1G_count; i++) + { + //(i.e. Acquisition_1G0.implementation=xxxx) + std::string acquisition_implementation_specific = configuration->property( + "Acquisition_1G" + std::to_string(channel_absolute_id) + ".implementation", + acquisition_implementation); + //(i.e. Tracking_1G0.implementation=xxxx) + std::string tracking_implementation_specific = configuration->property( + "Tracking_1G" + std::to_string(channel_absolute_id) + ".implementation", + tracking_implementation); + std::string telemetry_decoder_implementation_specific = configuration->property( + "TelemetryDecoder_1G" + std::to_string(channel_absolute_id) + ".implementation", + telemetry_decoder_implementation); + + // Push back the channel to the vector of channels + channels->at(channel_absolute_id) = std::move(GetChannel_1G(configuration, + acquisition_implementation_specific, + tracking_implementation_specific, + telemetry_decoder_implementation_specific, + channel_absolute_id, + queue)); + channel_absolute_id++; + } + + //**************** GLONASS L2 C/A CHANNELS ********************** + LOG(INFO) << "Getting " << Channels_2G_count << " GLONASS L2 C/A channels"; + acquisition_implementation = configuration->property("Acquisition_2G.implementation", default_implementation); + tracking_implementation = configuration->property("Tracking_2G.implementation", default_implementation); + telemetry_decoder_implementation = configuration->property("TelemetryDecoder_2G.implementation", default_implementation); + + for (unsigned int i = 0; i < Channels_2G_count; i++) + { + //(i.e. Acquisition_2G0.implementation=xxxx) + std::string acquisition_implementation_specific = configuration->property( + "Acquisition_2G" + std::to_string(channel_absolute_id) + ".implementation", + acquisition_implementation); + //(i.e. Tracking_2G0.implementation=xxxx) + std::string tracking_implementation_specific = configuration->property( + "Tracking_2G" + std::to_string(channel_absolute_id) + ".implementation", + tracking_implementation); + std::string telemetry_decoder_implementation_specific = configuration->property( + "TelemetryDecoder_2G" + std::to_string(channel_absolute_id) + ".implementation", + telemetry_decoder_implementation); + + // Push back the channel to the vector of channels + channels->at(channel_absolute_id) = std::move(GetChannel_2G(configuration, + acquisition_implementation_specific, + tracking_implementation_specific, + telemetry_decoder_implementation_specific, + channel_absolute_id, + queue)); + channel_absolute_id++; + } } - - //**************** GPS L2C (M) CHANNELS ********************** - LOG(INFO) << "Getting " << Channels_2S_count << " GPS L2C (M) channels"; - tracking_implementation = configuration->property("Tracking_2S.implementation", default_implementation); - telemetry_decoder_implementation = configuration->property("TelemetryDecoder_2S.implementation", default_implementation); - acquisition_implementation = configuration->property("Acquisition_2S.implementation", default_implementation); - for (unsigned int i = 0; i < Channels_2S_count; i++) + catch (const std::exception &e) { - //(i.e. Acquisition_1C0.implementation=xxxx) - std::string acquisition_implementation_specific = configuration->property( - "Acquisition_2S" + boost::lexical_cast(channel_absolute_id) + ".implementation", - acquisition_implementation); - //(i.e. Tracking_1C0.implementation=xxxx) - std::string tracking_implementation_specific = configuration->property( - "Tracking_2S" + boost::lexical_cast(channel_absolute_id) + ".implementation", - tracking_implementation); - std::string telemetry_decoder_implementation_specific = configuration->property( - "TelemetryDecoder_2S" + boost::lexical_cast(channel_absolute_id) + ".implementation", - telemetry_decoder_implementation); - - // Push back the channel to the vector of channels - channels->at(channel_absolute_id) = std::move(GetChannel_2S(configuration, - acquisition_implementation_specific, - tracking_implementation_specific, - telemetry_decoder_implementation_specific, - channel_absolute_id, - queue)); - channel_absolute_id++; - } - - //**************** GPS L5 CHANNELS ********************** - LOG(INFO) << "Getting " << Channels_L5_count << " GPS L5 channels"; - tracking_implementation = configuration->property("Tracking_L5.implementation", default_implementation); - telemetry_decoder_implementation = configuration->property("TelemetryDecoder_L5.implementation", default_implementation); - acquisition_implementation = configuration->property("Acquisition_L5.implementation", default_implementation); - for (unsigned int i = 0; i < Channels_L5_count; i++) - { - //(i.e. Acquisition_1C0.implementation=xxxx) - std::string acquisition_implementation_specific = configuration->property( - "Acquisition_L5" + boost::lexical_cast(channel_absolute_id) + ".implementation", - acquisition_implementation); - //(i.e. Tracking_1C0.implementation=xxxx) - std::string tracking_implementation_specific = configuration->property( - "Tracking_L5" + boost::lexical_cast(channel_absolute_id) + ".implementation", - tracking_implementation); - std::string telemetry_decoder_implementation_specific = configuration->property( - "TelemetryDecoder_L5" + boost::lexical_cast(channel_absolute_id) + ".implementation", - telemetry_decoder_implementation); - - // Push back the channel to the vector of channels - channels->at(channel_absolute_id) = std::move(GetChannel_L5(configuration, - acquisition_implementation_specific, - tracking_implementation_specific, - telemetry_decoder_implementation_specific, - channel_absolute_id, - queue)); - channel_absolute_id++; - } - - //**************** GALILEO E1 B (I/NAV OS) CHANNELS ********************** - LOG(INFO) << "Getting " << Channels_1B_count << " GALILEO E1 B (I/NAV OS) channels"; - tracking_implementation = configuration->property("Tracking_1B.implementation", default_implementation); - telemetry_decoder_implementation = configuration->property("TelemetryDecoder_1B.implementation", default_implementation); - acquisition_implementation = configuration->property("Acquisition_1B.implementation", default_implementation); - for (unsigned int i = 0; i < Channels_1B_count; i++) - { - //(i.e. Acquisition_1C0.implementation=xxxx) - std::string acquisition_implementation_specific = configuration->property( - "Acquisition_1B" + boost::lexical_cast(channel_absolute_id) + ".implementation", - acquisition_implementation); - //(i.e. Tracking_1C0.implementation=xxxx) - std::string tracking_implementation_specific = configuration->property( - "Tracking_1B" + boost::lexical_cast(channel_absolute_id) + ".implementation", - tracking_implementation); - std::string telemetry_decoder_implementation_specific = configuration->property( - "TelemetryDecoder_1B" + boost::lexical_cast(channel_absolute_id) + ".implementation", - telemetry_decoder_implementation); - - // Push back the channel to the vector of channels - channels->at(channel_absolute_id) = std::move(GetChannel_1B(configuration, - acquisition_implementation_specific, - tracking_implementation_specific, - telemetry_decoder_implementation_specific, - channel_absolute_id, - queue)); - channel_absolute_id++; - } - - //**************** GALILEO E5a I (F/NAV OS) CHANNELS ********************** - LOG(INFO) << "Getting " << Channels_5X_count << " GALILEO E5a I (F/NAV OS) channels"; - tracking_implementation = configuration->property("Tracking_5X.implementation", default_implementation); - telemetry_decoder_implementation = configuration->property("TelemetryDecoder_5X.implementation", default_implementation); - acquisition_implementation = configuration->property("Acquisition_5X.implementation", default_implementation); - for (unsigned int i = 0; i < Channels_5X_count; i++) - { - //(i.e. Acquisition_1C0.implementation=xxxx) - std::string acquisition_implementation_specific = configuration->property( - "Acquisition_5X" + boost::lexical_cast(channel_absolute_id) + ".implementation", - acquisition_implementation); - //(i.e. Tracking_1C0.implementation=xxxx) - std::string tracking_implementation_specific = configuration->property( - "Tracking_5X" + boost::lexical_cast(channel_absolute_id) + ".implementation", - tracking_implementation); - std::string telemetry_decoder_implementation_specific = configuration->property( - "TelemetryDecoder_5X" + boost::lexical_cast(channel_absolute_id) + ".implementation", - telemetry_decoder_implementation); - - // Push back the channel to the vector of channels - channels->at(channel_absolute_id) = std::move(GetChannel_5X(configuration, - acquisition_implementation_specific, - tracking_implementation_specific, - telemetry_decoder_implementation_specific, - channel_absolute_id, - queue)); - channel_absolute_id++; - } - - //**************** GLONASS L1 C/A CHANNELS ********************** - LOG(INFO) << "Getting " << Channels_1G_count << " GLONASS L1 C/A channels"; - acquisition_implementation = configuration->property("Acquisition_1G.implementation", default_implementation); - tracking_implementation = configuration->property("Tracking_1G.implementation", default_implementation); - telemetry_decoder_implementation = configuration->property("TelemetryDecoder_1G.implementation", default_implementation); - - for (unsigned int i = 0; i < Channels_1G_count; i++) - { - //(i.e. Acquisition_1G0.implementation=xxxx) - std::string acquisition_implementation_specific = configuration->property( - "Acquisition_1G" + boost::lexical_cast(channel_absolute_id) + ".implementation", - acquisition_implementation); - //(i.e. Tracking_1G0.implementation=xxxx) - std::string tracking_implementation_specific = configuration->property( - "Tracking_1G" + boost::lexical_cast(channel_absolute_id) + ".implementation", - tracking_implementation); - std::string telemetry_decoder_implementation_specific = configuration->property( - "TelemetryDecoder_1G" + boost::lexical_cast(channel_absolute_id) + ".implementation", - telemetry_decoder_implementation); - - // Push back the channel to the vector of channels - channels->at(channel_absolute_id) = std::move(GetChannel_1G(configuration, - acquisition_implementation_specific, - tracking_implementation_specific, - telemetry_decoder_implementation_specific, - channel_absolute_id, - queue)); - channel_absolute_id++; - } - - //**************** GLONASS L2 C/A CHANNELS ********************** - LOG(INFO) << "Getting " << Channels_2G_count << " GLONASS L2 C/A channels"; - acquisition_implementation = configuration->property("Acquisition_2G.implementation", default_implementation); - tracking_implementation = configuration->property("Tracking_2G.implementation", default_implementation); - telemetry_decoder_implementation = configuration->property("TelemetryDecoder_2G.implementation", default_implementation); - - for (unsigned int i = 0; i < Channels_2G_count; i++) - { - //(i.e. Acquisition_2G0.implementation=xxxx) - std::string acquisition_implementation_specific = configuration->property( - "Acquisition_2G" + boost::lexical_cast(channel_absolute_id) + ".implementation", - acquisition_implementation); - //(i.e. Tracking_2G0.implementation=xxxx) - std::string tracking_implementation_specific = configuration->property( - "Tracking_2G" + boost::lexical_cast(channel_absolute_id) + ".implementation", - tracking_implementation); - std::string telemetry_decoder_implementation_specific = configuration->property( - "TelemetryDecoder_2G" + boost::lexical_cast(channel_absolute_id) + ".implementation", - telemetry_decoder_implementation); - - // Push back the channel to the vector of channels - channels->at(channel_absolute_id) = std::move(GetChannel_2G(configuration, - acquisition_implementation_specific, - tracking_implementation_specific, - telemetry_decoder_implementation_specific, - channel_absolute_id, - queue)); - channel_absolute_id++; + LOG(WARNING) << e.what(); } return channels; diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 7085f9394..c12c126ae 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -310,7 +310,6 @@ void GNSSFlowgraph::connect() return; } } - #else // connect the signal source to sample counter // connect the sample counter to Observables @@ -341,7 +340,14 @@ void GNSSFlowgraph::connect() { if (FPGA_enabled == false) { - selected_signal_conditioner_ID = configuration_->property("Channel" + boost::lexical_cast(i) + ".RF_channel_ID", 0); + try + { + selected_signal_conditioner_ID = configuration_->property("Channel" + std::to_string(i) + ".RF_channel_ID", 0); + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } try { top_block_->connect(sig_conditioner_.at(selected_signal_conditioner_ID)->get_right_block(), 0, @@ -376,7 +382,15 @@ void GNSSFlowgraph::connect() std::vector vector_of_channels; for (unsigned int i = 0; i < channels_count_; i++) { - unsigned int sat = configuration_->property("Channel" + boost::lexical_cast(i) + ".satellite", 0); + unsigned int sat = 0; + try + { + sat = configuration_->property("Channel" + std::to_string(i) + ".satellite", 0); + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } if (sat == 0) { vector_of_channels.push_back(i); @@ -392,7 +406,15 @@ void GNSSFlowgraph::connect() for (unsigned int& i : vector_of_channels) { std::string gnss_signal = channels_.at(i)->get_signal().get_signal_str(); // use channel's implicit signal - unsigned int sat = configuration_->property("Channel" + boost::lexical_cast(i) + ".satellite", 0); + unsigned int sat = 0; + try + { + sat = configuration_->property("Channel" + std::to_string(i) + ".satellite", 0); + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } if (sat == 0) { channels_.at(i)->set_signal(search_next_signal(gnss_signal, true)); @@ -459,7 +481,7 @@ void GNSSFlowgraph::disconnect() LOG(INFO) << "flowgraph was not connected"; return; } - + connected_ = false; // Signal Source (i) > Signal conditioner (i) > int RF_Channels = 0; int signal_conditioner_ID = 0; @@ -511,24 +533,77 @@ void GNSSFlowgraph::disconnect() catch (const std::exception& e) { LOG(INFO) << "Can't disconnect signal source " << i << " to signal conditioner " << i << ": " << e.what(); + top_block_->disconnect_all(); + return; } } + bool FPGA_enabled = configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false); + +#if ENABLE_FPGA + if (FPGA_enabled == false) + { + // disconnect the signal source to sample counter + // disconnect the sample counter to Observables + try + { + top_block_->disconnect(sig_conditioner_.at(0)->get_right_block(), 0, ch_out_sample_counter, 0); + top_block_->disconnect(ch_out_sample_counter, 0, observables_->get_left_block(), channels_count_); // extra port for the sample counter pulse + } + catch (const std::exception& e) + { + LOG(WARNING) << "Can't disconnect sample counter"; + LOG(ERROR) << e.what(); + top_block_->disconnect_all(); + return; + } + } + else + { + try + { + top_block_->disconnect(null_source_, 0, throttle_, 0); + top_block_->disconnect(throttle_, 0, time_counter_, 0); + top_block_->disconnect(time_counter_, 0, observables_->get_left_block(), channels_count_); + } + catch (const std::exception& e) + { + LOG(WARNING) << "Can't connect sample counter"; + LOG(ERROR) << e.what(); + top_block_->disconnect_all(); + return; + } + } +#else + // disconnect the signal source to sample counter + // disconnect the sample counter to Observables try { top_block_->disconnect(sig_conditioner_.at(0)->get_right_block(), 0, ch_out_sample_counter, 0); - top_block_->disconnect(ch_out_sample_counter, 0, observables_->get_left_block(), channels_count_); //extra port for the sample counter pulse + top_block_->disconnect(ch_out_sample_counter, 0, observables_->get_left_block(), channels_count_); // extra port for the sample counter pulse } catch (const std::exception& e) { - LOG(INFO) << "Can't disconnect sample counter: " << e.what(); + LOG(WARNING) << "Can't connect sample counter"; + LOG(ERROR) << e.what(); + top_block_->disconnect_all(); + return; } - +#endif // Signal conditioner (selected_signal_source) >> channels (i) (dependent of their associated SignalSource_ID) int selected_signal_conditioner_ID; for (unsigned int i = 0; i < channels_count_; i++) { - selected_signal_conditioner_ID = configuration_->property("Channel" + boost::lexical_cast(i) + ".RF_channel_ID", 0); + try + { + selected_signal_conditioner_ID = configuration_->property("Channel" + std::to_string(i) + ".RF_channel_ID", 0); + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + top_block_->disconnect_all(); + return; + } try { top_block_->disconnect(sig_conditioner_.at(selected_signal_conditioner_ID)->get_right_block(), 0, @@ -537,6 +612,8 @@ void GNSSFlowgraph::disconnect() catch (const std::exception& e) { LOG(INFO) << "Can't disconnect signal conditioner " << selected_signal_conditioner_ID << " to channel " << i << ": " << e.what(); + top_block_->disconnect_all(); + return; } // Signal Source > Signal conditioner >> Channels >> Observables @@ -548,6 +625,8 @@ void GNSSFlowgraph::disconnect() catch (const std::exception& e) { LOG(INFO) << "Can't disconnect channel " << i << " to observables: " << e.what(); + top_block_->disconnect_all(); + return; } } @@ -562,6 +641,8 @@ void GNSSFlowgraph::disconnect() catch (const std::exception& e) { LOG(INFO) << "Can't disconnect observables to PVT: " << e.what(); + top_block_->disconnect_all(); + return; } for (int i = 0; i < sources_count_; i++) @@ -573,6 +654,8 @@ void GNSSFlowgraph::disconnect() catch (const std::exception& e) { LOG(INFO) << "Can't disconnect signal source block " << i << " internally: " << e.what(); + top_block_->disconnect_all(); + return; } } @@ -586,6 +669,8 @@ void GNSSFlowgraph::disconnect() catch (const std::exception& e) { LOG(INFO) << "Can't disconnect signal conditioner block " << i << " internally: " << e.what(); + top_block_->disconnect_all(); + return; } } @@ -598,6 +683,8 @@ void GNSSFlowgraph::disconnect() catch (const std::exception& e) { LOG(INFO) << "Can't disconnect channel " << i << " internally: " << e.what(); + top_block_->disconnect_all(); + return; } } @@ -608,6 +695,8 @@ void GNSSFlowgraph::disconnect() catch (const std::exception& e) { LOG(INFO) << "Can't disconnect observables block internally: " << e.what(); + top_block_->disconnect_all(); + return; } // Signal Source > Signal conditioner >> Channels >> Observables > PVT @@ -618,11 +707,11 @@ void GNSSFlowgraph::disconnect() catch (const std::exception& e) { LOG(INFO) << "Can't disconnect PVT block internally: " << e.what(); + top_block_->disconnect_all(); + return; } DLOG(INFO) << "blocks disconnected internally"; - - connected_ = false; LOG(INFO) << "Flowgraph disconnected"; } @@ -658,7 +747,15 @@ bool GNSSFlowgraph::send_telemetry_msg(pmt::pmt_t msg) void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) { DLOG(INFO) << "Received " << what << " from " << who << ". Number of applied actions = " << applied_actions_; - unsigned int sat = configuration_->property("Channel" + boost::lexical_cast(who) + ".satellite", 0); + unsigned int sat = 0; + try + { + sat = configuration_->property("Channel" + std::to_string(who) + ".satellite", 0); + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } switch (what) { case 0: @@ -679,7 +776,15 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) acq_channels_count_--; for (unsigned int i = 0; i < channels_count_; i++) { - unsigned int sat_ = configuration_->property("Channel" + boost::lexical_cast(i) + ".satellite", 0); + unsigned int sat_ = 0; + try + { + sat_ = configuration_->property("Channel" + std::to_string(i) + ".satellite", 0); + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } if (!available_GNSS_signals_.empty() && (acq_channels_count_ < max_acq_channels_) && (channels_state_[i] == 0)) { channels_state_[i] = 1; @@ -828,7 +933,7 @@ void GNSSFlowgraph::init() std::cout << "Please update your configuration file." << std::endl; } - std::shared_ptr > > channels = block_factory_->GetChannels(configuration_, queue_); + std::shared_ptr>> channels = block_factory_->GetChannels(configuration_, queue_); channels_count_ = channels->size(); for (unsigned int i = 0; i < channels_count_; i++)