Added option to read data with nanosecond timestamps

This commit is contained in:
2019-10-01 14:55:19 +02:00
parent 8761dce3ce
commit 2668cfc600

View File

@@ -71,6 +71,8 @@ namespace Offline {
static constexpr char sep = ';'; static constexpr char sep = ';';
bool convertNanoSecondTimestamps = true; // otherwise use milliseconds
public: public:
/** empty ctor. call open() */ /** empty ctor. call open() */
@@ -83,6 +85,13 @@ namespace Offline {
open(file); open(file);
} }
/** ctor with filename */
FileReader(const std::string& file, bool convertNanoSecondTimestamps)
: convertNanoSecondTimestamps(convertNanoSecondTimestamps)
{
open(file);
}
/** open the given file */ /** open the given file */
void open(const std::string& file) { void open(const std::string& file) {
clear(); clear();
@@ -192,6 +201,12 @@ namespace Offline {
sline >> delim; sline >> delim;
sline >> data; // might be "" if there is no data sline >> data; // might be "" if there is no data
if (convertNanoSecondTimestamps)
{
ts /= 1000000;
}
if (idx == (int)Sensor::WIFI) {parseWiFi(ts, data);} if (idx == (int)Sensor::WIFI) {parseWiFi(ts, data);}
else if (idx == (int)Sensor::BEACON) {parseBeacons(ts, data);} else if (idx == (int)Sensor::BEACON) {parseBeacons(ts, data);}
else if (idx == (int)Sensor::GROUND_TRUTH) {parseGroundTruth(ts, data);} else if (idx == (int)Sensor::GROUND_TRUTH) {parseGroundTruth(ts, data);}