[Positioning] Add Request, complete InputCSV
== code/owlps-positioning == - Add new class Request (split of Measurement). - Update Measurement and CalibrationMeasurement (suppress the 'mobile' attribute). - Update InputCSV (and InputMedium) to use Request instead of Measurement. Complete the file reading (mobile & ap pointers remain to be implemented). - PosUtil: Add timespec_to_ms(), timespec_to_ns(), ms_to_timespec(), and ns_to_timespec(). - Makefile: Update to use stlport, fix all deps and add new classes. - Minor fixes. - TODO: Add UML-related things, updates Measurement & Request. == code == - libowlps: Add ms_to_timeval() (commented), may be useful later. - Add TODO.
This commit is contained in:
parent
8f071d13b0
commit
5f8f955a3d
|
@ -0,0 +1,4 @@
|
||||||
|
Abandonner gettimeofday() et struct timeval au profit de clock_gettime()
|
||||||
|
et struct timespec. gettimeofday() est obsolète depuis POSIX:2008.
|
||||||
|
|
||||||
|
Abandonner int, long & Cie pour les échanges de données, passer à stdint.h
|
|
@ -92,6 +92,20 @@ unsigned long long timeval_to_ms(struct timeval d)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convertit une date sous forme de valeur entière en millisecondes,
|
||||||
|
* en une struct timeval, et retourne cette structure.
|
||||||
|
struct timeval ms_to_timeval(unsigned long long tms)
|
||||||
|
{
|
||||||
|
struct timeval d ;
|
||||||
|
d.tv_sec = tms / 1000 ;
|
||||||
|
d.tv_usec = (tms - d.tv_sec * 1000) * 1000 ;
|
||||||
|
return d ;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Retourne le temps (en millisecondes) écoulé entre deux dates */
|
/* Retourne le temps (en millisecondes) écoulé entre deux dates */
|
||||||
unsigned long sub_date(struct timeval sup, struct timeval inf)
|
unsigned long sub_date(struct timeval sup, struct timeval inf)
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,16 +11,19 @@ CP = cp -v
|
||||||
# Autres outils
|
# Autres outils
|
||||||
STYLE = astyle --style=gnu
|
STYLE = astyle --style=gnu
|
||||||
|
|
||||||
GXX = g++
|
GXX = g++-4.4
|
||||||
DEBUG = -g
|
DEBUG = -g
|
||||||
GXXFLAGS = $(DEBUG) -Wall -pedantic
|
STLPORTGXXFLAGS = -I/usr/include/stlport -pthread -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
|
||||||
LD = g++
|
GXXFLAGS = $(DEBUG) -Wall -Wextra $(STLPORTGXXFLAGS)
|
||||||
LDFLAGS = -lm
|
LD = $(GXX)
|
||||||
|
LDFLAGS = -lm -lstlport
|
||||||
LIBS = -lpq -lboost_program_options-mt
|
LIBS = -lpq -lboost_program_options-mt
|
||||||
|
|
||||||
TARGET = owlps-positioning
|
TARGET = owlps-positioning
|
||||||
HEADER = owlps-positioning.hh
|
HEADER = owlps-positioning.hh
|
||||||
OBJ = posutil.o point3d.o referencepoint.o waypoint.o building.o area.o wifidevice.o accesspoint.o mobile.o measurement.o calibrationmeasurement.o inputcsv.o
|
OBJ = posutil.o point3d.o referencepoint.o waypoint.o building.o \
|
||||||
|
area.o wifidevice.o accesspoint.o mobile.o measurement.o \
|
||||||
|
calibrationmeasurement.o request.o inputcsv.o
|
||||||
|
|
||||||
all: $(TARGET)
|
all: $(TARGET)
|
||||||
|
|
||||||
|
@ -31,16 +34,17 @@ all: $(TARGET)
|
||||||
|
|
||||||
posutil.o: posutil.hh
|
posutil.o: posutil.hh
|
||||||
point3d.o: point3d.hh
|
point3d.o: point3d.hh
|
||||||
referencepoint.o : referencepoint.hh point3d.hh calibrationmeasurement.hh
|
referencepoint.o : referencepoint.hh point3d.o
|
||||||
waypoint.o: waypoint.hh point3d.hh building.hh
|
waypoint.o: waypoint.hh point3d.o building.o
|
||||||
building.o: building.hh
|
building.o: building.hh
|
||||||
area.o: area.hh building.hh point3d.hh
|
area.o: area.hh building.o point3d.o
|
||||||
wifidevice.o: wifidevice.hh posutil.hh
|
wifidevice.o: wifidevice.hh posutil.o
|
||||||
accesspoint.o: accesspoint.hh wifidevice.hh point3d.hh
|
accesspoint.o: accesspoint.hh wifidevice.o point3d.o
|
||||||
mobile.o: mobile.hh wifidevice.hh
|
mobile.o: mobile.hh wifidevice.o
|
||||||
measurement.o: measurement.hh mobile.hh accesspoint.hh
|
measurement.o: measurement.hh accesspoint.o
|
||||||
calibrationmeasurement.o: calibrationmeasurement.hh measurement.hh referencepoint.hh
|
calibrationmeasurement.o: calibrationmeasurement.hh measurement.o referencepoint.o
|
||||||
inputcsv.o: inputcsv.hh inputmedium.hh
|
request.o: request.hh measurement.o
|
||||||
|
inputcsv.o: inputcsv.hh inputmedium.hh request.o
|
||||||
#libowlps-positioning.o: libowlps-positioning.hh
|
#libowlps-positioning.o: libowlps-positioning.hh
|
||||||
#positioning.o: point.hh referencepoint.hh accesspoint.hh area.hh measurement.hh libowlps-positioning.hh
|
#positioning.o: point.hh referencepoint.hh accesspoint.hh area.hh measurement.hh libowlps-positioning.hh
|
||||||
#server.o: server.hh positioning.hh point.hh measurement.hh treatment.hh libowlps-positioning.hh
|
#server.o: server.hh positioning.hh point.hh measurement.hh treatment.hh libowlps-positioning.hh
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
|
|
||||||
- Measurement
|
- Measurement & Request
|
||||||
Un Measurement est un groupe de mesures de signaux envoyés par un
|
Actuellement, l'AP associé à chaque Measurement (pointeur) n'est
|
||||||
mobile à un AP. Pour une demande de localisation, on aura donc
|
pas initialisé lors de la lecture depuis un InputCSV. Les
|
||||||
plusieurs Measurement. Cela pose-t-il problème ? Faut-il grouper
|
Measurement sont créés par accès direct dans la table de hachage :
|
||||||
les Measurement dans une classe Demande ?
|
measurements[mac_ap].add_ss(ss)
|
||||||
Anciennement, on avait une liste de points de référence, et à
|
C'est donc le constructeur par défaut Measurement() qui est utilisé
|
||||||
chaque point étaient associés des mesures {MAC AP, SS}.
|
lors du premier accès.
|
||||||
|
|
||||||
|
- InputCSV
|
||||||
|
° Différencier une requête normale d'une requête de calibration, en
|
||||||
|
utilisant les champs de direction.
|
||||||
|
° Lire la direction en tant qu'entier plutôt que float ?
|
||||||
|
|
||||||
- '\n' vs. endl.
|
- '\n' vs. endl.
|
||||||
Utiliser '\n' plutôt que endl lorsque le vidage du tampon n'est pas
|
Utiliser '\n' plutôt que endl lorsque le vidage du tampon n'est pas
|
||||||
|
@ -13,6 +18,12 @@
|
||||||
|
|
||||||
- Measurement : corriger le calcul de moyenne.
|
- Measurement : corriger le calcul de moyenne.
|
||||||
|
|
||||||
|
- Revoir le diagramme UML
|
||||||
|
° Associations : devraient êtres représentées par des attributs
|
||||||
|
pointeurs.
|
||||||
|
° Compositions : devraient être représentées par des attributs
|
||||||
|
normaux.
|
||||||
|
|
||||||
- AccessPoint : attribut float friis_index ?
|
- AccessPoint : attribut float friis_index ?
|
||||||
|
|
||||||
- Mobile : attributs Viterbi ?
|
- Mobile : attributs Viterbi ?
|
||||||
|
|
|
@ -11,11 +11,10 @@ protected:
|
||||||
ReferencePoint *reference_point ;
|
ReferencePoint *reference_point ;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CalibrationMeasurement(const Mobile *_mobile = NULL,
|
CalibrationMeasurement(const AccessPoint *_ap = NULL,
|
||||||
const AccessPoint *_ap = NULL,
|
|
||||||
const std::vector<int> &_ss_list = std::vector<int>(),
|
const std::vector<int> &_ss_list = std::vector<int>(),
|
||||||
ReferencePoint *_reference_point = NULL):
|
ReferencePoint *_reference_point = NULL):
|
||||||
Measurement(_mobile, _ap, _ss_list), reference_point(_reference_point) {}
|
Measurement(_ap, _ss_list), reference_point(_reference_point) {}
|
||||||
CalibrationMeasurement(const CalibrationMeasurement &cm):
|
CalibrationMeasurement(const CalibrationMeasurement &cm):
|
||||||
Measurement(cm), reference_point(cm.reference_point) {}
|
Measurement(cm), reference_point(cm.reference_point) {}
|
||||||
CalibrationMeasurement(const Measurement &m):
|
CalibrationMeasurement(const Measurement &m):
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
*.csv
|
|
@ -1,10 +1,17 @@
|
||||||
#include "inputcsv.hh"
|
#include "inputcsv.hh"
|
||||||
|
#include "posutil.hh"
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
using namespace std ;
|
||||||
|
using std::tr1::unordered_map ;
|
||||||
|
|
||||||
#include <boost/tokenizer.hpp>
|
#include <boost/tokenizer.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
using namespace std ;
|
|
||||||
using namespace boost ;
|
using namespace boost ;
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,8 +26,8 @@ InputCSV::InputCSV(const string &filename)
|
||||||
input_file.open(input_file_name.c_str()) ;
|
input_file.open(input_file_name.c_str()) ;
|
||||||
if (! input_file)
|
if (! input_file)
|
||||||
cerr
|
cerr
|
||||||
<< "InputCSV(): Error opening input file « " << input_file_name
|
<< "InputCSV::InputCSV(): Error opening input file « "
|
||||||
<< " »!" << endl ;
|
<< input_file_name << " »!" << endl ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,10 +35,10 @@ InputCSV::InputCSV(const string &filename)
|
||||||
/*** Opérations ***/
|
/*** Opérations ***/
|
||||||
|
|
||||||
|
|
||||||
const Measurement& InputCSV::get_next_measurement()
|
const Request& InputCSV::get_next_request()
|
||||||
{
|
{
|
||||||
if (! input_file)
|
if (! input_file)
|
||||||
return current_measurement ;
|
return current_request ;
|
||||||
|
|
||||||
string line ;
|
string line ;
|
||||||
|
|
||||||
|
@ -46,37 +53,115 @@ const Measurement& InputCSV::get_next_measurement()
|
||||||
|
|
||||||
if (input_file.eof())
|
if (input_file.eof())
|
||||||
{
|
{
|
||||||
// End of file reached: blank current measurement
|
// End of file reached: blank current request
|
||||||
current_measurement.clear() ;
|
current_request.clear() ;
|
||||||
return current_measurement ;
|
return current_request ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Split read string into fields (semicolon-separated)
|
// Split read string into fields (semicolon-separated)
|
||||||
tokenizer<escaped_list_separator<char> > tok(
|
tokenizer<escaped_list_separator<char> > tok(
|
||||||
line, escaped_list_separator<char>('\\', ';', '\"')) ;
|
line, escaped_list_separator<char>('\\', ';', '\"')) ;
|
||||||
|
|
||||||
vector<int> ss_list ;
|
tokenizer<escaped_list_separator<char> >::iterator ti(tok.begin()) ;
|
||||||
|
|
||||||
for (tokenizer<escaped_list_separator<char> >::iterator i(tok.begin()) ;
|
// Read Mobile MAC field
|
||||||
i != tok.end() ; ++i)
|
if (ti == tok.end())
|
||||||
{
|
{
|
||||||
|
// Wrong number of fields: blank current request
|
||||||
|
current_request.clear() ;
|
||||||
|
return current_request ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME! We need to search for the mobile corresponding to the read
|
||||||
|
// MAC address and set the mobile pointer in the Request.
|
||||||
|
//current_request.set_mobile(NULL) ;
|
||||||
|
|
||||||
|
// Read Timestamp field
|
||||||
|
if (++ti == tok.end())
|
||||||
|
{
|
||||||
|
// Wrong number of fields: blank current request
|
||||||
|
current_request.clear() ;
|
||||||
|
return current_request ;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
current_request.set_timestamp(PosUtil::ns_to_timespec
|
||||||
|
(lexical_cast<uint64_t>(*ti))) ;
|
||||||
|
}
|
||||||
|
catch (bad_lexical_cast &e)
|
||||||
|
{
|
||||||
|
cerr
|
||||||
|
<< "InputCSV::get_next_request(): Bad value « "
|
||||||
|
<< *ti << " » at line "
|
||||||
|
<< current_line << ", field « Timestamp », of input file « "
|
||||||
|
<< input_file_name << " »!" << endl ;
|
||||||
|
current_request.clear() ; // Blank current request
|
||||||
|
return current_request ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read position fields
|
||||||
|
float pos[4] ;
|
||||||
|
for (int i = 0 ; i < 4 ; ++i)
|
||||||
|
{
|
||||||
|
if (++ti == tok.end())
|
||||||
|
{
|
||||||
|
// Wrong number of fields: blank current request
|
||||||
|
current_request.clear() ;
|
||||||
|
return current_request ;
|
||||||
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ss_list.push_back(lexical_cast<int>(*i)) ;
|
pos[i] = lexical_cast<float>(*ti) ;
|
||||||
}
|
}
|
||||||
catch (bad_lexical_cast &e)
|
catch (bad_lexical_cast &e)
|
||||||
{
|
{
|
||||||
cerr
|
cerr
|
||||||
<< "InputCSV::getNextMeasurement(): Bad value at line "
|
<< "InputCSV::get_next_request(): Bad value « "
|
||||||
<< current_line
|
<< *ti << " » at line "
|
||||||
<< " of input file « " << input_file_name << " »!"
|
<< current_line << ", position field #" << i
|
||||||
|
<< ", of input file « " << input_file_name << " »!"
|
||||||
<< endl ;
|
<< endl ;
|
||||||
current_measurement.clear() ; // Blank current measurement
|
current_request.clear() ; // Blank current request
|
||||||
return current_measurement ;
|
return current_request ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
current_measurement.set_ss_list(ss_list) ;
|
unordered_map<string, Measurement> measurements ;
|
||||||
|
|
||||||
return current_measurement ;
|
// Reading {MAC_AP;SS} couples
|
||||||
|
for (++ti ; ti != tok.end() ; ++ti)
|
||||||
|
{
|
||||||
|
string mac_ap(*ti) ;
|
||||||
|
|
||||||
|
if (++ti == tok.end())
|
||||||
|
{
|
||||||
|
// Wrong number of fields: blank current request
|
||||||
|
current_request.clear() ;
|
||||||
|
return current_request ;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ss ;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ss = lexical_cast<int>(*ti) ;
|
||||||
|
}
|
||||||
|
catch (bad_lexical_cast &e)
|
||||||
|
{
|
||||||
|
cerr
|
||||||
|
<< "InputCSV::get_next_request(): Bad value « "
|
||||||
|
<< *ti << " » at line "
|
||||||
|
<< current_line
|
||||||
|
<< " of input file « " << input_file_name << " »!"
|
||||||
|
<< endl ;
|
||||||
|
current_request.clear() ; // Blank current request
|
||||||
|
return current_request ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adding value
|
||||||
|
measurements[mac_ap].add_ss(ss) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
current_request.set_measurements(measurements) ;
|
||||||
|
|
||||||
|
return current_request ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ public:
|
||||||
|
|
||||||
bool eof(void) const ;
|
bool eof(void) const ;
|
||||||
|
|
||||||
const Measurement& get_next_measurement(void) ;
|
const Request& get_next_request(void) ;
|
||||||
|
|
||||||
operator bool(void) const ;
|
operator bool(void) const ;
|
||||||
} ;
|
} ;
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
#ifndef _OWLPS_POSITIONING_INPUTMEDIUM_HH_
|
#ifndef _OWLPS_POSITIONING_INPUTMEDIUM_HH_
|
||||||
#define _OWLPS_POSITIONING_INPUTMEDIUM_HH_
|
#define _OWLPS_POSITIONING_INPUTMEDIUM_HH_
|
||||||
|
|
||||||
#include "measurement.hh"
|
#include "request.hh"
|
||||||
|
|
||||||
class InputMedium
|
class InputMedium
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
Measurement current_measurement ;
|
Request current_request ;
|
||||||
unsigned long current_line ;
|
unsigned long current_line ;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InputMedium() ;
|
InputMedium() ;
|
||||||
|
|
||||||
const Measurement& get_current_measurement(void) const ;
|
const Request& get_current_request(void) const ;
|
||||||
unsigned int get_current_line(void) const ;
|
unsigned int get_current_line(void) const ;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reads the next measurement and returns it, increments current_line
|
* Reads the next request and returns it, increments current_line
|
||||||
* Returns an empty Measurement in case of error or EOF (note that
|
* Returns an empty Request in case of error or EOF (note that
|
||||||
* when casted in bool, an empty Measurement is false).
|
* when casted in bool, an empty Request is false).
|
||||||
*/
|
*/
|
||||||
virtual const Measurement& get_next_measurement(void) = 0 ;
|
virtual const Request& get_next_request(void) = 0 ;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns true if the last measurement has been reached
|
* Returns true if the last request has been reached
|
||||||
*/
|
*/
|
||||||
virtual bool eof(void) const = 0 ;
|
virtual bool eof(void) const = 0 ;
|
||||||
} ;
|
} ;
|
||||||
|
@ -43,9 +43,9 @@ inline InputMedium::InputMedium()
|
||||||
/*** Accesseurs lecture ***/
|
/*** Accesseurs lecture ***/
|
||||||
|
|
||||||
|
|
||||||
inline const Measurement& InputMedium::get_current_measurement() const
|
inline const Request& InputMedium::get_current_request() const
|
||||||
{
|
{
|
||||||
return current_measurement ;
|
return current_request ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,19 +8,18 @@ using namespace std ;
|
||||||
/*** Constructeurs ***/
|
/*** Constructeurs ***/
|
||||||
|
|
||||||
|
|
||||||
Measurement::Measurement(const Mobile *_mobile, const AccessPoint *_ap,
|
Measurement::Measurement(const AccessPoint *_ap,
|
||||||
const vector<int> &_ss_list)
|
const vector<int> &_ss_list)
|
||||||
{
|
{
|
||||||
mobile = (Mobile *) _mobile ;
|
|
||||||
ap = (AccessPoint *) _ap ;
|
ap = (AccessPoint *) _ap ;
|
||||||
ss_list = _ss_list ;
|
ss_list = _ss_list ;
|
||||||
|
ss_list.reserve(10) ;
|
||||||
update_average_ss() ;
|
update_average_ss() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Measurement::Measurement(const Measurement &m)
|
Measurement::Measurement(const Measurement &m)
|
||||||
{
|
{
|
||||||
mobile = m.mobile ;
|
|
||||||
ap = m.ap ;
|
ap = m.ap ;
|
||||||
ss_list = m.ss_list ;
|
ss_list = m.ss_list ;
|
||||||
average_ss = m.average_ss ;
|
average_ss = m.average_ss ;
|
||||||
|
@ -45,7 +44,8 @@ void Measurement::update_average_ss()
|
||||||
{
|
{
|
||||||
average_ss = 0 ;
|
average_ss = 0 ;
|
||||||
|
|
||||||
for (vector<int>::iterator i = ss_list.begin() ; i < ss_list.end() ; i++)
|
for (vector<int>::iterator i = ss_list.begin() ;
|
||||||
|
i != ss_list.end() ; i++)
|
||||||
{
|
{
|
||||||
float ss_mwatts =
|
float ss_mwatts =
|
||||||
pow(10, (float) *i / 10.0) +
|
pow(10, (float) *i / 10.0) +
|
||||||
|
@ -81,7 +81,6 @@ void Measurement::clear()
|
||||||
ss_list.clear() ;
|
ss_list.clear() ;
|
||||||
average_ss = 0 ;
|
average_ss = 0 ;
|
||||||
ap = NULL ;
|
ap = NULL ;
|
||||||
mobile = NULL ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,7 +93,6 @@ Measurement Measurement::operator=(const Measurement &m)
|
||||||
if (this == &m)
|
if (this == &m)
|
||||||
return *this ;
|
return *this ;
|
||||||
|
|
||||||
mobile = m.mobile ;
|
|
||||||
ap = m.ap ;
|
ap = m.ap ;
|
||||||
ss_list = m.ss_list ;
|
ss_list = m.ss_list ;
|
||||||
average_ss = m.average_ss ;
|
average_ss = m.average_ss ;
|
||||||
|
@ -109,7 +107,6 @@ bool Measurement::operator==(const Measurement &m) const
|
||||||
return true ;
|
return true ;
|
||||||
|
|
||||||
return
|
return
|
||||||
mobile == m.mobile &&
|
|
||||||
ap == m.ap &&
|
ap == m.ap &&
|
||||||
ss_list == m.ss_list &&
|
ss_list == m.ss_list &&
|
||||||
average_ss == m.average_ss ;
|
average_ss == m.average_ss ;
|
||||||
|
@ -119,10 +116,9 @@ bool Measurement::operator==(const Measurement &m) const
|
||||||
|
|
||||||
ostream &operator<<(ostream &os, const Measurement &m)
|
ostream &operator<<(ostream &os, const Measurement &m)
|
||||||
{
|
{
|
||||||
// MAC addresses
|
// MAC address
|
||||||
os
|
os
|
||||||
<< (m.mobile != NULL ? m.mobile->get_mac_addr() : "Unknown_mobile")
|
<< "AP: " << (m.ap != NULL ? m.ap->get_mac_addr() : "Unknown_AP")
|
||||||
<< "->" << (m.ap != NULL ? m.ap->get_mac_addr() : "Unknown_AP")
|
|
||||||
<< ": " ;
|
<< ": " ;
|
||||||
|
|
||||||
// List of SS
|
// List of SS
|
||||||
|
@ -130,7 +126,7 @@ ostream &operator<<(ostream &os, const Measurement &m)
|
||||||
os << "No values" ;
|
os << "No values" ;
|
||||||
else
|
else
|
||||||
for (vector<int>::const_iterator i = m.ss_list.begin() ;
|
for (vector<int>::const_iterator i = m.ss_list.begin() ;
|
||||||
i < m.ss_list.end() ; i++)
|
i != m.ss_list.end() ; i++)
|
||||||
{
|
{
|
||||||
os << *i ;
|
os << *i ;
|
||||||
if (i != m.ss_list.end() - 1)
|
if (i != m.ss_list.end() - 1)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#ifndef _OWLPS_POSITIONING_MEASUREMENT_HH_
|
#ifndef _OWLPS_POSITIONING_MEASUREMENT_HH_
|
||||||
#define _OWLPS_POSITIONING_MEASUREMENT_HH_
|
#define _OWLPS_POSITIONING_MEASUREMENT_HH_
|
||||||
|
|
||||||
#include "mobile.hh"
|
|
||||||
#include "accesspoint.hh"
|
#include "accesspoint.hh"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -11,7 +10,6 @@
|
||||||
class Measurement
|
class Measurement
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
Mobile *mobile ;
|
|
||||||
AccessPoint *ap ;
|
AccessPoint *ap ;
|
||||||
float average_ss ;
|
float average_ss ;
|
||||||
std::vector<int> ss_list ;
|
std::vector<int> ss_list ;
|
||||||
|
@ -19,19 +17,17 @@ protected:
|
||||||
void update_average_ss(void) ;
|
void update_average_ss(void) ;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Measurement(const Mobile *_mobile = NULL, const AccessPoint *_ap = NULL,
|
Measurement(const AccessPoint *_ap = NULL,
|
||||||
const std::vector<int> &_ss_list = std::vector<int>()) ;
|
const std::vector<int> &_ss_list = std::vector<int>()) ;
|
||||||
Measurement(const Measurement &m) ;
|
Measurement(const Measurement &m) ;
|
||||||
|
|
||||||
~Measurement() ;
|
~Measurement() ;
|
||||||
|
|
||||||
Mobile* get_mobile() const ;
|
|
||||||
AccessPoint* get_ap() const ;
|
AccessPoint* get_ap() const ;
|
||||||
std::vector<int> get_ss_list() const ;
|
std::vector<int> get_ss_list() const ;
|
||||||
float get_average_ss() const ;
|
float get_average_ss() const ;
|
||||||
//float get_ss_square_distance(const float &ss) const ;
|
//float get_ss_square_distance(const float &ss) const ;
|
||||||
|
|
||||||
void set_mobile(const Mobile *_mobile) ;
|
|
||||||
void set_ap(const AccessPoint *_ap) ;
|
void set_ap(const AccessPoint *_ap) ;
|
||||||
void add_ss(const int &ss) ;
|
void add_ss(const int &ss) ;
|
||||||
void set_ss_list(const std::vector<int> &_ss_list) ;
|
void set_ss_list(const std::vector<int> &_ss_list) ;
|
||||||
|
@ -50,12 +46,6 @@ public:
|
||||||
/*** Accesseurs lecture ***/
|
/*** Accesseurs lecture ***/
|
||||||
|
|
||||||
|
|
||||||
inline Mobile* Measurement::get_mobile() const
|
|
||||||
{
|
|
||||||
return mobile ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline AccessPoint* Measurement::get_ap() const
|
inline AccessPoint* Measurement::get_ap() const
|
||||||
{
|
{
|
||||||
return ap ;
|
return ap ;
|
||||||
|
@ -84,12 +74,6 @@ inline float Measurement::get_average_ss() const
|
||||||
/*** Accesseurs écriture ***/
|
/*** Accesseurs écriture ***/
|
||||||
|
|
||||||
|
|
||||||
inline void Measurement::set_mobile(const Mobile *_mobile)
|
|
||||||
{
|
|
||||||
mobile = (Mobile *) _mobile ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline void Measurement::set_ap(const AccessPoint *_ap)
|
inline void Measurement::set_ap(const AccessPoint *_ap)
|
||||||
{
|
{
|
||||||
ap = (AccessPoint *) _ap ;
|
ap = (AccessPoint *) _ap ;
|
||||||
|
@ -114,7 +98,6 @@ inline Measurement::operator bool() const
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
ap != NULL ||
|
ap != NULL ||
|
||||||
mobile != NULL ||
|
|
||||||
ss_list.size() > 0 ;
|
ss_list.size() > 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,3 +56,37 @@ unsigned int PosUtil::channel_to_frequency(const int &channel)
|
||||||
|
|
||||||
return 0 ; // Error: wrong channel value
|
return 0 ; // Error: wrong channel value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint64_t PosUtil::timespec_to_ms(const struct timespec &d)
|
||||||
|
{
|
||||||
|
return d.tv_sec * 1000 + d.tv_nsec / 1000000 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct timespec PosUtil::ms_to_timespec(const uint64_t &tms)
|
||||||
|
{
|
||||||
|
struct timespec d ;
|
||||||
|
d.tv_sec = tms / 1000 ;
|
||||||
|
d.tv_nsec = (tms - d.tv_sec * 1000) * 1000000 ;
|
||||||
|
return d ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint64_t PosUtil::timespec_to_ns(const struct timespec &d)
|
||||||
|
{
|
||||||
|
return d.tv_sec * 1000000000 + d.tv_nsec ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct timespec PosUtil::ns_to_timespec(const uint64_t &tns)
|
||||||
|
{
|
||||||
|
struct timespec d ;
|
||||||
|
d.tv_sec = tns / 1000000000 ;
|
||||||
|
d.tv_nsec = tns - d.tv_sec * 1000000000 ;
|
||||||
|
return d ;
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#ifndef _OWLPS_POSITIONING_POSUTIL_HH_
|
#ifndef _OWLPS_POSITIONING_POSUTIL_HH_
|
||||||
#define _OWLPS_POSITIONING_POSUTIL_HH_
|
#define _OWLPS_POSITIONING_POSUTIL_HH_
|
||||||
|
|
||||||
|
#include <ctime>
|
||||||
|
#include <stdint.h> // <cstdint> is not C++ 98 compliant
|
||||||
|
|
||||||
/* Wi-Fi channel frequencies in Hz */
|
/* Wi-Fi channel frequencies in Hz */
|
||||||
#define CHANNEL_1 2412
|
#define CHANNEL_1 2412
|
||||||
#define CHANNEL_2 2417
|
#define CHANNEL_2 2417
|
||||||
|
@ -20,7 +23,14 @@
|
||||||
class PosUtil
|
class PosUtil
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/* Wi-Fi */
|
||||||
static unsigned int channel_to_frequency(const int &channel) ;
|
static unsigned int channel_to_frequency(const int &channel) ;
|
||||||
|
|
||||||
|
/* Time & Dates */
|
||||||
|
static uint64_t timespec_to_ms(const struct timespec &d) ;
|
||||||
|
static struct timespec ms_to_timespec(const uint64_t &tms) ;
|
||||||
|
static uint64_t timespec_to_ns(const struct timespec &d) ;
|
||||||
|
static struct timespec ns_to_timespec(const uint64_t &tns) ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
#endif // _OWLPS_POSITIONING_POSUTIL_HH_
|
#endif // _OWLPS_POSITIONING_POSUTIL_HH_
|
||||||
|
|
|
@ -160,7 +160,7 @@ ostream &operator<<(ostream &os, const ReferencePoint &rp)
|
||||||
else
|
else
|
||||||
for (vector<CalibrationMeasurement*>::const_iterator
|
for (vector<CalibrationMeasurement*>::const_iterator
|
||||||
i = rp.measurements.begin() ;
|
i = rp.measurements.begin() ;
|
||||||
i < rp.measurements.end() ; i++)
|
i != rp.measurements.end() ; i++)
|
||||||
os << endl << *i ;
|
os << endl << *i ;
|
||||||
|
|
||||||
return os ;
|
return os ;
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
#include "request.hh"
|
||||||
|
#include "mobile.hh"
|
||||||
|
|
||||||
|
using namespace std ;
|
||||||
|
using std::tr1::unordered_map ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*** Constructeurs ***/
|
||||||
|
|
||||||
|
|
||||||
|
Request::Request(const unordered_map<string, Measurement> &_measurements)
|
||||||
|
{
|
||||||
|
mobile = NULL ;
|
||||||
|
timestamp.tv_sec = 0 ;
|
||||||
|
timestamp.tv_nsec = 0 ;
|
||||||
|
measurements = _measurements ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Request::Request(const struct timespec &_timestamp,
|
||||||
|
const unordered_map<string, Measurement> &_measurements)
|
||||||
|
{
|
||||||
|
mobile = NULL ;
|
||||||
|
timestamp = _timestamp ;
|
||||||
|
measurements = _measurements ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Request::Request(const Mobile *_mobile, const struct timespec &_timestamp,
|
||||||
|
const unordered_map<string, Measurement> &_measurements)
|
||||||
|
{
|
||||||
|
mobile = (Mobile*) _mobile ;
|
||||||
|
timestamp = _timestamp ;
|
||||||
|
measurements = _measurements ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*** Accesseurs écriture ***/
|
||||||
|
|
||||||
|
|
||||||
|
void Request::clear()
|
||||||
|
{
|
||||||
|
mobile = NULL ;
|
||||||
|
timestamp.tv_sec = 0 ;
|
||||||
|
timestamp.tv_nsec = 0 ;
|
||||||
|
measurements.clear() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*** Opérateurs ***/
|
||||||
|
|
||||||
|
|
||||||
|
ostream &operator<<(ostream &os, const Request &r)
|
||||||
|
{
|
||||||
|
// Timestamp
|
||||||
|
os
|
||||||
|
<< "At " << PosUtil::timespec_to_ns(r.timestamp) << "; " ;
|
||||||
|
|
||||||
|
// MAC address
|
||||||
|
os
|
||||||
|
<< "Mobile: "
|
||||||
|
<< (r.mobile != NULL ? r.mobile->get_mac_addr() : "Unknown_Mobile")
|
||||||
|
<< ":" ;
|
||||||
|
|
||||||
|
// List of Measurements
|
||||||
|
if (r.measurements.size() == 0)
|
||||||
|
os << " No values" ;
|
||||||
|
else
|
||||||
|
for (unordered_map<string, Measurement>::const_iterator i
|
||||||
|
= r.measurements.begin() ; i != r.measurements.end() ; i++)
|
||||||
|
{
|
||||||
|
os << '\n' << i->first << ": " << i->second ;
|
||||||
|
}
|
||||||
|
|
||||||
|
return os ;
|
||||||
|
}
|
|
@ -0,0 +1,94 @@
|
||||||
|
#ifndef _OWLPS_POSITIONING_REQUEST_HH_
|
||||||
|
#define _OWLPS_POSITIONING_REQUEST_HH_
|
||||||
|
|
||||||
|
class Mobile ;
|
||||||
|
|
||||||
|
#include "measurement.hh"
|
||||||
|
|
||||||
|
#include <ctime>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
class Request
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
Mobile *mobile ;
|
||||||
|
struct timespec timestamp ;
|
||||||
|
std::tr1::unordered_map<std::string, Measurement> measurements ;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Request(const std::tr1::unordered_map<std::string, Measurement> &_measurements
|
||||||
|
= std::tr1::unordered_map<std::string, Measurement>()) ;
|
||||||
|
Request(const struct timespec &_timestamp,
|
||||||
|
const std::tr1::unordered_map<std::string, Measurement> &_measurements
|
||||||
|
= std::tr1::unordered_map<std::string, Measurement>()) ;
|
||||||
|
Request(const Mobile *_mobile, const struct timespec &_timestamp,
|
||||||
|
const std::tr1::unordered_map<std::string, Measurement> &_measurements
|
||||||
|
= std::tr1::unordered_map<std::string, Measurement>()) ;
|
||||||
|
|
||||||
|
Mobile* get_mobile() const ;
|
||||||
|
|
||||||
|
void set_mobile(const Mobile *_mobile) ;
|
||||||
|
void set_timestamp(const struct timespec &_timestamp) ;
|
||||||
|
void set_measurements(const std::tr1::unordered_map
|
||||||
|
<std::string, Measurement> &_measurements) ;
|
||||||
|
void clear(void) ;
|
||||||
|
|
||||||
|
operator bool(void) const ;
|
||||||
|
|
||||||
|
friend std::ostream &operator<<(std::ostream &os, const Request &r) ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*** Accesseurs lecture ***/
|
||||||
|
|
||||||
|
|
||||||
|
inline Mobile* Request::get_mobile() const
|
||||||
|
{
|
||||||
|
return mobile ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*** Accesseurs écriture ***/
|
||||||
|
|
||||||
|
|
||||||
|
inline void Request::set_mobile(const Mobile *_mobile)
|
||||||
|
{
|
||||||
|
mobile = (Mobile *) _mobile ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Request::set_timestamp(const struct timespec &_timestamp)
|
||||||
|
{
|
||||||
|
timestamp = _timestamp ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Request::set_measurements(const std::tr1::unordered_map
|
||||||
|
<std::string, Measurement> &_measurements)
|
||||||
|
{
|
||||||
|
measurements = _measurements ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*** Opérateurs ***/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns false if the Request is empty, or true if at least one
|
||||||
|
* attribute is initialised.
|
||||||
|
*/
|
||||||
|
inline Request::operator bool() const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
mobile != NULL ||
|
||||||
|
timestamp.tv_sec != 0 ||
|
||||||
|
measurements.size() > 0 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _OWLPS_POSITIONING_REQUEST_HH_
|
|
@ -66,7 +66,7 @@ ostream &operator<<(ostream &os, const Waypoint &wp)
|
||||||
os << endl << "Belongs to no building!" ;
|
os << endl << "Belongs to no building!" ;
|
||||||
else
|
else
|
||||||
for (vector<Building*>::const_iterator i = wp.buildings.begin() ;
|
for (vector<Building*>::const_iterator i = wp.buildings.begin() ;
|
||||||
i < wp.buildings.end() ; i++)
|
i != wp.buildings.end() ; i++)
|
||||||
os << endl << *i ;
|
os << endl << *i ;
|
||||||
|
|
||||||
return os ;
|
return os ;
|
||||||
|
|
Loading…
Reference in New Issue