From cbe8fae7ec18fe11031bc7f4c89d3ed6af5fc3e1 Mon Sep 17 00:00:00 2001 From: Marcin Masternak Date: Wed, 23 Nov 2016 18:43:04 +0100 Subject: [PATCH] [my-place] Change debug flag from TIZEN_ENGINEER_MODE to DEBUG_MODE. Change-Id: I9744d8a8698807e9e42ee9a3203a05bbbc586cff Signed-off-by: Marcin Masternak --- src/my-place/place/PlacesDetector.cpp | 20 +++++++++--------- src/my-place/utils/UserPlacesTypes.cpp | 6 +++--- src/my-place/utils/UserPlacesTypes.h | 18 ++++++++--------- src/my-place/visit-detector/LocationLogger.cpp | 28 +++++++++++++------------- src/my-place/visit-detector/VisitDetector.cpp | 10 ++++----- src/my-place/visit-detector/WifiLogger.cpp | 6 +++--- 6 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/my-place/place/PlacesDetector.cpp b/src/my-place/place/PlacesDetector.cpp index 31d0a3f..7a226c7 100644 --- a/src/my-place/place/PlacesDetector.cpp +++ b/src/my-place/place/PlacesDetector.cpp @@ -21,9 +21,9 @@ #include "PlacesDetector.h" #include "PlaceCateger.h" #include -#ifdef TIZEN_ENGINEER_MODE +#ifdef DEBUG_MODE #include -#endif /* TIZEN_ENGINEER_MODE */ +#endif /* DEBUG_MODE */ #include #include #include @@ -33,9 +33,9 @@ #define __DELETE_PLACES_QUERY "DELETE FROM " PLACE_TABLE -#ifdef TIZEN_ENGINEER_MODE +#ifdef DEBUG_MODE #define __USER_PLACES_FILE "/tmp/user_places.txt" // TODO: Only for debug purposes -> Remove in final solution -#endif /* TIZEN_ENGINEER_MODE */ +#endif /* DEBUG_MODE */ #define __GET_VISITS_QUERY "SELECT "\ VISIT_COLUMN_END_TIME ", "\ @@ -165,9 +165,9 @@ void ctx::PlacesDetector::__reduceOutliers(ctx::Visits &visits) std::vector> ctx::PlacesDetector::__processVisits(ctx::Visits &visits, bool testMode) { -#ifdef TIZEN_ENGINEER_MODE +#ifdef DEBUG_MODE std::vector placesVisits; // TODO: remove from final solution. -#endif /* TIZEN_ENGINEER_MODE */ +#endif /* DEBUG_MODE */ std::vector> newDetectedPlaces; @@ -189,7 +189,7 @@ std::vector> ctx::PlacesDetector::__processVisits(ct if (!testMode) __dbInsertPlace(*place); -#ifdef TIZEN_ENGINEER_MODE +#ifdef DEBUG_MODE { // TODO: Only for debug -> remove in final solution Visits placeVisits; for (graph::Node i : *component) { @@ -197,10 +197,10 @@ std::vector> ctx::PlacesDetector::__processVisits(ct } placesVisits.push_back(placeVisits); } -#endif /* TIZEN_ENGINEER_MODE */ +#endif /* DEBUG_MODE */ } -#ifdef TIZEN_ENGINEER_MODE +#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++) { @@ -213,7 +213,7 @@ std::vector> ctx::PlacesDetector::__processVisits(ct out.close(); Gmap::writeMap(newDetectedPlaces); } -#endif /* TIZEN_ENGINEER_MODE */ +#endif /* DEBUG_MODE */ return newDetectedPlaces; } diff --git a/src/my-place/utils/UserPlacesTypes.cpp b/src/my-place/utils/UserPlacesTypes.cpp index c5ed30c..06074c4 100644 --- a/src/my-place/utils/UserPlacesTypes.cpp +++ b/src/my-place/utils/UserPlacesTypes.cpp @@ -159,20 +159,20 @@ 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 TIZEN_ENGINEER_MODE +#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 /* TIZEN_ENGINEER_MODE */ +#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 /* TIZEN_ENGINEER_MODE */ +#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 9365beb..cce02a1 100644 --- a/src/my-place/utils/UserPlacesTypes.h +++ b/src/my-place/utils/UserPlacesTypes.h @@ -32,10 +32,10 @@ #define VISIT_COLUMN_END_TIME "end_time" #define VISIT_COLUMN_WIFI_APS "wifi_aps" #define VISIT_COLUMN_CATEGORY "category" -#ifdef TIZEN_ENGINEER_MODE +#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 /* TIZEN_ENGINEER_MODE */ +#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 +70,10 @@ #define LOCATION_COLUMN_LONGITUDE "longitude" #define LOCATION_COLUMN_ACCURACY "accuracy" #define LOCATION_COLUMN_TIMESTAMP "timestamp" -#ifdef TIZEN_ENGINEER_MODE +#ifdef DEBUG_MODE #define LOCATION_COLUMN_TIMESTAMP_HUMAN "time_human" // only for debug: human readable time data: #define LOCATION_COLUMN_METHOD "method" -#endif /* TIZEN_ENGINEER_MODE */ +#endif /* DEBUG_MODE */ #define MYPLACE_SETTINGS_TABLE "Myplace_Settings" #define MYPLACE_SETTINGS_COLUMN_KEY "key" @@ -195,13 +195,13 @@ namespace ctx { typedef std::map Categs; // scores of categories -#ifdef TIZEN_ENGINEER_MODE +#ifdef DEBUG_MODE enum LocationSource { LOCATION_METHOD_REQUEST = 0, LOCATION_METHOD_GET_LOCATION = 1, LOCATION_METHOD_GET_LAST_LOCATION = 2 }; -#endif /* TIZEN_ENGINEER_MODE */ +#endif /* DEBUG_MODE */ /* * location + timestamp + method @@ -210,17 +210,17 @@ namespace ctx { Location coordinates; time_t timestamp; -#ifdef TIZEN_ENGINEER_MODE +#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 /* TIZEN_ENGINEER_MODE */ +#else /* DEBUG_MODE */ LocationEvent(double latitude_, double longitude_, double accuracy_, time_t timestamp_) : coordinates(latitude_, longitude_, accuracy_), timestamp(timestamp_) {} -#endif /* TIZEN_ENGINEER_MODE */ +#endif /* DEBUG_MODE */ void log(); diff --git a/src/my-place/visit-detector/LocationLogger.cpp b/src/my-place/visit-detector/LocationLogger.cpp index 6369694..16bec65 100644 --- a/src/my-place/visit-detector/LocationLogger.cpp +++ b/src/my-place/visit-detector/LocationLogger.cpp @@ -23,7 +23,7 @@ #include #include "LocationLogger.h" -#ifdef TIZEN_ENGINEER_MODE +#ifdef DEBUG_MODE #define __LOCATION_CREATE_TABLE_COLUMNS \ LOCATION_COLUMN_LATITUDE " REAL NOT NULL, "\ LOCATION_COLUMN_LONGITUDE " REAL NOT NULL, "\ @@ -31,13 +31,13 @@ LOCATION_COLUMN_TIMESTAMP " timestamp NOT NULL, "\ LOCATION_COLUMN_TIMESTAMP_HUMAN " TEXT, "\ LOCATION_COLUMN_METHOD " INTEGER " -#else /* TIZEN_ENGINEER_MODE */ +#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 /* TIZEN_ENGINEER_MODE */ +#endif /* DEBUG_MODE */ #define __LOCATION_ERROR_LOG(error) { \ if (error != LOCATIONS_ERROR_NONE) { \ @@ -111,11 +111,11 @@ void ctx::LocationLogger::__positionUpdatedCb(double latitude, double longitude, _D(""); ctx::LocationLogger* locationLogger = (ctx::LocationLogger *)userData; double horizontal = locationLogger->__locationManagerGetHorizontalAccuracy(); -#ifdef TIZEN_ENGINEER_MODE +#ifdef DEBUG_MODE ctx::LocationEvent location(latitude, longitude, horizontal, timestamp, LOCATION_METHOD_REQUEST); -#else /* TIZEN_ENGINEER_MODE */ +#else /* DEBUG_MODE */ ctx::LocationEvent location(latitude, longitude, horizontal, timestamp); -#endif /* TIZEN_ENGINEER_MODE */ +#endif /* DEBUG_MODE */ locationLogger->__broadcast(location); locationLogger->__onActiveRequestSucceeded(); } @@ -188,11 +188,11 @@ 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 TIZEN_ENGINEER_MODE +#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 /* TIZEN_ENGINEER_MODE */ +#endif /* DEBUG_MODE */ DatabaseManager dbManager; int64_t rowId; @@ -351,11 +351,11 @@ bool ctx::LocationLogger::__locationManagerGetLocation() __activeAttempts++; __allAttempts++; if (ret == LOCATIONS_ERROR_NONE) { -#ifdef TIZEN_ENGINEER_MODE +#ifdef DEBUG_MODE ctx::LocationEvent location(latitude, longitude, horizontal, timestamp, LOCATION_METHOD_GET_LOCATION); -#else /* TIZEN_ENGINEER_MODE */ +#else /* DEBUG_MODE */ ctx::LocationEvent location(latitude, longitude, horizontal, timestamp); -#endif /* TIZEN_ENGINEER_MODE */ +#endif /* DEBUG_MODE */ __broadcast(location); __onActiveLocationSucceeded(); return true; @@ -384,11 +384,11 @@ void ctx::LocationLogger::__locationManagerGetLastLocation() __LOCATION_ERROR_LOG(ret); __allAttempts++; if (ret == LOCATIONS_ERROR_NONE) { -#ifdef TIZEN_ENGINEER_MODE +#ifdef DEBUG_MODE ctx::LocationEvent location(latitude, longitude, horizontal, timestamp, LOCATION_METHOD_GET_LAST_LOCATION); -#else /* TIZEN_ENGINEER_MODE */ +#else /* DEBUG_MODE */ ctx::LocationEvent location(latitude, longitude, horizontal, timestamp); -#endif /* TIZEN_ENGINEER_MODE */ +#endif /* DEBUG_MODE */ __broadcast(location); } } diff --git a/src/my-place/visit-detector/VisitDetector.cpp b/src/my-place/visit-detector/VisitDetector.cpp index ba431f6..4f81baf 100644 --- a/src/my-place/visit-detector/VisitDetector.cpp +++ b/src/my-place/visit-detector/VisitDetector.cpp @@ -33,7 +33,7 @@ typedef void (*visit_categer_t)(ctx::Visit &visit); -#ifdef TIZEN_ENGINEER_MODE +#ifdef DEBUG_MODE #define __VISIT_TABLE_COLUMNS \ VISIT_COLUMN_WIFI_APS " TEXT, "\ VISIT_COLUMN_START_TIME " timestamp, "\ @@ -47,7 +47,7 @@ typedef void (*visit_categer_t)(ctx::Visit &visit); VISIT_COLUMN_CATEG_HOME " REAL, "\ VISIT_COLUMN_CATEG_WORK " REAL, "\ VISIT_COLUMN_CATEG_OTHER " REAL" -#else /* TIZEN_ENGINEER_MODE */ +#else /* DEBUG_MODE */ #define __VISIT_TABLE_COLUMNS \ VISIT_COLUMN_WIFI_APS " TEXT, "\ VISIT_COLUMN_START_TIME " timestamp, "\ @@ -59,7 +59,7 @@ typedef void (*visit_categer_t)(ctx::Visit &visit); VISIT_COLUMN_CATEG_HOME " REAL, "\ VISIT_COLUMN_CATEG_WORK " REAL, "\ VISIT_COLUMN_CATEG_OTHER " REAL" -#endif /* TIZEN_ENGINEER_MODE */ +#endif /* DEBUG_MODE */ #define __WIFI_APS_MAP_TABLE_COLUMNS \ WIFI_APS_MAP_COLUMN_MAC " TEXT NOT NULL UNIQUE, "\ @@ -427,7 +427,7 @@ int ctx::VisitDetector::__dbInsertVisit(Visit visit) data.set(NULL, VISIT_COLUMN_START_TIME, static_cast(visit.interval.start)); data.set(NULL, VISIT_COLUMN_END_TIME, static_cast(visit.interval.end)); -#ifdef TIZEN_ENGINEER_MODE +#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()); @@ -436,7 +436,7 @@ int ctx::VisitDetector::__dbInsertVisit(Visit visit) visit.interval.start, visit.interval.end, startTimeHuman.c_str(), endTimeHuman.c_str()); #else _D("db: visit table insert interval: (%d, %d)", visit.interval.start, visit.interval.end); -#endif /* TIZEN_ENGINEER_MODE */ +#endif /* DEBUG_MODE */ __putVisitCategsToJson(visit.categs, data); diff --git a/src/my-place/visit-detector/WifiLogger.cpp b/src/my-place/visit-detector/WifiLogger.cpp index b46ecd9..df4dfa8 100644 --- a/src/my-place/visit-detector/WifiLogger.cpp +++ b/src/my-place/visit-detector/WifiLogger.cpp @@ -67,7 +67,7 @@ int ctx::WifiLogger::__dbInsertLogs() return 0; } -ctx::WifiLogger::WifiLogger(IWifiListener * listener, PlaceRecogMode energyMode) : +ctx::WifiLogger::WifiLogger(IWifiListener *listener, PlaceRecogMode energyMode) : __timerOn(false), __timerId(-1), __intervalMinutes(WIFI_LOGGER_INTERVAL_MINUTES_HIGH_ACCURACY), @@ -220,7 +220,7 @@ void ctx::WifiLogger::__wifiScanFinishedCb(wifi_error_e errorCode, void *userDat ctx::WifiLogger* wifiLogger = (ctx::WifiLogger *)userData; time_t now = time(nullptr); -#ifdef TIZEN_ENGINEER_MODE +#ifdef DEBUG_MODE double seconds = 0; if (wifiLogger->__lastScanTime > 0) { seconds = difftime(now, wifiLogger->__lastScanTime); @@ -232,7 +232,7 @@ void ctx::WifiLogger::__wifiScanFinishedCb(wifi_error_e errorCode, void *userDat wifiLogger->__lastScansPool.size(), timeStr.c_str(), seconds); -#endif /* TIZEN_ENGINEER_MODE */ +#endif /* DEBUG_MODE */ wifiLogger->__lastScanTime = now; int ret = wifiLogger->__wifiForeachFoundApsRequest(userData); -- 2.7.4