package net.heartshield.sensors;

import net.heartshield.data.Measurement;

import java.util.List;

/**
 * @author David Madl (git@abanbytes.eu)
 * @date 2017-04-12
 */
public class DummyAccelerationSensor implements ISensor {
    Measurement mMeasurement;
    long mStartTimeNanos;

    public DummyAccelerationSensor(Measurement measurement) {
        mMeasurement = measurement;
    }

    @Override
    public double getFps() {
        return mMeasurement.meta.bcgFps;
    }

    @Override
    public void start() {
        // TODO: mock state machine logic

        mStartTimeNanos = System.nanoTime();
    }

    @Override
    public void stop() {

    }

    @Override
    public List<double[]> getSamples() {
        //return SensorData.transposeSamples(mMeasurement.series.bcgData);

        // subtract static timestamps, and add current start (will be subtracted by MeasurementController)
        double dt = mMeasurement.series.ppgData.get(0)[0] - mStartTimeNanos / 1e9;
        return SensorData.transposeSamples(SensorData.transposeSamples(SensorData.transposeSamples(mMeasurement.series.ppgData), dt));
    }

    @Override
    public int length() {
        return mMeasurement.series.bcgData.size();
    }

    @Override
    public void setListener(Listener listener) {

    }

    @Override
    public Exception getError() {
        return null;
    }
}
