[Positioner] AP::received_calibration…(): percents
AccessPoint::received_calibration_from_ap() now returns a percentage of the received packets (instead of a boolean).
This commit is contained in:
parent
a2629dd5a9
commit
5f26d7a28e
|
@ -25,11 +25,17 @@ double AccessPoint::friis_constant_term() const
|
|||
}
|
||||
|
||||
|
||||
bool AccessPoint::
|
||||
/**
|
||||
* @param trx The transmitter AP.
|
||||
* @returns The percentage of calibration packets sent by \em trx and
|
||||
* received by the AP.
|
||||
* @returns 0 if no packet were received from \em trx.
|
||||
*/
|
||||
float AccessPoint::
|
||||
received_calibration_from_ap(const AccessPoint &trx) const
|
||||
{
|
||||
if (this == &trx)
|
||||
return true ;
|
||||
return 100 ;
|
||||
|
||||
// If no reference point is associated with trx, no AP received
|
||||
// any calibration from it:
|
||||
|
@ -40,22 +46,34 @@ received_calibration_from_ap(const AccessPoint &trx) const
|
|||
}
|
||||
catch (element_not_found &e)
|
||||
{
|
||||
return false ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
// Check if trx sent a calibration request:
|
||||
const vector<CalibrationRequest*> &ref_requests =
|
||||
ref_trx->get_requests(trx.mac_addr) ;
|
||||
if (ref_requests.empty())
|
||||
return false ;
|
||||
return 0 ;
|
||||
|
||||
// Check if the AP received at least one message sent by trx:
|
||||
// Count the number of messages sent by trx and the number of
|
||||
// messages actually received by the AP:
|
||||
unsigned int
|
||||
received_packets = 0,
|
||||
expected_packets = 0 ;
|
||||
for (vector<CalibrationRequest*>::const_iterator cr =
|
||||
ref_requests.begin() ; cr != ref_requests.end() ; ++cr)
|
||||
if ((*cr)->get_measurement(mac_addr))
|
||||
return true ;
|
||||
{
|
||||
const Measurement *const measurement =
|
||||
(*cr)->get_measurement(mac_addr) ;
|
||||
if (! measurement)
|
||||
continue ;
|
||||
received_packets += measurement->get_ss_list_size() ;
|
||||
expected_packets += (*cr)->get_nb_packets() ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
// Compute the score (percent):
|
||||
float score = received_packets * 100.0 / expected_packets ;
|
||||
return score ;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -78,8 +78,9 @@ public:
|
|||
//@{
|
||||
/// Returns the Friis formula's constant term
|
||||
double friis_constant_term(void) const ;
|
||||
/// Checks if the AP received calibration packets from \em trx
|
||||
bool received_calibration_from_ap(const AccessPoint &trx) const ;
|
||||
/// \brief Computes the percentage of the calibration packets from
|
||||
/// \em trx received by the AP
|
||||
float received_calibration_from_ap(const AccessPoint &trx) const ;
|
||||
//@}
|
||||
|
||||
/** @name Operators */
|
||||
|
|
Loading…
Reference in New Issue