#include "PlacesDetector.h"
#include "PlaceCateger.h"
#include <Median.h>
-#ifdef TIZEN_ENGINEER_MODE
+#ifdef DEBUG_MODE
#include <Gmap.h>
-#endif /* TIZEN_ENGINEER_MODE */
+#endif /* DEBUG_MODE */
#include <UserPlacesTypes.h>
#include <fstream>
#include <algorithm>
#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 ", "\
std::vector<std::shared_ptr<ctx::Place>> ctx::PlacesDetector::__processVisits(ctx::Visits &visits, bool testMode)
{
-#ifdef TIZEN_ENGINEER_MODE
+#ifdef DEBUG_MODE
std::vector<Visits> placesVisits; // TODO: remove from final solution.
-#endif /* TIZEN_ENGINEER_MODE */
+#endif /* DEBUG_MODE */
std::vector<std::shared_ptr<Place>> newDetectedPlaces;
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) {
}
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++) {
out.close();
Gmap::writeMap(newDetectedPlaces);
}
-#endif /* TIZEN_ENGINEER_MODE */
+#endif /* DEBUG_MODE */
return newDetectedPlaces;
}
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_)
#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"
#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"
typedef std::map<int, num_t> 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
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();
#include <DebugUtils.h>
#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, "\
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) { \
_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();
}
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<int>(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<int>(locationEvent.method));
-#endif /* TIZEN_ENGINEER_MODE */
+#endif /* DEBUG_MODE */
DatabaseManager dbManager;
int64_t rowId;
__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;
__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);
}
}
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, "\
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, "\
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, "\
data.set(NULL, VISIT_COLUMN_START_TIME, static_cast<int>(visit.interval.start));
data.set(NULL, VISIT_COLUMN_END_TIME, static_cast<int>(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());
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);
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),
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);
wifiLogger->__lastScansPool.size(),
timeStr.c_str(),
seconds);
-#endif /* TIZEN_ENGINEER_MODE */
+#endif /* DEBUG_MODE */
wifiLogger->__lastScanTime = now;
int ret = wifiLogger->__wifiForeachFoundApsRequest(userData);