From acfe9155f5767a28353e8c79045810dd7fbccffd Mon Sep 17 00:00:00 2001 From: Marcin Masternak Date: Tue, 29 Nov 2016 16:27:34 +0100 Subject: [PATCH] [my-place] DEBUG_MODE simplification. Change-Id: If9c1be9ff546b6fc15a5390dee704ff29d9eebd0 Signed-off-by: Marcin Masternak --- src/my-place/facade/UserPlaces.cpp | 1 - src/my-place/place/PlacesDetector.cpp | 9 ++++----- src/my-place/utils/Gmap.h | 2 +- src/my-place/utils/UserPlacesTypes.cpp | 9 --------- src/my-place/utils/UserPlacesTypes.h | 24 ----------------------- src/my-place/visit-detector/LocationLogger.cpp | 27 -------------------------- src/my-place/visit-detector/LocationLogger.h | 2 +- src/my-place/visit-detector/VisitDetector.cpp | 18 ----------------- 8 files changed, 6 insertions(+), 86 deletions(-) diff --git a/src/my-place/facade/UserPlaces.cpp b/src/my-place/facade/UserPlaces.cpp index 4fc6024..067d595 100755 --- a/src/my-place/facade/UserPlaces.cpp +++ b/src/my-place/facade/UserPlaces.cpp @@ -154,7 +154,6 @@ std::map ctx::UserPlaces::__dbGetWifiAPsMap() std::map wifiAPsMap; DatabaseManager dbManager; bool ret = dbManager.executeSync(__GET_WIFI_APS_MAP_QUERY, &records); - // TODO: add return statements if db fail _D("load Wifi APs map (size = %d), result: %s", records.size(), ret ? "SUCCESS" : "FAIL"); std::string mac = ""; std::string networkName = ""; diff --git a/src/my-place/place/PlacesDetector.cpp b/src/my-place/place/PlacesDetector.cpp index 7a226c7..96e9a41 100644 --- a/src/my-place/place/PlacesDetector.cpp +++ b/src/my-place/place/PlacesDetector.cpp @@ -34,7 +34,7 @@ #define __DELETE_PLACES_QUERY "DELETE FROM " PLACE_TABLE #ifdef DEBUG_MODE -#define __USER_PLACES_FILE "/tmp/user_places.txt" // TODO: Only for debug purposes -> Remove in final solution +#define __USER_PLACES_FILE "/tmp/user_places.txt" #endif /* DEBUG_MODE */ #define __GET_VISITS_QUERY "SELECT "\ @@ -166,7 +166,7 @@ void ctx::PlacesDetector::__reduceOutliers(ctx::Visits &visits) std::vector> ctx::PlacesDetector::__processVisits(ctx::Visits &visits, bool testMode) { #ifdef DEBUG_MODE - std::vector placesVisits; // TODO: remove from final solution. + std::vector placesVisits; #endif /* DEBUG_MODE */ std::vector> newDetectedPlaces; @@ -190,7 +190,7 @@ std::vector> ctx::PlacesDetector::__processVisits(ct __dbInsertPlace(*place); #ifdef DEBUG_MODE - { // TODO: Only for debug -> remove in final solution + { Visits placeVisits; for (graph::Node i : *component) { placeVisits.push_back(visits[i]); @@ -201,7 +201,7 @@ std::vector> ctx::PlacesDetector::__processVisits(ct } #ifdef DEBUG_MODE - { // Print to file TODO: Only for debug -> remove in final solution + { std::ofstream out(__USER_PLACES_FILE); for (size_t i = 0; i < newDetectedPlaces.size(); i++) { DebugUtils::printPlace2Stream(*newDetectedPlaces[i], out); @@ -327,7 +327,6 @@ void ctx::PlacesDetector::__dbDeleteOlderVisitsThan(time_t threshold) std::stringstream query; query << "DELETE FROM " << VISIT_TABLE; query << " WHERE " << VISIT_COLUMN_END_TIME << " < " << threshold; - // query << " AND 0"; // XXX: Always false condition. Uncomment it for not deleting any visit during development. std::vector records; DatabaseManager dbManager; bool ret = dbManager.executeSync(query.str().c_str(), &records); diff --git a/src/my-place/utils/Gmap.h b/src/my-place/utils/Gmap.h index c6a5482..9e5c930 100644 --- a/src/my-place/utils/Gmap.h +++ b/src/my-place/utils/Gmap.h @@ -25,7 +25,7 @@ namespace ctx { /* * Class for generating a HTML page with GoogleMaps with all user places. - * This class is for test/demo purposes only. TODO: Remove this class from final solution. + * This class is for test/demo purposes only. */ class Gmap { diff --git a/src/my-place/utils/UserPlacesTypes.cpp b/src/my-place/utils/UserPlacesTypes.cpp index 06074c4..1b8857f 100644 --- a/src/my-place/utils/UserPlacesTypes.cpp +++ b/src/my-place/utils/UserPlacesTypes.cpp @@ -159,20 +159,11 @@ std::ostream& ctx::operator<<(std::ostream &output, const ctx::MacSet &macSet) void ctx::LocationEvent::log() { std::string time_str = DebugUtils::humanReadableDateTime(timestamp, "%T", 9); -#ifdef DEBUG_MODE - _D("location lat=%.8f, lon=%.8f, acc=%.2f[m], time=%s, method=%d", - coordinates.latitude, - coordinates.longitude, - coordinates.accuracy, - time_str.c_str(), - method); -#else /* DEBUG_MODE */ _D("location lat=%.8f, lon=%.8f, acc=%.2f[m], time=%s", coordinates.latitude, coordinates.longitude, coordinates.accuracy, time_str.c_str()); -#endif /* DEBUG_MODE */ } void ctx::Visit::setLocation(Location location_) diff --git a/src/my-place/utils/UserPlacesTypes.h b/src/my-place/utils/UserPlacesTypes.h index cce02a1..7955080 100644 --- a/src/my-place/utils/UserPlacesTypes.h +++ b/src/my-place/utils/UserPlacesTypes.h @@ -32,10 +32,6 @@ #define VISIT_COLUMN_END_TIME "end_time" #define VISIT_COLUMN_WIFI_APS "wifi_aps" #define VISIT_COLUMN_CATEGORY "category" -#ifdef DEBUG_MODE -#define VISIT_COLUMN_START_TIME_HUMAN "start_time_human" // only for debug: human readable time data: -#define VISIT_COLUMN_END_TIME_HUMAN "end_time_human" // only for debug: human readable time data: -#endif /* DEBUG_MODE */ #define VISIT_COLUMN_LOCATION_VALID "location_valid" #define VISIT_COLUMN_LOCATION_LATITUDE "location_latitude" #define VISIT_COLUMN_LOCATION_LONGITUDE "location_longitude" @@ -70,10 +66,6 @@ #define LOCATION_COLUMN_LONGITUDE "longitude" #define LOCATION_COLUMN_ACCURACY "accuracy" #define LOCATION_COLUMN_TIMESTAMP "timestamp" -#ifdef DEBUG_MODE -#define LOCATION_COLUMN_TIMESTAMP_HUMAN "time_human" // only for debug: human readable time data: -#define LOCATION_COLUMN_METHOD "method" -#endif /* DEBUG_MODE */ #define MYPLACE_SETTINGS_TABLE "Myplace_Settings" #define MYPLACE_SETTINGS_COLUMN_KEY "key" @@ -195,14 +187,6 @@ namespace ctx { typedef std::map Categs; // scores of categories -#ifdef DEBUG_MODE - enum LocationSource { - LOCATION_METHOD_REQUEST = 0, - LOCATION_METHOD_GET_LOCATION = 1, - LOCATION_METHOD_GET_LAST_LOCATION = 2 - }; -#endif /* DEBUG_MODE */ - /* * location + timestamp + method */ @@ -210,17 +194,9 @@ namespace ctx { Location coordinates; time_t timestamp; -#ifdef DEBUG_MODE - LocationSource method; - - LocationEvent(double latitude_, double longitude_, double accuracy_, time_t timestamp_, LocationSource method_) : - coordinates(latitude_, longitude_, accuracy_), - timestamp(timestamp_), method(method_) {} -#else /* DEBUG_MODE */ LocationEvent(double latitude_, double longitude_, double accuracy_, time_t timestamp_) : coordinates(latitude_, longitude_, accuracy_), timestamp(timestamp_) {} -#endif /* DEBUG_MODE */ void log(); diff --git a/src/my-place/visit-detector/LocationLogger.cpp b/src/my-place/visit-detector/LocationLogger.cpp index 16bec65..cf4ce95 100644 --- a/src/my-place/visit-detector/LocationLogger.cpp +++ b/src/my-place/visit-detector/LocationLogger.cpp @@ -23,21 +23,11 @@ #include #include "LocationLogger.h" -#ifdef DEBUG_MODE -#define __LOCATION_CREATE_TABLE_COLUMNS \ - LOCATION_COLUMN_LATITUDE " REAL NOT NULL, "\ - LOCATION_COLUMN_LONGITUDE " REAL NOT NULL, "\ - LOCATION_COLUMN_ACCURACY " REAL, "\ - LOCATION_COLUMN_TIMESTAMP " timestamp NOT NULL, "\ - LOCATION_COLUMN_TIMESTAMP_HUMAN " TEXT, "\ - LOCATION_COLUMN_METHOD " INTEGER " -#else /* DEBUG_MODE */ #define __LOCATION_CREATE_TABLE_COLUMNS \ LOCATION_COLUMN_LATITUDE " REAL NOT NULL, "\ LOCATION_COLUMN_LONGITUDE " REAL NOT NULL, "\ LOCATION_COLUMN_ACCURACY " REAL, "\ LOCATION_COLUMN_TIMESTAMP " timestamp NOT NULL " -#endif /* DEBUG_MODE */ #define __LOCATION_ERROR_LOG(error) { \ if (error != LOCATIONS_ERROR_NONE) { \ @@ -111,11 +101,7 @@ void ctx::LocationLogger::__positionUpdatedCb(double latitude, double longitude, _D(""); ctx::LocationLogger* locationLogger = (ctx::LocationLogger *)userData; double horizontal = locationLogger->__locationManagerGetHorizontalAccuracy(); -#ifdef DEBUG_MODE - ctx::LocationEvent location(latitude, longitude, horizontal, timestamp, LOCATION_METHOD_REQUEST); -#else /* DEBUG_MODE */ ctx::LocationEvent location(latitude, longitude, horizontal, timestamp); -#endif /* DEBUG_MODE */ locationLogger->__broadcast(location); locationLogger->__onActiveRequestSucceeded(); } @@ -188,11 +174,6 @@ int ctx::LocationLogger::__dbInsertLog(LocationEvent locationEvent) data.set(NULL, LOCATION_COLUMN_LONGITUDE, locationEvent.coordinates.longitude); data.set(NULL, LOCATION_COLUMN_ACCURACY, locationEvent.coordinates.accuracy); data.set(NULL, LOCATION_COLUMN_TIMESTAMP, static_cast(locationEvent.timestamp)); -#ifdef DEBUG_MODE - std::string timeHuman = DebugUtils::humanReadableDateTime(locationEvent.timestamp, "%F %T", 80); - data.set(NULL, LOCATION_COLUMN_TIMESTAMP_HUMAN, timeHuman); - data.set(NULL, LOCATION_COLUMN_METHOD, static_cast(locationEvent.method)); -#endif /* DEBUG_MODE */ DatabaseManager dbManager; int64_t rowId; @@ -351,11 +332,7 @@ bool ctx::LocationLogger::__locationManagerGetLocation() __activeAttempts++; __allAttempts++; if (ret == LOCATIONS_ERROR_NONE) { -#ifdef DEBUG_MODE - ctx::LocationEvent location(latitude, longitude, horizontal, timestamp, LOCATION_METHOD_GET_LOCATION); -#else /* DEBUG_MODE */ ctx::LocationEvent location(latitude, longitude, horizontal, timestamp); -#endif /* DEBUG_MODE */ __broadcast(location); __onActiveLocationSucceeded(); return true; @@ -384,11 +361,7 @@ void ctx::LocationLogger::__locationManagerGetLastLocation() __LOCATION_ERROR_LOG(ret); __allAttempts++; if (ret == LOCATIONS_ERROR_NONE) { -#ifdef DEBUG_MODE - ctx::LocationEvent location(latitude, longitude, horizontal, timestamp, LOCATION_METHOD_GET_LAST_LOCATION); -#else /* DEBUG_MODE */ ctx::LocationEvent location(latitude, longitude, horizontal, timestamp); -#endif /* DEBUG_MODE */ __broadcast(location); } } diff --git a/src/my-place/visit-detector/LocationLogger.h b/src/my-place/visit-detector/LocationLogger.h index b901dee..c0c3dc8 100644 --- a/src/my-place/visit-detector/LocationLogger.h +++ b/src/my-place/visit-detector/LocationLogger.h @@ -23,7 +23,7 @@ #include "LocationListenerIface.h" /* Database usage flag */ -#define LOCATION_LOGGER_DATABASE false // TODO: false in final solution +#define LOCATION_LOGGER_DATABASE false /* Locations measure method */ #define LOCATION_LOGGER_METHOD LOCATIONS_METHOD_HYBRID diff --git a/src/my-place/visit-detector/VisitDetector.cpp b/src/my-place/visit-detector/VisitDetector.cpp index 7a6786d..5fbc5cb 100644 --- a/src/my-place/visit-detector/VisitDetector.cpp +++ b/src/my-place/visit-detector/VisitDetector.cpp @@ -33,13 +33,10 @@ typedef void (*visit_categer_t)(ctx::Visit &visit); -#ifdef DEBUG_MODE #define __VISIT_TABLE_COLUMNS \ VISIT_COLUMN_WIFI_APS " TEXT, "\ VISIT_COLUMN_START_TIME " timestamp, "\ VISIT_COLUMN_END_TIME " timestamp, "\ - VISIT_COLUMN_START_TIME_HUMAN " TEXT, "\ - VISIT_COLUMN_END_TIME_HUMAN " TEXT, "\ VISIT_COLUMN_LOCATION_VALID " INTEGER, "\ VISIT_COLUMN_LOCATION_LATITUDE " REAL, "\ VISIT_COLUMN_LOCATION_LONGITUDE " REAL, "\ @@ -47,19 +44,6 @@ typedef void (*visit_categer_t)(ctx::Visit &visit); VISIT_COLUMN_CATEG_HOME " REAL, "\ VISIT_COLUMN_CATEG_WORK " REAL, "\ VISIT_COLUMN_CATEG_OTHER " REAL" -#else /* DEBUG_MODE */ -#define __VISIT_TABLE_COLUMNS \ - VISIT_COLUMN_WIFI_APS " TEXT, "\ - VISIT_COLUMN_START_TIME " timestamp, "\ - VISIT_COLUMN_END_TIME " timestamp, "\ - VISIT_COLUMN_LOCATION_VALID " INTEGER, "\ - VISIT_COLUMN_LOCATION_LATITUDE " REAL, "\ - VISIT_COLUMN_LOCATION_LONGITUDE " REAL, "\ - VISIT_COLUMN_LOCATION_ACCURACY " REAL, "\ - VISIT_COLUMN_CATEG_HOME " REAL, "\ - VISIT_COLUMN_CATEG_WORK " REAL, "\ - VISIT_COLUMN_CATEG_OTHER " REAL" -#endif /* DEBUG_MODE */ #define __WIFI_APS_MAP_TABLE_COLUMNS \ WIFI_APS_MAP_COLUMN_MAC " TEXT NOT NULL UNIQUE, "\ @@ -430,8 +414,6 @@ int ctx::VisitDetector::__dbInsertVisit(Visit visit) #ifdef DEBUG_MODE std::string startTimeHuman = DebugUtils::humanReadableDateTime(visit.interval.start, "%F %T", 80); std::string endTimeHuman = DebugUtils::humanReadableDateTime(visit.interval.end, "%F %T", 80); - data.set(NULL, VISIT_COLUMN_START_TIME_HUMAN, startTimeHuman.c_str()); - data.set(NULL, VISIT_COLUMN_END_TIME_HUMAN, endTimeHuman.c_str()); _D("db: visit table insert interval: (%d, %d): (%s, %s)", visit.interval.start, visit.interval.end, startTimeHuman.c_str(), endTimeHuman.c_str()); #else -- 2.7.4