[Positioning] Add class Stock, finish InputCSV
Add AP and mobile management in InputCSV. Lists of known APs and mobiles are static attributes of the class Stock.
This commit is contained in:
parent
5f8f955a3d
commit
cc31b5dcc6
|
@ -23,7 +23,7 @@ TARGET = owlps-positioning
|
|||
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 request.o inputcsv.o
|
||||
calibrationmeasurement.o request.o inputcsv.o stock.o
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
|
@ -33,6 +33,7 @@ all: $(TARGET)
|
|||
$(GXX) $(GXXFLAGS) -c $<
|
||||
|
||||
posutil.o: posutil.hh
|
||||
stock.o: stock.hh
|
||||
point3d.o: point3d.hh
|
||||
referencepoint.o : referencepoint.hh point3d.o
|
||||
waypoint.o: waypoint.hh point3d.o building.o
|
||||
|
@ -44,7 +45,7 @@ mobile.o: mobile.hh wifidevice.o
|
|||
measurement.o: measurement.hh accesspoint.o
|
||||
calibrationmeasurement.o: calibrationmeasurement.hh measurement.o referencepoint.o
|
||||
request.o: request.hh measurement.o
|
||||
inputcsv.o: inputcsv.hh inputmedium.hh request.o
|
||||
inputcsv.o: inputcsv.hh inputmedium.hh request.o stock.o
|
||||
#libowlps-positioning.o: 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
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
Utiliser '\n' plutôt que endl lorsque le vidage du tampon n'est pas
|
||||
nécessaire.
|
||||
|
||||
- Measurement : corriger le calcul de moyenne.
|
||||
- Measurement
|
||||
Vérifier le calcul de moyenne (a priori OK).
|
||||
|
||||
- Revoir le diagramme UML
|
||||
° Associations : devraient êtres représentées par des attributs
|
||||
|
@ -31,6 +32,7 @@
|
|||
|
||||
- Accesseurs par références ?
|
||||
getref_mon_attribut() (cf. l'ancien clientinfo.hh)
|
||||
−> Accesseur en lecture : retourne une référence constante.
|
||||
|
||||
- C++ en action
|
||||
Espaces de noms ? 109
|
||||
|
|
|
@ -18,9 +18,9 @@ public:
|
|||
const Point3D &_coordinates,
|
||||
const unsigned int &_frequency = AP_DEFAULT_CHANNEL):
|
||||
WifiDevice(wd), coordinates(_coordinates), frequency(_frequency) {}
|
||||
AccessPoint(const Point3D &_coordinates,
|
||||
const std::string &_ip_addr,
|
||||
const std::string &_mac_addr,
|
||||
AccessPoint(const Point3D &_coordinates = Point3D(),
|
||||
const std::string &_ip_addr = "",
|
||||
const std::string &_mac_addr = "",
|
||||
const float &_antenna_gain = AP_DEFAULT_ANTENNA_GAIN,
|
||||
const float &_trx_power = WIFIDEVICE_DEFAULT_TRX_POWER,
|
||||
const unsigned int &_frequency = AP_DEFAULT_CHANNEL):
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "inputcsv.hh"
|
||||
#include "posutil.hh"
|
||||
#include "stock.hh"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
@ -72,9 +73,10 @@ const Request& InputCSV::get_next_request()
|
|||
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) ;
|
||||
// If the mobile did not exist, we create it
|
||||
if (Stock::get_mobile(*ti).get_mac_addr().size() == 0)
|
||||
Stock::getw_mobile(*ti).set_mac_addr(*ti) ;
|
||||
current_request.set_mobile(&Stock::get_mobile(*ti)) ;
|
||||
|
||||
// Read Timestamp field
|
||||
if (++ti == tok.end())
|
||||
|
@ -157,6 +159,11 @@ const Request& InputCSV::get_next_request()
|
|||
return current_request ;
|
||||
}
|
||||
|
||||
// If the AP did not exist, we create it
|
||||
if (Stock::get_ap(mac_ap).get_mac_addr().size() == 0)
|
||||
Stock::getw_ap(mac_ap).set_mac_addr(mac_ap) ;
|
||||
measurements[mac_ap].set_ap(&Stock::get_ap(mac_ap)) ;
|
||||
|
||||
// Adding value
|
||||
measurements[mac_ap].add_ss(ss) ;
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
class Mobile: public WifiDevice
|
||||
{
|
||||
public:
|
||||
Mobile(const std::string &_ip_addr,
|
||||
const std::string &_mac_addr,
|
||||
Mobile(const std::string &_ip_addr = "",
|
||||
const std::string &_mac_addr = "",
|
||||
const float &_antenna_gain = MOBILE_DEFAULT_ANTENNA_GAIN,
|
||||
const float &_trx_power = WIFIDEVICE_DEFAULT_TRX_POWER):
|
||||
WifiDevice(_ip_addr, _mac_addr, _antenna_gain, _trx_power) {}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
#include "stock.hh"
|
||||
|
||||
using namespace std ;
|
||||
using std::tr1::unordered_map ;
|
||||
|
||||
|
||||
|
||||
unordered_map<string, Mobile> Stock::mobiles =
|
||||
unordered_map<string, Mobile>() ;
|
||||
|
||||
unordered_map<string, AccessPoint> Stock::aps =
|
||||
unordered_map<string, AccessPoint>() ;
|
|
@ -0,0 +1,52 @@
|
|||
#ifndef _OWLPS_POSITIONING_STOCK_HH_
|
||||
#define _OWLPS_POSITIONING_STOCK_HH_
|
||||
|
||||
#include "mobile.hh"
|
||||
#include "accesspoint.hh"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
class Stock
|
||||
{
|
||||
private:
|
||||
static std::tr1::unordered_map<std::string, Mobile> mobiles ;
|
||||
static std::tr1::unordered_map<std::string, AccessPoint> aps ;
|
||||
|
||||
public:
|
||||
static const Mobile& get_mobile(const std::string &mac) ;
|
||||
static Mobile& getw_mobile(const std::string &mac) ;
|
||||
static const AccessPoint& get_ap(const std::string &mac) ;
|
||||
static AccessPoint& getw_ap(const std::string &mac) ;
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
/*** Accesseurs lecture ***/
|
||||
|
||||
|
||||
inline const Mobile& Stock::get_mobile(const std::string &mac)
|
||||
{
|
||||
return mobiles[mac] ;
|
||||
}
|
||||
|
||||
|
||||
inline Mobile& Stock::getw_mobile(const std::string &mac)
|
||||
{
|
||||
return mobiles[mac] ;
|
||||
}
|
||||
|
||||
|
||||
inline const AccessPoint& Stock::get_ap(const std::string &mac)
|
||||
{
|
||||
return aps[mac] ;
|
||||
}
|
||||
|
||||
|
||||
inline AccessPoint& Stock::getw_ap(const std::string &mac)
|
||||
{
|
||||
return aps[mac] ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // _OWLPS_POSITIONING_STOCK_HH_
|
|
@ -18,8 +18,8 @@ protected:
|
|||
float trx_power ; // Transmit power in dBm
|
||||
|
||||
public:
|
||||
WifiDevice(const std::string &_ip_addr,
|
||||
const std::string &_mac_addr,
|
||||
WifiDevice(const std::string &_ip_addr = "",
|
||||
const std::string &_mac_addr = "",
|
||||
const float &_antenna_gain = WIFIDEVICE_DEFAULT_ANTENNA_GAIN,
|
||||
const float &_trx_power = WIFIDEVICE_DEFAULT_TRX_POWER) ;
|
||||
WifiDevice(const WifiDevice &wd) ;
|
||||
|
|
Loading…
Reference in New Issue