diff --git a/owlps-positioning/TODO b/owlps-positioning/TODO index e47bf7e..a1ad98f 100644 --- a/owlps-positioning/TODO +++ b/owlps-positioning/TODO @@ -1,4 +1,7 @@ +- const_iterator + Utiliser const_iterator quand on ne modifie pas la valeur pointée. + - InputCSV ° Différencier une requête normale d'une requête de calibration, en utilisant les champs de direction. @@ -33,6 +36,9 @@ - Request Constructeur par recopie, operator==(), etc. +- PosUtil + Remplacer timespec_equals() par operator==(timespec, timespec) ? + - AccessPoint Attribut float friis_index ? @@ -47,3 +53,4 @@ Espaces de noms ? 109 Réserver l'espace mémoire des vector avec reserve(). 217 Utiliser hash_map plutôt que map s'il n'y a pas besoin de trier. 252 + Copie de conteneur vers un flux (cas de certains operator<<). 275 diff --git a/owlps-positioning/building.hh b/owlps-positioning/building.hh index ec782c7..6ba9567 100644 --- a/owlps-positioning/building.hh +++ b/owlps-positioning/building.hh @@ -1,5 +1,5 @@ -#ifndef _OWLPS_POSITIONING_REFERENCEPOINT_HH_ -#define _OWLPS_POSITIONING_REFERENCEPOINT_HH_ +#ifndef _OWLPS_POSITIONING_BUILDING_HH_ +#define _OWLPS_POSITIONING_BUILDING_HH_ class Area ; class Waypoint ; @@ -121,4 +121,4 @@ inline bool Building::operator!=(const Building &b) const -#endif // _OWLPS_POSITIONING_REFERENCEPOINT_HH_ +#endif // _OWLPS_POSITIONING_BUILDING_HH_ diff --git a/owlps-positioning/inputcsv.cc b/owlps-positioning/inputcsv.cc index b01411e..4cfc131 100644 --- a/owlps-positioning/inputcsv.cc +++ b/owlps-positioning/inputcsv.cc @@ -113,7 +113,7 @@ const Request& InputCSV::get_next_request() } try { - current_request.set_timestamp(PosUtil::ns_to_timespec + current_request.set_timestamp(PosUtil::ms_to_timespec (lexical_cast(*ti))) ; } catch (bad_lexical_cast &e) diff --git a/owlps-positioning/measurement.cc b/owlps-positioning/measurement.cc index 94b17bd..8f97303 100644 --- a/owlps-positioning/measurement.cc +++ b/owlps-positioning/measurement.cc @@ -8,6 +8,14 @@ using namespace std ; /* *** Constructors *** */ +Measurement::Measurement(const AccessPoint *_ap) +{ + ap = const_cast(_ap) ; + ss_list.reserve(10) ; + average_ss = 0 ; +} + + Measurement::Measurement(const AccessPoint *_ap, const vector &_ss_list) { diff --git a/owlps-positioning/measurement.hh b/owlps-positioning/measurement.hh index 427dfa9..61e33e7 100644 --- a/owlps-positioning/measurement.hh +++ b/owlps-positioning/measurement.hh @@ -22,10 +22,12 @@ protected: void update_average_ss(void) ; public: + /// Constructs a Measurement from an AccessPoint (or default constructor) + Measurement(const AccessPoint *_ap = NULL) ; /// \brief Constructs a Measurement from an AccessPoint and a list - /// of signal strengths (or default constructor) - Measurement(const AccessPoint *_ap = NULL, - const std::vector &_ss_list = std::vector()) ; + /// of signal strengths + Measurement(const AccessPoint *_ap, + const std::vector &_ss_list) ; /// Copy constructor Measurement(const Measurement &m) ; diff --git a/owlps-positioning/posutil.cc b/owlps-positioning/posutil.cc index b1bf0c7..dfa1fe4 100644 --- a/owlps-positioning/posutil.cc +++ b/owlps-positioning/posutil.cc @@ -61,6 +61,30 @@ unsigned int PosUtil::channel_to_frequency(const int &channel) +/** + * d.tv_nsec precision is set to ms, but the value is still in ns. + * @param d The date to round. + */ +void PosUtil::timespec_round_to_ms(struct timespec &d) +{ + d.tv_nsec = d.tv_nsec / 1000000 * 1000000 ; +} + + +/** + * @return \em true if the two dates are equals. + * @return \em false if they are different. + */ +bool PosUtil::timespec_equals(const struct timespec &d1, + const struct timespec &d2) +{ + return + d1.tv_sec == d2.tv_sec && + d1.tv_nsec == d2.tv_nsec ; +} + + + uint64_t PosUtil::timespec_to_ms(const struct timespec &d) { return d.tv_sec * 1000 + d.tv_nsec / 1000000 ; @@ -75,20 +99,3 @@ struct timespec PosUtil::ms_to_timespec(const uint64_t &tms) d.tv_nsec = (tms - d.tv_sec * 1000) * 1000000 ; return d ; } - - - -uint64_t PosUtil::timespec_to_ns(const struct timespec &d) -{ - return d.tv_sec * 1000000000 + d.tv_nsec ; -} - - - -struct timespec PosUtil::ns_to_timespec(const uint64_t &tns) -{ - struct timespec d ; - d.tv_sec = tns / 1000000000 ; - d.tv_nsec = tns - d.tv_sec * 1000000000 ; - return d ; -} diff --git a/owlps-positioning/posutil.hh b/owlps-positioning/posutil.hh index 31096c1..8268254 100644 --- a/owlps-positioning/posutil.hh +++ b/owlps-positioning/posutil.hh @@ -32,14 +32,15 @@ public: /** @name Time & Dates */ //@{ + /// Lowers the precision of a \em timespec to ms + static void timespec_round_to_ms(struct timespec &d) ; + /// Compares two struct timespec + static bool timespec_equals(const struct timespec &d1, + const struct timespec &d2) ; /// Converts a struct timespec into a value in milliseconds static uint64_t timespec_to_ms(const struct timespec &d) ; /// Converts a time value in milliseconds into a struct timespec static struct timespec ms_to_timespec(const uint64_t &tms) ; - /// Converts a struct timespec into a value in nanoseconds - static uint64_t timespec_to_ns(const struct timespec &d) ; - /// Converts a time value in nanoseconds into a struct timespec - static struct timespec ns_to_timespec(const uint64_t &tns) ; //@} } ; diff --git a/owlps-positioning/request.cc b/owlps-positioning/request.cc index c70da92..07a85b7 100644 --- a/owlps-positioning/request.cc +++ b/owlps-positioning/request.cc @@ -72,7 +72,7 @@ ostream &operator<<(ostream &os, const Request &r) { // Timestamp os - << "At " << PosUtil::timespec_to_ns(r.timestamp) << "; " ; + << "At " << PosUtil::timespec_to_ms(r.timestamp) << "; " ; // MAC address os diff --git a/owlps-positioning/request.hh b/owlps-positioning/request.hh index e5641d7..dda88c7 100644 --- a/owlps-positioning/request.hh +++ b/owlps-positioning/request.hh @@ -18,7 +18,8 @@ protected: /// Local date of the request on the mobile struct timespec timestamp ; /// List of Measurement of the request - /** Note that this is not a pointer list, values are actually stored. */ + /** Note that this is not a pointer list, values are actually stored. + The \em string parameter is the MAC address of the AP. */ std::tr1::unordered_map measurements ; public: