// Path: fsensor/src/main/java/com/kircherelectronics/fsensor/observer/SensorSubject.java
// public class SensorSubject {
//     private final List<SensorObserver> observers = new ArrayList<>();
// 
//     public interface SensorObserver {
//         void onSensorChanged(float[] values);
//     }
// 
//     public void register(SensorObserver observer) {
//         if(!observers.contains(observer)) {
//             observers.add(observer);
//         }
//     }
// 
//     public void unregister(SensorObserver observer) {
//         observers.remove(observer);
//     }
// 
//     public void onNext(float[] values) {
//         for(int i = 0; i < observers.size(); i++) {
//             observers.get(i).onSensorChanged(values);
//         }
//     }
// }
// 
// Path: fsensor/src/main/java/com/kircherelectronics/fsensor/sensor/FSensor.java
// public interface FSensor {
//     void register(SensorSubject.SensorObserver sensorObserver);
//     void unregister(SensorSubject.SensorObserver sensorObserver);
// 
//     void start();
//     void stop();
//     void reset();
// }


import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import com.kircherelectronics.fsensor.observer.SensorSubject;
import com.kircherelectronics.fsensor.sensor.FSensor;
    public void unregister(SensorSubject.SensorObserver sensorObserver) {
        sensorSubject.unregister(sensorObserver);
    }

    /**
     * Set the gyroscope sensor type.
     * @param sensorType must be Sensor.TYPE_GYROSCOPE or Sensor.TYPE_GYROSCOPE_UNCALIBRATED
     */
    public void setSensorType(int sensorType) {
        if(sensorType != Sensor.TYPE_ACCELEROMETER && sensorType != Sensor.TYPE_ACCELEROMETER_UNCALIBRATED && sensorType != Sensor.TYPE_LINEAR_ACCELERATION) {
            throw new IllegalStateException("Sensor Type must be Sensor.TYPE_ACCELEROMETER or Sensor.TYPE_ACCELEROMETER_UNCALIBRATED or sensorType != Sensor.TYPE_LINEAR_ACCELERATION");
        }

        this.sensorType = sensorType;
    }

    /**
     * Set the sensor frequency.
     * @param sensorDelay Must be SensorManager.SENSOR_DELAY_FASTEST, SensorManager.SENSOR_DELAY_GAME, SensorManager.SENSOR_DELAY_NORMAL or SensorManager.SENSOR_DELAY_UI
     */
    public void setSensorDelay(int sensorDelay) {
        if(sensorDelay != SensorManager.SENSOR_DELAY_FASTEST && sensorDelay != SensorManager.SENSOR_DELAY_GAME && sensorDelay != SensorManager.SENSOR_DELAY_NORMAL && sensorDelay != SensorManager.SENSOR_DELAY_UI) {
            throw new IllegalStateException("Sensor Frequency must be SensorManager.SENSOR_DELAY_FASTEST, SensorManager.SENSOR_DELAY_GAME, SensorManager.SENSOR_DELAY_NORMAL or " +
                    "SensorManager.SENSOR_DELAY_UI");
        }
        this.sensorDelay = sensorDelay;
    }

    public void reset() {
        stop();
// Path: fsensor/src/main/java/com/kircherelectronics/fsensor/observer/SensorSubject.java
// public class SensorSubject {
//     private final List<SensorObserver> observers = new ArrayList<>();
// 
//     public interface SensorObserver {
//         void onSensorChanged(float[] values);
//     }
// 
//     public void register(SensorObserver observer) {
//         if(!observers.contains(observer)) {
//             observers.add(observer);
//         }
//     }
// 
//     public void unregister(SensorObserver observer) {
//         observers.remove(observer);
//     }
// 
//     public void onNext(float[] values) {
//         for(int i = 0; i < observers.size(); i++) {
//             observers.get(i).onSensorChanged(values);
//         }
//     }
// }
// 
// Path: fsensor/src/main/java/com/kircherelectronics/fsensor/sensor/FSensor.java
// public interface FSensor {
//     void register(SensorSubject.SensorObserver sensorObserver);
//     void unregister(SensorSubject.SensorObserver sensorObserver);
// 
//     void start();
//     void stop();
//     void reset();
// }


// Path: fsensor/src/main/java/com/kircherelectronics/fsensor/sensor/acceleration/AccelerationSensor.java
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import com.kircherelectronics.fsensor.observer.SensorSubject;
import com.kircherelectronics.fsensor.sensor.FSensor;

    public void unregister(SensorSubject.SensorObserver sensorObserver) {
        sensorSubject.unregister(sensorObserver);
    }

    /**
     * Set the gyroscope sensor type.
     * @param sensorType must be Sensor.TYPE_GYROSCOPE or Sensor.TYPE_GYROSCOPE_UNCALIBRATED
     */
    public void setSensorType(int sensorType) {
        if(sensorType != Sensor.TYPE_ACCELEROMETER && sensorType != Sensor.TYPE_ACCELEROMETER_UNCALIBRATED && sensorType != Sensor.TYPE_LINEAR_ACCELERATION) {
            throw new IllegalStateException("Sensor Type must be Sensor.TYPE_ACCELEROMETER or Sensor.TYPE_ACCELEROMETER_UNCALIBRATED or sensorType != Sensor.TYPE_LINEAR_ACCELERATION");
        }

        this.sensorType = sensorType;
    }

    /**
     * Set the sensor frequency.
     * @param sensorDelay Must be SensorManager.SENSOR_DELAY_FASTEST, SensorManager.SENSOR_DELAY_GAME, SensorManager.SENSOR_DELAY_NORMAL or SensorManager.SENSOR_DELAY_UI
     */
    public void setSensorDelay(int sensorDelay) {
        if(sensorDelay != SensorManager.SENSOR_DELAY_FASTEST && sensorDelay != SensorManager.SENSOR_DELAY_GAME && sensorDelay != SensorManager.SENSOR_DELAY_NORMAL && sensorDelay != SensorManager.SENSOR_DELAY_UI) {
            throw new IllegalStateException("Sensor Frequency must be SensorManager.SENSOR_DELAY_FASTEST, SensorManager.SENSOR_DELAY_GAME, SensorManager.SENSOR_DELAY_NORMAL or " +
                    "SensorManager.SENSOR_DELAY_UI");
        }
        this.sensorDelay = sensorDelay;
    }

    public void reset() {
        stop();
        acceleration = new float[3];