[Positioning] Read mobiles characteristics
Add MobilesReaderCSV, that reads the known mobiles from a CSV file.
This commit is contained in:
parent
8878bb2390
commit
0b43e7f5fc
|
@ -82,6 +82,7 @@ OBJ_LIST = \
|
||||||
userinterface.o \
|
userinterface.o \
|
||||||
inputdatareader.o \
|
inputdatareader.o \
|
||||||
accesspointsreadercsv.o \
|
accesspointsreadercsv.o \
|
||||||
|
mobilesreadercsv.o \
|
||||||
topologyreadercsv.o \
|
topologyreadercsv.o \
|
||||||
textfilereader.o \
|
textfilereader.o \
|
||||||
csvfilereader.o \
|
csvfilereader.o \
|
||||||
|
@ -155,6 +156,7 @@ $(OBJ_DIR)/userinterface.o: \
|
||||||
$(OBJ_DIR)/configuration.o
|
$(OBJ_DIR)/configuration.o
|
||||||
$(OBJ_DIR)/inputdatareader.o: \
|
$(OBJ_DIR)/inputdatareader.o: \
|
||||||
$(OBJ_DIR)/accesspointsreadercsv.o \
|
$(OBJ_DIR)/accesspointsreadercsv.o \
|
||||||
|
$(OBJ_DIR)/mobilesreadercsv.o \
|
||||||
$(OBJ_DIR)/topologyreadercsv.o \
|
$(OBJ_DIR)/topologyreadercsv.o \
|
||||||
$(OBJ_DIR)/configuration.o \
|
$(OBJ_DIR)/configuration.o \
|
||||||
$(OBJ_DIR)/posexcept.o
|
$(OBJ_DIR)/posexcept.o
|
||||||
|
@ -162,6 +164,10 @@ $(OBJ_DIR)/accesspointsreadercsv.o: \
|
||||||
$(OBJ_DIR)/csvfilereader.o \
|
$(OBJ_DIR)/csvfilereader.o \
|
||||||
$(OBJ_DIR)/accesspoint.o \
|
$(OBJ_DIR)/accesspoint.o \
|
||||||
$(OBJ_DIR)/stock.o
|
$(OBJ_DIR)/stock.o
|
||||||
|
$(OBJ_DIR)/mobilesreadercsv.o: \
|
||||||
|
$(OBJ_DIR)/csvfilereader.o \
|
||||||
|
$(OBJ_DIR)/mobile.o \
|
||||||
|
$(OBJ_DIR)/stock.o
|
||||||
$(OBJ_DIR)/topologyreadercsv.o: \
|
$(OBJ_DIR)/topologyreadercsv.o: \
|
||||||
$(OBJ_DIR)/csvfilereader.o \
|
$(OBJ_DIR)/csvfilereader.o \
|
||||||
$(OBJ_DIR)/area.o \
|
$(OBJ_DIR)/area.o \
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Mobiles' physical description file.
|
||||||
|
#
|
||||||
|
# Each line follows this format:
|
||||||
|
# MAC address;Antenna gain (dBi);Trx power (dBm)
|
||||||
|
#
|
||||||
|
# Blank lines are ignored. Commented lines must have a sharp (#) as
|
||||||
|
# their FIRST character.
|
||||||
|
|
||||||
|
# Example mobile:
|
||||||
|
#aa:bb:cc:dd:ee:ff;1.8;18.0
|
|
|
@ -10,6 +10,10 @@
|
||||||
ap-medium = CSV
|
ap-medium = CSV
|
||||||
ap-csv-file = cfg/listeners.csv
|
ap-csv-file = cfg/listeners.csv
|
||||||
|
|
||||||
|
# Description of the clients
|
||||||
|
mobile-medium = CSV
|
||||||
|
mobile-csv-file = cfg/mobiles.csv
|
||||||
|
|
||||||
# Description of deployment area topology.
|
# Description of deployment area topology.
|
||||||
# You probably don't need a full description of the topology, see the
|
# You probably don't need a full description of the topology, see the
|
||||||
# topology example file for details.
|
# topology example file for details.
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "inputdatareader.hh"
|
#include "inputdatareader.hh"
|
||||||
#include "accesspointsreadercsv.hh"
|
#include "accesspointsreadercsv.hh"
|
||||||
|
#include "mobilesreadercsv.hh"
|
||||||
#include "topologyreadercsv.hh"
|
#include "topologyreadercsv.hh"
|
||||||
#include "inputcsv.hh"
|
#include "inputcsv.hh"
|
||||||
#include "calibrationrequest.hh"
|
#include "calibrationrequest.hh"
|
||||||
|
@ -19,6 +20,7 @@ using namespace std ;
|
||||||
InputDataReader::InputDataReader()
|
InputDataReader::InputDataReader()
|
||||||
{
|
{
|
||||||
read_access_points() ;
|
read_access_points() ;
|
||||||
|
read_mobiles() ;
|
||||||
read_topology() ;
|
read_topology() ;
|
||||||
read_reference_points() ;
|
read_reference_points() ;
|
||||||
}
|
}
|
||||||
|
@ -80,6 +82,51 @@ void InputDataReader::initialise_access_points_csv()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* *** Mobiles *** */
|
||||||
|
|
||||||
|
|
||||||
|
void InputDataReader::read_mobiles()
|
||||||
|
{
|
||||||
|
if (! Configuration::is_configured("data-input.mobile-medium"))
|
||||||
|
return ;
|
||||||
|
|
||||||
|
initialise_mobiles_media() ;
|
||||||
|
|
||||||
|
if (Configuration::is_configured("verbose"))
|
||||||
|
cerr << Stock::nb_mobiles() << " mobiles stored.\n" ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InputDataReader::initialise_mobiles_media()
|
||||||
|
{
|
||||||
|
const vector<string> &media_names =
|
||||||
|
Configuration::string_vector_value("data-input.mobile-medium") ;
|
||||||
|
|
||||||
|
for (vector<string>::const_iterator i = media_names.begin() ;
|
||||||
|
i != media_names.end() ; ++i)
|
||||||
|
{
|
||||||
|
if (*i == "CSV")
|
||||||
|
initialise_mobiles_csv() ;
|
||||||
|
|
||||||
|
else
|
||||||
|
throw bad_configuration(
|
||||||
|
"Mobiles' input medium type unknown « "+ *i +" »") ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InputDataReader::initialise_mobiles_csv()
|
||||||
|
{
|
||||||
|
if (! Configuration::is_configured("data-input.mobile-csv-file"))
|
||||||
|
throw missing_configuration(
|
||||||
|
"No input CSV file specified for mobiles") ;
|
||||||
|
|
||||||
|
MobilesReaderCSV(
|
||||||
|
Configuration::string_value("data-input.mobile-csv-file")) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* *** Topology *** */
|
/* *** Topology *** */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,10 @@ protected:
|
||||||
void initialise_access_points_media(void) ;
|
void initialise_access_points_media(void) ;
|
||||||
void initialise_access_points_csv(void) ;
|
void initialise_access_points_csv(void) ;
|
||||||
|
|
||||||
|
void read_mobiles(void) ;
|
||||||
|
void initialise_mobiles_media(void) ;
|
||||||
|
void initialise_mobiles_csv(void) ;
|
||||||
|
|
||||||
void read_topology(void) ;
|
void read_topology(void) ;
|
||||||
void initialise_topology_media(void) ;
|
void initialise_topology_media(void) ;
|
||||||
void initialise_topology_csv(void) ;
|
void initialise_topology_csv(void) ;
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
#include "mobilesreadercsv.hh"
|
||||||
|
#include "point3d.hh"
|
||||||
|
#include "stock.hh"
|
||||||
|
#include "posexcept.hh"
|
||||||
|
|
||||||
|
using namespace std ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* *** Constructors *** */
|
||||||
|
|
||||||
|
|
||||||
|
MobilesReaderCSV::MobilesReaderCSV(const string &file_name):
|
||||||
|
file(file_name)
|
||||||
|
{
|
||||||
|
read_devices() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* *** Operations *** */
|
||||||
|
|
||||||
|
|
||||||
|
void MobilesReaderCSV::read_devices()
|
||||||
|
{
|
||||||
|
while (file.next_line())
|
||||||
|
process_device_line() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MobilesReaderCSV::process_device_line()
|
||||||
|
{
|
||||||
|
string mac ;
|
||||||
|
if (! file.read_field(mac))
|
||||||
|
throw malformed_input_data("Cannot read mobile's MAC address!") ;
|
||||||
|
PosUtil::to_upper(mac) ;
|
||||||
|
|
||||||
|
float gain ;
|
||||||
|
if (! file.read_field(gain))
|
||||||
|
throw malformed_input_data("Cannot read mobile's gain!") ;
|
||||||
|
|
||||||
|
float power ;
|
||||||
|
if (! file.read_field(power))
|
||||||
|
throw malformed_input_data("Cannot read mobile's power!") ;
|
||||||
|
|
||||||
|
string ip("") ;
|
||||||
|
|
||||||
|
Mobile device(ip, mac, gain, power) ;
|
||||||
|
Stock::find_create_mobile(device) ;
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
#ifndef _OWLPS_POSITIONING_MOBILESREADERCSV_HH_
|
||||||
|
#define _OWLPS_POSITIONING_MOBILESREADERCSV_HH_
|
||||||
|
|
||||||
|
class Point3D ;
|
||||||
|
|
||||||
|
#include "csvfilereader.hh"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
/// Reads and registers to the Stock Mobile list from CSV files
|
||||||
|
/**
|
||||||
|
* CSV format for access points is:
|
||||||
|
* MAC;Antenna_gain_dBi;Trx_power_dBm
|
||||||
|
*/
|
||||||
|
class MobilesReaderCSV
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
CSVFileReader file ;
|
||||||
|
|
||||||
|
void read_devices(void) ;
|
||||||
|
void process_device_line(void) ;
|
||||||
|
|
||||||
|
public:
|
||||||
|
MobilesReaderCSV(const std::string &file_name) ;
|
||||||
|
|
||||||
|
~MobilesReaderCSV(void) {}
|
||||||
|
} ;
|
||||||
|
|
||||||
|
#endif // _OWLPS_POSITIONING_MOBILESREADERCSV_HH_
|
|
@ -106,6 +106,13 @@ void UserInterface::fill_data_input_options()
|
||||||
("data-input.ap-csv-file", po::value<string>(),
|
("data-input.ap-csv-file", po::value<string>(),
|
||||||
"CSV file to use for access points input (when"
|
"CSV file to use for access points input (when"
|
||||||
" data-input.ap-medium = CSV).")
|
" data-input.ap-medium = CSV).")
|
||||||
|
("data-input.mobile-medium", po::value< vector<string> >()
|
||||||
|
->composing(),
|
||||||
|
"Medium from which mobiles are read. You can specify this"
|
||||||
|
" option more than once. Allowed: CSV.")
|
||||||
|
("data-input.mobile-csv-file", po::value<string>(),
|
||||||
|
"CSV file to use for mobiles input (when"
|
||||||
|
" data-input.mobile-medium = CSV).")
|
||||||
("data-input.topology-medium,T", po::value< vector<string> >()
|
("data-input.topology-medium,T", po::value< vector<string> >()
|
||||||
->composing(),
|
->composing(),
|
||||||
"Medium from which topology (buildings, areas and waypoints) is"
|
"Medium from which topology (buildings, areas and waypoints) is"
|
||||||
|
|
Loading…
Reference in New Issue