[Positioner] Add ReferencePoint::friis_idx(AP, pkt)
This function allows to get the Friis index for a single packet in a measurement instead of for the whole measurement.
This commit is contained in:
parent
f14c1de473
commit
833c647220
|
@ -6,7 +6,6 @@
|
|||
|
||||
|
||||
#include "referencepoint.hh"
|
||||
#include "measurement.hh"
|
||||
#include "calibrationrequest.hh"
|
||||
#include "stock.hh"
|
||||
|
||||
|
@ -97,6 +96,7 @@ get_all_measurements(const string &mac_transmitter) const
|
|||
|
||||
/**
|
||||
* @param mac_transmitter The MAC address of the transmitting mobile.
|
||||
*
|
||||
* @return A vector containing all the requests sent by the mobile.
|
||||
* The returned vector is empty if no request was sent by the mobile.
|
||||
*/
|
||||
|
@ -138,6 +138,7 @@ void ReferencePoint::delete_requests()
|
|||
/**
|
||||
* Note that the requests pointed by the elements of #requests are
|
||||
* actually deleted from the Stock.
|
||||
*
|
||||
* @returns \em true if at least one request was deleted.
|
||||
* @returns \em false if the ReferencePoint was left untouched.
|
||||
*/
|
||||
|
@ -204,6 +205,7 @@ float ReferencePoint::ss_square_distance(const Request &source) const
|
|||
|
||||
/**
|
||||
* @param ap_mac The MAC address of the AccessPoint to work on.
|
||||
*
|
||||
* @returns The Friis index associated to the AccessPoint.
|
||||
* @returns 0 if the AP is unknown at this ReferencePoint.
|
||||
*/
|
||||
|
@ -224,12 +226,16 @@ friis_index_for_ap(const string &ap_mac) const
|
|||
|
||||
|
||||
/**
|
||||
* Computes a Friis index for the distance AP-ReferencePoint, based on
|
||||
* the measurements of this AP that are present in the ReferencePoint.
|
||||
* Computes a Friis index sum for the distance AP-ReferencePoint,
|
||||
* based on the measurements of this AP that are present in the
|
||||
* ReferencePoint. To obtain the real (averaged) Friis index, one
|
||||
* has to divide the returned sum by the number of indexes.
|
||||
*
|
||||
* @param ap The AccessPoint to work on.
|
||||
* @param const_term The "constant" part of the computation.
|
||||
* @param nb_indexes (result) The number of indexes computed.
|
||||
* @return The sum of all Friis indexes for the AccessPoint.
|
||||
*
|
||||
* @returns The sum of all Friis indexes for the AccessPoint.
|
||||
* @returns 0 if the AP is unknown at this ReferencePoint.
|
||||
*/
|
||||
float ReferencePoint::friis_indexes_for_ap(
|
||||
|
@ -274,6 +280,54 @@ float ReferencePoint::friis_indexes_for_ap(
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Computes a Friis index for the distance AP-ReferencePoint, based on a
|
||||
* given packet (\em pkt_id), of a measurement of this AP present in the
|
||||
* ReferencePoint. This measurement is the first found in the
|
||||
* ReferencePoint. This works well when we keep only one calibration
|
||||
* request per reference point.
|
||||
*
|
||||
* @param ap_mac The MAC address of the AccessPoint to work on.
|
||||
* @param pkt_id The packet ID to look for.
|
||||
*
|
||||
* @returns The Friis index for this AP and packet.
|
||||
* @returns 0 if the AP is unknown at this ReferencePoint, or if there
|
||||
* is no packet with the wanted ID.
|
||||
*/
|
||||
float ReferencePoint::
|
||||
friis_index_for_ap(const string &ap_mac, pkt_id_t pkt_id) const
|
||||
{
|
||||
const AccessPoint &ap = Stock::get_ap(ap_mac) ;
|
||||
double const_term = ap.friis_constant_term() ;
|
||||
float distance = this->distance(ap.get_coordinates()) ;
|
||||
float friis_idx = 0 ;
|
||||
|
||||
for (vector<CalibrationRequest*>::const_iterator request =
|
||||
requests.begin() ; request != requests.end() ; ++request)
|
||||
{
|
||||
const unordered_map<string, Measurement> &measurements =
|
||||
(*request)->get_measurements() ;
|
||||
unordered_map<string, Measurement>::const_iterator measurement =
|
||||
measurements.find(ap_mac) ;
|
||||
if (measurement == measurements.end())
|
||||
continue ;
|
||||
ss_t ss = measurement->second.get_ss(pkt_id) ;
|
||||
if (ss == 0)
|
||||
continue ;
|
||||
|
||||
assert((*request)->get_mobile()) ;
|
||||
float mobile_gain = (*request)->get_mobile()->get_antenna_gain() ;
|
||||
float mobile_pow = (*request)->get_mobile()->get_trx_power() ;
|
||||
friis_idx =
|
||||
(const_term + mobile_gain + mobile_pow - ss)
|
||||
/ (10 * log10(distance)) ;
|
||||
break ;
|
||||
}
|
||||
|
||||
return friis_idx ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* *** Operators *** */
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
class AccessPoint ;
|
||||
class CalibrationRequest ;
|
||||
class Request ;
|
||||
class Measurement ;
|
||||
|
||||
#include "point3d.hh"
|
||||
#include "measurement.hh"
|
||||
|
||||
#include <vector>
|
||||
#include <ostream>
|
||||
|
@ -81,6 +81,9 @@ public:
|
|||
float friis_indexes_for_ap(
|
||||
const AccessPoint &ap, const double &const_term,
|
||||
int &nb_indexes) const ;
|
||||
/// Computes the Friis index for the given AccessPoint and packet ID
|
||||
float friis_index_for_ap(
|
||||
const std::string &ap_mac, pkt_id_t pkt_id) const ;
|
||||
//@}
|
||||
|
||||
/** @name Operators */
|
||||
|
@ -91,7 +94,8 @@ public:
|
|||
//@}
|
||||
|
||||
/// Displays a ReferencePoint
|
||||
friend std::ostream &operator<<(std::ostream &os, const ReferencePoint &rp) ;
|
||||
friend std::ostream &operator<<(
|
||||
std::ostream &os, const ReferencePoint &rp) ;
|
||||
|
||||
/// Hashes a ReferencePoint
|
||||
friend std::size_t hash_value(const ReferencePoint &source) ;
|
||||
|
|
Loading…
Reference in New Issue