[Positioning] InputCSV: handle calib. requests (end)
InputCSV now handles CalibrationRequest, adding position and direction information. Input: - Add add_request_to_stock(). Stock: - Add list of ReferencePoint. - Add list of CalibrationRequest.
This commit is contained in:
parent
9dd30a50c9
commit
e70a255083
|
@ -84,7 +84,7 @@ mobile.o: wifidevice.o
|
|||
measurement.o: accesspoint.o
|
||||
request.o: timestamp.o measurement.o
|
||||
calibrationrequest.o: request.o referencepoint.o direction.o
|
||||
inputcsv.o: inputmedium.o request.o stock.o
|
||||
inputcsv.o: inputmedium.o request.o calibrationrequest.o stock.o
|
||||
inputlogcsv.o: inputlogmedium.hh request.o
|
||||
input.o: posexcept.o
|
||||
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
|
||||
- InputCSV
|
||||
° Différencier une requête normale d'une requête de calibration, en
|
||||
utilisant les champs de direction.
|
||||
|
||||
- Input
|
||||
° Finir le test unitaire.
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#include "input.hh"
|
||||
#include "inputcsv.hh"
|
||||
#include "inputlogcsv.hh"
|
||||
#include "request.hh"
|
||||
#include "calibrationrequest.hh"
|
||||
#include "configuration.hh"
|
||||
#include "posexcept.hh"
|
||||
#include "stock.hh"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
@ -88,7 +89,8 @@ const Request& Input::get_next_request() const
|
|||
{
|
||||
if (! eof())
|
||||
{
|
||||
medium->get_next_request() ;
|
||||
const Request &request = medium->get_next_request() ;
|
||||
add_request_to_stock(request) ;
|
||||
log_current_request() ;
|
||||
}
|
||||
|
||||
|
@ -104,6 +106,23 @@ bool Input::eof() const
|
|||
}
|
||||
|
||||
|
||||
void Input::add_request_to_stock(const Request &request) const
|
||||
{
|
||||
// For the moment we add only the CalibrationRequests to the Stock
|
||||
const CalibrationRequest *calibration_request =
|
||||
dynamic_cast<const CalibrationRequest*>(&request) ;
|
||||
if (calibration_request == NULL)
|
||||
return ;
|
||||
|
||||
// Add request to the Stock
|
||||
const CalibrationRequest &stock_calibration_request =
|
||||
Stock::find_create_calibration_request(*calibration_request) ;
|
||||
|
||||
// Add the request to the request list of its reference point
|
||||
stock_calibration_request.reference_point_backward_link() ;
|
||||
}
|
||||
|
||||
|
||||
void Input::log_current_request() const
|
||||
{
|
||||
for (vector<InputLogMedium*>::const_iterator i = log_media.begin() ;
|
||||
|
|
|
@ -19,6 +19,7 @@ protected:
|
|||
void initialise_input_medium(void) ;
|
||||
void initialise_log_media(void) ;
|
||||
void initialise_log_csv(void) ;
|
||||
void add_request_to_stock(const Request &request) const ;
|
||||
void log_current_request(void) const ;
|
||||
|
||||
public:
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "posutil.hh"
|
||||
#include "posexcept.hh"
|
||||
#include "stock.hh"
|
||||
#include "calibrationrequest.hh"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
@ -271,7 +272,16 @@ const Request& InputCSV::get_next_request()
|
|||
read_next_line() ;
|
||||
|
||||
if (is_calibration_request)
|
||||
current_request_to_calibration_request() ;
|
||||
{
|
||||
current_request_to_calibration_request() ;
|
||||
CalibrationRequest *request =
|
||||
static_cast<CalibrationRequest*>(current_request) ;
|
||||
request->set_direction(direction) ;
|
||||
ReferencePoint position(pos) ;
|
||||
const ReferencePoint &reference_point =
|
||||
Stock::find_create_reference_point(position) ;
|
||||
request->set_reference_point(&reference_point) ;
|
||||
}
|
||||
|
||||
return *current_request ;
|
||||
}
|
||||
|
|
|
@ -3,8 +3,15 @@
|
|||
|
||||
using namespace std ;
|
||||
using std::tr1::unordered_map ;
|
||||
using std::tr1::unordered_set ;
|
||||
|
||||
|
||||
/// Hash function, required to put ReferencePoint in a set
|
||||
size_t hash_value(const ReferencePoint &object)
|
||||
{
|
||||
return boost::hash_value(static_cast<string>(object)) ;
|
||||
}
|
||||
|
||||
|
||||
/* *** Attribute definitions *** */
|
||||
|
||||
|
@ -12,9 +19,13 @@ unordered_map<string, Mobile> Stock::mobiles ;
|
|||
|
||||
unordered_map<string, AccessPoint> Stock::aps ;
|
||||
|
||||
unordered_set<ReferencePoint> Stock::reference_points ;
|
||||
|
||||
unordered_set<CalibrationRequest> Stock::calibration_requests ;
|
||||
|
||||
|
||||
/* *** Read accessors *** */
|
||||
|
||||
/* *** Accessors *** */
|
||||
|
||||
|
||||
/**
|
||||
|
@ -50,12 +61,30 @@ const AccessPoint& Stock::get_ap(const string &mac)
|
|||
}
|
||||
|
||||
|
||||
const ReferencePoint& Stock::
|
||||
find_create_reference_point(const ReferencePoint &point)
|
||||
{
|
||||
// unordered_set::insert() do all the job: see the documentation at
|
||||
// http://www.boost.org/doc/libs/1_41_0/doc/html/boost/unordered_set.html
|
||||
pair<unordered_set<ReferencePoint>::iterator, bool> ret =
|
||||
reference_points.insert(point) ;
|
||||
return *ret.first ;
|
||||
}
|
||||
|
||||
/* *** Write accessors *** */
|
||||
|
||||
const CalibrationRequest& Stock::
|
||||
find_create_calibration_request(const CalibrationRequest &request)
|
||||
{
|
||||
pair<unordered_set<CalibrationRequest>::iterator, bool> ret =
|
||||
calibration_requests.insert(request) ;
|
||||
return *ret.first ;
|
||||
}
|
||||
|
||||
|
||||
void Stock::clear()
|
||||
{
|
||||
mobiles.clear() ;
|
||||
aps.clear() ;
|
||||
reference_points.clear() ;
|
||||
calibration_requests.clear() ;
|
||||
}
|
||||
|
|
|
@ -3,8 +3,11 @@
|
|||
|
||||
#include "mobile.hh"
|
||||
#include "accesspoint.hh"
|
||||
#include "referencepoint.hh"
|
||||
#include "calibrationrequest.hh"
|
||||
|
||||
#include <boost/tr1/unordered_map.hpp>
|
||||
#include <boost/tr1/unordered_set.hpp>
|
||||
|
||||
/// Storage class
|
||||
class Stock
|
||||
|
@ -16,6 +19,12 @@ private:
|
|||
/// List of known AccessPoint
|
||||
static std::tr1::unordered_map<std::string, AccessPoint> aps ;
|
||||
|
||||
/// List of known ReferencePoint
|
||||
static std::tr1::unordered_set<ReferencePoint> reference_points ;
|
||||
|
||||
/// List of known CalibrationRequest
|
||||
static std::tr1::unordered_set<CalibrationRequest> calibration_requests ;
|
||||
|
||||
public:
|
||||
/// Read the Mobile corresponding to a given MAC address
|
||||
static const Mobile& get_mobile(const std::string &mac) ;
|
||||
|
@ -27,13 +36,21 @@ public:
|
|||
/// Get a reference to the AccessPoint corresponding to a given MAC address
|
||||
static AccessPoint& getw_ap(const std::string &mac) ;
|
||||
|
||||
/// Look for a ReferencePoint and create it if it does not exist
|
||||
static const ReferencePoint&
|
||||
find_create_reference_point(const ReferencePoint &point) ;
|
||||
|
||||
/// Get a reference to a CalibrationRequest
|
||||
static const CalibrationRequest&
|
||||
find_create_calibration_request(const CalibrationRequest &request) ;
|
||||
|
||||
/// Deletes all elements in all attributes
|
||||
static void clear(void) ;
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
/* *** Read accessors *** */
|
||||
/* *** Accessors *** */
|
||||
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue