added gps support
added compass support added ui elements for gps and compass added support for writing sensor data
This commit is contained in:
101
sensors/SensorWriter.h
Normal file
101
sensors/SensorWriter.h
Normal file
@@ -0,0 +1,101 @@
|
||||
#ifndef SENSORWRITER_H
|
||||
#define SENSORWRITER_H
|
||||
|
||||
#include "AccelerometerSensor.h"
|
||||
#include "GyroscopeSensor.h"
|
||||
#include "BarometerSensor.h"
|
||||
#include "StepSensor.h"
|
||||
#include "TurnSensor.h"
|
||||
#include "WiFiSensor.h"
|
||||
#include "ActivitySensor.h"
|
||||
#include "GPSSensor.h"
|
||||
#include "CompassSensor.h"
|
||||
#include "SensorFactory.h"
|
||||
|
||||
#include <Indoor/sensors/offline/FileWriter.h>
|
||||
|
||||
/**
|
||||
* receives live sensor data
|
||||
* writes it to a file
|
||||
*/
|
||||
class SensorWriter :
|
||||
public SensorListener<AccelerometerData>,
|
||||
public SensorListener<GyroscopeData>,
|
||||
public SensorListener<BarometerData>,
|
||||
// public SensorListener<ActivityData>,
|
||||
// public SensorListener<StepData>,
|
||||
// public SensorListener<TurnData>,
|
||||
public SensorListener<WiFiMeasurements>,
|
||||
public SensorListener<GPSData>,
|
||||
public SensorListener<CompassData> {
|
||||
|
||||
private:
|
||||
|
||||
Offline::FileWriter writer;
|
||||
bool active = false;
|
||||
|
||||
public:
|
||||
|
||||
/** empty ctor */
|
||||
SensorWriter() {
|
||||
|
||||
// attach as listener to all sensors we want to store
|
||||
SensorFactory::get().getAccelerometer().addListener(this);
|
||||
SensorFactory::get().getGyroscope().addListener(this);
|
||||
SensorFactory::get().getBarometer().addListener(this);
|
||||
// SensorFactory::get().getActivity().addListener(this);
|
||||
// SensorFactory::get().getSteps().addListener(this);
|
||||
// SensorFactory::get().getTurns().addListener(this);
|
||||
SensorFactory::get().getWiFi().addListener(this);
|
||||
SensorFactory::get().getCompass().addListener(this);
|
||||
SensorFactory::get().getGPS().addListener(this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void start(const std::string& file) {
|
||||
writer.open(file);
|
||||
active = true;
|
||||
}
|
||||
|
||||
void stop() {
|
||||
active = false;
|
||||
writer.close();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
virtual void onSensorData(Sensor<AccelerometerData>* , const Timestamp ts, const AccelerometerData& data) override {
|
||||
if (!active) {return;}
|
||||
writer.add(ts, data);
|
||||
}
|
||||
|
||||
virtual void onSensorData(Sensor<GyroscopeData>* , const Timestamp ts, const GyroscopeData& data) override {
|
||||
if (!active) {return;}
|
||||
writer.add(ts, data);
|
||||
}
|
||||
|
||||
virtual void onSensorData(Sensor<BarometerData>* , const Timestamp ts, const BarometerData& data) override {
|
||||
if (!active) {return;}
|
||||
writer.add(ts, data);
|
||||
}
|
||||
|
||||
virtual void onSensorData(Sensor<WiFiMeasurements>* , const Timestamp ts, const WiFiMeasurements& data) override {
|
||||
if (!active) {return;}
|
||||
writer.add(ts, data);
|
||||
}
|
||||
|
||||
virtual void onSensorData(Sensor<GPSData>* , const Timestamp ts, const GPSData& data) override {
|
||||
if (!active) {return;}
|
||||
writer.add(ts, data);
|
||||
}
|
||||
|
||||
virtual void onSensorData(Sensor<CompassData>* , const Timestamp ts, const CompassData& data) override {
|
||||
if (!active) {return;}
|
||||
writer.add(ts, data);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // SENSORWRITER_H
|
||||
Reference in New Issue
Block a user