mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-15 04:30:33 +00:00
Add more flag validators
This commit is contained in:
parent
658e677fc3
commit
2ca458cea1
@ -30,11 +30,16 @@
|
||||
|
||||
|
||||
#include "gnss_sdr_flags.h"
|
||||
#include <boost/filesystem/operations.hpp> // for exists
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
DEFINE_string(c, "-", "Path to the configuration file (if set, overrides --config_file).");
|
||||
|
||||
DEFINE_string(config_file, std::string(GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/default.conf"),
|
||||
"Path to the configuration file.");
|
||||
|
||||
DEFINE_string(s, "-",
|
||||
"If defined, path to the file containing the signal samples (overrides the configuration file and --signal_source).");
|
||||
|
||||
@ -62,71 +67,126 @@ DEFINE_double(pll_bw_hz, 0.0, "If defined, bandwidth of the PLL low pass filter,
|
||||
|
||||
#if GFLAGS_GREATER_2_0
|
||||
|
||||
static bool ValidateC(const char* flagname, const std::string & value)
|
||||
{
|
||||
if (boost::filesystem::exists( value ) or value.compare("-") == 0) // value is ok
|
||||
return true;
|
||||
std::cout << "Invalid value for flag -" << flagname << ". The file '" << value << "' does not exist." << std::endl;
|
||||
std::cout << "GNSS-SDR program ended." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool ValidateConfigFile(const char* flagname, const std::string & value)
|
||||
{
|
||||
if (boost::filesystem::exists( value ) or value.compare(std::string(GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/default.conf")) == 0) // value is ok
|
||||
return true;
|
||||
std::cout << "Invalid value for flag -" << flagname << ". The file '" << value << "' does not exist." << std::endl;
|
||||
std::cout << "GNSS-SDR program ended." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool ValidateS(const char* flagname, const std::string & value)
|
||||
{
|
||||
if (boost::filesystem::exists( value ) or value.compare("-") == 0) // value is ok
|
||||
return true;
|
||||
std::cout << "Invalid value for flag -" << flagname << ". The file '" << value << "' does not exist." << std::endl;
|
||||
std::cout << "GNSS-SDR program ended." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool ValidateSignalSource(const char* flagname, const std::string & value)
|
||||
{
|
||||
if (boost::filesystem::exists( value ) or value.compare("-") == 0) // value is ok
|
||||
return true;
|
||||
std::cout << "Invalid value for flag -" << flagname << ". The file '" << value << "' does not exist." << std::endl;
|
||||
std::cout << "GNSS-SDR program ended." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool ValidateDopplerMax(const char* flagname, int32_t value)
|
||||
{
|
||||
if (value >= 0 && value < 1000000) // value is ok
|
||||
const int32_t max_value = 1000000;
|
||||
if (value >= 0 && value < max_value) // value is ok
|
||||
return true;
|
||||
std::cout << "Invalid value for " << flagname << ": " << value << std::endl;
|
||||
std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " Hz." << std::endl;
|
||||
std::cout << "GNSS-SDR program ended." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool ValidateDopplerStep(const char* flagname, int32_t value)
|
||||
{
|
||||
if (value >= 0 && value < 10000) // value is ok
|
||||
const int32_t max_value = 10000;
|
||||
if (value >= 0 && value < max_value) // value is ok
|
||||
return true;
|
||||
std::cout << "Invalid value for " << flagname << ": " << value << std::endl;
|
||||
std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " Hz." << std::endl;
|
||||
std::cout << "GNSS-SDR program ended." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool ValidateCn0Samples(const char* flagname, int32_t value)
|
||||
{
|
||||
if (value > 0 && value < 10000) // value is ok
|
||||
const int32_t max_value = 10000;
|
||||
if (value > 0 && value < max_value) // value is ok
|
||||
return true;
|
||||
std::cout << "Invalid value for " << flagname << ": " << value << std::endl;
|
||||
std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " samples." << std::endl;
|
||||
std::cout << "GNSS-SDR program ended." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool ValidateCn0Min(const char* flagname, int32_t value)
|
||||
{
|
||||
if (value > 0 && value < 100) // value is ok
|
||||
const int32_t max_value = 100;
|
||||
if (value > 0 && value < max_value) // value is ok
|
||||
return true;
|
||||
std::cout << "Invalid value for " << flagname << ": " << value << std::endl;
|
||||
std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " dB-Hz." << std::endl;
|
||||
std::cout << "GNSS-SDR program ended." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool ValidateMaxLockFail(const char* flagname, int32_t value)
|
||||
{
|
||||
if (value > 0 && value < 10000) // value is ok
|
||||
const int32_t max_value = 10000;
|
||||
if (value > 0 && value < max_value) // value is ok
|
||||
return true;
|
||||
std::cout << "Invalid value for " << flagname << ": " << value << std::endl;
|
||||
std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " fails." << std::endl;
|
||||
std::cout << "GNSS-SDR program ended." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool ValidateCarrierLockTh(const char* flagname, double value)
|
||||
{
|
||||
if (value > 0.0 && value < 1.508) // value is ok
|
||||
const double max_value = 1.508;
|
||||
if (value > 0.0 && value < max_value) // value is ok
|
||||
return true;
|
||||
std::cout << "Invalid value for " << flagname << ": " << value << std::endl;
|
||||
std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " rad." << std::endl;
|
||||
std::cout << "GNSS-SDR program ended." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool ValidateDllBw(const char* flagname, double value)
|
||||
{
|
||||
if (value >= 0.0 && value < 10000.0) // value is ok
|
||||
const double max_value = 10000.0;
|
||||
if (value >= 0.0 && value < max_value) // value is ok
|
||||
return true;
|
||||
std::cout << "Invalid value for " << flagname << ": " << value << std::endl;
|
||||
std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " Hz." << std::endl;
|
||||
std::cout << "GNSS-SDR program ended." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool ValidatePllBw(const char* flagname, double value)
|
||||
{
|
||||
if (value >= 0.0 && value < 10000.0) // value is ok
|
||||
const double max_value = 10000.0;
|
||||
if (value >= 0.0 && value < max_value) // value is ok
|
||||
return true;
|
||||
std::cout << "Invalid value for " << flagname << ": " << value << std::endl;
|
||||
std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " Hz." << std::endl;
|
||||
std::cout << "GNSS-SDR program ended." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
DEFINE_validator(c, &ValidateC);
|
||||
DEFINE_validator(config_file, &ValidateConfigFile);
|
||||
DEFINE_validator(s, &ValidateS);
|
||||
DEFINE_validator(signal_source, &ValidateSignalSource);
|
||||
DEFINE_validator(doppler_max, &ValidateDopplerMax);
|
||||
DEFINE_validator(doppler_step, &ValidateDopplerStep);
|
||||
DEFINE_validator(cn0_samples, &ValidateCn0Samples);
|
||||
|
@ -90,8 +90,6 @@ if(ENABLE_FMCOMMS2)
|
||||
set(OPT_RECEIVER_INCLUDE_DIRS ${OPT_RECEIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS})
|
||||
endif(ENABLE_FMCOMMS2)
|
||||
|
||||
add_definitions(-DGNSSSDR_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}")
|
||||
|
||||
if(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.13" )
|
||||
add_definitions( -DGR_GREATER_38=1 )
|
||||
endif(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.13" )
|
||||
|
@ -66,8 +66,6 @@ extern concurrent_queue<Gps_Acq_Assist> global_gps_acq_assist_queue;
|
||||
|
||||
using google::LogMessage;
|
||||
|
||||
DEFINE_string(config_file, std::string(GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/default.conf"),
|
||||
"Path to the configuration file");
|
||||
|
||||
ControlThread::ControlThread()
|
||||
{
|
||||
|
@ -33,6 +33,7 @@ include_directories(
|
||||
${CMAKE_SOURCE_DIR}/src/core/libs/supl/asn-supl
|
||||
${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/adapters
|
||||
${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/gnuradio_blocks
|
||||
${CMAKE_SOURCE_DIR}/src/algorithms/libs
|
||||
${GLOG_INCLUDE_DIRS}
|
||||
${GFlags_INCLUDE_DIRS}
|
||||
${GNURADIO_RUNTIME_INCLUDE_DIRS}
|
||||
@ -59,6 +60,7 @@ target_link_libraries(front_end_cal_lib ${MAC_LIBRARIES}
|
||||
${VOLK_GNSSSDR_LIBRARIES} ${ORC_LIBRARIES}
|
||||
${GNSS_SDR_OPTIONAL_LIBS}
|
||||
rx_core_lib
|
||||
gnss_sdr_flags
|
||||
gnss_rx
|
||||
channel_fsm
|
||||
)
|
||||
|
@ -32,26 +32,7 @@
|
||||
#define FRONT_END_CAL_VERSION "0.0.1"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <chrono>
|
||||
#include <ctime> // for ctime
|
||||
#include <exception>
|
||||
#include <memory>
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/exception/detail/exception_ptr.hpp>
|
||||
#include <gflags/gflags.h>
|
||||
#include <glog/logging.h>
|
||||
#include <gnuradio/msg_queue.h>
|
||||
#include <gnuradio/top_block.h>
|
||||
#include <gnuradio/blocks/null_sink.h>
|
||||
#include <gnuradio/blocks/skiphead.h>
|
||||
#include <gnuradio/blocks/head.h>
|
||||
#include <gnuradio/blocks/file_source.h>
|
||||
#include <gnuradio/blocks/file_sink.h>
|
||||
#include "front_end_cal.h"
|
||||
#include "concurrent_map.h"
|
||||
#include "concurrent_queue.h"
|
||||
#include "file_configuration.h"
|
||||
@ -72,21 +53,32 @@
|
||||
#include "galileo_utc_model.h"
|
||||
#include "sbas_ephemeris.h"
|
||||
#include "gnss_sdr_supl_client.h"
|
||||
#include "gnss_sdr_flags.h"
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/exception/detail/exception_ptr.hpp>
|
||||
#include <glog/logging.h>
|
||||
#include <gnuradio/msg_queue.h>
|
||||
#include <gnuradio/top_block.h>
|
||||
#include <gnuradio/blocks/null_sink.h>
|
||||
#include <gnuradio/blocks/skiphead.h>
|
||||
#include <gnuradio/blocks/head.h>
|
||||
#include <gnuradio/blocks/file_source.h>
|
||||
#include <gnuradio/blocks/file_sink.h>
|
||||
#include <stdlib.h>
|
||||
#include <chrono>
|
||||
#include <ctime> // for ctime
|
||||
#include <exception>
|
||||
#include <memory>
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
|
||||
|
||||
#include "front_end_cal.h"
|
||||
|
||||
using google::LogMessage;
|
||||
|
||||
DECLARE_string(log_dir);
|
||||
|
||||
std::string s1_(GNSSSDR_INSTALL_DIR);
|
||||
std::string s2_("/share/gnss-sdr/conf/front-end-cal.conf");
|
||||
std::string s3_ = s1_ + s2_;
|
||||
|
||||
DEFINE_string(config_file, s3_,
|
||||
"Path to the file containing the configuration parameters");
|
||||
|
||||
concurrent_map<Gps_Ephemeris> global_gps_ephemeris_map;
|
||||
concurrent_map<Gps_Iono> global_gps_iono_map;
|
||||
concurrent_map<Gps_Utc_Model> global_gps_utc_model_map;
|
||||
|
Loading…
Reference in New Issue
Block a user