[Positioning] Stock: generate one CR for all APs
A Request is received by *all* the APs, therefore we have to generate one CalibrationRequest per ReferencePoint, and not one CalibrationRequest per AP in each ReferencePoint.
This commit is contained in:
parent
3402809c09
commit
2ddad20371
|
@ -450,9 +450,31 @@ void Stock::regenerate_reference_points()
|
|||
if (is_ap_coordinate(current_point))
|
||||
continue ;
|
||||
|
||||
/* Get/create the reference point */
|
||||
const ReferencePoint ¤t_rp =
|
||||
find_create_reference_point(current_point) ;
|
||||
|
||||
/* Create the timestamp */
|
||||
Timestamp time_sent ;
|
||||
time_sent.now() ;
|
||||
|
||||
/* Create the measurement list */
|
||||
unordered_map<string, Measurement> measurements ;
|
||||
|
||||
/* Prepare the virtual mobile */
|
||||
string vmob_mac(PosUtil::int_to_mac(nb_virtual_mobiles++)) ;
|
||||
// The gain and trx power of the mobile will be the average of
|
||||
// those of all the known APs (could be better, probably)
|
||||
double vmob_gain = 0 ;
|
||||
double vmob_pow = 0 ;
|
||||
|
||||
for (unordered_map<string, AccessPoint>::const_iterator
|
||||
rx = aps.begin() ; rx != aps.end() ; ++rx)
|
||||
{
|
||||
/* Update the mobile's attributes */
|
||||
vmob_gain += rx->second.get_antenna_gain() / aps.size() ;
|
||||
vmob_pow += rx->second.get_trx_power() / aps.size() ;
|
||||
|
||||
/* Choose the 2 nearest APs in angle */
|
||||
const Point3D &rx_coord =
|
||||
rx->second.get_coordinates() ;
|
||||
|
@ -540,39 +562,24 @@ void Stock::regenerate_reference_points()
|
|||
ref2_ss = ref2_ss * ref2_percent / 100 ;
|
||||
double rx_ss = (ref1_ss + ref2_ss) / 2 ;
|
||||
|
||||
/* Create the timestamp */
|
||||
Timestamp time_sent ;
|
||||
time_sent.now() ;
|
||||
|
||||
/* Create the virtual mobile */
|
||||
string vmob_mac(PosUtil::int_to_mac(nb_virtual_mobiles++)) ;
|
||||
float vmob_gain =
|
||||
ref1.get_antenna_gain() * ref1_percent / 100 +
|
||||
ref2.get_antenna_gain() * ref2_percent / 100 ;
|
||||
float vmob_pow =
|
||||
ref1.get_trx_power() * ref1_percent / 100 +
|
||||
ref2.get_trx_power() * ref2_percent / 100 ;
|
||||
Mobile vmob("", vmob_mac, vmob_gain, vmob_pow) ;
|
||||
const Mobile &mobile = find_create_mobile(vmob) ;
|
||||
|
||||
/* Create the measurement list */
|
||||
/* Create the measurement, add it to the list */
|
||||
Measurement m(&rx->second) ;
|
||||
m.add_ss(rx_ss) ;
|
||||
unordered_map<string, Measurement> measurements ;
|
||||
measurements[rx->second.get_mac_addr()] = m ;
|
||||
|
||||
/* Get/create the reference point */
|
||||
const ReferencePoint &rp =
|
||||
find_create_reference_point(current_point) ;
|
||||
|
||||
/* Create the calibration request */
|
||||
CalibrationRequest cr(OWL_REQUEST_GENERATED) ;
|
||||
cr.set_time_sent(time_sent) ;
|
||||
cr.set_mobile(&mobile) ;
|
||||
cr.set_measurements(measurements) ;
|
||||
cr.set_reference_point(&rp) ;
|
||||
store_calibration_request(cr) ;
|
||||
}
|
||||
|
||||
/* Create the virtual mobile */
|
||||
Mobile vmob("", vmob_mac, vmob_gain, vmob_pow) ;
|
||||
const Mobile &mobile = find_create_mobile(vmob) ;
|
||||
|
||||
/* Create the calibration request */
|
||||
CalibrationRequest cr(OWL_REQUEST_GENERATED) ;
|
||||
cr.set_time_sent(time_sent) ;
|
||||
cr.set_mobile(&mobile) ;
|
||||
cr.set_measurements(measurements) ;
|
||||
cr.set_reference_point(¤t_rp) ;
|
||||
|
||||
store_calibration_request(cr) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue