fixed fallback step-logger

moved vap-grouping to settings-file
sanity-checks
This commit is contained in:
2016-10-02 18:28:17 +02:00
parent a4a8593023
commit 3a1cd1bccc
9 changed files with 95 additions and 32 deletions

View File

@@ -7,6 +7,8 @@
#include <unordered_map>
#include "IPINHelper.h"
#include <Indoor/Exception.h>
class EvalConfig {
private:
@@ -31,9 +33,10 @@ public:
/** load the given configuration file */
void load(const std::string& file) {
std::ifstream inp(file);
if (!inp.good()) {throw "error while opening config file " + file;}
if (!inp.good()) {throw Exception("error while opening config file " + file);}
std::string line;
@@ -78,7 +81,7 @@ private:
// split key and value
const size_t pos = line.find(" = ");
if (pos == std::string::npos) {throw "something wrong";}
if (pos == std::string::npos) {throw Exception("something wrong");}
const std::string key = line.substr(0, pos);
const std::string val = line.substr(pos+3);

View File

@@ -11,7 +11,8 @@ public:
static std::string getDataFolder() {
#ifdef ANDROID
return getenv("DIRECTORY_DOWNLOADS");
//return std::string(getenv("DIRECTORY_DOWNLOADS")) + "/";
return "/sdcard/Download/";
#else
return "/apps/android/workspace/YASMIN_DATA/";
#endif

View File

@@ -43,7 +43,7 @@ public:
void onButtonPress() {
// sanity check
if (isDone()) {throw "all waypoints were processed";}
if (isDone()) {throw Exception("all waypoints were processed");}
// construct output string
std::stringstream ss;
@@ -142,8 +142,8 @@ private:
const std::string fPos = folder + "positions.log";
// open two output files
outButtons.open(fBtn); if (!outButtons.good()) {throw "error while creating file";}
outPositions.open(fPos); if (!outPositions.good()) {throw "error while creating file";}
outButtons.open(fBtn); if (!outButtons.good()) {throw Exception("error while creating file");}
outPositions.open(fPos); if (!outPositions.good()) {throw Exception("error while creating file");}
// reset current WayPoint
curWP = 0;

View File

@@ -6,10 +6,15 @@
#include "../nav/NavControllerListener.h"
#include <QWidget>
#include <QDialog>
#include <QPushButton>
#include <QWindow>
#include <QMainWindow>
#include <QDesktopWidget>
#include <QGridLayout>
#include <QLabel>
#include <Indoor/data/Timestamp.h>
/**
* helper class to connect our NavigationController with the StepLogger
@@ -21,13 +26,17 @@ private:
/** convert from our position-format to ipin position-format */
IPINScaler& scaler;
QMainWindow* window;
QPushButton* btn;
QWidget* widget = nullptr;
QPushButton* btn = nullptr;
QLabel* lblInfo = nullptr;
QWidget* parent;// = nullptr;
int cnt = 0;
Timestamp lastEstTS;
public:
/** ctor */
StepLoggerWrapper(IPINScaler& scaler) : scaler(scaler) {
StepLoggerWrapper(IPINScaler& scaler, QWidget* parent) : scaler(scaler), parent(parent) {
setupUI();
}
@@ -44,6 +53,12 @@ public:
// inform the logger
StepLogger::onNewEstimation(ipin.lat, ipin.lon, ipin.floorNr);
++cnt;
const Timestamp curTS = Timestamp::fromUnixTime();
const Timestamp diff = curTS - lastEstTS;
lastEstTS = curTS;
lblInfo->setText("Est: " + QString::number(cnt) + " time: " + QString::number(diff.ms()));
}
private:
@@ -51,23 +66,43 @@ private:
/** create a clickable check button */
void setupUI() {
window = new QMainWindow();
//window->setTitle("StepLogger");
btn = new QPushButton(window);
// almost fullscreen
QRect geom = QDesktopWidget().availableGeometry();
const int w = geom.width() * 0.9;
const int h = geom.height() * 0.6;
const int w = std::min(geom.width(), geom.height()) * 0.4;
const int h = w;
/*
window = new QDialog();
// center and set always-on-top
window->setGeometry(geom.width()/2 - w/2, geom.height()/2 - h/2, w, h);
window->setGeometry(geom.width()*0.7 - w/2, geom.height()*0.7 - h/2, w, h);
const Qt::WindowFlags flags = window->windowFlags();
window->setWindowFlags(flags | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint);
btn = new QPushButton(window);
btn->setGeometry(5,5,w-5-5,h-5-5);
window->show();
*/
widget = new QWidget(parent);
widget->setGeometry(geom.width() - w - 5, geom.height()*0.85 - h, w, h);
widget->setWindowFlags(widget->windowFlags() | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint);
widget->setVisible(true);
QGridLayout* lay = new QGridLayout(widget);
btn = new QPushButton();
btn->setMinimumSize(w-10, h*0.8);
btn->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
btn->setWindowFlags(btn->windowFlags() | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint);
lay->addWidget(btn, 0, 0, 1, 1);
lblInfo = new QLabel();
lblInfo->setMinimumHeight(32); lblInfo->setMaximumHeight(32);
lblInfo->setText("123");
lay->addWidget(lblInfo, 1, 0, 1, 1);
// button clicked -> next waypoint
btn->connect(btn, &QPushButton::clicked, [&] () {
@@ -78,6 +113,11 @@ private:
// show the current waypoint
updateButton();
// //window->exec();
// window->setFocusPolicy(Qt::StrongFocus);
// window->setAttribute(Qt::WA_AcceptTouchEvents, true);
// window->show();
}
/** update the current button label */

View File

@@ -53,7 +53,7 @@ private:
double rounded_z = std::round(z);
int res = QAndroidJniObject::callStaticMethod<int>("indoor/java/StepLoggerClient", "log", "(DDD)I", x, y, rounded_z);
//if (res != 1337) {throw Exception("invalid return code while sending the current position to StepLogger.\nService Down?");}
if (res != 1337) {throw Exception("invalid return code while sending the current position to StepLogger.\nService Down?");}
#endif
}