From 055dca77111977f9457584c4d99d2c89f5e99ec1 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Fri, 30 Dec 2011 19:52:51 +0100 Subject: [PATCH] [Positioner] Measurement: declare type pkt_id_t Like ss_t, pkt_id_t is now declared in measurement.hh to help use the same type everywhere for packet IDs. --- owlps-positioner/src/inputcsv.cc | 2 +- owlps-positioner/src/inputudpsocket.cc | 2 +- owlps-positioner/src/measurement.cc | 14 +++++++------- owlps-positioner/src/measurement.hh | 7 ++++--- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/owlps-positioner/src/inputcsv.cc b/owlps-positioner/src/inputcsv.cc index 56304c9..00e93a5 100644 --- a/owlps-positioner/src/inputcsv.cc +++ b/owlps-positioner/src/inputcsv.cc @@ -119,7 +119,7 @@ bool InputCSV::fill_current_request() string mac_ap ; while (file.read_field(mac_ap)) { - uint_fast16_t packet_id ; + pkt_id_t packet_id ; if (! file.read_field(packet_id)) { // Wrong number of fields diff --git a/owlps-positioner/src/inputudpsocket.cc b/owlps-positioner/src/inputudpsocket.cc index ff8ff06..01ef25e 100644 --- a/owlps-positioner/src/inputudpsocket.cc +++ b/owlps-positioner/src/inputudpsocket.cc @@ -172,7 +172,7 @@ bool InputUDPSocket::fill_current_request() return false ; } - uint_fast16_t packet_id = ntohs(request_info.packet_id) ; + pkt_id_t packet_id = ntohs(request_info.packet_id) ; string mac_ap( owl_mac_bytes_to_string(request_info.ap_mac_addr_bytes)) ; diff --git a/owlps-positioner/src/measurement.cc b/owlps-positioner/src/measurement.cc index 8e7c809..22a303b 100644 --- a/owlps-positioner/src/measurement.cc +++ b/owlps-positioner/src/measurement.cc @@ -37,12 +37,12 @@ Measurement::~Measurement() * @param ss_dbm The signal strength to add to #ss_list (in dBm). */ void Measurement:: -add_ss(const uint_fast16_t packet_id, const ss_t ss_dbm) +add_ss(const pkt_id_t packet_id, const ss_t ss_dbm) { unsigned int ss_list_size = ss_list.size() ; // Add the new value (in dBm) along with the packet identifier: - pair packet(make_pair(packet_id, ss_dbm)) ; + pair packet(make_pair(packet_id, ss_dbm)) ; if (! ss_list.insert(packet).second) { cerr @@ -66,11 +66,11 @@ add_ss(const uint_fast16_t packet_id, const ss_t ss_dbm) * is overwritten. */ void Measurement:: -add_ss_list(const map &_ss_list) +add_ss_list(const map &_ss_list) { // We cannot use insert() here because we want to overwrite the // previous values with the same ID, if any. - for (map::const_iterator + for (map::const_iterator i = _ss_list.begin() ; i != _ss_list.end() ; ++i) ss_list[i->first] = i->second ; @@ -120,7 +120,7 @@ void Measurement::update_average_ss() double total_ss_mwatts = 0 ; - for (map::const_iterator + for (map::const_iterator i = ss_list.begin() ; i != ss_list.end() ; ++i) // Add the current value in mW to the total total_ss_mwatts += pow(10, static_cast(i->second) / 10.0) ; @@ -171,7 +171,7 @@ const string Measurement::to_csv() const if (ap) mac_ap = ap->get_mac_addr() ; - for (map::const_iterator + for (map::const_iterator i = ss_list.begin() ; i != ss_list.end() ; ++i) { if (i != ss_list.begin()) @@ -198,7 +198,7 @@ ostream &operator<<(ostream &os, const Measurement &m) if (m.ss_list.empty()) os << "No values" ; else - for (map::const_iterator + for (map::const_iterator i = m.ss_list.begin() ; i != m.ss_list.end() ; ++i) { if (i != m.ss_list.begin()) diff --git a/owlps-positioner/src/measurement.hh b/owlps-positioner/src/measurement.hh index 950964c..dcd8d78 100644 --- a/owlps-positioner/src/measurement.hh +++ b/owlps-positioner/src/measurement.hh @@ -14,6 +14,7 @@ #include #include +typedef uint_fast16_t pkt_id_t ; typedef int_fast16_t ss_t ; /// Represents a list of signal strengths captured by one AccessPoint @@ -23,7 +24,7 @@ protected: /// The AccessPoint that performed the measurement AccessPoint *ap ; /// List of signal strengths captured (in dBm) - std::map ss_list ; + std::map ss_list ; /// Average of all signal strength captured (dBm) double average_ss ; @@ -55,9 +56,9 @@ public: //@{ void set_ap(const AccessPoint *_ap) ; /// Adds a signal strength to #ss_list - void add_ss(const uint_fast16_t packet_id, const ss_t ss_dbm) ; + void add_ss(const pkt_id_t packet_id, const ss_t ss_dbm) ; /// Adds several signal strengths to #ss_list - void add_ss_list(const std::map &_ss_list) ; + void add_ss_list(const std::map &_ss_list) ; /// Merges a given Measurement into the current Measurement void merge(const Measurement &source) ; void clear(void) ;