[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.
This commit is contained in:
Matteo Cypriani 2011-12-30 19:52:51 +01:00
parent a3b8b90760
commit 055dca7711
4 changed files with 13 additions and 12 deletions

View File

@ -119,7 +119,7 @@ bool InputCSV::fill_current_request()
string mac_ap ; string mac_ap ;
while (file.read_field(mac_ap)) while (file.read_field(mac_ap))
{ {
uint_fast16_t packet_id ; pkt_id_t packet_id ;
if (! file.read_field(packet_id)) if (! file.read_field(packet_id))
{ {
// Wrong number of fields // Wrong number of fields

View File

@ -172,7 +172,7 @@ bool InputUDPSocket::fill_current_request()
return false ; 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( string mac_ap(
owl_mac_bytes_to_string(request_info.ap_mac_addr_bytes)) ; owl_mac_bytes_to_string(request_info.ap_mac_addr_bytes)) ;

View File

@ -37,12 +37,12 @@ Measurement::~Measurement()
* @param ss_dbm The signal strength to add to #ss_list (in dBm). * @param ss_dbm The signal strength to add to #ss_list (in dBm).
*/ */
void Measurement:: 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() ; unsigned int ss_list_size = ss_list.size() ;
// Add the new value (in dBm) along with the packet identifier: // Add the new value (in dBm) along with the packet identifier:
pair<uint_fast16_t, ss_t> packet(make_pair(packet_id, ss_dbm)) ; pair<pkt_id_t, ss_t> packet(make_pair(packet_id, ss_dbm)) ;
if (! ss_list.insert(packet).second) if (! ss_list.insert(packet).second)
{ {
cerr cerr
@ -66,11 +66,11 @@ add_ss(const uint_fast16_t packet_id, const ss_t ss_dbm)
* is overwritten. * is overwritten.
*/ */
void Measurement:: void Measurement::
add_ss_list(const map<uint_fast16_t, ss_t> &_ss_list) add_ss_list(const map<pkt_id_t, ss_t> &_ss_list)
{ {
// We cannot use insert() here because we want to overwrite the // We cannot use insert() here because we want to overwrite the
// previous values with the same ID, if any. // previous values with the same ID, if any.
for (map<uint_fast16_t, ss_t>::const_iterator for (map<pkt_id_t, ss_t>::const_iterator
i = _ss_list.begin() ; i != _ss_list.end() ; ++i) i = _ss_list.begin() ; i != _ss_list.end() ; ++i)
ss_list[i->first] = i->second ; ss_list[i->first] = i->second ;
@ -120,7 +120,7 @@ void Measurement::update_average_ss()
double total_ss_mwatts = 0 ; double total_ss_mwatts = 0 ;
for (map<uint_fast16_t, ss_t>::const_iterator for (map<pkt_id_t, ss_t>::const_iterator
i = ss_list.begin() ; i != ss_list.end() ; ++i) i = ss_list.begin() ; i != ss_list.end() ; ++i)
// Add the current value in mW to the total // Add the current value in mW to the total
total_ss_mwatts += pow(10, static_cast<double>(i->second) / 10.0) ; total_ss_mwatts += pow(10, static_cast<double>(i->second) / 10.0) ;
@ -171,7 +171,7 @@ const string Measurement::to_csv() const
if (ap) if (ap)
mac_ap = ap->get_mac_addr() ; mac_ap = ap->get_mac_addr() ;
for (map<uint_fast16_t, ss_t>::const_iterator for (map<pkt_id_t, ss_t>::const_iterator
i = ss_list.begin() ; i != ss_list.end() ; ++i) i = ss_list.begin() ; i != ss_list.end() ; ++i)
{ {
if (i != ss_list.begin()) if (i != ss_list.begin())
@ -198,7 +198,7 @@ ostream &operator<<(ostream &os, const Measurement &m)
if (m.ss_list.empty()) if (m.ss_list.empty())
os << "No values" ; os << "No values" ;
else else
for (map<uint_fast16_t, ss_t>::const_iterator for (map<pkt_id_t, ss_t>::const_iterator
i = m.ss_list.begin() ; i != m.ss_list.end() ; ++i) i = m.ss_list.begin() ; i != m.ss_list.end() ; ++i)
{ {
if (i != m.ss_list.begin()) if (i != m.ss_list.begin())

View File

@ -14,6 +14,7 @@
#include <ostream> #include <ostream>
#include <cmath> #include <cmath>
typedef uint_fast16_t pkt_id_t ;
typedef int_fast16_t ss_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 AccessPoint
@ -23,7 +24,7 @@ protected:
/// The AccessPoint that performed the measurement /// The AccessPoint that performed the measurement
AccessPoint *ap ; AccessPoint *ap ;
/// List of signal strengths captured (in dBm) /// List of signal strengths captured (in dBm)
std::map<uint_fast16_t, ss_t> ss_list ; std::map<pkt_id_t, ss_t> ss_list ;
/// Average of all signal strength captured (dBm) /// Average of all signal strength captured (dBm)
double average_ss ; double average_ss ;
@ -55,9 +56,9 @@ public:
//@{ //@{
void set_ap(const AccessPoint *_ap) ; void set_ap(const AccessPoint *_ap) ;
/// Adds a signal strength to #ss_list /// 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 /// Adds several signal strengths to #ss_list
void add_ss_list(const std::map<uint_fast16_t, ss_t> &_ss_list) ; void add_ss_list(const std::map<pkt_id_t, ss_t> &_ss_list) ;
/// Merges a given Measurement into the current Measurement /// Merges a given Measurement into the current Measurement
void merge(const Measurement &source) ; void merge(const Measurement &source) ;
void clear(void) ; void clear(void) ;