2012-02-06 16:44:09 +01:00
|
|
|
/*
|
2013-05-29 18:43:35 +02:00
|
|
|
* This file is part of the Owl Positioning System (OwlPS) project.
|
|
|
|
* It is subject to the copyright notice and license terms in the
|
|
|
|
* COPYRIGHT.t2t file found in the top-level directory of this
|
|
|
|
* distribution and at
|
2016-11-03 05:10:34 +01:00
|
|
|
* https://code.lm7.fr/mcy/owlps/src/master/COPYRIGHT.t2t
|
2013-05-29 18:43:35 +02:00
|
|
|
* No part of the OwlPS Project, including this file, may be copied,
|
|
|
|
* modified, propagated, or distributed except according to the terms
|
|
|
|
* contained in the COPYRIGHT.t2t file; the COPYRIGHT.t2t file must be
|
|
|
|
* distributed along with this file, either separately or by replacing
|
2013-06-22 23:30:17 +02:00
|
|
|
* this notice by the COPYRIGHT.t2t file's contents.
|
2012-02-06 16:44:09 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-02-11 09:46:40 +01:00
|
|
|
#include "userinterface.hh"
|
|
|
|
#include "configuration.hh"
|
|
|
|
|
2013-06-04 17:57:59 +02:00
|
|
|
#include <owlps-config.h>
|
|
|
|
|
2011-03-29 12:32:26 +02:00
|
|
|
#include <owlps.h>
|
|
|
|
|
2010-02-11 09:46:40 +01:00
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
|
|
|
#include <boost/program_options.hpp>
|
|
|
|
|
|
|
|
using namespace std ;
|
|
|
|
namespace po = boost::program_options ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* *** Default value definitions *** */
|
|
|
|
|
2011-12-27 18:07:28 +01:00
|
|
|
/* General options */
|
2013-06-04 17:57:59 +02:00
|
|
|
#define DEFAULT_CONFIG_FILE OWL_CONFIG_PREFIX "/owlps-positioner.conf"
|
2010-02-11 09:46:40 +01:00
|
|
|
|
2011-12-27 18:07:28 +01:00
|
|
|
/* Positioning options */
|
2012-03-02 10:54:34 +01:00
|
|
|
#define DEFAULT_SS_SIMILARITY "mean"
|
2011-12-27 18:07:28 +01:00
|
|
|
#define DEFAULT_MESHING_GRAIN 0.5
|
2012-01-09 10:31:12 +01:00
|
|
|
#define DEFAULT_Z_MESHING_GRAIN 1
|
2011-12-30 12:21:59 +01:00
|
|
|
#define DEFAULT_SMALLEST_SS -99
|
2011-12-27 18:07:28 +01:00
|
|
|
|
|
|
|
/* Output options */
|
2011-07-24 17:25:00 +02:00
|
|
|
#define DEFAULT_TCPEVAAL_HOST "127.0.0.1"
|
|
|
|
#define DEFAULT_TCPEVAAL_PORT 4444
|
|
|
|
|
2010-02-11 09:46:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* *** Constructors *** */
|
|
|
|
|
|
|
|
|
2010-03-05 17:24:18 +01:00
|
|
|
/**
|
2013-05-30 21:23:05 +02:00
|
|
|
* `argc` and `argv` are (normally) the ones passed to the main()
|
2010-03-05 17:24:18 +01:00
|
|
|
* function.
|
|
|
|
* @param argc Number of arguments passed to the program.
|
|
|
|
* @param argv Values of the arguments.
|
|
|
|
*/
|
2013-10-02 20:38:45 +02:00
|
|
|
UserInterface::UserInterface(const int argc,
|
|
|
|
const char *const *const argv):
|
2013-06-22 02:10:38 +02:00
|
|
|
cli_argument_count(argc), cli_argument_values(argv)
|
2010-02-11 09:46:40 +01:00
|
|
|
{
|
2013-06-22 02:10:38 +02:00
|
|
|
assert(cli_argument_values) ;
|
2010-02-11 09:46:40 +01:00
|
|
|
|
2010-02-26 13:09:45 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
cli_options = new po::options_description("General options") ;
|
|
|
|
file_options = new po::options_description("Parameters") ;
|
|
|
|
}
|
2011-05-11 10:29:17 +02:00
|
|
|
catch (bad_alloc &e)
|
2010-02-26 13:09:45 +01:00
|
|
|
{
|
|
|
|
throw ;
|
|
|
|
}
|
|
|
|
|
2010-02-11 09:46:40 +01:00
|
|
|
fill_options() ;
|
|
|
|
parse_options() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UserInterface::~UserInterface()
|
|
|
|
{
|
|
|
|
delete cli_options ;
|
|
|
|
delete file_options ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* *** Operations *** */
|
|
|
|
|
|
|
|
|
|
|
|
void UserInterface::fill_options()
|
|
|
|
{
|
|
|
|
fill_cli_options() ;
|
|
|
|
fill_file_options() ;
|
|
|
|
|
|
|
|
// File options are also accepted on the command line
|
|
|
|
cli_options->add(*file_options) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UserInterface::fill_cli_options()
|
|
|
|
{
|
|
|
|
cli_options->add_options()
|
2011-12-27 18:07:28 +01:00
|
|
|
("help,h",
|
|
|
|
"Print help.")
|
|
|
|
("version,V",
|
|
|
|
"Print version information.")
|
|
|
|
("config-file,f",
|
2013-06-04 17:57:59 +02:00
|
|
|
po::value<string>()->default_value(DEFAULT_CONFIG_FILE),
|
2011-04-13 00:10:49 +02:00
|
|
|
"Alternative configuration file.")
|
2011-12-27 18:07:28 +01:00
|
|
|
("verbose,v",
|
|
|
|
"Verbose mode.")
|
2010-03-05 17:24:18 +01:00
|
|
|
; // End of options
|
2010-02-11 09:46:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UserInterface::fill_file_options()
|
|
|
|
{
|
2010-04-02 15:49:22 +02:00
|
|
|
fill_data_input_options() ;
|
2010-03-23 14:53:37 +01:00
|
|
|
fill_input_options() ;
|
|
|
|
fill_log_options() ;
|
|
|
|
fill_positioning_options() ;
|
|
|
|
fill_output_options() ;
|
2011-03-29 14:21:14 +02:00
|
|
|
fill_misc_options() ;
|
2010-03-23 14:53:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-02 15:49:22 +02:00
|
|
|
void UserInterface::fill_data_input_options()
|
|
|
|
{
|
|
|
|
po::options_description options("Data input options") ;
|
|
|
|
|
|
|
|
options.add_options()
|
2013-06-14 21:54:26 +02:00
|
|
|
("data-input.cp-medium",
|
2011-12-27 18:07:28 +01:00
|
|
|
po::value< vector<string> >()->composing(),
|
2013-06-14 21:54:26 +02:00
|
|
|
"Medium from which capture points are read. You can specify this"
|
2011-06-08 19:05:48 +02:00
|
|
|
" option more than once. Allowed: CSV.")
|
2013-06-14 21:54:26 +02:00
|
|
|
("data-input.cp-csv-file",
|
2011-12-27 18:07:28 +01:00
|
|
|
po::value<string>(),
|
2013-06-14 21:54:26 +02:00
|
|
|
"CSV file to use for capture points input (when"
|
|
|
|
" data-input.cp-medium = CSV).")
|
2011-12-27 18:07:28 +01:00
|
|
|
("data-input.mobile-medium",
|
|
|
|
po::value< vector<string> >()->composing(),
|
2011-07-19 18:40:17 +02:00
|
|
|
"Medium from which mobiles are read. You can specify this"
|
|
|
|
" option more than once. Allowed: CSV.")
|
2011-12-27 18:07:28 +01:00
|
|
|
("data-input.mobile-csv-file",
|
|
|
|
po::value<string>(),
|
2011-07-19 18:40:17 +02:00
|
|
|
"CSV file to use for mobiles input (when"
|
|
|
|
" data-input.mobile-medium = CSV).")
|
2011-12-27 18:07:28 +01:00
|
|
|
("data-input.topology-medium",
|
|
|
|
po::value< vector<string> >()->composing(),
|
2011-06-08 19:05:48 +02:00
|
|
|
"Medium from which topology (buildings, areas and waypoints) is"
|
|
|
|
" read. You can specify this option more than once. Allowed: CSV.")
|
2011-12-27 18:07:28 +01:00
|
|
|
("data-input.areas-csv-file",
|
|
|
|
po::value<string>(),
|
2011-06-08 19:05:48 +02:00
|
|
|
"CSV file to use for topology input (when"
|
|
|
|
" data-input.topology-medium = CSV).")
|
2011-12-27 18:07:28 +01:00
|
|
|
("data-input.waypoints-csv-file",
|
|
|
|
po::value<string>(),
|
2011-06-08 19:05:48 +02:00
|
|
|
"CSV file to use for waypoints input (when"
|
|
|
|
" data-input.topology-medium = CSV).")
|
2011-12-27 18:07:28 +01:00
|
|
|
("data-input.reference-points-medium",
|
|
|
|
po::value< vector<string> >()->composing(),
|
2011-06-08 19:05:48 +02:00
|
|
|
"Medium from which reference points are read. You can specify this"
|
|
|
|
" option more than once. Allowed: CSV.")
|
2011-12-27 18:07:28 +01:00
|
|
|
("data-input.reference-points-csv-file",
|
|
|
|
po::value<string>(),
|
2011-06-08 19:05:48 +02:00
|
|
|
"CSV file to use for reference points input (when"
|
|
|
|
" data-input.reference-points-medium = CSV).")
|
2010-04-02 15:49:22 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
file_options->add(options) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-23 14:53:37 +01:00
|
|
|
void UserInterface::fill_input_options()
|
|
|
|
{
|
|
|
|
po::options_description options("Input options") ;
|
|
|
|
|
|
|
|
options.add_options()
|
2011-12-27 18:07:28 +01:00
|
|
|
("input.medium,I",
|
|
|
|
po::value<string>(),
|
2011-03-18 10:37:06 +01:00
|
|
|
"Medium from which requests are read. Allowed: CSV, UDP.")
|
2011-12-27 18:07:28 +01:00
|
|
|
("input.csv-file",
|
|
|
|
po::value<string>(),
|
2010-02-16 16:19:39 +01:00
|
|
|
"CSV file to use for input (when input.medium = CSV).")
|
2011-12-27 18:07:28 +01:00
|
|
|
("input.udp-port",
|
|
|
|
po::value<int>()->default_value(OWL_DEFAULT_AGGREGATION_PORT),
|
2011-03-18 10:37:06 +01:00
|
|
|
"Port on which the UDP socket listens (when input.medium = UDP).")
|
2010-03-23 14:53:37 +01:00
|
|
|
;
|
|
|
|
|
|
|
|
file_options->add(options) ;
|
|
|
|
}
|
|
|
|
|
2010-03-05 17:24:18 +01:00
|
|
|
|
2010-03-23 14:53:37 +01:00
|
|
|
void UserInterface::fill_log_options()
|
|
|
|
{
|
|
|
|
po::options_description options("Log options") ;
|
|
|
|
|
|
|
|
options.add_options()
|
2011-12-27 18:07:28 +01:00
|
|
|
("log.medium,L",
|
|
|
|
po::value< vector<string> >()->composing(),
|
2011-06-08 19:05:48 +02:00
|
|
|
"Medium to which the requests will be logged. You can specify"
|
|
|
|
" this option more than once. Allowed: none, CSV. The `none`"
|
|
|
|
" value completely disables logging.")
|
2011-12-27 18:07:28 +01:00
|
|
|
("log.csv-file",
|
|
|
|
po::value<string>(),
|
2010-02-16 16:19:39 +01:00
|
|
|
"CSV file to use for logging (when log.medium = CSV).")
|
2010-03-23 14:53:37 +01:00
|
|
|
;
|
|
|
|
|
|
|
|
file_options->add(options) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UserInterface::fill_positioning_options()
|
|
|
|
{
|
|
|
|
po::options_description options("Positioning options") ;
|
2010-03-05 17:24:18 +01:00
|
|
|
|
2010-03-23 14:53:37 +01:00
|
|
|
options.add_options()
|
2011-12-27 18:07:28 +01:00
|
|
|
("positioning.algorithm,a",
|
|
|
|
po::value< vector<string> >()->composing(),
|
2011-06-08 19:05:48 +02:00
|
|
|
"Algorithms used to compute positions. You can specify"
|
2011-12-27 18:07:28 +01:00
|
|
|
" this option more than once (but at least once). Allowed: Real,"
|
2011-12-30 13:43:01 +01:00
|
|
|
" FBCM, FRBHMBasic, InterlinkNetworks, NSS.")
|
2011-12-27 18:07:28 +01:00
|
|
|
("positioning.accept-new-mobiles",
|
|
|
|
po::value<bool>()->default_value(false),
|
|
|
|
"When receiving requests, add unknown mobiles (mobiles which are not"
|
|
|
|
" declared in the mobiles' configuration file) to the mobiles' list.")
|
2013-06-14 21:54:26 +02:00
|
|
|
("positioning.accept-new-cps",
|
2011-12-27 18:07:28 +01:00
|
|
|
po::value<bool>()->default_value(false),
|
2013-06-14 21:54:26 +02:00
|
|
|
"When receiving requests, add unknown CPs (CPs which are not"
|
|
|
|
" declared in the CPs' configuration file) to the CPs' list"
|
2011-12-27 18:07:28 +01:00
|
|
|
" (default is false, for security purposes).")
|
2013-06-14 21:54:26 +02:00
|
|
|
("positioning.update-cp-coordinates-online",
|
2011-12-27 18:07:28 +01:00
|
|
|
po::value<bool>()->default_value(false),
|
2013-06-14 21:54:26 +02:00
|
|
|
"Allow CP's coordinates to be updated when a calibration request"
|
|
|
|
" with new coordinates is received from the CP (default is false,"
|
2011-12-27 18:07:28 +01:00
|
|
|
" for security purposes).")
|
|
|
|
("positioning.area-start",
|
|
|
|
po::value<string>(),
|
2011-07-30 14:21:37 +02:00
|
|
|
"Coordinates of the first point of the deployment area; this is"
|
2012-04-11 16:31:48 +02:00
|
|
|
" used to delimit the area in which the MinMax trilateration"
|
2011-07-30 14:21:37 +02:00
|
|
|
" method tests points and in which the reference points are"
|
|
|
|
" generated, if the corresponding options are activated"
|
|
|
|
" (string format: \"X;Y;Z\").")
|
2011-12-27 18:07:28 +01:00
|
|
|
("positioning.area-stop",
|
|
|
|
po::value<string>(),
|
2011-07-30 14:21:37 +02:00
|
|
|
"Coordinates of the last point of the deployment area"
|
|
|
|
" (string format: \"X;Y;Z\").")
|
2011-12-30 12:21:59 +01:00
|
|
|
("positioning.smallest-ss",
|
|
|
|
po::value<int>()->default_value(DEFAULT_SMALLEST_SS),
|
|
|
|
"Smallest possible value for a received signal strength, in dBm.")
|
2012-03-02 10:54:34 +01:00
|
|
|
("positioning.ss-similarity",
|
|
|
|
po::value<string>()->default_value(DEFAULT_SS_SIMILARITY),
|
|
|
|
"Algorithm to calculate the similarity, in the signal strength space,"
|
2012-03-06 12:27:15 +01:00
|
|
|
" between two measurements. Allowed: mean, interval, interval2.")
|
2011-07-22 11:29:30 +02:00
|
|
|
("positioning.generate-reference-points",
|
2013-05-17 21:08:35 +02:00
|
|
|
po::value<string>()->default_value("false"),
|
2011-07-22 11:29:30 +02:00
|
|
|
"Generate reference points from the (auto)calibration requests"
|
2013-05-17 21:08:35 +02:00
|
|
|
" received. Can be 'false', 'mesh' to generate reference points"
|
|
|
|
" regularly according to the meshing grain specified and the"
|
2013-07-10 00:00:00 +02:00
|
|
|
" positioning area defined, 'line' to generate reference points"
|
|
|
|
" regularly according to a straight path (cf. options"
|
|
|
|
" generated-line-path and generated-line-step), 'list' to generate"
|
|
|
|
" reference points from a list (cf. option generated-points-list),"
|
|
|
|
" or a combination of the three previous options (separated by any"
|
|
|
|
" character) to generate points in several ways.")
|
2012-05-31 20:18:49 +02:00
|
|
|
("positioning.generate-multi-packet-reference-points",
|
2012-02-29 17:14:23 +01:00
|
|
|
po::value<bool>()->default_value(true),
|
2012-05-31 20:18:49 +02:00
|
|
|
"Generate several packets per reference point by trying to match the"
|
|
|
|
" packets in the real requests. If false, the SS values of the"
|
|
|
|
" requests are averaged and only one packet is generated.")
|
2011-07-29 16:14:39 +02:00
|
|
|
("positioning.generated-meshing-grain-x",
|
2011-12-27 18:07:28 +01:00
|
|
|
po::value<float>()->default_value(DEFAULT_MESHING_GRAIN),
|
2013-07-10 00:00:00 +02:00
|
|
|
"When generate-reference-points includes 'mesh', this distance (in"
|
|
|
|
" metres) will separate each point to the next in X.")
|
2011-07-29 16:14:39 +02:00
|
|
|
("positioning.generated-meshing-grain-y",
|
2011-12-27 18:07:28 +01:00
|
|
|
po::value<float>()->default_value(DEFAULT_MESHING_GRAIN),
|
2013-07-10 00:00:00 +02:00
|
|
|
"When generate-reference-points includes 'mesh', this distance (in"
|
|
|
|
" metres) will separate each point to the next in Y.")
|
2012-01-09 10:31:12 +01:00
|
|
|
("positioning.generated-meshing-grain-z",
|
|
|
|
po::value<float>()->default_value(DEFAULT_Z_MESHING_GRAIN),
|
2013-07-10 00:00:00 +02:00
|
|
|
"When generate-reference-points includes 'mesh', this parameter"
|
|
|
|
" represents the number of the floor. Currently, each increment of Y"
|
|
|
|
" is a new floor (full 3-D coordinates are not supported yet).")
|
|
|
|
("positioning.generated-line-path",
|
|
|
|
po::value<string>(),
|
|
|
|
"Path of reference points to generate, if generate-reference-points"
|
|
|
|
" includes 'line'; the reference points are generated in straight"
|
|
|
|
" lines between the given points, and one of the points must be the"
|
|
|
|
" coordinates of a CP (string format: \"(X1;Y1;Z1);(X2;Y2;Z2);...\""
|
|
|
|
" or \"X1;Y1;Z1;X2;Y2;Z2;...\").")
|
|
|
|
("positioning.generated-line-step",
|
|
|
|
po::value<float>()->default_value(DEFAULT_MESHING_GRAIN),
|
|
|
|
"When generate-reference-points includes 'line', two generated points"
|
|
|
|
" will be separated approximately by this distance (in metres).")
|
2013-05-17 21:08:35 +02:00
|
|
|
("positioning.generated-points-list",
|
|
|
|
po::value<string>(),
|
|
|
|
"List of reference points to generate, if generate-reference-points"
|
2013-07-10 00:00:00 +02:00
|
|
|
" includes 'list' (string format: \"(X1;Y1;Z1);(X2;Y2;Z2);...\" or"
|
|
|
|
" \"X1;Y1;Z1;X2;Y2;Z2;...\").")
|
2011-06-17 16:02:19 +02:00
|
|
|
("positioning.accept-new-calibration-requests",
|
|
|
|
po::value<bool>()->default_value(false),
|
|
|
|
"Add the calibration requests received during the run-time to"
|
|
|
|
" the calibration requests' list; this is required for the"
|
|
|
|
" self-calibration. If unactivated, the calibration requests"
|
|
|
|
" are handled as positioning requests (default is unactivated,"
|
|
|
|
" for security purposes).")
|
2011-12-28 13:40:51 +01:00
|
|
|
("positioning.calibration-requests-timeout",
|
|
|
|
po::value<unsigned int>()->default_value(0),
|
|
|
|
"Maximum age of a calibration request before to delete it"
|
2012-06-08 12:27:51 +02:00
|
|
|
" (0 = unlimited). See also the \"replay\" option.")
|
2012-06-08 18:43:41 +02:00
|
|
|
("positioning.unique-calibration-requests",
|
|
|
|
po::value<bool>()->default_value(true),
|
|
|
|
"Always delete existing former calibration requests when receiving"
|
|
|
|
" a new calibration request for an existing reference point.")
|
2011-07-23 11:44:04 +02:00
|
|
|
("positioning.position-calibration-requests",
|
|
|
|
po::value<bool>()->default_value(false),
|
|
|
|
"When accept-new-calibration-requests is activated, allow the"
|
|
|
|
" calibration requests to be positioned as normal requests."
|
|
|
|
" The default is to add them to the calibration requests' list"
|
|
|
|
" without position them.")
|
2011-12-30 13:43:01 +01:00
|
|
|
("positioning.nss.average-reference-points",
|
2011-06-29 16:45:36 +02:00
|
|
|
po::value<bool>()->default_value(false),
|
2011-12-30 13:43:01 +01:00
|
|
|
"With the NSS algorithm, for a given positioning request, average"
|
2011-12-27 18:07:28 +01:00
|
|
|
" all the calibration requests associated with a reference point"
|
2012-03-02 10:54:34 +01:00
|
|
|
" before to compute the SS similarity."
|
2011-12-27 18:07:28 +01:00
|
|
|
" The default is false, i.e the positioning request is compared"
|
|
|
|
" directly to each calibration request.")
|
2013-06-14 21:54:26 +02:00
|
|
|
("positioning.nss.ignore-cp-reference-points",
|
2011-07-19 19:05:38 +02:00
|
|
|
po::value<bool>()->default_value(false),
|
2011-12-30 13:43:01 +01:00
|
|
|
"With the NSS algorithm, try to avoid selecting the reference"
|
2013-06-14 21:54:26 +02:00
|
|
|
" points which are coordinates of a CP.")
|
2014-05-13 22:55:19 +02:00
|
|
|
("positioning.filter.max-speed",
|
|
|
|
po::value<float>()->default_value(0),
|
|
|
|
"Maximal speed at which the mobiles can move, in km/h (0 = unlimited"
|
|
|
|
" speed).")
|
2014-05-14 23:04:44 +02:00
|
|
|
("positioning.filter.cp-reset-distance",
|
|
|
|
po::value<float>()->default_value(0),
|
2014-05-28 22:59:16 +02:00
|
|
|
"Use max-speed-cp instead of max-speed when the computed position is"
|
|
|
|
" at this distance (in m) from a CP or closer (0 = never use"
|
|
|
|
" max-speed-cp).")
|
|
|
|
("positioning.filter.max-speed-cp",
|
|
|
|
po::value<float>()->default_value(0),
|
|
|
|
"Maximal (virtual) speed at which the mobiles can move when they are"
|
|
|
|
" within cp-reset-distance, in km/h (0 = unlimited speed, i.e."
|
|
|
|
" completely disables filtering when the mobile is close to a CP).")
|
2010-03-23 14:53:37 +01:00
|
|
|
;
|
2010-03-05 17:24:18 +01:00
|
|
|
|
2010-03-23 14:53:37 +01:00
|
|
|
file_options->add(options) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UserInterface::fill_output_options()
|
|
|
|
{
|
|
|
|
po::options_description options("Output options") ;
|
|
|
|
|
|
|
|
options.add_options()
|
2012-08-24 16:39:00 +02:00
|
|
|
("output.2d-error",
|
|
|
|
po::value<bool>()->default_value(false),
|
|
|
|
"Compute the distance error in two dimensions instead of three"
|
|
|
|
" dimensions.")
|
2011-12-27 18:07:28 +01:00
|
|
|
("output.medium,O",
|
|
|
|
po::value< vector<string> >()->composing(),
|
|
|
|
"Medium to which the results will be written. You can specify"
|
2011-07-14 22:07:48 +02:00
|
|
|
" this option more than once."
|
2013-07-05 17:07:31 +02:00
|
|
|
" Allowed: Terminal, CSV, UDP, TCPEvAAL (EvAAL 2012 format)."
|
2011-07-14 22:07:48 +02:00
|
|
|
" If this option is absent, the results are printed on the terminal.")
|
2011-12-27 18:07:28 +01:00
|
|
|
("output.csv-file",
|
|
|
|
po::value<string>(),
|
2010-03-08 17:36:16 +01:00
|
|
|
"CSV file to use for output (when output.medium = CSV).")
|
2011-12-27 18:07:28 +01:00
|
|
|
("output.udp-host",
|
|
|
|
po::value<string>(),
|
2011-04-05 11:22:28 +02:00
|
|
|
"Host to which the UDP data is sent (when output.medium = UDP).")
|
2011-12-27 18:07:28 +01:00
|
|
|
("output.udp-port",
|
|
|
|
po::value<int>()->default_value(OWL_DEFAULT_RESULT_PORT),
|
2011-04-05 11:22:28 +02:00
|
|
|
"Port on which the UDP data is sent (when output.medium = UDP).")
|
2011-12-27 18:07:28 +01:00
|
|
|
("output.tcpevaal-host",
|
|
|
|
po::value<string>()->default_value(DEFAULT_TCPEVAAL_HOST),
|
2013-09-23 21:32:19 +02:00
|
|
|
"IP address of the host to which the TCP data is sent (when"
|
|
|
|
" output.medium = TCPEvAAL).")
|
2011-12-27 18:07:28 +01:00
|
|
|
("output.tcpevaal-port",
|
|
|
|
po::value<int>()->default_value(DEFAULT_TCPEVAAL_PORT),
|
2011-07-24 17:25:00 +02:00
|
|
|
"Port on which the TCP data is sent (when output.medium = TCPEvAAL).")
|
2010-03-23 14:53:37 +01:00
|
|
|
;
|
2010-03-05 17:24:18 +01:00
|
|
|
|
2010-03-23 14:53:37 +01:00
|
|
|
file_options->add(options) ;
|
2010-02-11 09:46:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-29 14:21:14 +02:00
|
|
|
void UserInterface::fill_misc_options()
|
|
|
|
{
|
|
|
|
po::options_description options("Miscellaneous options") ;
|
|
|
|
|
|
|
|
options.add_options()
|
2011-12-27 18:07:28 +01:00
|
|
|
("flush-output-files",
|
|
|
|
po::value<bool>()->default_value(true),
|
2011-03-29 14:21:14 +02:00
|
|
|
"Flush output text files after each line.")
|
2012-06-08 12:27:51 +02:00
|
|
|
("replay",
|
|
|
|
po::value<bool>()->default_value(false),
|
|
|
|
"\"Replay\" mode. With this option enabled, the current time is the"
|
2013-09-23 21:32:19 +02:00
|
|
|
" transmission timestamp of the most recent request; you will want"
|
|
|
|
" to enable this when reading inputs (requests) offline to replay"
|
2012-06-08 12:27:51 +02:00
|
|
|
" scenarios, if time-related options are enabled (e.g."
|
|
|
|
" \"positioning.calibration-requests-timeout\"). To be useful, this"
|
2013-05-17 21:08:35 +02:00
|
|
|
" option requires the listeners' clocks to be synchronised.")
|
2011-03-29 14:21:14 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
file_options->add(options) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-11 09:46:40 +01:00
|
|
|
void UserInterface::parse_options()
|
|
|
|
{
|
|
|
|
parse_command_line() ;
|
2011-08-24 11:41:07 +02:00
|
|
|
print_information() ;
|
|
|
|
if (! owl_run)
|
|
|
|
return ;
|
2010-02-11 09:46:40 +01:00
|
|
|
|
|
|
|
parse_file() ;
|
|
|
|
|
|
|
|
po::notify(Configuration::getw_configuration()) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UserInterface::parse_command_line() const
|
|
|
|
{
|
|
|
|
po::store(po::parse_command_line(cli_argument_count,
|
|
|
|
cli_argument_values,
|
|
|
|
*cli_options),
|
|
|
|
Configuration::getw_configuration()) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-24 11:41:07 +02:00
|
|
|
/**
|
|
|
|
* If information is printed, owl_run is set to false, to indicate that
|
|
|
|
* the program should stop.
|
|
|
|
*/
|
|
|
|
void UserInterface::print_information() const
|
2010-02-11 09:46:40 +01:00
|
|
|
{
|
2011-04-13 00:10:49 +02:00
|
|
|
// Print version if requested
|
|
|
|
if (Configuration::is_configured("version"))
|
|
|
|
{
|
|
|
|
cout
|
2012-02-06 17:17:25 +01:00
|
|
|
<< "This is OwlPS Positioner, part of the Owl"
|
2011-04-13 00:10:49 +02:00
|
|
|
<< " Positioning System project.\nVersion: " <<
|
|
|
|
#ifdef OWLPS_VERSION
|
|
|
|
OWLPS_VERSION
|
|
|
|
#else // OWLPS_VERSION
|
|
|
|
"unknown version"
|
|
|
|
#endif // OWLPS_VERSION
|
|
|
|
<< ".\n" ;
|
2013-05-15 21:46:13 +02:00
|
|
|
owl_run = false ; // Tell main() to exit
|
2011-04-13 00:10:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Print usage if requested
|
2010-02-11 09:46:40 +01:00
|
|
|
if (Configuration::is_configured("help"))
|
|
|
|
{
|
|
|
|
cout << *cli_options ;
|
2013-05-15 21:46:13 +02:00
|
|
|
owl_run = false ; // Tell main() to exit
|
2010-02-11 09:46:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UserInterface::parse_file() const
|
|
|
|
{
|
2010-03-08 11:38:25 +01:00
|
|
|
string config_file_name = Configuration::string_value("config-file") ;
|
2010-02-11 09:46:40 +01:00
|
|
|
ifstream config_file(config_file_name.c_str()) ;
|
|
|
|
|
|
|
|
if (! config_file)
|
|
|
|
{
|
|
|
|
cerr
|
2012-01-24 18:43:00 +01:00
|
|
|
<< "Warning! Error opening input configuration file \""
|
2010-02-11 09:46:40 +01:00
|
|
|
<< config_file_name
|
2012-01-24 18:43:00 +01:00
|
|
|
<< "\"! Using command line and default values..."
|
2010-02-11 09:46:40 +01:00
|
|
|
<< endl ;
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
|
|
|
po::store(po::parse_config_file(config_file, *file_options),
|
|
|
|
Configuration::getw_configuration()) ;
|
|
|
|
}
|