#ifndef BAROMETERACTIVITYSENSOR_H
#define BAROMETERACTIVITYSENSOR_H

#include <Indoor/sensors/pressure/ActivityButterPressure.h>
#include "BarometerSensor.h"
#include "AccelerometerSensor.h"


struct ActivityData {
	const ActivityButterPressure::Activity curActivity;
	ActivityData(const ActivityButterPressure::Activity act) : curActivity(act) {;}
};

/**
 * step-sensor detects steps from the accelerometer
 */
class ActivitySensor :
		public SensorListener<BarometerData>,		// << takes
		public SensorListener<AccelerometerData>,	// << takes
		public Sensor<ActivityData> {				// << provides

private:

	ActivityButterPressure act;

	BarometerSensor& baro;
	AccelerometerSensor& acc;

public:

	ActivitySensor(BarometerSensor& baro, AccelerometerSensor& acc) : baro(baro), acc(acc) {
		baro.addListener(this);
		acc.addListener(this);
	}

	virtual void start() override {
		// not needed
	}

	virtual void stop() override {
		// not needed
	}

	bool isRunning() const override {
		return acc.isRunning() && baro.isRunning();
	}

	virtual void onSensorData(Sensor<BarometerData>* sensor, const Timestamp ts, const BarometerData& data) override {
		(void) sensor;
		const ActivityButterPressure::Activity curAct = act.add(ts, data);
		informListeners(ts, ActivityData(curAct));
	}

	virtual void onSensorData(Sensor<AccelerometerData>* sensor, const Timestamp ts, const AccelerometerData& data) override {
		(void) sensor;
		(void) ts;
		(void) data;
		// TODO!
	}

};

#endif // BAROMETERACTIVITYSENSOR_H
