[hamradio-commits] [gnss-sdr] 03/27: Improving thread management
Carles Fernandez
carles_fernandez-guest at moszumanska.debian.org
Wed Jan 14 09:07:40 UTC 2015
This is an automated email from the git hooks/post-receive script.
carles_fernandez-guest pushed a commit to branch master
in repository gnss-sdr.
commit 9b95919ddb2942a67f05b0098d449bd7ddb3d3f3
Author: Carles Fernandez <carles.fernandez at gmail.com>
Date: Sun Dec 21 22:46:57 2014 +0100
Improving thread management
---
CMakeLists.txt | 4 +-
README.md | 2 +-
src/algorithms/channel/adapters/CMakeLists.txt | 5 ++
src/algorithms/channel/adapters/channel.cc | 12 +++-
src/core/receiver/CMakeLists.txt | 3 +
src/core/receiver/control_thread.cc | 32 +++++++--
src/tests/CMakeLists.txt | 77 ++++++++++++++++++++--
src/tests/control_thread/control_thread_test.cc | 47 +++++++------
src/tests/flowgraph/gnss_flowgraph_test.cc | 44 ++++++-------
src/tests/flowgraph/pass_through_test.cc | 10 ++-
.../galileo_e1_dll_pll_veml_tracking_test.cc | 2 +-
...pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc | 18 ++++-
...ileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc | 14 +++-
...cps_tong_ambiguous_acquisition_gsoc2013_test.cc | 8 +++
.../gnss_block/gps_l1_ca_pcps_acquisition_test.cc | 31 +++++----
src/tests/test_main.cc | 4 +-
16 files changed, 221 insertions(+), 92 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c1cde59..a4ff3cd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -303,9 +303,9 @@ set(Boost_ADDITIONAL_VERSIONS
)
set(Boost_USE_MULTITHREAD ON)
set(Boost_USE_STATIC_LIBS OFF)
-find_package(Boost COMPONENTS date_time system filesystem thread serialization REQUIRED)
+find_package(Boost COMPONENTS date_time system filesystem thread serialization chrono REQUIRED)
if(NOT Boost_FOUND)
- message(FATAL_ERROR "Fatal error: Boost (version >=1.42.0) required.")
+ message(FATAL_ERROR "Fatal error: Boost (version >=1.45.0) required.")
endif(NOT Boost_FOUND)
diff --git a/README.md b/README.md
index 7bada58..74307ce 100644
--- a/README.md
+++ b/README.md
@@ -31,7 +31,7 @@ Before building GNSS-SDR, you need to install all the required dependencies. If
~~~~~~
$ sudo apt-get install build-essential cmake git libboost-dev libboost-date-time-dev \
- libboost-system-dev libboost-filesystem-dev libboost-thread-dev \
+ libboost-system-dev libboost-filesystem-dev libboost-thread-dev libboost-chrono-dev \
libboost-serialization-dev libboost-program-options-dev libboost-test-dev \
liblog4cpp5-dev libuhd-dev gnuradio-dev gr-osmosdr libblas-dev liblapack-dev gfortran \
libarmadillo-dev libgflags-dev libgoogle-glog-dev libssl-dev libgtest-dev
diff --git a/src/algorithms/channel/adapters/CMakeLists.txt b/src/algorithms/channel/adapters/CMakeLists.txt
index 09c8a15..5264ae3 100644
--- a/src/algorithms/channel/adapters/CMakeLists.txt
+++ b/src/algorithms/channel/adapters/CMakeLists.txt
@@ -18,6 +18,10 @@
set(CHANNEL_ADAPTER_SOURCES channel.cc)
+if(Boost_VERSION LESS 105000)
+ add_definitions(-DOLD_BOOST=1)
+endif(Boost_VERSION LESS 105000)
+
include_directories(
$(CMAKE_CURRENT_SOURCE_DIR)
${CMAKE_SOURCE_DIR}/src/core/system_parameters
@@ -26,6 +30,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/src/algorithms/channel/libs
${GLOG_INCLUDE_DIRS}
${GFlags_INCLUDE_DIRS}
+ ${Boost_INCLUDE_DIRS}
${GNURADIO_RUNTIME_INCLUDE_DIRS}
)
diff --git a/src/algorithms/channel/adapters/channel.cc b/src/algorithms/channel/adapters/channel.cc
index b720ed5..5c1b7ef 100644
--- a/src/algorithms/channel/adapters/channel.cc
+++ b/src/algorithms/channel/adapters/channel.cc
@@ -34,6 +34,8 @@
#include <sstream>
#include <boost/lexical_cast.hpp>
#include <boost/thread/thread.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/chrono.hpp>
#include <glog/logging.h>
#include <gnuradio/io_signature.h>
#include <gnuradio/message.h>
@@ -234,9 +236,15 @@ void Channel::stop()
* the boost::thread object must be used. join() will block the calling
* thread until the thread represented by the boost::thread object
* has completed.
- *
+ * NOTE: timed_join() is deprecated and only present up to Boost 1.56
+ * try_join_until() was introduced in Boost 1.50
*/
- ch_thread_.join();
+#ifdef OLD_BOOST
+ ch_thread_.timed_join(boost::posix_time::seconds(1));
+#endif
+#ifndef OLD_BOOST
+ ch_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50));
+#endif
}
diff --git a/src/core/receiver/CMakeLists.txt b/src/core/receiver/CMakeLists.txt
index e185f87..92521bf 100644
--- a/src/core/receiver/CMakeLists.txt
+++ b/src/core/receiver/CMakeLists.txt
@@ -64,6 +64,9 @@ include_directories(
${GNURADIO_RUNTIME_INCLUDE_DIRS}
)
+if(Boost_VERSION LESS 105000)
+ add_definitions(-DOLD_BOOST=1)
+endif(Boost_VERSION LESS 105000)
if(ENABLE_GN3S)
add_definitions(-DGN3S_DRIVER=1)
diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc
index f27c704..f68c397 100644
--- a/src/core/receiver/control_thread.cc
+++ b/src/core/receiver/control_thread.cc
@@ -19,7 +19,7 @@
* GNSS-SDR is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
- * at your option) any later version.
+ * (at your option) any later version.
*
* GNSS-SDR is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -40,6 +40,7 @@
#include <string>
#include <boost/lexical_cast.hpp>
#include <boost/thread/thread.hpp>
+#include <boost/chrono.hpp>
#include <gnuradio/message.h>
#include <gflags/gflags.h>
#include <glog/logging.h>
@@ -174,6 +175,7 @@ void ControlThread::run()
std::cout << "Stopping GNSS-SDR, please wait!" << std::endl;
flowgraph_->stop();
+#ifdef OLD_BOOST
// Join GPS threads
gps_ephemeris_data_collector_thread_.timed_join(boost::posix_time::seconds(1));
gps_iono_data_collector_thread_.timed_join(boost::posix_time::seconds(1));
@@ -190,6 +192,25 @@ void ControlThread::run()
//Join keyboard threads
keyboard_thread_.timed_join(boost::posix_time::seconds(1));
+#endif
+#ifndef OLD_BOOST
+ // Join GPS threads
+ gps_ephemeris_data_collector_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50));
+ gps_iono_data_collector_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50));
+ gps_utc_model_data_collector_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50));
+ gps_acq_assist_data_collector_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50));
+ gps_ref_location_data_collector_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50));
+ gps_ref_time_data_collector_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50));
+
+ //Join Galileo threads
+ galileo_ephemeris_data_collector_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50));
+ galileo_iono_data_collector_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50));
+ galileo_almanac_data_collector_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50));
+ galileo_utc_model_data_collector_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50));
+
+ //Join keyboard threads
+ keyboard_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50));
+#endif
LOG(INFO) << "Flowgraph stopped";
}
@@ -886,27 +907,26 @@ void ControlThread::galileo_utc_model_data_collector()
// Check the UTC timestamp. If it is newer, then update the ephemeris
if (galileo_utc.WNot_6 > galileo_utc_old.WNot_6) //further check because it is not clear when IOD is reset
{
- //std::cout << "UTC record updated --new GALILEO UTC Week Number ="<<galileo_utc.WNot_6<<std::endl;
+ DLOG(INFO) << "UTC record updated --new GALILEO UTC Week Number =" << galileo_utc.WNot_6;
global_galileo_utc_model_map.write(0, galileo_utc);
}
else
{
if (galileo_utc.t0t_6 > galileo_utc_old.t0t_6)
{
- //std::cout << "UTC record updated --new GALILEO UTC time of Week ="<<galileo_utc.t0t_6<<std::endl;
+ DLOG(INFO) << "UTC record updated --new GALILEO UTC time of Week =" << galileo_utc.t0t_6;
global_galileo_utc_model_map.write(0, galileo_utc);
- //std::cout << "GALILEO UTC time of Week old: " << galileo_utc_old.t0t_6<<std::endl;
}
else
{
- LOG(INFO) << "Not updating the existing UTC in global map, timestamp is not changing" << std::endl;
+ LOG(INFO) << "Not updating the existing UTC in global map, timestamp is not changing";
}
}
}
else
{
// insert new ephemeris record
- LOG(INFO) << "New UTC record inserted in global map" << std::endl;
+ LOG(INFO) << "New UTC record inserted in global map";
global_galileo_utc_model_map.write(0, galileo_utc);
}
}
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index a43eb91..36ca66a 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -111,6 +111,9 @@ if(ENABLE_GPERFTOOLS)
endif(GPERFTOOLS_FOUND)
endif(ENABLE_GPERFTOOLS)
+if(Boost_VERSION LESS 105000)
+ add_definitions(-DOLD_BOOST=1)
+endif(Boost_VERSION LESS 105000)
include_directories(
${GTEST_INCLUDE_DIRECTORIES}
@@ -193,7 +196,6 @@ target_link_libraries(run_tests ${CLANG_FLAGS}
#########################################################
# Adding Tests to Ctest
#########################################################
-# ToDo
set(CMAKE_CTEST_COMMAND ctest -V)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
@@ -201,7 +203,7 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
add_executable(control_thread_test EXCLUDE_FROM_ALL
${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc
${CMAKE_CURRENT_SOURCE_DIR}/control_thread/control_message_factory_test.cc
-# ${CMAKE_CURRENT_SOURCE_DIR}/control_thread/control_thread_test.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/control_thread/control_thread_test.cc
)
target_link_libraries(control_thread_test ${Boost_LIBRARIES}
@@ -214,15 +216,30 @@ target_link_libraries(control_thread_test ${Boost_LIBRARIES}
)
add_test(control_thread_test control_thread_test)
+set_property(TEST control_thread_test PROPERTY TIMEOUT 5)
+add_executable(flowgraph_test EXCLUDE_FROM_ALL
+ ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/flowgraph/gnss_flowgraph_test.cc
+)
+
+target_link_libraries(flowgraph_test ${Boost_LIBRARIES}
+ ${GFLAGS_LIBS}
+ ${GLOG_LIBRARIES}
+ ${GTEST_LIBRARIES}
+ gnss_sp_libs
+ gnss_rx
+ ${VOLK_GNSSSDR_LIBRARIES} ${ORC_LIBRARIES}
+ )
+
+add_test(flowgraph_test flowgraph_test)
+set_property(TEST flowgraph_test PROPERTY TIMEOUT 5)
add_executable(gnss_block_test EXCLUDE_FROM_ALL
${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc
${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/file_signal_source_test.cc
${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/fir_filter_test.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/gps_l1_ca_pcps_acquisition_test.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/galileo_e1_pcps_ambiguous_acquisition_test.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/galileo_e1_dll_pll_veml_tracking_test.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/flowgraph/pass_through_test.cc
${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/file_output_filter_test.cc
${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/gnss_block_factory_test.cc
)
@@ -237,11 +254,57 @@ target_link_libraries(gnss_block_test ${Boost_LIBRARIES}
gnss_sp_libs
gnss_rx
gnss_system_parameters
- signal_generator_blocks
+ # signal_generator_blocks
out_adapters
${VOLK_GNSSSDR_LIBRARIES} ${ORC_LIBRARIES}
)
add_test(gnss_block_test gnss_block_test)
-add_dependencies(check control_thread_test gnss_block_test)
+
+# add_executable(acq_test EXCLUDE_FROM_ALL
+# ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc
+# ${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/gps_l1_ca_pcps_acquisition_test.cc
+# ${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/galileo_e1_pcps_ambiguous_acquisition_test.cc
+# )
+# target_link_libraries(acq_test ${Boost_LIBRARIES}
+# ${GFLAGS_LIBS}
+# ${GLOG_LIBRARIES}
+# ${GTEST_LIBRARIES}
+# ${GNURADIO_RUNTIME_LIBRARIES}
+# ${GNURADIO_BLOCKS_LIBRARIES}
+# ${GNURADIO_FILTER_LIBRARIES}
+# ${GNURADIO_ANALOG_LIBRARIES}
+# gnss_sp_libs
+# gnss_rx
+# gnss_system_parameters
+# signal_generator_blocks
+# out_adapters
+# ${VOLK_GNSSSDR_LIBRARIES} ${ORC_LIBRARIES}
+# )
+# add_test(acq_test acq_test)
+
+add_executable(trk_test EXCLUDE_FROM_ALL
+ ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/galileo_e1_dll_pll_veml_tracking_test.cc
+)
+target_link_libraries(trk_test ${Boost_LIBRARIES}
+ ${GFLAGS_LIBS}
+ ${GLOG_LIBRARIES}
+ ${GTEST_LIBRARIES}
+ ${GNURADIO_RUNTIME_LIBRARIES}
+ ${GNURADIO_BLOCKS_LIBRARIES}
+ ${GNURADIO_FILTER_LIBRARIES}
+ ${GNURADIO_ANALOG_LIBRARIES}
+ gnss_sp_libs
+ gnss_rx
+ gnss_system_parameters
+ signal_generator_blocks
+ out_adapters
+ ${VOLK_GNSSSDR_LIBRARIES} ${ORC_LIBRARIES}
+ )
+
+add_test(trk_test trk_test)
+
+
+add_dependencies(check control_thread_test flowgraph_test gnss_block_test trk_test)
diff --git a/src/tests/control_thread/control_thread_test.cc b/src/tests/control_thread/control_thread_test.cc
index 002c74f..80e3e3b 100644
--- a/src/tests/control_thread/control_thread_test.cc
+++ b/src/tests/control_thread/control_thread_test.cc
@@ -7,7 +7,7 @@
*
* -------------------------------------------------------------------------
*
- * Copyright (C) 2010-2013 (see AUTHORS file for a list of contributors)
+ * Copyright (C) 2010-2014 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
@@ -17,7 +17,7 @@
* GNSS-SDR is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
- * at your option) any later version.
+ * (at your option) any later version.
*
* GNSS-SDR is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -62,10 +62,14 @@ TEST(Control_Thread_Test, InstantiateRunControlMessages)
config->set_property("SignalSource.repeat", "true");
config->set_property("SignalConditioner.implementation", "Pass_Through");
config->set_property("SignalConditioner.item_type", "gr_complex");
- config->set_property("Channels_GPS.count", "2");
+ config->set_property("Channels_GPS.count", "1");
+ config->set_property("Channels.in_acquisition", "1");
+ config->set_property("Channel.system", "GPS");
+ config->set_property("Channel.signal", "1C");
config->set_property("Acquisition_GPS.implementation", "GPS_L1_CA_PCPS_Acquisition");
- config->set_property("Acquisition_GPS.item_type", "gr_complex");
- config->set_property("Acquisition_GPS.threshold", "0.8");
+ config->set_property("Acquisition_GPS.threshold", "1");
+ config->set_property("Acquisition_GPS.doppler_max", "5000");
+ config->set_property("Acquisition_GPS.doppler_min", "-5000");
config->set_property("Tracking_GPS.implementation", "GPS_L1_CA_DLL_PLL_Tracking");
config->set_property("Tracking_GPS.item_type", "gr_complex");
config->set_property("TelemetryDecoder_GPS.implementation", "GPS_L1_CA_Telemetry_Decoder");
@@ -77,22 +81,12 @@ TEST(Control_Thread_Test, InstantiateRunControlMessages)
config->set_property("OutputFilter.implementation", "Null_Sink_Output_Filter");
config->set_property("OutputFilter.item_type", "gr_complex");
- std::unique_ptr<ControlThread> control_thread(new ControlThread(config));
+ std::shared_ptr<ControlThread> control_thread = std::make_shared<ControlThread>(config);
gr::msg_queue::sptr control_queue = gr::msg_queue::make(0);
- //ControlMessageFactory *control_msg_factory = new ControlMessageFactory();
- //try
- //{
- std::unique_ptr<ControlMessageFactory> control_msg_factory(new ControlMessageFactory());
- //}
- //catch( boost::exception & e )
- //{
- // std::cout << "Boost exception: " << boost::diagnostic_information(e);
- //}
- //catch(std::exception const& ex)
- //{
- // std::cout << "STD exception: " << ex.what();
- //}
+
+ std::unique_ptr<ControlMessageFactory> control_msg_factory(new ControlMessageFactory());
+
control_queue->handle(control_msg_factory->GetQueueMessage(0,0));
control_queue->handle(control_msg_factory->GetQueueMessage(1,0));
control_queue->handle(control_msg_factory->GetQueueMessage(200,0));
@@ -111,10 +105,10 @@ TEST(Control_Thread_Test, InstantiateRunControlMessages)
std::cout << "STD exception: " << ex.what();
}
- unsigned int expected3 = 3;
+ unsigned int expected0 = 0;
unsigned int expected1 = 1;
- EXPECT_EQ(expected3, control_thread->processed_control_messages());
- EXPECT_EQ(expected1, control_thread->applied_actions());
+ EXPECT_EQ(expected1, control_thread->processed_control_messages());
+ EXPECT_EQ(expected0, control_thread->applied_actions());
}
@@ -135,8 +129,13 @@ TEST(Control_Thread_Test, InstantiateRunControlMessages2)
config->set_property("SignalConditioner.implementation", "Pass_Through");
config->set_property("SignalConditioner.item_type", "gr_complex");
config->set_property("Channels_GPS.count", "1");
+ config->set_property("Channels.in_acquisition", "4");
+ config->set_property("Channel.system", "GPS");
+ config->set_property("Channel.signal", "1C");
config->set_property("Acquisition_GPS.implementation", "GPS_L1_CA_PCPS_Acquisition");
- config->set_property("Acquisition_GPS.item_type", "gr_complex");
+ config->set_property("Acquisition_GPS.threshold", "1");
+ config->set_property("Acquisition_GPS.doppler_max", "5000");
+ config->set_property("Acquisition_GPS.doppler_min", "-5000");
config->set_property("Tracking_GPS.implementation", "GPS_L1_CA_DLL_FLL_PLL_Tracking");
config->set_property("Tracking_GPS.item_type", "gr_complex");
config->set_property("TelemetryDecoder_GPS.implementation", "GPS_L1_CA_Telemetry_Decoder");
@@ -151,7 +150,7 @@ TEST(Control_Thread_Test, InstantiateRunControlMessages2)
std::unique_ptr<ControlThread> control_thread2(new ControlThread(config));
gr::msg_queue::sptr control_queue2 = gr::msg_queue::make(0);
- //ControlMessageFactory *control_msg_factory = new ControlMessageFactory();
+
std::unique_ptr<ControlMessageFactory> control_msg_factory2(new ControlMessageFactory());
control_queue2->handle(control_msg_factory2->GetQueueMessage(0,0));
diff --git a/src/tests/flowgraph/gnss_flowgraph_test.cc b/src/tests/flowgraph/gnss_flowgraph_test.cc
index 25e6745..2b35a79 100644
--- a/src/tests/flowgraph/gnss_flowgraph_test.cc
+++ b/src/tests/flowgraph/gnss_flowgraph_test.cc
@@ -17,7 +17,7 @@
* GNSS-SDR is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
- * at your option) any later version.
+ * (at your option) any later version.
*
* GNSS-SDR is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -31,6 +31,7 @@
*/
#include <gnuradio/msg_queue.h>
+#include <gtest/gtest.h>
#include "gnss_flowgraph.h"
#include "gnss_block_interface.h"
#include "in_memory_configuration.h"
@@ -48,45 +49,40 @@ TEST(GNSSFlowgraph, InstantiateConnectStartStop)
{
std::shared_ptr<ConfigurationInterface> config = std::make_shared<InMemoryConfiguration>();
+ config->set_property("GNSS-SDR.SUPL_gps_enabled", "false");
config->set_property("SignalSource.sampling_frequency", "4000000");
config->set_property("SignalSource.implementation", "File_Signal_Source");
config->set_property("SignalSource.item_type", "gr_complex");
+ config->set_property("SignalSource.repeat", "true");
std::string path = std::string(TEST_PATH);
std::string filename = path + "signal_samples/Galileo_E1_ID_1_Fs_4Msps_8ms.dat";
config->set_property("SignalSource.filename", filename);
config->set_property("SignalConditioner.implementation", "Pass_Through");
- config->set_property("Channels.count", "2");
- config->set_property("Acquisition.implementation", "GPS_L1_CA_PCPS_Acquisition");
- config->set_property("Tracking.implementation", "GPS_L1_CA_DLL_PLL_Tracking");
- config->set_property("TelemetryDecoder.implementation", "GPS_L1_CA_Telemetry_Decoder");
- //config->set_property("Channels.observables.implementation", "Pass_Through");
+ config->set_property("Channels_GPS.count", "1");
+ config->set_property("Channels.in_acquisition", "1");
+ config->set_property("Channel.system", "GPS");
+ config->set_property("Channel.signal", "1C");
+ config->set_property("Acquisition_GPS.implementation", "GPS_L1_CA_PCPS_Acquisition");
+ config->set_property("Acquisition_GPS.threshold", "1");
+ config->set_property("Acquisition_GPS.doppler_max", "5000");
+ config->set_property("Acquisition_GPS.doppler_min", "-5000");
+ config->set_property("Tracking_GPS.implementation", "GPS_L1_CA_DLL_PLL_Tracking");
+ config->set_property("TelemetryDecoder_GPS.implementation", "GPS_L1_CA_Telemetry_Decoder");
config->set_property("Observables.implementation", "GPS_L1_CA_Observables");
config->set_property("PVT.implementation", "GPS_L1_CA_PVT");
config->set_property("OutputFilter.implementation", "Null_Sink_Output_Filter");
+ config->set_property("OutputFilter.item_type", "gr_complex");
std::shared_ptr<GNSSFlowgraph> flowgraph = std::make_shared<GNSSFlowgraph>(config, gr::msg_queue::make(0));
- flowgraph->set_configuration(config);
- EXPECT_NO_THROW(flowgraph->connect());
- EXPECT_TRUE(flowgraph->connected());
- EXPECT_STREQ("File_Signal_Source", flowgraph->sig_source_->implementation().c_str());
- EXPECT_STREQ("Pass_Through", flowgraph->sig_conditioner_->implementation().c_str());
- EXPECT_STREQ("Channel", flowgraph->channels_.at(0)->implementation().c_str());
- // EXPECT_STREQ("Pass_Through", (flowgraph->channel(0)->acquisition()->implementation().c_str()));
- // EXPECT_STREQ("Pass_Through", (flowgraph->channel(0)->tracking()->implementation().c_str());
- // EXPECT_STREQ("Pass_Through", (flowgraph->channel(0)->telemetry()->implementation().c_str());
- EXPECT_STREQ("Channel", flowgraph->channels_.at(1)->implementation().c_str());
- // EXPECT_STREQ("Pass_Through", (flowgraph->channel(1)->acquisition()->implementation().c_str());
- // EXPECT_STREQ("Pass_Through", (flowgraph->channel(1)->tracking()->implementation().c_str());
- // EXPECT_STREQ("Pass_Through", (flowgraph->channel(1)->telemetry()->implementation().c_str());
- EXPECT_STREQ("GPS_L1_CA_Observables", flowgraph->observables_->implementation().c_str());
- EXPECT_STREQ("GPS_L1_CA_PVT", flowgraph->pvt_->implementation().c_str());
- EXPECT_STREQ("Null_Sink_Output_Filter", flowgraph->output_filter_->implementation().c_str());
+ EXPECT_NO_THROW(flowgraph->connect());
+ EXPECT_TRUE(flowgraph->connected());
EXPECT_NO_THROW(flowgraph->start());
EXPECT_TRUE(flowgraph->running());
flowgraph->stop();
EXPECT_FALSE(flowgraph->running());
-
- //delete flowgraph;
}
+
+
+
diff --git a/src/tests/flowgraph/pass_through_test.cc b/src/tests/flowgraph/pass_through_test.cc
index f11069c..274dd17 100644
--- a/src/tests/flowgraph/pass_through_test.cc
+++ b/src/tests/flowgraph/pass_through_test.cc
@@ -17,7 +17,7 @@
* GNSS-SDR is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
- * at your option) any later version.
+ * (at your option) any later version.
*
* GNSS-SDR is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -32,20 +32,18 @@
#include "pass_through.h"
+#include <gtest/gtest.h>
#include "in_memory_configuration.h"
TEST(Pass_Through_Test, Instantiate)
{
- InMemoryConfiguration* config = new InMemoryConfiguration();
+ std::shared_ptr<ConfigurationInterface> config = std::make_shared<InMemoryConfiguration>();
config->set_property("Test.item_type", "gr_complex");
config->set_property("Test.vector_size", "2");
- Pass_Through *signal_conditioner = new Pass_Through(config, "Test", 1, 1);
-
+ std::shared_ptr<Pass_Through> signal_conditioner = std::make_shared<Pass_Through>(config.get(), "Test", 1, 1);
EXPECT_STREQ("gr_complex", signal_conditioner->item_type().c_str());
unsigned int expected2 = 2;
EXPECT_EQ(expected2, signal_conditioner->vector_size());
-
- delete signal_conditioner;
}
diff --git a/src/tests/gnss_block/galileo_e1_dll_pll_veml_tracking_test.cc b/src/tests/gnss_block/galileo_e1_dll_pll_veml_tracking_test.cc
index 115f062..58fba85 100644
--- a/src/tests/gnss_block/galileo_e1_dll_pll_veml_tracking_test.cc
+++ b/src/tests/gnss_block/galileo_e1_dll_pll_veml_tracking_test.cc
@@ -113,7 +113,7 @@ TEST_F(GalileoE1DllPllVemlTrackingInternalTest, Instantiate)
TEST_F(GalileoE1DllPllVemlTrackingInternalTest, ConnectAndRun)
{
int fs_in = 8000000;
- int nsamples = 80000000;
+ int nsamples = 40000000;
struct timeval tv;
long long int begin = 0;
long long int end = 0;
diff --git a/src/tests/gnss_block/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/gnss_block/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc
index 7139e89..c9cf803 100644
--- a/src/tests/gnss_block/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc
+++ b/src/tests/gnss_block/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc
@@ -32,6 +32,8 @@
#include <ctime>
#include <iostream>
+#include <boost/chrono.hpp>
+#include <boost/shared_ptr.hpp>
#include <gnuradio/top_block.h>
#include <gnuradio/blocks/file_source.h>
#include <gnuradio/analog/sig_source_waveform.h>
@@ -46,7 +48,6 @@
#include "signal_generator_c.h"
#include "fir_filter.h"
#include "gen_signal_source.h"
-#include "boost/shared_ptr.hpp"
#include "gnss_sdr_valve.h"
@@ -502,9 +503,16 @@ TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ValidationOfResults)
EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL.";
}
+#ifdef OLD_BOOST
ASSERT_NO_THROW( {
ch_thread.timed_join(boost::posix_time::seconds(1));
}) << "Failure while waiting the queue to stop" << std::endl;
+#endif
+#ifndef OLD_BOOST
+ ASSERT_NO_THROW( {
+ ch_thread.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50));
+ }) << "Failure while waiting the queue to stop" << std::endl;
+#endif
}
}
@@ -590,9 +598,15 @@ TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ValidationOfResultsProb
std::cout << "Estimated probability of false alarm (satellite absent) = " << Pfa_a << std::endl;
std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl;
}
+#ifdef OLD_BOOST
ASSERT_NO_THROW( {
ch_thread.timed_join(boost::posix_time::seconds(1));
}) << "Failure while waiting the queue to stop" << std::endl;
-
+#endif
+#ifndef OLD_BOOST
+ ASSERT_NO_THROW( {
+ ch_thread.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50));
+ }) << "Failure while waiting the queue to stop" << std::endl;
+#endif
}
}
diff --git a/src/tests/gnss_block/galileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc b/src/tests/gnss_block/galileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc
index 5068ca9..5ab4789 100644
--- a/src/tests/gnss_block/galileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc
+++ b/src/tests/gnss_block/galileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc
@@ -43,6 +43,7 @@
#include <ctime>
#include <iostream>
+#include <boost/chrono.hpp>
#include <gnuradio/top_block.h>
#include <gnuradio/blocks/file_source.h>
#include <gnuradio/analog/sig_source_waveform.h>
@@ -244,9 +245,16 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoCTest, ValidationOfResults)
end = tv.tv_sec*1000000 + tv.tv_usec;
}) << "Failure running the top_block." << std::endl;
- ASSERT_NO_THROW( {
- ch_thread.timed_join(boost::posix_time::seconds(1));
- }) << "Failure while waiting the queue to stop" << std::endl;
+#ifdef OLD_BOOST
+ ASSERT_NO_THROW( {
+ ch_thread.timed_join(boost::posix_time::seconds(1));
+ }) << "Failure while waiting the queue to stop" << std::endl;
+#endif
+#ifndef OLD_BOOST
+ ASSERT_NO_THROW( {
+ ch_thread.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50));
+ }) << "Failure while waiting the queue to stop" << std::endl;
+#endif
unsigned long int nsamples = gnss_synchro.Acq_samplestamp_samples;
std::cout << "Acquired " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
diff --git a/src/tests/gnss_block/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/gnss_block/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc
index cf0b923..b4056d0 100644
--- a/src/tests/gnss_block/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc
+++ b/src/tests/gnss_block/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc
@@ -36,6 +36,7 @@
#include <ctime>
#include <iostream>
#include <boost/shared_ptr.hpp>
+#include <boost/chrono.hpp>
#include <gnuradio/top_block.h>
#include <gnuradio/blocks/file_source.h>
#include <gnuradio/analog/sig_source_waveform.h>
@@ -570,8 +571,15 @@ TEST_F(GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test, ValidationOfResultsPro
std::cout << "Estimated probability of false alarm (satellite absent) = " << Pfa_a << std::endl;
std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl;
}
+#ifdef OLD_BOOST
ASSERT_NO_THROW( {
ch_thread.timed_join(boost::posix_time::seconds(1));
}) << "Failure while waiting the queue to stop" << std::endl;
+#endif
+#ifndef OLD_BOOST
+ ASSERT_NO_THROW( {
+ ch_thread.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50));
+ }) << "Failure while waiting the queue to stop" << std::endl;
+#endif
}
}
diff --git a/src/tests/gnss_block/gps_l1_ca_pcps_acquisition_test.cc b/src/tests/gnss_block/gps_l1_ca_pcps_acquisition_test.cc
index 27bd262..c564543 100644
--- a/src/tests/gnss_block/gps_l1_ca_pcps_acquisition_test.cc
+++ b/src/tests/gnss_block/gps_l1_ca_pcps_acquisition_test.cc
@@ -33,7 +33,9 @@
#include <ctime>
+#include <cstdlib>
#include <iostream>
+#include <boost/chrono.hpp>
#include <gnuradio/top_block.h>
#include <gnuradio/blocks/file_source.h>
#include <gnuradio/analog/sig_source_waveform.h>
@@ -99,8 +101,8 @@ void GpsL1CaPcpsAcquisitionTest::init()
config->set_property("Acquisition.dump", "false");
config->set_property("Acquisition.implementation", "GPS_L1_CA_PCPS_Acquisition");
config->set_property("Acquisition.threshold", "0.000");
- config->set_property("Acquisition.doppler_max", "7200");
- config->set_property("Acquisition.doppler_step", "600");
+ config->set_property("Acquisition.doppler_max", "5000");
+ config->set_property("Acquisition.doppler_step", "500");
config->set_property("Acquisition.repeat_satellite", "false");
}
@@ -170,8 +172,8 @@ TEST_F(GpsL1CaPcpsAcquisitionTest, ValidationOfResults)
struct timeval tv;
long long int begin = 0;
long long int end = 0;
- double expected_delay_samples = 127;
- double expected_doppler_hz = -2400;
+ double expected_delay_samples = 945;
+ double expected_doppler_hz = 4500;
init();
std::shared_ptr<GpsL1CaPcpsAcquisition> acquisition = std::make_shared<GpsL1CaPcpsAcquisition>(config.get(), "Acquisition", 1, 1, queue);
@@ -188,15 +190,15 @@ TEST_F(GpsL1CaPcpsAcquisitionTest, ValidationOfResults)
}) << "Failure setting channel_internal_queue." << std::endl;
ASSERT_NO_THROW( {
- acquisition->set_threshold(config->property("Acquisition.threshold", 0.0001));
+ acquisition->set_threshold(config->property("Acquisition.threshold", 0));
}) << "Failure setting threshold." << std::endl;
ASSERT_NO_THROW( {
- acquisition->set_doppler_max(config->property("Acquisition.doppler_max", 10000));
+ acquisition->set_doppler_max(config->property("Acquisition.doppler_max", 5000));
}) << "Failure setting doppler_max." << std::endl;
ASSERT_NO_THROW( {
- acquisition->set_doppler_step(config->property("Acquisition.doppler_step", 500));
+ acquisition->set_doppler_step(config->property("Acquisition.doppler_step", 50));
}) << "Failure setting doppler_step." << std::endl;
ASSERT_NO_THROW( {
@@ -224,20 +226,25 @@ TEST_F(GpsL1CaPcpsAcquisitionTest, ValidationOfResults)
end = tv.tv_sec*1000000 + tv.tv_usec;
}) << "Failure running the top_block." << std::endl;
+#ifdef OLD_BOOST
ch_thread.timed_join(boost::posix_time::seconds(1));
+#endif
+#ifndef OLD_BOOST
+ ch_thread.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50));
+#endif
unsigned long int nsamples = gnss_synchro.Acq_samplestamp_samples;
std::cout << "Acquired " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
ASSERT_EQ(1, message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS.";
- //std::cout << "----Aq_delay: " << gnss_synchro.Acq_delay_samples << std::endl;
- //std::cout << "----Doppler: " << gnss_synchro.Acq_doppler_hz << std::endl;
+ std::cout << "----Aq_delay: " << gnss_synchro.Acq_delay_samples << std::endl;
+ std::cout << "----Doppler: " << gnss_synchro.Acq_doppler_hz << std::endl;
- double delay_error_samples = abs(expected_delay_samples - gnss_synchro.Acq_delay_samples);
+ double delay_error_samples = std::abs(expected_delay_samples - gnss_synchro.Acq_delay_samples);
float delay_error_chips = (float)(delay_error_samples*1023/4000);
- double doppler_error_hz = abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz);
+ double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz);
- EXPECT_LE(doppler_error_hz, 333) << "Doppler error exceeds the expected value: 333 Hz = 2/(3*integration period)";
+ EXPECT_LE(doppler_error_hz, 666) << "Doppler error exceeds the expected value: 666 Hz = 2/(3*integration period)";
EXPECT_LT(delay_error_chips, 0.5) << "Delay error exceeds the expected value: 0.5 chips";
}
diff --git a/src/tests/test_main.cc b/src/tests/test_main.cc
index 5e7d565..b6d1206 100644
--- a/src/tests/test_main.cc
+++ b/src/tests/test_main.cc
@@ -76,9 +76,9 @@ DECLARE_string(log_dir);
#include "configuration/file_configuration_test.cc"
#include "configuration/in_memory_configuration_test.cc"
#include "control_thread/control_message_factory_test.cc"
-//#include "control_thread/control_thread_test.cc"
+#include "control_thread/control_thread_test.cc"
#include "flowgraph/pass_through_test.cc"
-//#include "flowgraph/gnss_flowgraph_test.cc"
+#include "flowgraph/gnss_flowgraph_test.cc"
#include "gnss_block/gnss_block_factory_test.cc"
#include "gnss_block/rtcm_printer_test.cc"
#include "gnss_block/file_output_filter_test.cc"
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/gnss-sdr.git
More information about the pkg-hamradio-commits
mailing list