package net.heartshield.data;

import net.heartshield.control.IMeasurementController;
import net.heartshield.sensors.IAudioSensor;
import net.heartshield.sensors.IntensityDetector;

import java.nio.ByteOrder;
import java.util.Map;
import java.util.TimeZone;

/**
 * Meta-data on a measurement, the device, and the user.
 *
 * @author David Madl (git@abanbytes.eu)
 * @date 2016-04-07
 */
public class MeasurementMeta {
    // DTO: all public members are serialized to JSON (both for local persistence and to transmit to remote server)

    //public final TimeZone timeZone; // we store String instead
    // "ZoneInfo declares multiple JSON fields named serialVersionUID" on Android, fine in test harness on PC
    public final String timeZone;

    /** time when camera A3 was locked, measured in seconds since the start of measurement, `startTime` */
    public double lockTime;

    /** times when camera A3 was locked, see `lockTime` */
    public double[] lockTimes;
    /** times when camera A3 was unlocked, see `lockTime` */
    public double[] unlockTimes;

    /** time when audio recording starts, measured in seconds since the start of measurement, `startTime` */
    public double audioStartTime;

    public IAudioSensor.AudioStartTimeAccuracy audioStartTimeAccuracy;

    /** native byte order, for audio PCM */
    public boolean littleEndian;

    /** whether this is a test/replay that should not be stored on the server database */
    public boolean test;

    public double ppgMeanFps;
    public double audioFps;
    public double bcgFps;

    /** number of dropped camera frames */
    public int ppgNumDropped;

    public IntensityDetector.CameraFeatures cameraFeatures;

    /** JSON string describing and logging camera parameters actually retrieved and used */
    public String cameraMeta;

    /** type/purpose of the measurement */
    public IMeasurementController.MeasurementMode mode;

    /** whether this Measurement failed the client signal checks, and should hence stay UNCLASSIFIED */
    public boolean failed = false;

    public MeasurementMeta(TimeZone timeZone) {
        this.timeZone = timeZone.getID();
        this.littleEndian = ByteOrder.nativeOrder().equals(ByteOrder.LITTLE_ENDIAN);
    }
}
