From 4ae0874e1f6ad7f8323343ade0babdca612a9efd Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Fri, 14 Jun 2013 15:54:26 -0400 Subject: [PATCH] [Positioner] Access Point -> Capture Point Like in the other modules, we get rid of the old use of "access point". This has user-visible changes, especially in the configuration (the name of a few options has been changed). --- owlps-positioner/CMakeLists.txt | 4 +- owlps-positioner/autocalibration.cc | 156 +++++++++--------- owlps-positioner/autocalibration.hh | 47 +++--- .../{accesspoint.cc => capturepoint.cc} | 30 ++-- .../{accesspoint.hh => capturepoint.hh} | 62 +++---- ...readercsv.cc => capturepointsreadercsv.cc} | 22 +-- ...readercsv.hh => capturepointsreadercsv.hh} | 10 +- owlps-positioner/cfg/listeners.csv | 2 +- owlps-positioner/cfg/owlps-positioner.conf | 32 ++-- owlps-positioner/fbcm.cc | 8 +- owlps-positioner/fbcm.hh | 2 +- owlps-positioner/frbhmbasic.cc | 10 +- owlps-positioner/frbhmbasic.hh | 2 +- owlps-positioner/inputcsv.cc | 18 +- owlps-positioner/inputcsv.hh | 4 +- owlps-positioner/inputdatareader.cc | 16 +- owlps-positioner/inputmedium.cc | 28 ++-- owlps-positioner/inputudpsocket.cc | 22 +-- owlps-positioner/measurement.cc | 28 ++-- owlps-positioner/measurement.hh | 32 ++-- owlps-positioner/minmax.cc | 14 +- owlps-positioner/minmax.hh | 6 +- owlps-positioner/mobilesreadercsv.hh | 2 +- owlps-positioner/posutil.cc | 10 +- owlps-positioner/posutil.hh | 2 +- owlps-positioner/referencepoint.cc | 72 ++++---- owlps-positioner/referencepoint.hh | 20 +-- owlps-positioner/request.cc | 4 +- owlps-positioner/request.hh | 4 +- owlps-positioner/stock.cc | 132 +++++++-------- owlps-positioner/stock.hh | 76 ++++----- owlps-positioner/trilaterationalgorithm.cc | 14 +- owlps-positioner/trilaterationalgorithm.hh | 8 +- owlps-positioner/trilaterationmethod.hh | 8 +- owlps-positioner/userinterface.cc | 26 +-- 35 files changed, 467 insertions(+), 466 deletions(-) rename owlps-positioner/{accesspoint.cc => capturepoint.cc} (78%) rename owlps-positioner/{accesspoint.hh => capturepoint.hh} (66%) rename owlps-positioner/{accesspointsreadercsv.cc => capturepointsreadercsv.cc} (64%) rename owlps-positioner/{accesspointsreadercsv.hh => capturepointsreadercsv.hh} (81%) diff --git a/owlps-positioner/CMakeLists.txt b/owlps-positioner/CMakeLists.txt index 2049a28..877a65e 100644 --- a/owlps-positioner/CMakeLists.txt +++ b/owlps-positioner/CMakeLists.txt @@ -31,8 +31,8 @@ endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(OWLPS_POSITIONER_SRC_FILES - accesspoint.cc - accesspointsreadercsv.cc + capturepoint.cc + capturepointsreadercsv.cc area.cc autocalibration.cc building.cc diff --git a/owlps-positioner/autocalibration.cc b/owlps-positioner/autocalibration.cc index 0310fa4..02b8ed0 100644 --- a/owlps-positioner/autocalibration.cc +++ b/owlps-positioner/autocalibration.cc @@ -14,7 +14,7 @@ #include "autocalibration.hh" -#include "accesspoint.hh" +#include "capturepoint.hh" #include "stock.hh" #include "configuration.hh" #include "posexcept.hh" @@ -38,11 +38,11 @@ uint32_t Autocalibration::nb_virtual_mobiles = 0 ; /** * The reference point P we want to generate will end-up containing - * as many calibration requests as the total number of APs. + * as many calibration requests as the total number of CPs. * For each of these requests, we consider a transmitter TRX (which is - * a virtual mobile located in P) and a receiver RX (the current AP). + * a virtual mobile located in P) and a receiver RX (the current CP). * To generate the signal strength (SS) received by RX from TRX, - * we first select two reference APs REF1 and REF2. Then, we average + * we first select two reference CPs REF1 and REF2. Then, we average * the real measurements REF1->RX and REF2->RX, weighting in function * of the angles REF-RX-TRX and the distance from RX to TRX to compute * the SS. @@ -50,9 +50,9 @@ uint32_t Autocalibration::nb_virtual_mobiles = 0 ; */ void Autocalibration::generate_reference_point() { - // If the point is the coordinates of an existing AP, we don't + // If the point is the coordinates of an existing CP, we don't // need to generate it - if (Stock::is_ap_coordinate(point)) + if (Stock::is_cp_coordinate(point)) return ; /* Get/create the reference point */ @@ -62,12 +62,12 @@ void Autocalibration::generate_reference_point() /* 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) + // those of all the known CPs (could be better, probably) vmob_gain = 0 ; vmob_pow = 0 ; - /* Generate the SS(s) for each AP */ - for (rx = Stock::aps.begin() ; rx != Stock::aps.end() ; ++rx) + /* Generate the SS(s) for each CP */ + for (rx = Stock::cps.begin() ; rx != Stock::cps.end() ; ++rx) generate_ss() ; assert(! measurements.empty()) ; @@ -89,10 +89,10 @@ void Autocalibration::generate_reference_point() void Autocalibration::generate_ss() { /* Update the mobile's attributes */ - vmob_gain += rx->second.get_antenna_gain() / Stock::aps.size() ; - vmob_pow += rx->second.get_trx_power() / Stock::aps.size() ; + vmob_gain += rx->second.get_antenna_gain() / Stock::cps.size() ; + vmob_pow += rx->second.get_trx_power() / Stock::cps.size() ; - /* Skip the RX AP if it is not at the same floor as the point + /* Skip the RX CP if it is not at the same floor as the point * to generate */ const Point3D &rx_coord = rx->second.get_coordinates() ; if (rx_coord.get_z() != point.get_z()) @@ -105,140 +105,140 @@ void Autocalibration::generate_ss() if (point.get_y() > rx_coord.get_y()) origin_angle = -origin_angle ; - /* Choose the nearest AP(s) in angle */ - sort_reference_aps() ; - // We need at least one reference AP: + /* Choose the nearest CP(s) in angle */ + sort_reference_cps() ; + // We need at least one reference CP: if (sorted_negative_angles.empty() && sorted_positive_angles.empty()) - throw autocalibration_error("Not enough APs in coverage!") ; + throw autocalibration_error("Not enough CPs in coverage!") ; - /* Compute the angle weight of the reference APs */ - weight_aps() ; + /* Compute the angle weight of the reference CPs */ + weight_cps() ; /* Compute the SS that would be received from a mobile at a - * distance of RX-P, in the direction of each reference AP */ + * distance of RX-P, in the direction of each reference CP */ compute_ss() ; } /** - * The reference (transmitter) APs are first filtered (floor, coverage), + * The reference (transmitter) CPs are first filtered (floor, coverage), * then sorted according to their angles with RX and P. */ -void Autocalibration::sort_reference_aps() +void Autocalibration::sort_reference_cps() { const Point3D &rx_coord = rx->second.get_coordinates() ; sorted_negative_angles.clear() ; sorted_positive_angles.clear() ; - for (unordered_map::const_iterator - ref = Stock::aps.begin() ; ref != Stock::aps.end() ; ++ref) + for (unordered_map::const_iterator + ref = Stock::cps.begin() ; ref != Stock::cps.end() ; ++ref) { if (ref == rx) continue ; - /* Skip the AP if it is not at the same floor than the - * receiver AP */ + /* Skip the CP if it is not at the same floor than the + * receiver CP */ const Point3D &ref_coord = ref->second.get_coordinates() ; if (ref_coord.get_z() != rx_coord.get_z()) continue ; - /* Skip the AP if it is not in coverage with the receiver AP */ + /* Skip the CP if it is not in coverage with the receiver CP */ float coverage = - rx->second.received_calibration_from_ap(ref->second) ; + rx->second.received_calibration_from_cp(ref->second) ; if (coverage < 1) // Less than 1% coverage is ridiculous! continue ; /* Angle P-RX-REF */ double angle = rx_coord.angle_2d(point, ref_coord) ; - /* Weight in the APs' list according to coverage and angle */ + /* Weight in the CPs' list according to coverage and angle */ double weight = angle / coverage ; - /* Note: this weight is used only to sort the APs, it has nothing - to do with the angle weight (see weight_aps()) used to compute + /* Note: this weight is used only to sort the CPs, it has nothing + to do with the angle weight (see weight_cps()) used to compute the SSs. */ /* Create the list entry */ pair::const_iterator> - angle_ap(angle, ref) ; + unordered_map::const_iterator> + angle_cp(angle, ref) ; pair::const_iterator> > - weight_angle_ap(weight, angle_ap) ; + unordered_map::const_iterator> > + weight_angle_cp(weight, angle_cp) ; - /* Rotate the AP's coordinates to know the angle direction */ + /* Rotate the CP's coordinates to know the angle direction */ Point3D ref_coord_r(ref_coord) ; ref_coord_r.rotate_2d(rx_coord, origin_angle) ; - // Insert the AP in the right list, according to the direction: + // Insert the CP in the right list, according to the direction: if (ref_coord_r.get_y() < rx_coord.get_y()) - sorted_negative_angles.insert(weight_angle_ap) ; + sorted_negative_angles.insert(weight_angle_cp) ; else - sorted_positive_angles.insert(weight_angle_ap) ; + sorted_positive_angles.insert(weight_angle_cp) ; } } -void Autocalibration::weight_aps() +void Autocalibration::weight_cps() { - /* Retrieve the reference APs & angles */ - ref_aps.clear() ; + /* Retrieve the reference CPs & angles */ + ref_cps.clear() ; map::const_iterator> > + unordered_map::const_iterator> > ::const_iterator s ; s = sorted_negative_angles.begin() ; if (s != sorted_negative_angles.end()) - init_ap(s) ; + init_cp(s) ; s = sorted_positive_angles.begin() ; if (s != sorted_positive_angles.end()) - init_ap(s) ; + init_cp(s) ; - /* Weight the APs */ - if (ref_aps.size() == 1) - ref_aps[0].weight = 100 ; - else if (ref_aps.size() == 2) - weight_2_aps() ; + /* Weight the CPs */ + if (ref_cps.size() == 1) + ref_cps[0].weight = 100 ; + else if (ref_cps.size() == 2) + weight_2_cps() ; else { ostringstream oss ; oss << "We should not be here... error when sorting the reference" - << " APs? (" << ref_aps.size() << " APs sorted)" ; + << " CPs? (" << ref_cps.size() << " CPs sorted)" ; throw autocalibration_error(oss.str()) ; } } -void Autocalibration::init_ap( +void Autocalibration::init_cp( map::const_iterator> >::const_iterator s) + string, CapturePoint>::const_iterator> >::const_iterator s) { - struct ap ref ; - ref.ap = &s->second.second->second ; + struct cp ref ; + ref.cp = &s->second.second->second ; ref.angle = s->second.first ; // Angle P-REF-RX - ref_aps.push_back(ref) ; + ref_cps.push_back(ref) ; } -void Autocalibration::weight_2_aps() +void Autocalibration::weight_2_cps() { - assert(ref_aps.size() > 1) ; + assert(ref_cps.size() > 1) ; /* Compute the angle REF1-RX-REF2 */ - double reference_angle = ref_aps[0].angle + ref_aps[1].angle ; + double reference_angle = ref_cps[0].angle + ref_cps[1].angle ; /* Note: the reference angle must be the sum of the two angles P-RX-REF1 and P-RX-REF2 instead of simply REF1-RX-REF2, to allow the angle to be within [0;360[° instead of [0;180[°. This is needed if P-RX-REF1 or P-RX-REF2 are greater than 90°, otherwise the weights would be wrong. */ - /* Weight the two APs */ + /* Weight the two CPs */ if (reference_angle == 0) - ref_aps[0].weight = ref_aps[1].weight = 50 ; + ref_cps[0].weight = ref_cps[1].weight = 50 ; else { - ref_aps[0].weight = ref_aps[0].angle * 100 / reference_angle ; - if (ref_aps[0].weight > 100) - ref_aps[0].weight = 100 ; - ref_aps[1].weight = 100 - ref_aps[0].weight ; + ref_cps[0].weight = ref_cps[0].angle * 100 / reference_angle ; + if (ref_cps[0].weight > 100) + ref_cps[0].weight = 100 ; + ref_cps[1].weight = 100 - ref_cps[0].weight ; } } @@ -255,9 +255,9 @@ void Autocalibration::compute_ss() void Autocalibration::compute_multi_packet_ss() { - const ap &ref1 = ref_aps[0] ; + const cp &ref1 = ref_cps[0] ; const ReferencePoint &ref1_rp = - Stock::get_reference_point(ref1.ap->get_coordinates()) ; + Stock::get_reference_point(ref1.cp->get_coordinates()) ; const vector &ref1_cr = ref1_rp.get_requests() ; @@ -272,7 +272,7 @@ void Autocalibration::compute_multi_packet_ss() break ; } - // The selected reference APs are in coverage of RX, therefore + // The selected reference CPs are in coverage of RX, therefore // we should always find a measurement of RX in ref1_rp assert(rx_measurement) ; @@ -286,7 +286,7 @@ void Autocalibration::compute_multi_packet_ss() if (! packet_generated) { if (Configuration::is_configured("verbose")) - cerr << "No packet has been generated for RX AP " << rx_mac + cerr << "No packet has been generated for RX CP " << rx_mac << "... failing back to single packet request. Calibration" << " request involved : " << **cr << "\n" ; compute_single_packet_ss(0) ; @@ -306,7 +306,7 @@ bool Autocalibration::compute_single_packet_ss(pkt_id_t pkt_id) /* Compute the consolidated SS */ double rx_ss = 0 ; - for (unsigned int i = 0 ; i < ref_aps.size() ; ++i) + for (unsigned int i = 0 ; i < ref_cps.size() ; ++i) { double tmp_ss = compute_weighted_ss(i, pkt_id, point_dst) ; if (tmp_ss > 0) // error @@ -324,14 +324,14 @@ bool Autocalibration::compute_single_packet_ss(pkt_id_t pkt_id) measurements[rx_mac].add_ss(pkt_id, rx_ss) ; // Useful only if the measurement was just created, but it is not // worth a test: - measurements[rx_mac].set_ap(&rx->second) ; + measurements[rx_mac].set_cp(&rx->second) ; return true ; } /** - * @param ap_idx The index of the AP in #ref_aps. + * @param cp_idx The index of the CP in #ref_cps. * @param pkt_id The number of the packet to generate, or 0 if we * generate only one packet per reference point. * @param point_dst The distance RX-P. @@ -339,20 +339,20 @@ bool Autocalibration::compute_single_packet_ss(pkt_id_t pkt_id) * @returns The weighted SS value in dBm, or 1 in case of error. */ double Autocalibration::compute_weighted_ss( - unsigned int ap_idx, pkt_id_t pkt_id, float point_dst) + unsigned int cp_idx, pkt_id_t pkt_id, float point_dst) { - const ap &ref = ref_aps[ap_idx] ; + const cp &ref = ref_cps[cp_idx] ; const ReferencePoint &rp = - Stock::get_reference_point(ref.ap->get_coordinates()) ; + Stock::get_reference_point(ref.cp->get_coordinates()) ; /* Friis index */ const string &rx_mac = rx->second.get_mac_addr() ; float friis_idx ; if (pkt_id == 0) - friis_idx = rp.friis_index_for_ap(rx_mac) ; + friis_idx = rp.friis_index_for_cp(rx_mac) ; else { - friis_idx = rp.friis_index_for_ap(rx_mac, pkt_id) ; + friis_idx = rp.friis_index_for_cp(rx_mac, pkt_id) ; if (friis_idx == 0) return 1 ; // The packet pkt_id does not exist in rp } @@ -362,8 +362,8 @@ double Autocalibration::compute_weighted_ss( double common_ss = rx->second.friis_constant_term() ; double ss = common_ss + - ref.ap->get_trx_power() + - ref.ap->get_antenna_gain() - + ref.cp->get_trx_power() + + ref.cp->get_antenna_gain() - 10 * friis_idx * log10(point_dst) ; return ss * ref.weight / 100 ; diff --git a/owlps-positioner/autocalibration.hh b/owlps-positioner/autocalibration.hh index f1b875c..90e8626 100644 --- a/owlps-positioner/autocalibration.hh +++ b/owlps-positioner/autocalibration.hh @@ -15,7 +15,7 @@ #ifndef _OWLPS_POSITIONING_AUTOCALIBRATION_HH_ #define _OWLPS_POSITIONING_AUTOCALIBRATION_HH_ -class AccessPoint ; +class CapturePoint ; class Point3D ; #include "measurement.hh" @@ -30,20 +30,20 @@ class Point3D ; class Autocalibration { private: - struct ap + struct cp { - const AccessPoint *ap ; - float weight ; // Weight of the AP in percents + const CapturePoint *cp ; + float weight ; // Weight of the CP in percents float angle ; } ; - /// Current AP to generate a SS for - std::unordered_map::const_iterator rx ; + /// Current CP to generate a SS for + std::unordered_map::const_iterator rx ; /// Angle P-RX-O, O being the origin of the trigonometric circle float origin_angle ; - /// Selected transmitter APs - std::vector ref_aps ; - /// Angles of the transmitter APs (before M on the trigonometric + /// Selected transmitter CPs + std::vector ref_cps ; + /// Angles of the transmitter CPs (before M on the trigonometric /// circle) /** * Note that the angles are stored in absolute value. @@ -51,13 +51,13 @@ private: std::multimap::const_iterator> > + std::string, CapturePoint>::const_iterator> > sorted_negative_angles ; - /// Angles of the transmitter APs (after M on the trigonometric circle) + /// Angles of the transmitter CPs (after M on the trigonometric circle) std::multimap::const_iterator> > + std::string, CapturePoint>::const_iterator> > sorted_positive_angles ; /// Characteristics of the virtual mobile double vmob_gain, vmob_pow ; @@ -71,26 +71,26 @@ protected: /// The coordinates of the reference point to generate const Point3D &point ; - /// Generates the SSs for all the APs + /// Generates the SSs for all the CPs void generate_ss(void) ; - /// Sorts the reference APs for a receiver AP - void sort_reference_aps(void) ; - /// Computes the weight of the selected AP(s) - void weight_aps(void) ; - void init_ap( + /// Sorts the reference CPs for a receiver CP + void sort_reference_cps(void) ; + /// Computes the weight of the selected CP(s) + void weight_cps(void) ; + void init_cp( std::map::const_iterator> >::const_iterator s) ; - /// Weights two APs according to their angles - void weight_2_aps(void) ; + std::string, CapturePoint>::const_iterator> >::const_iterator s) ; + /// Weights two CPs according to their angles + void weight_2_cps(void) ; /// Computes the SS of the virtual mobile void compute_ss(void) ; /// Computes a SS with several packets in it void compute_multi_packet_ss(void) ; /// Computes a SS with only one packet in it bool compute_single_packet_ss(pkt_id_t pkt_id) ; - /// Computes a SS according to the weight of the AP + /// Computes a SS according to the weight of the CP double compute_weighted_ss( - unsigned int ap_idx, pkt_id_t pkt_id, float point_dst) ; + unsigned int cp_idx, pkt_id_t pkt_id, float point_dst) ; public: Autocalibration(const Point3D &_point): point(_point) {} @@ -100,3 +100,4 @@ public: } ; #endif // _OWLPS_POSITIONING_AUTOCALIBRATION_HH_ + diff --git a/owlps-positioner/accesspoint.cc b/owlps-positioner/capturepoint.cc similarity index 78% rename from owlps-positioner/accesspoint.cc rename to owlps-positioner/capturepoint.cc index 3915041..e3b424a 100644 --- a/owlps-positioner/accesspoint.cc +++ b/owlps-positioner/capturepoint.cc @@ -12,7 +12,7 @@ */ -#include "accesspoint.hh" +#include "capturepoint.hh" #include "stock.hh" #include "posexcept.hh" @@ -23,7 +23,7 @@ using namespace std ; /* *** Operations *** */ -double AccessPoint::friis_constant_term() const +double CapturePoint::friis_constant_term() const { double wavelength = static_cast(PosUtil::LIGHT_SPEED) / frequency ; @@ -32,18 +32,18 @@ double AccessPoint::friis_constant_term() const /** - * @param trx The transmitter AP. + * @param trx The transmitter CP. * @returns The percentage of calibration packets sent by `trx` and - * received by the AP. + * received by the CP. * @returns 0 if no packet were received from `trx.` */ -float AccessPoint:: -received_calibration_from_ap(const AccessPoint &trx) const +float CapturePoint:: +received_calibration_from_cp(const CapturePoint &trx) const { if (this == &trx) return 100 ; - // If no reference point is associated with trx, no AP received + // If no reference point is associated with trx, no CP received // any calibration from it: const ReferencePoint *ref_trx ; try @@ -62,7 +62,7 @@ received_calibration_from_ap(const AccessPoint &trx) const return 0 ; // Count the number of messages sent by trx and the number of - // messages actually received by the AP: + // messages actually received by the CP: unsigned int received_packets = 0, expected_packets = 0 ; @@ -90,7 +90,7 @@ received_calibration_from_ap(const AccessPoint &trx) const /* *** Operators *** */ -AccessPoint& AccessPoint::operator=(const AccessPoint &source) +CapturePoint& CapturePoint::operator=(const CapturePoint &source) { if (this == &source) return *this ; @@ -104,7 +104,7 @@ AccessPoint& AccessPoint::operator=(const AccessPoint &source) } -bool AccessPoint::operator==(const AccessPoint &source) const +bool CapturePoint::operator==(const CapturePoint &source) const { if (this == &source) return true ; @@ -118,13 +118,13 @@ bool AccessPoint::operator==(const AccessPoint &source) const -ostream &operator<<(ostream &os, const AccessPoint &ap) +ostream &operator<<(ostream &os, const CapturePoint &cp) { os - << "Coordinates: " << ap.coordinates << '\n' - << "Frequency: " << ap.frequency << " Hz" << '\n' - << "Friis index: " << ap.friis_index << '\n' - << (WifiDevice) ap ; + << "Coordinates: " << cp.coordinates << '\n' + << "Frequency: " << cp.frequency << " Hz" << '\n' + << "Friis index: " << cp.friis_index << '\n' + << (WifiDevice) cp ; return os ; } diff --git a/owlps-positioner/accesspoint.hh b/owlps-positioner/capturepoint.hh similarity index 66% rename from owlps-positioner/accesspoint.hh rename to owlps-positioner/capturepoint.hh index b595489..8cbb7e3 100644 --- a/owlps-positioner/accesspoint.hh +++ b/owlps-positioner/capturepoint.hh @@ -19,12 +19,12 @@ #include "point3d.hh" #include "posutil.hh" -#define AP_DEFAULT_CHANNEL 6 -#define AP_DEFAULT_ANTENNA_GAIN 5 +#define CP_DEFAULT_CHANNEL 6 +#define CP_DEFAULT_ANTENNA_GAIN 5 /// Represents a [Wi-Fi device](@ref WifiDevice) used for capturing /// requests -class AccessPoint: public WifiDevice +class CapturePoint: public WifiDevice { protected: Point3D coordinates ; @@ -36,36 +36,36 @@ public: * Special parameters: * - `_antenna_gain` Antenna gain in dBi. * - `_trx_power` Transmit power in dBm. - * - `channel` Wi-Fi channel the AP is listening to (integer + * - `channel` Wi-Fi channel the CP is listening to (integer * between 1 and 14). It will be converted to a frequency in Hz. */ - 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 &channel = AP_DEFAULT_CHANNEL): + CapturePoint(const Point3D &_coordinates = Point3D(), + const std::string &_ip_addr = "", + const std::string &_mac_addr = "", + const float _antenna_gain = CP_DEFAULT_ANTENNA_GAIN, + const float _trx_power = WIFIDEVICE_DEFAULT_TRX_POWER, + const unsigned int &channel = CP_DEFAULT_CHANNEL): WifiDevice(_ip_addr, _mac_addr, _antenna_gain, _trx_power), coordinates(_coordinates), frequency(PosUtil::wifi_channel_to_hz(channel)), friis_index(0) {} - AccessPoint(const WifiDevice &source, - const Point3D &_coordinates, - const unsigned int channel = AP_DEFAULT_CHANNEL): + CapturePoint(const WifiDevice &source, + const Point3D &_coordinates, + const unsigned int channel = CP_DEFAULT_CHANNEL): WifiDevice(source), coordinates(_coordinates), frequency(PosUtil::wifi_channel_to_hz(channel)), friis_index(0) {} - AccessPoint(const WifiDevice &source): + CapturePoint(const WifiDevice &source): WifiDevice(source), coordinates(Point3D()), frequency(0), friis_index(0) {} - AccessPoint(const AccessPoint &source): + CapturePoint(const CapturePoint &source): WifiDevice(source), coordinates(source.coordinates), frequency(source.frequency), friis_index(0) {} - ~AccessPoint(void) {} + ~CapturePoint(void) {} /** @name Read accessors */ //@{ @@ -87,19 +87,19 @@ public: /// Returns the Friis formula's constant term double friis_constant_term(void) const ; /// Computes the percentage of the calibration packets from `trx` - /// received by the AP - float received_calibration_from_ap(const AccessPoint &trx) const ; + /// received by the CP + float received_calibration_from_cp(const CapturePoint &trx) const ; //@} /** @name Operators */ //@{ - AccessPoint& operator=(const AccessPoint &source) ; - bool operator==(const AccessPoint &source) const ; - bool operator!=(const AccessPoint &source) const ; + CapturePoint& operator=(const CapturePoint &source) ; + bool operator==(const CapturePoint &source) const ; + bool operator!=(const CapturePoint &source) const ; //@} - /// Displays an AccessPoint - friend std::ostream &operator<<(std::ostream &os, const AccessPoint &ap) ; + /// Displays a CapturePoint + friend std::ostream &operator<<(std::ostream &os, const CapturePoint &cp) ; } ; @@ -107,19 +107,19 @@ public: /* *** Read accessors *** */ -inline const Point3D& AccessPoint::get_coordinates() const +inline const Point3D& CapturePoint::get_coordinates() const { return coordinates ; } -inline unsigned long AccessPoint::get_frequency() const +inline unsigned long CapturePoint::get_frequency() const { return frequency ; } -inline float AccessPoint::get_friis_index() const +inline float CapturePoint::get_friis_index() const { return friis_index ; } @@ -129,7 +129,7 @@ inline float AccessPoint::get_friis_index() const /* *** Write accessors *** */ -inline void AccessPoint::set_coordinates(const Point3D &_coordinates) +inline void CapturePoint::set_coordinates(const Point3D &_coordinates) { coordinates = _coordinates ; } @@ -140,7 +140,7 @@ inline void AccessPoint::set_coordinates(const Point3D &_coordinates) * be converted into a frequency in Hz and affected to #frequency. If * it is not a Wi-Fi channel number, 0 will be affected to #frequency. */ -inline void AccessPoint::set_channel(const unsigned int channel) +inline void CapturePoint::set_channel(const unsigned int channel) { set_frequency(PosUtil::wifi_channel_to_hz(channel)) ; } @@ -153,13 +153,13 @@ inline void AccessPoint::set_channel(const unsigned int channel) * Note that set_channel() is more secure because a wrong channel * number will cause #frequency to be set to zero. */ -inline void AccessPoint::set_frequency(const unsigned long _frequency) +inline void CapturePoint::set_frequency(const unsigned long _frequency) { frequency = _frequency ; } -inline void AccessPoint::set_friis_index(const float _friis_index) +inline void CapturePoint::set_friis_index(const float _friis_index) { friis_index = _friis_index ; } @@ -169,7 +169,7 @@ inline void AccessPoint::set_friis_index(const float _friis_index) /* *** Operators *** */ -inline bool AccessPoint::operator!=(const AccessPoint &source) const +inline bool CapturePoint::operator!=(const CapturePoint &source) const { return !(*this == source) ; } diff --git a/owlps-positioner/accesspointsreadercsv.cc b/owlps-positioner/capturepointsreadercsv.cc similarity index 64% rename from owlps-positioner/accesspointsreadercsv.cc rename to owlps-positioner/capturepointsreadercsv.cc index 48d2bfd..82308a9 100644 --- a/owlps-positioner/accesspointsreadercsv.cc +++ b/owlps-positioner/capturepointsreadercsv.cc @@ -12,7 +12,7 @@ */ -#include "accesspointsreadercsv.hh" +#include "capturepointsreadercsv.hh" #include "point3d.hh" #include "stock.hh" #include "posexcept.hh" @@ -24,7 +24,7 @@ using namespace std ; /* *** Constructors *** */ -AccessPointsReaderCSV::AccessPointsReaderCSV(const string &file_name): +CapturePointsReaderCSV::CapturePointsReaderCSV(const string &file_name): file(file_name) { read_devices() ; @@ -35,38 +35,38 @@ AccessPointsReaderCSV::AccessPointsReaderCSV(const string &file_name): /* *** Operations *** */ -void AccessPointsReaderCSV::read_devices() +void CapturePointsReaderCSV::read_devices() { while (file.next_line()) process_device_line() ; } -void AccessPointsReaderCSV::process_device_line() +void CapturePointsReaderCSV::process_device_line() { string mac ; if (! file.read_field(mac)) - throw malformed_input_data("Cannot read access point MAC address!") ; + throw malformed_input_data("Cannot read capture point MAC address!") ; PosUtil::to_upper(mac) ; Point3D coord ; if (! file.read_point3d(coord)) - throw malformed_input_data("Cannot read access point coordinates!") ; + throw malformed_input_data("Cannot read capture point coordinates!") ; unsigned long frequency ; if (! file.read_field(frequency)) - throw malformed_input_data("Cannot read access point frequency!") ; + throw malformed_input_data("Cannot read capture point frequency!") ; float gain ; if (! file.read_field(gain)) - throw malformed_input_data("Cannot read access point gain!") ; + throw malformed_input_data("Cannot read capture point gain!") ; float power ; if (! file.read_field(power)) - throw malformed_input_data("Cannot read access point power!") ; + throw malformed_input_data("Cannot read capture point power!") ; string ip("") ; - AccessPoint device(coord, ip, mac, gain, power, frequency) ; - Stock::find_create_ap(device) ; + CapturePoint device(coord, ip, mac, gain, power, frequency) ; + Stock::find_create_cp(device) ; } diff --git a/owlps-positioner/accesspointsreadercsv.hh b/owlps-positioner/capturepointsreadercsv.hh similarity index 81% rename from owlps-positioner/accesspointsreadercsv.hh rename to owlps-positioner/capturepointsreadercsv.hh index a0ad63d..cab6f77 100644 --- a/owlps-positioner/accesspointsreadercsv.hh +++ b/owlps-positioner/capturepointsreadercsv.hh @@ -21,12 +21,12 @@ class Point3D ; #include -/// Reads and registers to the Stock AccessPoint list from CSV files +/// Reads and registers to the Stock CapturePoint list from CSV files /** - * CSV format for access points is: + * CSV format for capture points is: * MAC;X;Y;Z;Frequency_Hz;Antenna_gain_dBi;Trx_power_dBm */ -class AccessPointsReaderCSV +class CapturePointsReaderCSV { protected: CSVFileReader file ; @@ -35,9 +35,9 @@ protected: void process_device_line(void) ; public: - AccessPointsReaderCSV(const std::string &file_name) ; + CapturePointsReaderCSV(const std::string &file_name) ; - ~AccessPointsReaderCSV(void) {} + ~CapturePointsReaderCSV(void) {} } ; #endif // _OWLPS_POSITIONING_ACCESSPOINTSREADERCSV_HH_ diff --git a/owlps-positioner/cfg/listeners.csv b/owlps-positioner/cfg/listeners.csv index f773f5d..8552feb 100644 --- a/owlps-positioner/cfg/listeners.csv +++ b/owlps-positioner/cfg/listeners.csv @@ -1,4 +1,4 @@ -# Listeners' physical description file. +# Capture points' (listeners') physical description file. # # Each line follows this format: # MAC address;X;Y;Z;Channel (Hz);Antenna gain (dBi);Trx power (dBm) diff --git a/owlps-positioner/cfg/owlps-positioner.conf b/owlps-positioner/cfg/owlps-positioner.conf index 38051bf..3805119 100644 --- a/owlps-positioner/cfg/owlps-positioner.conf +++ b/owlps-positioner/cfg/owlps-positioner.conf @@ -21,9 +21,9 @@ # The options in this section are related to the data that are read # when the program starts. -# Description of the machines running the listeners. -ap-medium = CSV -ap-csv-file = /usr/local/etc/owlps/listeners.csv +# Description of the machines running the listeners (capture points). +cp-medium = CSV +cp-csv-file = /usr/local/etc/owlps/listeners.csv # Description of the clients mobile-medium = CSV @@ -80,18 +80,18 @@ mobile-csv-file = /usr/local/etc/owlps/mobiles.csv # It is unactivated by default, mainly to avoid interferent devices. #accept-new-mobiles = false -# This option allows to create a new AP when a request is captured by an -# AP which is not currently in the APs' list (i.e. not declared in the -# APs' configuration file), or when a self-calibration request is sent -# by an unknown AP. +# This option allows to create a new capture point (CP) when a request +# is captured by a CP which is not currently in the CPs' list (i.e. not +# declared in the CPs' configuration file), or when a self-calibration +# request is sent by an unknown CP. # It is unactivated by default for the sake of security. -#accept-new-aps = false +#accept-new-cps = false -# When receiving a calibration or autocalibration request from an AP, -# containing the transmiter's coordinates, memorise the new AP's +# When receiving a calibration or autocalibration request from a CP, +# containing the transmiter's coordinates, memorise the new CP's # coordinates. # This is unactivated by default for the sake of security. -#update-ap-coordinates-online = false +#update-cp-coordinates-online = false # Coordinates of the deployment area. # This is used to delimit the area in which reference points are @@ -129,8 +129,8 @@ mobile-csv-file = /usr/local/etc/owlps/mobiles.csv #ss-similarity = interval2 # Smallest possible value for a received signal strength, in dBm. This -# depends on the sensibility of the APs' Wi-Fi hardware. It is used to -# compensate for APs that are not in coverage in a given measurement. +# depends on the sensibility of the CPs' Wi-Fi hardware. It is used to +# compensate for CPs that are not in coverage in a given measurement. # The default value is -99 dBm, which should be fine in most cases. #smallest-ss = -99 @@ -213,12 +213,12 @@ mobile-csv-file = /usr/local/etc/owlps/mobiles.csv # directly to each calibration request. #average-reference-points = false -# Do not select reference points on which an AP is sit, as far as -# possible (i.e. if there are reference points where no AP sits). +# Do not select reference points on which a CP is sit, as far as +# possible (i.e. if there are reference points where no CP sits). # This is useful if you are using autocalibration and want to select # only the generated reference points. # The default is false. -#ignore-ap-reference-points = false +#ignore-cp-reference-points = false [output] # The following options are related to the output of the results. diff --git a/owlps-positioner/fbcm.cc b/owlps-positioner/fbcm.cc index 8e30c41..4a77dd4 100644 --- a/owlps-positioner/fbcm.cc +++ b/owlps-positioner/fbcm.cc @@ -32,13 +32,13 @@ float FBCM::estimate_distance(const Measurement &measurement) { double constant_term = make_constant_term(measurement) ; const float &average_dbm = measurement.get_average_dbm() ; - const AccessPoint *ap = measurement.get_ap() ; + const CapturePoint *cp = measurement.get_cp() ; return pow(10, (constant_term - average_dbm) / - (10 * friis_index(ap))) ; + (10 * friis_index(cp))) ; } -inline float FBCM::friis_index(const AccessPoint *const ap) const +inline float FBCM::friis_index(const CapturePoint *const cp) const { - return ap->get_friis_index() ; + return cp->get_friis_index() ; } diff --git a/owlps-positioner/fbcm.hh b/owlps-positioner/fbcm.hh index 68042e5..fdae4ca 100644 --- a/owlps-positioner/fbcm.hh +++ b/owlps-positioner/fbcm.hh @@ -21,7 +21,7 @@ class FBCM: public TrilaterationAlgorithm { protected: - float friis_index(const AccessPoint *const ap) const ; + float friis_index(const CapturePoint *const cp) const ; public: FBCM(void): PositioningAlgorithm("FBCM") {} diff --git a/owlps-positioner/frbhmbasic.cc b/owlps-positioner/frbhmbasic.cc index 9dfaf1a..c60f696 100644 --- a/owlps-positioner/frbhmbasic.cc +++ b/owlps-positioner/frbhmbasic.cc @@ -23,7 +23,7 @@ Result FRBHMBasic::compute(const Request &_request) // Select the closest point in SS closest_in_ss = &select_point(_request) ; - compute_ap_distance_circles() ; + compute_cp_distance_circles() ; Point3D position(trilaterate_2d(closest_in_ss->get_z())) ; return Result(request, name, position) ; @@ -40,13 +40,13 @@ float FRBHMBasic::estimate_distance(const Measurement &measurement) { double constant_term = make_constant_term(measurement) ; const float &average_dbm = measurement.get_average_dbm() ; - const AccessPoint *ap = measurement.get_ap() ; + const CapturePoint *cp = measurement.get_cp() ; return pow(10, (constant_term - average_dbm) / - (10 * friis_index(ap))) ; + (10 * friis_index(cp))) ; } -inline float FRBHMBasic::friis_index(const AccessPoint *const ap) const +inline float FRBHMBasic::friis_index(const CapturePoint *const cp) const { - return closest_in_ss->friis_index_for_ap(ap->get_mac_addr()) ; + return closest_in_ss->friis_index_for_cp(cp->get_mac_addr()) ; } diff --git a/owlps-positioner/frbhmbasic.hh b/owlps-positioner/frbhmbasic.hh index af9a4cf..c69912e 100644 --- a/owlps-positioner/frbhmbasic.hh +++ b/owlps-positioner/frbhmbasic.hh @@ -24,7 +24,7 @@ class FRBHMBasic: public FBCM, public NSS protected: ReferencePoint const *closest_in_ss ; - float friis_index(const AccessPoint *const ap) const ; + float friis_index(const CapturePoint *const cp) const ; public: FRBHMBasic(void): diff --git a/owlps-positioner/inputcsv.cc b/owlps-positioner/inputcsv.cc index 34e2055..bb92070 100644 --- a/owlps-positioner/inputcsv.cc +++ b/owlps-positioner/inputcsv.cc @@ -124,12 +124,12 @@ bool InputCSV::fill_current_request() if (direction_int != 0) direction = direction_int ; - /* Read all the {AP_MAC;Packet_ID;SS} */ + /* Read all the {CP_MAC;Packet_ID;SS} */ unordered_map measurements ; - string mac_ap ; - while (file.read_field(mac_ap)) + string mac_cp ; + while (file.read_field(mac_cp)) { pkt_id_t packet_id ; if (! read_field(packet_id, "the packet ID")) @@ -139,14 +139,14 @@ bool InputCSV::fill_current_request() if (! read_field(ss, "the signal strength")) return false ; - PosUtil::to_upper(mac_ap) ; - if (! Configuration::bool_value("positioning.accept-new-aps") && - ! Stock::ap_exists(mac_ap)) + PosUtil::to_upper(mac_cp) ; + if (! Configuration::bool_value("positioning.accept-new-cps") && + ! Stock::cp_exists(mac_cp)) continue ; - const AccessPoint &ap = Stock::find_create_ap(mac_ap) ; - measurements[mac_ap].set_ap(&ap) ; - measurements[mac_ap].add_ss(packet_id, ss) ; + const CapturePoint &cp = Stock::find_create_cp(mac_cp) ; + measurements[mac_cp].set_cp(&cp) ; + measurements[mac_cp].add_ss(packet_id, ss) ; } if (measurements.empty()) return false ; diff --git a/owlps-positioner/inputcsv.hh b/owlps-positioner/inputcsv.hh index 82274ed..6be6f49 100644 --- a/owlps-positioner/inputcsv.hh +++ b/owlps-positioner/inputcsv.hh @@ -26,8 +26,8 @@ /** * CSV format is: * Format_version;Mobile_MAC;Request_type;Number_of_packets; - * Timestamp;X;Y;Z;Direction;AP_MAC_1;Packet_ID_1;SS_1;…; - * AP_MAC_n;Packet_ID_n;SS_n + * Timestamp;X;Y;Z;Direction;CP_MAC_1;Packet_ID_1;SS_1;…; + * CP_MAC_n;Packet_ID_n;SS_n */ class InputCSV: public InputMedium { diff --git a/owlps-positioner/inputdatareader.cc b/owlps-positioner/inputdatareader.cc index dd5d76e..5ef3db4 100644 --- a/owlps-positioner/inputdatareader.cc +++ b/owlps-positioner/inputdatareader.cc @@ -13,7 +13,7 @@ #include "inputdatareader.hh" -#include "accesspointsreadercsv.hh" +#include "capturepointsreadercsv.hh" #include "mobilesreadercsv.hh" #include "topologyreadercsv.hh" #include "inputcsv.hh" @@ -56,20 +56,20 @@ InputDataReader::~InputDataReader() void InputDataReader::read_access_points() { - if (! Configuration::is_configured("data-input.ap-medium")) + if (! Configuration::is_configured("data-input.cp-medium")) return ; initialise_access_points_media() ; if (Configuration::is_configured("verbose")) - cerr << Stock::nb_aps() << " access points stored.\n" ; + cerr << Stock::nb_cps() << " capture points stored.\n" ; } void InputDataReader::initialise_access_points_media() { const vector &media_names = - Configuration::string_vector_value("data-input.ap-medium") ; + Configuration::string_vector_value("data-input.cp-medium") ; for (vector::const_iterator i = media_names.begin() ; i != media_names.end() ; ++i) @@ -86,12 +86,12 @@ void InputDataReader::initialise_access_points_media() void InputDataReader::initialise_access_points_csv() { - if (! Configuration::is_configured("data-input.ap-csv-file")) + if (! Configuration::is_configured("data-input.cp-csv-file")) throw missing_configuration( - "No input CSV file specified for access points") ; + "No input CSV file specified for capture points") ; - AccessPointsReaderCSV( - Configuration::string_value("data-input.ap-csv-file")) ; + CapturePointsReaderCSV( + Configuration::string_value("data-input.cp-csv-file")) ; } diff --git a/owlps-positioner/inputmedium.cc b/owlps-positioner/inputmedium.cc index 30884f1..c4b3d77 100644 --- a/owlps-positioner/inputmedium.cc +++ b/owlps-positioner/inputmedium.cc @@ -100,30 +100,30 @@ fill_calibration_request_data(const string &mac_mobile, Point3D &position, if (position) { - // Update the AP's coordinates if allowed (and if the mobile is - // an AP, of course) + // Update the CP's coordinates if allowed (and if the mobile is + // a CP, of course) if (Configuration:: - bool_value("positioning.update-ap-coordinates-online")) + bool_value("positioning.update-cp-coordinates-online")) { if (type == OWL_REQUEST_AUTOCALIBRATION && - Configuration::bool_value("positioning.accept-new-aps")) + Configuration::bool_value("positioning.accept-new-cps")) { - AccessPoint &transmitter = - const_cast( - Stock::find_create_ap(mac_mobile)) ; + CapturePoint &transmitter = + const_cast( + Stock::find_create_cp(mac_mobile)) ; transmitter.set_coordinates(position) ; } else { try { - AccessPoint &transmitter = - const_cast(Stock::get_ap(mac_mobile)) ; + CapturePoint &transmitter = + const_cast(Stock::get_cp(mac_mobile)) ; transmitter.set_coordinates(position) ; } catch (element_not_found &e) { - // The mobile is not an AP or the AP does not exist + // The mobile is not a CP or the CP does not exist } } } @@ -132,17 +132,17 @@ fill_calibration_request_data(const string &mac_mobile, Point3D &position, else if (type == OWL_REQUEST_AUTOCALIBRATION) { // If an autocalibration request does not contain the coordinates - // of the AP, we use the current coordinates of the AP as + // of the CP, we use the current coordinates of the CP as // ReferencePoint. try { - AccessPoint &transmitter = - const_cast(Stock::get_ap(mac_mobile)) ; + CapturePoint &transmitter = + const_cast(Stock::get_cp(mac_mobile)) ; position = transmitter.get_coordinates() ; } catch (element_not_found &e) { - // The mobile is not an AP or the AP does not exist + // The mobile is not a CP or the CP does not exist } } diff --git a/owlps-positioner/inputudpsocket.cc b/owlps-positioner/inputudpsocket.cc index da93325..76cc337 100644 --- a/owlps-positioner/inputudpsocket.cc +++ b/owlps-positioner/inputudpsocket.cc @@ -178,7 +178,7 @@ bool InputUDPSocket::fill_current_request() request.y_position, request.z_position) ; - // Read the {MAC_AP;SS} couples (request_info) + // Read the {MAC_CP;SS} couples (request_info) unordered_map measurements ; owl_request_info request_info ; for (int i = 0 ; i < request.nb_info ; ++i) @@ -193,9 +193,9 @@ bool InputUDPSocket::fill_current_request() pkt_id_t packet_id = ntohs(request_info.packet_id) ; - string mac_ap( + string mac_cp( owl_mac_bytes_to_string(request_info.cp_mac_addr_bytes)) ; - PosUtil::to_upper(mac_ap) ; + PosUtil::to_upper(mac_cp) ; owl_ntoh_timestamp(&request_info.capture_time) ; Timestamp capture_time(request_info.capture_time) ; @@ -206,24 +206,24 @@ bool InputUDPSocket::fill_current_request() cerr << "\t* Packet received from the aggregator:" << "\n\t\tPacket number: " << packet_id - << "\n\t\tAP MAC: " << mac_ap + << "\n\t\tCP MAC: " << mac_cp << "\n\t\tCapture timestamp: " << capture_time << "\n\t\tSignal: " << ss << " dBm" << '\n' ; - if (! Configuration::bool_value("positioning.accept-new-aps") && - ! Stock::ap_exists(mac_ap)) + if (! Configuration::bool_value("positioning.accept-new-cps") && + ! Stock::cp_exists(mac_cp)) { if (Configuration::is_configured("verbose")) - cerr << "Dropping packet from unknown AP " - << mac_ap << ".\n" ; + cerr << "Dropping packet from unknown CP " + << mac_cp << ".\n" ; continue ; } - const AccessPoint &ap = Stock::find_create_ap(mac_ap) ; - measurements[mac_ap].set_ap(&ap) ; - measurements[mac_ap].add_ss(packet_id, ss) ; + const CapturePoint &cp = Stock::find_create_cp(mac_cp) ; + measurements[mac_cp].set_cp(&cp) ; + measurements[mac_cp].add_ss(packet_id, ss) ; } if (measurements.empty()) return false ; diff --git a/owlps-positioner/measurement.cc b/owlps-positioner/measurement.cc index dae0bdc..170874b 100644 --- a/owlps-positioner/measurement.cc +++ b/owlps-positioner/measurement.cc @@ -27,7 +27,7 @@ using namespace std ; /** - * Note that values pointed by #ap are not deleted. + * Note that values pointed by #cp are not deleted. */ Measurement::~Measurement() { @@ -99,21 +99,21 @@ add_ss_list(const map &_ss_list) /** * Merge consists of adding the SS values of `source` to #ss_list. It - * is possible only if the #ap of the two Measurement are identical. - * @throw cannot_merge if the AP of the two Measurement are different. + * is possible only if the #cp of the two Measurement are identical. + * @throw cannot_merge if the CP of the two Measurement are different. */ void Measurement::merge(const Measurement &source) { - if (ap != source.ap) + if (cp != source.cp) throw cannot_merge( - "error when trying to merge measurements, APs are different") ; + "error when trying to merge measurements, CPs are different") ; add_ss_list(source.ss_list) ; } /** - * - #ap is not deleted, only initialised to NULL. + * - #cp is not deleted, only initialised to NULL. * - #ss_list is cleared. * - average and variance variables are reset to 0. */ @@ -127,7 +127,7 @@ void Measurement::clear() variance_mw_m2 = 0 ; variance_dbm_m2 = 0 ; variance_size = 0 ; - ap = NULL ; + cp = NULL ; } @@ -254,7 +254,7 @@ Measurement& Measurement::operator=(const Measurement &m) if (this == &m) return *this ; - ap = m.ap ; + cp = m.cp ; ss_list = m.ss_list ; average_dbm = m.average_dbm ; average_mw = m.average_mw ; @@ -274,7 +274,7 @@ bool Measurement::operator==(const Measurement &m) const return true ; return - ap == m.ap && + cp == m.cp && ss_list == m.ss_list ; } @@ -287,9 +287,9 @@ const string Measurement::to_csv() const if (ss_list.empty()) return "" ; - string mac_ap("") ; - if (ap) - mac_ap = ap->get_mac_addr() ; + string mac_cp("") ; + if (cp) + mac_cp = cp->get_mac_addr() ; for (map::const_iterator i = ss_list.begin() ; i != ss_list.end() ; ++i) @@ -297,7 +297,7 @@ const string Measurement::to_csv() const if (i != ss_list.begin()) csv_line << ';' ; csv_line - << mac_ap << ';' + << mac_cp << ';' << i->first << ';' << static_cast(i->second) ; } @@ -311,7 +311,7 @@ ostream &operator<<(ostream &os, const Measurement &m) { // MAC address os - << "AP: " << (m.ap ? m.ap->get_mac_addr() : "Unknown_AP") + << "CP: " << (m.cp ? m.cp->get_mac_addr() : "Unknown_CP") << ": " ; // List of SS diff --git a/owlps-positioner/measurement.hh b/owlps-positioner/measurement.hh index b35a8b4..015e3db 100644 --- a/owlps-positioner/measurement.hh +++ b/owlps-positioner/measurement.hh @@ -15,7 +15,7 @@ #ifndef _OWLPS_POSITIONING_MEASUREMENT_HH_ #define _OWLPS_POSITIONING_MEASUREMENT_HH_ -#include "accesspoint.hh" +#include "capturepoint.hh" #include #include @@ -24,12 +24,12 @@ typedef uint_fast16_t pkt_id_t ; typedef int_fast16_t ss_t ; -/// Represents a list of signal strengths captured by one AccessPoint +/// Represents a list of signal strengths captured by one CapturePoint class Measurement { protected: - /// The AccessPoint that performed the measurement - AccessPoint *ap ; + /// The CapturePoint that performed the measurement + CapturePoint *cp ; /// List of signal strengths captured (in dBm) std::map ss_list ; /// Average of all the captured signal strengths (dBm) @@ -65,13 +65,13 @@ protected: public: - Measurement(const AccessPoint *_ap = NULL): - ap(const_cast(_ap)), average_dbm(0), + Measurement(const CapturePoint *_cp = NULL): + cp(const_cast(_cp)), average_dbm(0), average_mw(0), variance_mw(0), variance_dbm(0), variance_mw_m2(0), variance_dbm_m2(0), variance_size(0) {} Measurement(const Measurement &source): - ap(source.ap), ss_list(source.ss_list), + cp(source.cp), ss_list(source.ss_list), average_dbm(source.average_dbm), average_mw(source.average_mw), variance_mw(source.variance_mw), variance_dbm(source.variance_dbm), variance_mw_m2(0), variance_dbm_m2(0), variance_size(0) {} @@ -80,8 +80,8 @@ public: /** @name Read accessors */ //@{ - /// Returns the AccessPoint associated with the Measurement - AccessPoint* get_ap() const ; + /// Returns the CapturePoint associated with the Measurement + CapturePoint* get_cp() const ; /// Returns the packet number `pkt_id` ss_t get_ss(pkt_id_t pkt_id) const ; /// Returns the mean of the SS list, in dBm @@ -98,8 +98,8 @@ public: /** @name Write accessors */ //@{ - /// Associate the Measurement with an AccessPoint - void set_ap(const AccessPoint *_ap) ; + /// Associate the Measurement with a CapturePoint + void set_cp(const CapturePoint *_cp) ; /// Adds a signal strength (in dBm) to #ss_list void add_ss(const pkt_id_t packet_id, const ss_t ss_dbm) ; /// Adds several signal strengths (in dBm) to #ss_list @@ -147,9 +147,9 @@ public: /* *** Read accessors *** */ -inline AccessPoint* Measurement::get_ap() const +inline CapturePoint* Measurement::get_cp() const { - return ap ; + return cp ; } @@ -187,9 +187,9 @@ inline int Measurement::get_nb_ss() const /* *** Write accessors *** */ -inline void Measurement::set_ap(const AccessPoint *_ap) +inline void Measurement::set_cp(const CapturePoint *_cp) { - ap = const_cast(_ap) ; + cp = const_cast(_cp) ; } @@ -241,7 +241,7 @@ inline bool Measurement::operator!=(const Measurement &m) const inline Measurement::operator bool() const { return - ap != NULL || + cp != NULL || ! ss_list.empty() ; } diff --git a/owlps-positioner/minmax.cc b/owlps-positioner/minmax.cc index 1b12052..d53c3b9 100644 --- a/owlps-positioner/minmax.cc +++ b/owlps-positioner/minmax.cc @@ -13,18 +13,18 @@ #include "minmax.hh" -#include "accesspoint.hh" +#include "capturepoint.hh" using namespace std ; Point3D MinMax::trilaterate( - const unordered_map &_ap_distances) + const unordered_map &_cp_distances) { min = INFINITE ; centre = start ; - ap_distances = &_ap_distances ; + cp_distances = &_cp_distances ; for (float x = start.get_x() ; x <= stop.get_x() ; x += step) for (float y = start.get_y() ; y <= stop.get_y() ; y += step) @@ -36,11 +36,11 @@ Point3D MinMax::trilaterate( Point3D MinMax::trilaterate_2d( - const unordered_map &_ap_distances, float z) + const unordered_map &_cp_distances, float z) { min = INFINITE ; centre = start ; - ap_distances = &_ap_distances ; + cp_distances = &_cp_distances ; for (float x = start.get_x() ; x <= stop.get_x() ; x += step) for (float y = start.get_y() ; y <= stop.get_y() ; y += step) @@ -53,8 +53,8 @@ Point3D MinMax::trilaterate_2d( void MinMax::iterate(float x, float y, float z) { float d_max = 0 ; - for (unordered_map::const_iterator i = - ap_distances->begin() ; i != ap_distances->end() ; ++i) + for (unordered_map::const_iterator i = + cp_distances->begin() ; i != cp_distances->end() ; ++i) { float dist = Point3D(x, y, z).distance_to_sphere( diff --git a/owlps-positioner/minmax.hh b/owlps-positioner/minmax.hh index 885dc27..616d938 100644 --- a/owlps-positioner/minmax.hh +++ b/owlps-positioner/minmax.hh @@ -23,7 +23,7 @@ class MinMax: public TrilaterationMethod private: float min ; Point3D centre ; - std::unordered_map const *ap_distances ; + std::unordered_map const *cp_distances ; void iterate(float x, float y, float z) ; @@ -45,9 +45,9 @@ public: ~MinMax(void) {} Point3D trilaterate( - const std::unordered_map &_ap_distances) ; + const std::unordered_map &_cp_distances) ; Point3D trilaterate_2d( - const std::unordered_map &_ap_distances, + const std::unordered_map &_cp_distances, float z) ; } ; diff --git a/owlps-positioner/mobilesreadercsv.hh b/owlps-positioner/mobilesreadercsv.hh index 1cacc3e..06deee8 100644 --- a/owlps-positioner/mobilesreadercsv.hh +++ b/owlps-positioner/mobilesreadercsv.hh @@ -23,7 +23,7 @@ class Point3D ; /// Reads and registers to the Stock Mobile list from CSV files /** - * CSV format for access points is: + * CSV format for capture points is: * MAC;Antenna_gain_dBi;Trx_power_dBm */ class MobilesReaderCSV diff --git a/owlps-positioner/posutil.cc b/owlps-positioner/posutil.cc index 08b1692..9a21208 100644 --- a/owlps-positioner/posutil.cc +++ b/owlps-positioner/posutil.cc @@ -46,11 +46,11 @@ double PosUtil::rad2deg(const double &radians) /** - * APs that have not captured a Request must not have too much weight in + * CPs that have not captured a Request must not have too much weight in * the computation. Thus, in the measurements lists we compare, we add - * missing APs with a very low SS value. + * missing CPs with a very low SS value. * - * Both lists can be completed, depending of the APs they contain. + * Both lists can be completed, depending of the CPs they contain. * Both lists must initially contain at least one measurement. */ void PosUtil::complete_with_dummy_measurements( @@ -67,7 +67,7 @@ void PosUtil::complete_with_dummy_measurements( measurements1.begin() ; i != measurements1.end() ; ++i) if (measurements2.find(i->first) == measurements2.end()) { - dummy.set_ap(&Stock::get_ap(i->first)) ; + dummy.set_cp(&Stock::get_cp(i->first)) ; measurements2[i->first] = dummy ; } @@ -75,7 +75,7 @@ void PosUtil::complete_with_dummy_measurements( measurements2.begin() ; i != measurements2.end() ; ++i) if (measurements1.find(i->first) == measurements1.end()) { - dummy.set_ap(&Stock::get_ap(i->first)) ; + dummy.set_cp(&Stock::get_cp(i->first)) ; measurements1[i->first] = dummy ; } } diff --git a/owlps-positioner/posutil.hh b/owlps-positioner/posutil.hh index 0a9dd7d..d58855b 100644 --- a/owlps-positioner/posutil.hh +++ b/owlps-positioner/posutil.hh @@ -46,7 +46,7 @@ public: /** @name Measurements */ //@{ - /// Mutually completes two Measurement lists with missing APs + /// Mutually completes two Measurement lists with missing CPs static void complete_with_dummy_measurements( std::unordered_map &measurements1, std::unordered_map &measurements2) ; diff --git a/owlps-positioner/referencepoint.cc b/owlps-positioner/referencepoint.cc index 9e3bdd8..3d6f6a5 100644 --- a/owlps-positioner/referencepoint.cc +++ b/owlps-positioner/referencepoint.cc @@ -171,25 +171,25 @@ bool ReferencePoint::delete_generated_requests(void) while (r != requests.end()) { assert(*r) ; - unordered_map::const_iterator ap ; + unordered_map::const_iterator cp ; if ((*r)->get_mobile() == NULL) goto delete_request ; - // Check if the request was sent by an AP - for (ap = Stock::get_aps().begin() ; ap != Stock::get_aps().end() ; - ++ap) + // Check if the request was sent by a CP + for (cp = Stock::get_cps().begin() ; cp != Stock::get_cps().end() ; + ++cp) if ((*r)->get_mobile()->get_mac_addr() == - ap->second.get_mac_addr()) + cp->second.get_mac_addr()) break ; - if (ap != Stock::get_aps().end()) // r was sent by an AP + if (cp != Stock::get_cps().end()) // r was sent by a CP { ++r ; continue ; // Do not delete r } - // r is not associated with an AP, delete it + // r is not associated with a CP, delete it delete_request: Stock::delete_calibration_request(**r) ; r = requests.erase(r) ; @@ -228,20 +228,20 @@ float ReferencePoint::similarity(const Request &source) const /** - * @param ap_mac The MAC address of the AccessPoint to work on. + * @param cp_mac The MAC address of the CapturePoint to work on. * - * @returns The Friis index associated to the AccessPoint. - * @returns 0 if the AP is unknown at this ReferencePoint. + * @returns The Friis index associated to the CapturePoint. + * @returns 0 if the CP is unknown at this ReferencePoint. */ float ReferencePoint:: -friis_index_for_ap(const string &ap_mac) const +friis_index_for_cp(const string &cp_mac) const { - const AccessPoint &ap = Stock::get_ap(ap_mac) ; - double const_term = ap.friis_constant_term() ; + const CapturePoint &cp = Stock::get_cp(cp_mac) ; + double const_term = cp.friis_constant_term() ; int nb_friis_idx = 0 ; double friis_idx_sum = - friis_indexes_for_ap(ap, const_term, nb_friis_idx) ; + friis_indexes_for_cp(cp, const_term, nb_friis_idx) ; if (nb_friis_idx == 0) return 0 ; @@ -250,32 +250,32 @@ friis_index_for_ap(const string &ap_mac) const /** - * Computes a Friis index sum for the distance AP-ReferencePoint, - * based on the measurements of this AP that are present in the + * Computes a Friis index sum for the distance CP-ReferencePoint, + * based on the measurements of this CP 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 cp The CapturePoint to work on. * @param const_term The "constant" part of the computation. * @param nb_indexes (result) The number of indexes computed. * - * @returns The sum of all Friis indexes for the AccessPoint. - * @returns 0 if the AP is unknown at this ReferencePoint. + * @returns The sum of all Friis indexes for the CapturePoint. + * @returns 0 if the CP is unknown at this ReferencePoint. */ -float ReferencePoint::friis_indexes_for_ap( - const AccessPoint &ap, +float ReferencePoint::friis_indexes_for_cp( + const CapturePoint &cp, const double &const_term, int &nb_indexes) const { nb_indexes = 0 ; double friis_idx_sum = 0 ; - const string &ap_mac = ap.get_mac_addr() ; - float distance = this->distance(ap.get_coordinates()) ; + const string &cp_mac = cp.get_mac_addr() ; + float distance = this->distance(cp.get_coordinates()) ; /* - * Compute an index for the AP's Measurement in each Request in the - * ReferencePoint. The Friis index for the AP is the average of all + * Compute an index for the CP's Measurement in each Request in the + * ReferencePoint. The Friis index for the CP is the average of all * these indexes (we do not compute the average in this function). */ for (vector::const_iterator request = @@ -284,7 +284,7 @@ float ReferencePoint::friis_indexes_for_ap( const unordered_map &measurements = (*request)->get_measurements() ; unordered_map::const_iterator measurement = - measurements.find(ap_mac) ; + measurements.find(cp_mac) ; if (measurement != measurements.end()) { float ss = measurement->second.get_average_dbm() ; @@ -305,25 +305,25 @@ float ReferencePoint::friis_indexes_for_ap( /** - * Computes a Friis index for the distance AP-ReferencePoint, based on a - * given packet (`pkt_id),` of a measurement of this AP present in the + * Computes a Friis index for the distance CP-ReferencePoint, based on a + * given packet (`pkt_id),` of a measurement of this CP 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 cp_mac The MAC address of the CapturePoint 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 + * @returns The Friis index for this CP and packet. + * @returns 0 if the CP 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 +friis_index_for_cp(const string &cp_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()) ; + const CapturePoint &cp = Stock::get_cp(cp_mac) ; + double const_term = cp.friis_constant_term() ; + float distance = this->distance(cp.get_coordinates()) ; float friis_idx = 0 ; for (vector::const_iterator request = @@ -332,7 +332,7 @@ friis_index_for_ap(const string &ap_mac, pkt_id_t pkt_id) const const unordered_map &measurements = (*request)->get_measurements() ; unordered_map::const_iterator measurement = - measurements.find(ap_mac) ; + measurements.find(cp_mac) ; if (measurement == measurements.end()) continue ; ss_t ss = measurement->second.get_ss(pkt_id) ; diff --git a/owlps-positioner/referencepoint.hh b/owlps-positioner/referencepoint.hh index ceb5745..02929d6 100644 --- a/owlps-positioner/referencepoint.hh +++ b/owlps-positioner/referencepoint.hh @@ -15,7 +15,7 @@ #ifndef _OWLPS_POSITIONING_REFERENCEPOINT_HH_ #define _OWLPS_POSITIONING_REFERENCEPOINT_HH_ -class AccessPoint ; +class CapturePoint ; class CalibrationRequest ; class Request ; @@ -75,7 +75,7 @@ public: void delete_request(const CalibrationRequest *r) ; /// Deletes all the requests contained in #requests void delete_requests(void) ; - /// Deletes the requests that are not sent by an AP + /// Deletes the requests that are not sent by a CP bool delete_generated_requests(void) ; //@} @@ -83,15 +83,15 @@ public: //@{ /// Computes the similarity of the ReferencePoint and a Request float similarity(const Request &source) const ; - /// Computes the Friis index for the given AccessPoint - float friis_index_for_ap(const std::string &ap_mac) const ; - /// Computes the Friis indexes sum for the given AccessPoint - float friis_indexes_for_ap( - const AccessPoint &ap, const double &const_term, + /// Computes the Friis index for the given CapturePoint + float friis_index_for_cp(const std::string &cp_mac) const ; + /// Computes the Friis indexes sum for the given CapturePoint + float friis_indexes_for_cp( + const CapturePoint &cp, 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 ; + /// Computes the Friis index for the given CapturePoint and packet ID + float friis_index_for_cp( + const std::string &cp_mac, pkt_id_t pkt_id) const ; //@} /** @name Operators */ diff --git a/owlps-positioner/request.cc b/owlps-positioner/request.cc index 5e499b0..027313d 100644 --- a/owlps-positioner/request.cc +++ b/owlps-positioner/request.cc @@ -84,9 +84,9 @@ Request::~Request() /** - * @param mac_receiver The MAC address of the receiver AP. + * @param mac_receiver The MAC address of the receiver CP. * @returns A pointer on the found measurement, or NULL if no - * measurement was made by this AP. + * measurement was made by this CP. */ const Measurement* Request::get_measurement(const string &mac_receiver) const diff --git a/owlps-positioner/request.hh b/owlps-positioner/request.hh index beaa97f..a1a2b5d 100644 --- a/owlps-positioner/request.hh +++ b/owlps-positioner/request.hh @@ -43,7 +43,7 @@ protected: Timestamp time_received ; /// List of Measurement of the request /** Note that this is not a pointer list, values are actually stored. - The `string` parameter is the MAC address of the receiver AP. */ + The `string` parameter is the MAC address of the receiver CP. */ std::unordered_map measurements ; /// Real coordinates of the request (normally unavailable for a /// standard positioning request) @@ -92,7 +92,7 @@ public: /// Returns all the measurements const std::unordered_map& get_measurements(void) const ; - /// Returns the measurement made by the AP `mac_receiver,` if any + /// Returns the measurement made by the CP `mac_receiver,` if any const Measurement* get_measurement(const std::string &mac_receiver) const ; const Point3D* get_real_position(void) const ; diff --git a/owlps-positioner/stock.cc b/owlps-positioner/stock.cc index b0ccbb3..a955448 100644 --- a/owlps-positioner/stock.cc +++ b/owlps-positioner/stock.cc @@ -32,7 +32,7 @@ unordered_map Stock::waypoints ; unordered_map Stock::mobiles ; -unordered_map Stock::aps ; +unordered_map Stock::cps ; unordered_set Stock::reference_points ; @@ -49,7 +49,7 @@ void Stock::clear() waypoints.clear() ; mobiles.clear() ; - aps.clear() ; + cps.clear() ; reference_points.clear() ; calibration_requests.clear() ; } @@ -211,114 +211,114 @@ const Mobile& Stock::find_create_mobile(const Mobile &source) -/* *** AccessPoint operations *** */ +/* *** CapturePoint operations *** */ /** - * @param mac The MAC address of the AccessPoint to search for. + * @param mac The MAC address of the CapturePoint to search for. * It must be a valid MAC address, as no check is performed. - * @returns `true` if an AP with this MAC address exists. + * @returns `true` if a CP with this MAC address exists. * @returns `false` if this MAC address was not found. */ -bool Stock::ap_exists(const std::string &mac) +bool Stock::cp_exists(const std::string &mac) { - unordered_map::const_iterator i = aps.find(mac) ; - return i != aps.end() ; + unordered_map::const_iterator i = cps.find(mac) ; + return i != cps.end() ; } /** - * @param mac The MAC address of the AccessPoint to search for. + * @param mac The MAC address of the CapturePoint to search for. * It must be a valid MAC address, as no check is performed. - * @returns A const reference to the AccessPoint. - * @throw element_not_found is thrown if the AccessPoint corresponding + * @returns A const reference to the CapturePoint. + * @throw element_not_found is thrown if the CapturePoint corresponding * to `mac` does not exist. */ -const AccessPoint& Stock::get_ap(const string &mac) +const CapturePoint& Stock::get_cp(const string &mac) { - unordered_map::const_iterator i = aps.find(mac) ; - if (i != aps.end()) + unordered_map::const_iterator i = cps.find(mac) ; + if (i != cps.end()) return i->second ; - throw element_not_found("No AccessPoint with MAC address \"" + + throw element_not_found("No CapturePoint with MAC address \"" + mac + "\"!") ; } /** - * The MAC address of the AccessPoint is initialised. + * The MAC address of the CapturePoint is initialised. */ -const AccessPoint& Stock::find_create_ap(const string &mac) +const CapturePoint& Stock::find_create_cp(const string &mac) { - unordered_map::const_iterator i = aps.find(mac) ; - if (i != aps.end()) + unordered_map::const_iterator i = cps.find(mac) ; + if (i != cps.end()) return i->second ; - AccessPoint &ap = aps[mac] ; - ap.set_mac_addr(mac) ; + CapturePoint &cp = cps[mac] ; + cp.set_mac_addr(mac) ; if (Configuration::is_configured("verbose")) cerr - << "New AP \"" << mac - << "\" (total: " << nb_aps() << " APs).\n" ; + << "New CP \"" << mac + << "\" (total: " << nb_cps() << " CPs).\n" ; - return ap ; + return cp ; } /** - * If the AccessPoint already exists, it is replaced by `source.` + * If the CapturePoint already exists, it is replaced by `source.` */ -const AccessPoint& Stock::find_create_ap(const AccessPoint &source) +const CapturePoint& Stock::find_create_cp(const CapturePoint &source) { const string &mac = source.get_mac_addr() ; - unordered_map::const_iterator i = aps.find(mac) ; - if (i != aps.end()) + unordered_map::const_iterator i = cps.find(mac) ; + if (i != cps.end()) return i->second ; - aps[mac] = source ; - return aps[mac] ; + cps[mac] = source ; + return cps[mac] ; } void Stock::update_all_friis_indexes() { - for (unordered_map::iterator ap = aps.begin() ; - ap != aps.end() ; ++ap) + for (unordered_map::iterator cp = cps.begin() ; + cp != cps.end() ; ++cp) { double friis_idx_sum = 0 ; int nb_friis_idx = 0 ; // Compute main general term, independant from scans - double const_term = ap->second.friis_constant_term() ; + double const_term = cp->second.friis_constant_term() ; /* * Compute indexes for each ReferencePoint. The Friis index for an - * AP is the average of all indexes in all ReferencePoint. + * CP is the average of all indexes in all ReferencePoint. */ for (unordered_set::const_iterator rp = reference_points.begin() ; rp != reference_points.end() ; ++rp) { int nb_idx = 0 ; - float ap_friis_idx_sum = - rp->friis_indexes_for_ap(ap->second, const_term, nb_idx) ; + float cp_friis_idx_sum = + rp->friis_indexes_for_cp(cp->second, const_term, nb_idx) ; if (nb_idx != 0) { - friis_idx_sum += ap_friis_idx_sum ; + friis_idx_sum += cp_friis_idx_sum ; nb_friis_idx += nb_idx ; } } if (nb_friis_idx > 0) - ap->second.set_friis_index(friis_idx_sum / nb_friis_idx) ; + cp->second.set_friis_index(friis_idx_sum / nb_friis_idx) ; } } -double Stock::ap_matrix_get_ss(const std::string &mac_transmitter, +double Stock::cp_matrix_get_ss(const std::string &mac_transmitter, const std::string &mac_receiver) { - const AccessPoint &receiver = get_ap(mac_receiver) ; + const CapturePoint &receiver = get_cp(mac_receiver) ; const ReferencePoint &rp = get_reference_point(receiver.get_coordinates()) ; @@ -328,13 +328,13 @@ double Stock::ap_matrix_get_ss(const std::string &mac_transmitter, /** * @returns `true` if `coord` are the coordinates of an existing - * AP, `false` if not. + * CP, `false` if not. */ -bool Stock::is_ap_coordinate(const Point3D &coord) +bool Stock::is_cp_coordinate(const Point3D &coord) { - for (unordered_map::const_iterator ap = - aps.begin() ; ap != aps.end() ; ++ap) - if (ap->second.get_coordinates() == coord) + for (unordered_map::const_iterator cp = + cps.begin() ; cp != cps.end() ; ++cp) + if (cp->second.get_coordinates() == coord) return true ; return false ; @@ -390,21 +390,21 @@ closest_reference_point(const Request &request) "Cannot search for the closest reference point: reference points'" " list is empty!") ; - bool ignore_aps = Configuration::bool_value( - "positioning.nss.ignore-ap-reference-points") ; + bool ignore_cps = Configuration::bool_value( + "positioning.nss.ignore-cp-reference-points") ; unordered_set::const_iterator i = reference_points.begin() ; - if (ignore_aps) + if (ignore_cps) { - // Fast-forward to the next non-AP reference point - while (i != reference_points.end() && is_ap_coordinate(*i)) + // Fast-forward to the next non-CP reference point + while (i != reference_points.end() && is_cp_coordinate(*i)) ++i ; - // No non-AP reference point was found, we are forced to consider - // the AP reference points + // No non-CP reference point was found, we are forced to consider + // the CP reference points if (i == reference_points.end()) - ignore_aps = false ; + ignore_cps = false ; } float similarity = i->similarity(request) ; @@ -412,7 +412,7 @@ closest_reference_point(const Request &request) for (++i ; i != reference_points.end() ; ++i) { - if (ignore_aps && is_ap_coordinate(*i)) + if (ignore_cps && is_cp_coordinate(*i)) continue ; float tmp_similarity = i->similarity(request) ; @@ -430,10 +430,10 @@ closest_reference_point(const Request &request) void Stock::regenerate_reference_points() { assert(Configuration::autocalibration_enabled()) ; - assert(! aps.empty()) ; + assert(! cps.empty()) ; assert(! reference_points.empty()) ; - delete_non_ap_calibration_requests() ; + delete_non_cp_calibration_requests() ; if (reference_points.size() < 3) { @@ -604,24 +604,24 @@ closest_calibration_request(const Request &request) "Cannot search for the closest calibration request: calibration" " requests' list is empty!") ; - bool ignore_aps = Configuration::bool_value( - "positioning.nss.ignore-ap-reference-points") ; + bool ignore_cps = Configuration::bool_value( + "positioning.nss.ignore-cp-reference-points") ; unordered_set::const_iterator i = calibration_requests.begin() ; - if (ignore_aps) + if (ignore_cps) { - // Fast-forward to the next non-AP reference point + // Fast-forward to the next non-CP reference point while (i != calibration_requests.end() && - is_ap_coordinate(*i->get_reference_point())) + is_cp_coordinate(*i->get_reference_point())) ++i ; - // No non-AP reference point was found, we are forced to consider - // the AP reference points + // No non-CP reference point was found, we are forced to consider + // the CP reference points if (i == calibration_requests.end()) { i = calibration_requests.begin() ; - ignore_aps = false ; + ignore_cps = false ; } } @@ -630,7 +630,7 @@ closest_calibration_request(const Request &request) for (++i ; i != calibration_requests.end() ; ++i) { - if (ignore_aps && is_ap_coordinate(*i->get_reference_point())) + if (ignore_cps && is_cp_coordinate(*i->get_reference_point())) continue ; assert(! i->get_measurements().empty()) ; @@ -647,7 +647,7 @@ closest_calibration_request(const Request &request) } -void Stock::delete_non_ap_calibration_requests() +void Stock::delete_non_cp_calibration_requests() { unordered_set::iterator rp = reference_points.begin() ; while (rp != reference_points.end()) diff --git a/owlps-positioner/stock.hh b/owlps-positioner/stock.hh index 9a17732..763b89b 100644 --- a/owlps-positioner/stock.hh +++ b/owlps-positioner/stock.hh @@ -19,7 +19,7 @@ #include "building.hh" #include "waypoint.hh" #include "mobile.hh" -#include "accesspoint.hh" +#include "capturepoint.hh" #include "referencepoint.hh" #include "calibrationrequest.hh" @@ -43,9 +43,9 @@ private: /** The string key of the map is the Mobile MAC address. */ static std::unordered_map mobiles ; - /// List of known AccessPoint - /** The string key of the map is the AccessPoint MAC address. */ - static std::unordered_map aps ; + /// List of known CapturePoint + /** The string key of the map is the CapturePoint MAC address. */ + static std::unordered_map cps ; /// List of known ReferencePoint static std::unordered_set reference_points ; @@ -55,8 +55,8 @@ private: /** @name CalibrationRequest operations */ //@{ - /// Delete calibration requests that do not come from the APs - static void delete_non_ap_calibration_requests(void) ; + /// Delete calibration requests that do not come from the CPs + static void delete_non_cp_calibration_requests(void) ; //@} /** @name ReferencePoint operations */ @@ -118,33 +118,33 @@ public: static Mobile& getw_mobile(const std::string &mac) ; //@} - /** @name AccessPoint operations */ + /** @name CapturePoint operations */ //@{ - /// Returns the number of access points - static unsigned int nb_aps(void) ; - /// Returns a reference to the AP list + /// Returns the number of capture points + static unsigned int nb_cps(void) ; + /// Returns a reference to the CP list static - std::unordered_map& get_aps(void) ; - /// Verify the existence of an AP - static bool ap_exists(const std::string &mac) ; - /// Reads the AccessPoint corresponding to a given MAC address - static const AccessPoint& get_ap(const std::string &mac) ; - /// Searches for an AccessPoint given its MAC address and creates it + std::unordered_map& get_cps(void) ; + /// Verify the existence of a CP + static bool cp_exists(const std::string &mac) ; + /// Reads the CapturePoint corresponding to a given MAC address + static const CapturePoint& get_cp(const std::string &mac) ; + /// Searches for a CapturePoint given its MAC address and creates it /// if it does not exist - static const AccessPoint& find_create_ap(const std::string &mac) ; - /// Searches for an AccessPoint and create it if it does not exist - static const AccessPoint& find_create_ap(const AccessPoint &source) ; - /// Returns a reference to the AccessPoint corresponding to a given + static const CapturePoint& find_create_cp(const std::string &mac) ; + /// Searches for a CapturePoint and create it if it does not exist + static const CapturePoint& find_create_cp(const CapturePoint &source) ; + /// Returns a reference to the CapturePoint corresponding to a given /// MAC address - static AccessPoint& getw_ap(const std::string &mac) ; - /// Updates the friis indexes of all the APs + static CapturePoint& getw_cp(const std::string &mac) ; + /// Updates the friis indexes of all the CPs static void update_all_friis_indexes(void) ; - /// Returns the signal strenth received by an AP `mac_receiver` from - /// an AP `mac_transmitter` - static double ap_matrix_get_ss(const std::string &mac_transmitter, + /// Returns the signal strenth received by a CP `mac_receiver` from + /// a CP `mac_transmitter` + static double cp_matrix_get_ss(const std::string &mac_transmitter, const std::string &mac_receiver) ; - /// Checks if a Point3D is the coordinate of an existing AP - static bool is_ap_coordinate(const Point3D &coord) ; + /// Checks if a Point3D is the coordinate of an existing CP + static bool is_cp_coordinate(const Point3D &coord) ; //@} /** @name ReferencePoint operations */ @@ -164,7 +164,7 @@ public: static const ReferencePoint& closest_reference_point(const Request &request) ; /// Generates reference points from the reference points corresponding - /// to APs + /// to CPs static void regenerate_reference_points(void) ; //@} @@ -250,32 +250,32 @@ inline Mobile& Stock::getw_mobile(const std::string &mac) -/* *** AccessPoint operations *** */ +/* *** CapturePoint operations *** */ -inline unsigned int Stock::nb_aps() +inline unsigned int Stock::nb_cps() { - return aps.size() ; + return cps.size() ; } inline -std::unordered_map& Stock::get_aps() +std::unordered_map& Stock::get_cps() { - return aps ; + return cps ; } /** - * If the AccessPoint corresponding to `mac` does not exist, it is + * If the CapturePoint corresponding to `mac` does not exist, it is * created. - * @param mac The MAC address of the AccessPoint to search for. + * @param mac The MAC address of the CapturePoint to search for. * It must be a valid MAC address, as no check is performed. - * @returns A modifiable reference to the AccessPoint. + * @returns A modifiable reference to the CapturePoint. */ -inline AccessPoint& Stock::getw_ap(const std::string &mac) +inline CapturePoint& Stock::getw_cp(const std::string &mac) { - return aps[mac] ; + return cps[mac] ; } diff --git a/owlps-positioner/trilaterationalgorithm.cc b/owlps-positioner/trilaterationalgorithm.cc index 153c65f..4e45b31 100644 --- a/owlps-positioner/trilaterationalgorithm.cc +++ b/owlps-positioner/trilaterationalgorithm.cc @@ -62,11 +62,11 @@ make_constant_term(const Measurement &measurement) assert(request) ; const Mobile *mobile = request->get_mobile() ; assert(mobile) ; - const AccessPoint *ap = measurement.get_ap() ; - assert(ap) ; + const CapturePoint *cp = measurement.get_cp() ; + assert(cp) ; return - ap->friis_constant_term() + + cp->friis_constant_term() + mobile->get_antenna_gain() + mobile->get_trx_power() ; } @@ -76,21 +76,21 @@ Result TrilaterationAlgorithm::compute(const Request &_request) { request = &_request ; - compute_ap_distance_circles() ; + compute_cp_distance_circles() ; Point3D position(trilaterate()) ; return Result(request, name, position) ; } -void TrilaterationAlgorithm::compute_ap_distance_circles() +void TrilaterationAlgorithm::compute_cp_distance_circles() { - ap_distances.clear() ; + cp_distances.clear() ; const unordered_map &measurements = request->get_measurements() ; for (unordered_map::const_iterator i = measurements.begin() ; i != measurements.end() ; ++i) - ap_distances[i->second.get_ap()] = estimate_distance(i->second) ; + cp_distances[i->second.get_cp()] = estimate_distance(i->second) ; } diff --git a/owlps-positioner/trilaterationalgorithm.hh b/owlps-positioner/trilaterationalgorithm.hh index 502eda2..0386912 100644 --- a/owlps-positioner/trilaterationalgorithm.hh +++ b/owlps-positioner/trilaterationalgorithm.hh @@ -24,13 +24,13 @@ class TrilaterationAlgorithm: public virtual PositioningAlgorithm protected: const Request *request ; - std::unordered_map ap_distances ; + std::unordered_map cp_distances ; TrilaterationMethod *trilateration_method ; /** @name Operations */ //@{ double make_constant_term(const Measurement &measurement) ; - void compute_ap_distance_circles() ; + void compute_cp_distance_circles() ; Point3D trilaterate() ; Point3D trilaterate_2d(float z) ; //@} @@ -51,13 +51,13 @@ public: inline Point3D TrilaterationAlgorithm::trilaterate() { - return trilateration_method->trilaterate(ap_distances) ; + return trilateration_method->trilaterate(cp_distances) ; } inline Point3D TrilaterationAlgorithm::trilaterate_2d(float z) { - return trilateration_method->trilaterate_2d(ap_distances, z) ; + return trilateration_method->trilaterate_2d(cp_distances, z) ; } diff --git a/owlps-positioner/trilaterationmethod.hh b/owlps-positioner/trilaterationmethod.hh index d3c3a5d..f0a439f 100644 --- a/owlps-positioner/trilaterationmethod.hh +++ b/owlps-positioner/trilaterationmethod.hh @@ -15,7 +15,7 @@ #ifndef _OWLPS_POSITIONING_TRILATERATIONMETHOD_HH_ #define _OWLPS_POSITIONING_TRILATERATIONMETHOD_HH_ -class AccessPoint ; +class CapturePoint ; #include "point3d.hh" @@ -23,7 +23,7 @@ class AccessPoint ; /// Super-class of all trilateration methods /** - * The source data is a list of access points associated with the + * The source data is a list of capture points associated with the * distances to the mobile. These distances are estimated using a * TrilaterationAlgorithm. */ @@ -35,11 +35,11 @@ public: /// Selects a point in 3D space virtual Point3D trilaterate( - const std::unordered_map &ap_distances) = 0 ; + const std::unordered_map &cp_distances) = 0 ; /// Selects a point in 2D space, given its vertical coordinate (z) virtual Point3D trilaterate_2d( - const std::unordered_map &ap_distances, + const std::unordered_map &cp_distances, float z) = 0 ; } ; diff --git a/owlps-positioner/userinterface.cc b/owlps-positioner/userinterface.cc index 57b055f..57c4e85 100644 --- a/owlps-positioner/userinterface.cc +++ b/owlps-positioner/userinterface.cc @@ -128,14 +128,14 @@ void UserInterface::fill_data_input_options() po::options_description options("Data input options") ; options.add_options() - ("data-input.ap-medium", + ("data-input.cp-medium", po::value< vector >()->composing(), - "Medium from which access points are read. You can specify this" + "Medium from which capture points are read. You can specify this" " option more than once. Allowed: CSV.") - ("data-input.ap-csv-file", + ("data-input.cp-csv-file", po::value(), - "CSV file to use for access points input (when" - " data-input.ap-medium = CSV).") + "CSV file to use for capture points input (when" + " data-input.cp-medium = CSV).") ("data-input.mobile-medium", po::value< vector >()->composing(), "Medium from which mobiles are read. You can specify this" @@ -223,15 +223,15 @@ void UserInterface::fill_positioning_options() po::value()->default_value(false), "When receiving requests, add unknown mobiles (mobiles which are not" " declared in the mobiles' configuration file) to the mobiles' list.") - ("positioning.accept-new-aps", + ("positioning.accept-new-cps", po::value()->default_value(false), - "When receiving requests, add unknown APs (APs which are not" - " declared in the APs' configuration file) to the APs' list" + "When receiving requests, add unknown CPs (CPs which are not" + " declared in the CPs' configuration file) to the CPs' list" " (default is false, for security purposes).") - ("positioning.update-ap-coordinates-online", + ("positioning.update-cp-coordinates-online", po::value()->default_value(false), - "Allow AP's coordinates to be updated when a calibration request" - " with new coordinates is received from the AP (default is false," + "Allow CP's coordinates to be updated when a calibration request" + " with new coordinates is received from the CP (default is false," " for security purposes).") ("positioning.area-start", po::value(), @@ -310,10 +310,10 @@ void UserInterface::fill_positioning_options() " before to compute the SS similarity." " The default is false, i.e the positioning request is compared" " directly to each calibration request.") - ("positioning.nss.ignore-ap-reference-points", + ("positioning.nss.ignore-cp-reference-points", po::value()->default_value(false), "With the NSS algorithm, try to avoid selecting the reference" - " points which are coordinates of an AP.") + " points which are coordinates of a CP.") ; file_options->add(options) ;