From 7f9d3c385dbe2cb2c0e91974af2735d1f7a2559b Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 22 Dec 2016 01:35:31 +0100 Subject: [PATCH] Simple example of GPSTk usage --- src/tests/CMakeLists.txt | 4 ++ src/tests/system-tests/trk_system_test.cc | 47 ++++++++++++++++++----- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 9c086a6c2..02d972f90 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -152,6 +152,10 @@ if(ENABLE_SW_GENERATOR) add_definitions(-DSW_GENERATOR_BIN="${SW_GENERATOR_BIN}") add_definitions(-DDEFAULT_RINEX_NAV="${CMAKE_CURRENT_BINARY_DIR}/../../../thirdparty/gnss-sim/brdc3540.14n") add_definitions(-DDEFAULT_POSITION_FILE="${CMAKE_CURRENT_BINARY_DIR}/../../../thirdparty/gnss-sim/circle.csv") + + ################################################################################ + # Local installation of GPSTk http://www.gpstk.org/ + ################################################################################ set(gpstk_RELEASE "2.5") set(gpstk_md5 "9d79f6838d274f5edfd46c780a6b1b72") ExternalProject_Add( diff --git a/src/tests/system-tests/trk_system_test.cc b/src/tests/system-tests/trk_system_test.cc index 26d5d2400..527af63b4 100644 --- a/src/tests/system-tests/trk_system_test.cc +++ b/src/tests/system-tests/trk_system_test.cc @@ -12,6 +12,8 @@ #include "concurrent_queue.h" #include "in_memory_configuration.h" + + // For GPS NAVIGATION (L1) concurrent_queue global_gps_acq_assist_queue; concurrent_map global_gps_acq_assist_map; @@ -37,14 +39,36 @@ public: int configure_receiver(); int run_receiver(); int check_results(); + bool check_valid_rinex_nav(std::string filename); // return true if the file is a valid Rinex navigation file. + bool check_valid_rinex_obs(std::string filename); // return true if the file is a valid Rinex observation file. std::shared_ptr config; }; + +bool Trk_System_Test::check_valid_rinex_nav(std::string filename) +{ + bool res = false; + res = gpstk::isRinexNavFile(filename); + return res; +} + + +bool Trk_System_Test::check_valid_rinex_obs(std::string filename) +{ + bool res = false; + res = gpstk::isRinexObsFile(filename); + return res; +} + + int Trk_System_Test::configure_generator() { // Configure signal generator_binary = std::string(SW_GENERATOR_BIN); + + EXPECT_EQ(true, check_valid_rinex_nav(std::string(DEFAULT_RINEX_NAV))); + p1 = std::string("-rinex_nav_file=") + std::string(DEFAULT_RINEX_NAV); p2_static = std::string("-static_position=30.286502,120.032669,100,1000"); p2_dynamic = std::string("-obs_pos_file=") + std::string(DEFAULT_POSITION_FILE); // Observer positions file, in .csv or .nmea format" @@ -54,6 +78,7 @@ int Trk_System_Test::configure_generator() return 0; } + int Trk_System_Test::generate_signal() { pid_t wait_result; @@ -65,17 +90,20 @@ int Trk_System_Test::generate_signal() if ((pid = fork()) == -1) perror("fork error"); else if (pid == 0) - { - execv(&generator_binary[0], parmList); - std::cout << "Return not expected. Must be an execv error." << std::endl; - std::terminate(); - } + { + execv(&generator_binary[0], parmList); + std::cout << "Return not expected. Must be an execv error." << std::endl; + std::terminate(); + } wait_result = waitpid(pid, &child_status, 0); + + EXPECT_EQ(true, check_valid_rinex_obs(filename_rinex_obs)); std::cout << "Signal and Observables RINEX files created." << std::endl; return 0; } + int Trk_System_Test::configure_receiver() { config = std::make_shared(); @@ -231,6 +259,7 @@ int Trk_System_Test::configure_receiver() return 0; } + int Trk_System_Test::run_receiver() { std::shared_ptr control_thread; @@ -238,15 +267,15 @@ int Trk_System_Test::run_receiver() // start receiver try { - control_thread->run(); + control_thread->run(); } catch( boost::exception & e ) { - std::cout << "Boost exception: " << boost::diagnostic_information(e); + std::cout << "Boost exception: " << boost::diagnostic_information(e); } catch(std::exception const& ex) { - std::cout << "STD exception: " << ex.what(); + std::cout << "STD exception: " << ex.what(); } return 0; } @@ -300,7 +329,7 @@ int main(int argc, char **argv) int res = 0; try { - testing::InitGoogleTest(&argc, argv); + testing::InitGoogleTest(&argc, argv); } catch(...) {} // catch the "testing::internal::::ClassUniqueToAlwaysTrue" from gtest