mobile/src/main/java/de/unima/ar/collector/sensors/AmbientTemperatureSensorCollector.java
public class AmbientTemperatureSensorCollector extends SensorCollector
{
    private static final int      type       = 13;
    private static final String[] valueNames = new String[]{ "attr_temp", "attr_time" };

    private static Map<String, Plotter>        plotters = new HashMap<>();
    private static Map<String, List<String[]>> cache    = new HashMap<>();


    AmbientTemperatureSensorCollector(Sensor sensor)
    {
        super(sensor);

        // create new plotter
        List<String> devices = DatabaseHelper.getStringResultSet("SELECT device FROM " + SQLTableName.DEVICES, null);
        for(String device : devices) {
            AmbientTemperatureSensorCollector.createNewPlotter(device);
        }
    }


    @Override
    public void onAccuracyChanged(Sensor s, int i)
    {
    }


    @Override
    public void SensorChanged(float[] values, long time)
    {
        ContentValues newValues = new ContentValues();
        newValues.put(valueNames[0], values[0]);
        newValues.put(valueNames[1], time);

        String deviceID = DeviceID.get(SensorDataCollectorService.getInstance());
        AmbientTemperatureSensorCollector.writeDBStorage(deviceID, newValues);
        AmbientTemperatureSensorCollector.updateLivePlotter(deviceID, values);
    }


    @Override
    public Plotter getPlotter(String deviceID)
    {
        if(!plotters.containsKey(deviceID)) {
            AmbientTemperatureSensorCollector.createNewPlotter(deviceID);
        }

        return plotters.get(deviceID);
    }


    @Override
    public int getType()
    {
        return type;
    }


    public static void createNewPlotter(String deviceID)
    {
        PlotConfiguration levelPlot = new PlotConfiguration();
        levelPlot.plotName = "LevelPlot";
        levelPlot.rangeMin = -20;
        levelPlot.rangeMax = 40;
        levelPlot.rangeName = "Temperature Celsius";
        levelPlot.SeriesName = "Temp";
        levelPlot.domainName = "Axis";
        levelPlot.domainValueNames = Arrays.copyOfRange(valueNames, 0, 1);
        levelPlot.tableName = SQLTableName.AMBIENT;
        levelPlot.sensorName = "Ambient Temperature";


        PlotConfiguration historyPlot = new PlotConfiguration();
        historyPlot.plotName = "HistoryPlot";
        historyPlot.rangeMin = -20;
        historyPlot.rangeMax = 40;
        historyPlot.domainMin = 0;
        historyPlot.domainMax = 50;
        historyPlot.rangeName = "Temperature Celsius";
        historyPlot.SeriesName = "Temp";
        historyPlot.domainName = "Time";
        historyPlot.seriesValueNames = Arrays.copyOfRange(valueNames, 0, 1);

        Plotter plotter = new Plotter(deviceID, levelPlot, historyPlot);
        plotters.put(deviceID, plotter);
    }


    public static void updateLivePlotter(String deviceID, float[] values)
    {
        Plotter plotter = plotters.get(deviceID);
        if(plotter == null) {
            AmbientTemperatureSensorCollector.createNewPlotter(deviceID);
            plotter = plotters.get(deviceID);
        }

        plotter.setDynamicPlotData(values);
    }


    public static void createDBStorage(String deviceID)
    {
        String sqlTable = "CREATE TABLE IF NOT EXISTS " + SQLTableName.PREFIX + deviceID + SQLTableName.AMBIENT + " (id INTEGER PRIMARY KEY, " + valueNames[1] + " INTEGER, " + valueNames[0] + " REAL)";
        SQLDBController.getInstance().execSQL(sqlTable);
    }


    public static void writeDBStorage(String deviceID, ContentValues newValues)
    {
        String tableName = SQLTableName.PREFIX + deviceID + SQLTableName.AMBIENT;

        if(Settings.DATABASE_DIRECT_INSERT) {
            SQLDBController.getInstance().insert(tableName, null, newValues);
            return;
        }

        List<String[]> clone = DBUtils.manageCache(deviceID, cache, newValues, (Settings.DATABASE_CACHE_SIZE + type * 200));
        if(clone != null) {
            SQLDBController.getInstance().bulkInsert(tableName, clone);
        }
    }


    public static void flushDBCache(String deviceID)
    {
        DBUtils.flushCache(SQLTableName.AMBIENT, cache, deviceID);
    }
}
mobile/src/main/java/de/unima/ar/collector/sensors/RelativeHumiditySensorCollector.java
public class RelativeHumiditySensorCollector extends SensorCollector
{
    private static final int      type       = 12;
    private static final String[] valueNames = new String[]{ "attr_percent", "attr_time" };

    private static Map<String, Plotter>        plotters = new HashMap<>();
    private static Map<String, List<String[]>> cache    = new HashMap<>();


    RelativeHumiditySensorCollector(Sensor sensor)
    {
        super(sensor);

        // create new plotter
        List<String> devices = DatabaseHelper.getStringResultSet("SELECT device FROM " + SQLTableName.DEVICES, null);
        for(String device : devices) {
            RelativeHumiditySensorCollector.createNewPlotter(device);
        }
    }


    @Override
    public void onAccuracyChanged(Sensor s, int i)
    {
    }


    public void SensorChanged(float[] values, long time)
    {
        ContentValues newValues = new ContentValues();
        newValues.put(valueNames[0], values[0]);
        newValues.put(valueNames[1], time);

        String deviceID = DeviceID.get(SensorDataCollectorService.getInstance());
        RelativeHumiditySensorCollector.writeDBStorage(deviceID, newValues);
        RelativeHumiditySensorCollector.updateLivePlotter(deviceID, values);
    }


    @Override
    public Plotter getPlotter(String deviceID)
    {
        if(!plotters.containsKey(deviceID)) {
            RelativeHumiditySensorCollector.createNewPlotter(deviceID);
        }

        return plotters.get(deviceID);
    }


    @Override
    public int getType()
    {
        return type;
    }


    public static void createNewPlotter(String deviceID)
    {
        PlotConfiguration levelPlot = new PlotConfiguration();
        levelPlot.plotName = "LevelPlot";
        levelPlot.rangeMin = 0;
        levelPlot.rangeMax = 100;
        levelPlot.rangeName = "percent";
        levelPlot.SeriesName = "Humidity";
        levelPlot.domainName = "Axis";
        levelPlot.domainValueNames = Arrays.copyOfRange(valueNames, 0, 1);
        levelPlot.tableName = SQLTableName.RELATIVE;
        levelPlot.sensorName = "Relative Humidity";

        PlotConfiguration historyPlot = new PlotConfiguration();
        historyPlot.plotName = "HistoryPlot";
        historyPlot.rangeMin = 0;
        historyPlot.rangeMax = 100;
        historyPlot.domainMin = 0;
        historyPlot.domainMax = 50;
        historyPlot.rangeName = "percent";
        historyPlot.SeriesName = "Humidity";
        historyPlot.domainName = "Humidity";
        historyPlot.seriesValueNames = Arrays.copyOfRange(valueNames, 0, 1);

        Plotter plotter = new Plotter(deviceID, levelPlot, historyPlot);
        plotters.put(deviceID, plotter);
    }


    public static void updateLivePlotter(String deviceID, float[] values)
    {
        Plotter plotter = plotters.get(deviceID);
        if(plotter == null) {
            RelativeHumiditySensorCollector.createNewPlotter(deviceID);
            plotter = plotters.get(deviceID);
        }

        plotter.setDynamicPlotData(values);
    }


    public static void createDBStorage(String deviceID)
    {
        String sqlTable = "CREATE TABLE IF NOT EXISTS " + SQLTableName.PREFIX + deviceID + SQLTableName.RELATIVE + " (id INTEGER PRIMARY KEY, " + valueNames[1] + " INTEGER, " + valueNames[0] + " REAL)";
        SQLDBController.getInstance().execSQL(sqlTable);
    }


    public static void writeDBStorage(String deviceID, ContentValues newValues)
    {
        String tableName = SQLTableName.PREFIX + deviceID + SQLTableName.RELATIVE;

        if(Settings.DATABASE_DIRECT_INSERT) {
            SQLDBController.getInstance().insert(tableName, null, newValues);
            return;
        }

        List<String[]> clone = DBUtils.manageCache(deviceID, cache, newValues, (Settings.DATABASE_CACHE_SIZE + type * 200));
        if(clone != null) {
            SQLDBController.getInstance().bulkInsert(tableName, clone);
        }
    }


    public static void flushDBCache(String deviceID)
    {
        DBUtils.flushCache(SQLTableName.RELATIVE, cache, deviceID);
    }
}
mobile/src/main/java/de/unima/ar/collector/SensorDataCollectorService.java
public class SensorDataCollectorService extends Service
{
    private static SensorDataCollectorService INSTANCE = null;
    private static boolean                    created  = false;

    private SensorCollectorManager scm;
    private WakeLock               mWakeLock;


    public SensorDataCollectorService() // has to be public because it is a service
    {
        super();

        if(INSTANCE == null) {
            INSTANCE = this;
        }
    }


    public static SensorDataCollectorService getInstance()
    {
        if(INSTANCE == null) {
            new SensorDataCollectorService();
        }

        return INSTANCE;
    }


    public SensorCollectorManager getSCM()
    {
        return this.scm;
    }


    /**
     * observe action screen off - important part! - ensures that the sensors are working correct even if the screen turns off
     */
    public BroadcastReceiver mReceiver = new BroadcastReceiver()
    {
        @Override
        public void onReceive(Context context, Intent intent)
        {
            if(!intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
                return;
            }
            Runnable runnable = new Runnable()
            {
                public void run()
                {
                    scm.unregisterSensorCollectors();
                    scm.registerSensorCollectors();
                }
            };
            new Handler().postDelayed(runnable, 600);
        }
    };


    @Override
    public void onCreate()
    {
        if(this.scm != null) {
            return;
        }

        //SensorManager mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
        //List<Sensor> deviceSensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);

        SQLDBController.getInstance();
        scm = new SensorCollectorManager(this);
        // scm.addSensorCollector(new TestSensorCollector());
        // scm.addSensorCollector(new AccelerometerSensorCollector());
        // scm.openDatabase();

        registerReceiver(mReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF));

        // refresh/update DB
        Set<String> devices = ListenerService.getDevices();
        for(String device : devices) {
            DatabaseHelper.createDeviceDependentTables(device);
            SQLDBController.getInstance().registerDevice(device);
        }

        PowerManager manager = (PowerManager) getSystemService(Context.POWER_SERVICE);
        this.mWakeLock = manager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "SensorCollectorManager");
        this.mWakeLock.acquire();

        // reactivate sensors
        List<String[]> sensors = SQLDBController.getInstance().query("SELECT sensor FROM " + SQLTableName.SENSOROPTIONS + " WHERE enabled=1", null, false);
        int cou = 0;
        for(String[] sensor : sensors) {
            try {
                int sensorID = Integer.valueOf(sensor[0]);
                if(!scm.enableCollectors(sensorID)) {
                    continue;
                } else if(sensorID > 0 && Settings.WEARSENSOR) {
                    BroadcastService.getInstance().sendMessage("/sensor/register", "[" + sensorID + ", " + scm.getSensorCollectors().get(sensorID).getSensorRate() + "]");
                }
                cou++;
            } catch(Exception e) {
                e.printStackTrace();
            }
        }
        if(cou > 0) {
            scm.registerSensorCollectors();
            scm.registerCustomCollectors();
            Toast.makeText(this, getString(R.string.sensor_collector_reenable_notify) + " (" + cou + ")", Toast.LENGTH_SHORT).show();
        }
    }


    @Override
    public int onStartCommand(Intent intent, int flags, int startId)
    {
        if(!created) {
            created = true;

            // Start registered collectors
            scm.registerSensorCollectors();
        }

        return Service.START_STICKY;
    }


    @Override
    public IBinder onBind(Intent arg0)
    {
        return null;
    }


    @Override
    public void onDestroy()
    {
        // Den SensorCollectorManager schließen
        // scm.close();
        created = false;

        mWakeLock.release();

        unregisterReceiver(mReceiver);
    }
}
mobile/src/main/java/de/unima/ar/collector/sensors/GravitySensorCollector.java
public class GravitySensorCollector extends SensorCollector
{
    private static final int      type       = 9;
    private static final String[] valueNames = new String[]{ "attr_x", "attr_y", "attr_z", "attr_time" };

    private static Map<String, Plotter>        plotters = new HashMap<>();
    private static Map<String, List<String[]>> cache    = new HashMap<>();


    GravitySensorCollector(Sensor sensor)
    {
        super(sensor);

        // create new plotter
        List<String> devices = DatabaseHelper.getStringResultSet("SELECT device FROM " + SQLTableName.DEVICES, null);
        for(String device : devices) {
            GravitySensorCollector.createNewPlotter(device);
        }
    }


    @Override
    public void onAccuracyChanged(Sensor sensor, int accuracy)
    {
    }


    @Override
    public void SensorChanged(float[] values, long time)
    {
        ContentValues newValues = new ContentValues();
        newValues.put(valueNames[0], values[0]);
        newValues.put(valueNames[1], values[1]);
        newValues.put(valueNames[2], values[2]);
        newValues.put(valueNames[3], time);

        String deviceID = DeviceID.get(SensorDataCollectorService.getInstance());
        GravitySensorCollector.writeDBStorage(deviceID, newValues);
        GravitySensorCollector.updateLivePlotter(deviceID, values);
    }


    @Override
    public Plotter getPlotter(String deviceID)
    {
        if(!plotters.containsKey(deviceID)) {
            GravitySensorCollector.createNewPlotter(deviceID);
        }

        return plotters.get(deviceID);
    }


    @Override
    public int getType()
    {
        return type;
    }


    public static void createNewPlotter(String deviceID)
    {
        PlotConfiguration levelPlot = new PlotConfiguration();
        levelPlot.plotName = "LevelPlot";
        levelPlot.rangeMin = -20;
        levelPlot.rangeMax = 20;
        levelPlot.rangeName = "Speed";
        levelPlot.SeriesName = "Speed";
        levelPlot.domainName = "Axis";
        levelPlot.domainValueNames = Arrays.copyOfRange(valueNames, 0, 3);
        levelPlot.tableName = SQLTableName.GRAVITY;
        levelPlot.sensorName = "Gravity";


        PlotConfiguration historyPlot = new PlotConfiguration();
        historyPlot.plotName = "HistoryPlot";
        historyPlot.rangeMin = -20;
        historyPlot.rangeMax = 20;
        historyPlot.domainMin = 0;
        historyPlot.domainMax = 70;
        historyPlot.rangeName = "Speed m/s";
        historyPlot.SeriesName = "Speed";
        historyPlot.domainName = "Time";
        historyPlot.seriesValueNames = Arrays.copyOfRange(valueNames, 0, 3);

        Plotter plotter = new Plotter(deviceID, levelPlot, historyPlot);
        plotters.put(deviceID, plotter);
    }


    public static void updateLivePlotter(String deviceID, float[] values)
    {
        Plotter plotter = plotters.get(deviceID);
        if(plotter == null) {
            GravitySensorCollector.createNewPlotter(deviceID);
            plotter = plotters.get(deviceID);
        }

        plotter.setDynamicPlotData(values);
    }


    public static void createDBStorage(String deviceID)
    {
        String sqlTable = "CREATE TABLE IF NOT EXISTS " + SQLTableName.PREFIX + deviceID + SQLTableName.GRAVITY + " (id INTEGER PRIMARY KEY, " + valueNames[3] + " INTEGER, " + valueNames[0] + " REAL, " + valueNames[1] + " REAL, " + valueNames[2] + " REAL)";
        SQLDBController.getInstance().execSQL(sqlTable);
    }


    public static void writeDBStorage(String deviceID, ContentValues newValues)
    {
        String tableName = SQLTableName.PREFIX + deviceID + SQLTableName.GRAVITY;

        if(Settings.DATABASE_DIRECT_INSERT) {
            SQLDBController.getInstance().insert(tableName, null, newValues);
            return;
        }

        List<String[]> clone = DBUtils.manageCache(deviceID, cache, newValues, (Settings.DATABASE_CACHE_SIZE + type * 200));
        if(clone != null) {
            SQLDBController.getInstance().bulkInsert(tableName, clone);
        }
    }


    public static void flushDBCache(String deviceID)
    {
        DBUtils.flushCache(SQLTableName.GRAVITY, cache, deviceID);
    }
}
mobile/src/main/java/de/unima/ar/collector/sensors/MagneticFieldSensorCollector.java
public class MagneticFieldSensorCollector extends SensorCollector
{
    private static final int      type       = 2;
    private static final String[] valueNames = new String[]{ "attr_x", "attr_y", "attr_z", "attr_time" };

    private static Map<String, Plotter>        plotters = new HashMap<>();
    private static Map<String, List<String[]>> cache    = new HashMap<>();


    MagneticFieldSensorCollector(Sensor sensor)
    {
        super(sensor);

        // create new plotter
        List<String> devices = DatabaseHelper.getStringResultSet("SELECT device FROM " + SQLTableName.DEVICES, null);
        for(String device : devices) {
            MagneticFieldSensorCollector.createNewPlotter(device);
        }
    }


    @Override
    public void onAccuracyChanged(Sensor s, int i)
    {
    }


    @Override
    public void SensorChanged(float[] values, long time)
    {
        ContentValues newValues = new ContentValues();
        newValues.put(valueNames[0], values[0]);
        newValues.put(valueNames[1], values[1]);
        newValues.put(valueNames[2], values[2]);
        newValues.put(valueNames[3], time);

        String deviceID = DeviceID.get(SensorDataCollectorService.getInstance());
        MagneticFieldSensorCollector.writeDBStorage(deviceID, newValues);
        MagneticFieldSensorCollector.updateLivePlotter(deviceID, values);
    }


    @Override
    public Plotter getPlotter(String deviceID)
    {
        if(!plotters.containsKey(deviceID)) {
            MagneticFieldSensorCollector.createNewPlotter(deviceID);
        }

        return plotters.get(deviceID);
    }


    @Override
    public int getType()
    {
        return type;
    }


    public static void createNewPlotter(String deviceID)
    {
        PlotConfiguration levelPlot = new PlotConfiguration();
        levelPlot.plotName = "LevelPlot";
        levelPlot.rangeMin = -50;
        levelPlot.rangeMax = 50;
        levelPlot.rangeName = "microTesla";
        levelPlot.SeriesName = "Tesla";
        levelPlot.domainName = "Axis";
        levelPlot.domainValueNames = Arrays.copyOfRange(valueNames, 0, 3);
        levelPlot.tableName = SQLTableName.MAGNETIC;
        levelPlot.sensorName = "Magnetic Field";


        PlotConfiguration historyPlot = new PlotConfiguration();
        historyPlot.plotName = "HistoryPlot";
        historyPlot.rangeMin = -50;
        historyPlot.rangeMax = 50;
        historyPlot.domainMin = 0;
        historyPlot.domainMax = 50;
        historyPlot.rangeName = "microTesla";
        historyPlot.SeriesName = "Tesla";
        historyPlot.domainName = "Time";
        historyPlot.seriesValueNames = Arrays.copyOfRange(valueNames, 0, 3);

        Plotter plotter = new Plotter(deviceID, levelPlot, historyPlot);
        plotters.put(deviceID, plotter);
    }


    public static void updateLivePlotter(String deviceID, float[] values)
    {
        Plotter plotter = plotters.get(deviceID);
        if(plotter == null) {
            MagneticFieldSensorCollector.createNewPlotter(deviceID);
            plotter = plotters.get(deviceID);
        }

        plotter.setDynamicPlotData(values);
    }


    public static void createDBStorage(String deviceID)
    {
        String sqlTable = "CREATE TABLE IF NOT EXISTS " + SQLTableName.PREFIX + deviceID + SQLTableName.MAGNETIC + " (id INTEGER PRIMARY KEY, " + valueNames[3] + " INTEGER, " + valueNames[0] + " REAL, " + valueNames[1] + " REAL, " + valueNames[2] + " REAL)";
        SQLDBController.getInstance().execSQL(sqlTable);
    }


    public static void writeDBStorage(String deviceID, ContentValues newValues)
    {
        String tableName = SQLTableName.PREFIX + deviceID + SQLTableName.MAGNETIC;

        if(Settings.DATABASE_DIRECT_INSERT) {
            SQLDBController.getInstance().insert(tableName, null, newValues);
            return;
        }

        List<String[]> clone = DBUtils.manageCache(deviceID, cache, newValues, (Settings.DATABASE_CACHE_SIZE + type * 200));
        if(clone != null) {
            SQLDBController.getInstance().bulkInsert(tableName, clone);
        }
    }


    public static void flushDBCache(String deviceID)
    {
        DBUtils.flushCache(SQLTableName.MAGNETIC, cache, deviceID);
    }
}
mobile/src/main/java/de/unima/ar/collector/sensors/StepCounterSensorCollector.java
public class StepCounterSensorCollector extends SensorCollector
{
    private static final int      type       = 19;
    private static final String[] valueNames = new String[]{ "attr_step", "attr_time" };

    private static Map<String, Plotter>        plotters = new HashMap<>();
    private static Map<String, List<String[]>> cache    = new HashMap<>();


    StepCounterSensorCollector(Sensor sensor)
    {
        super(sensor);

        // create new plotter
        List<String> devices = DatabaseHelper.getStringResultSet("SELECT device FROM " + SQLTableName.DEVICES, null);
        for(String device : devices) {
            StepCounterSensorCollector.createNewPlotter(device);
        }
    }


    @Override
    public void onAccuracyChanged(Sensor s, int i)
    {
    }


    @Override
    public void SensorChanged(float[] values, long time)
    {
        ContentValues newValues = new ContentValues();
        newValues.put(valueNames[0], values[0]);
        newValues.put(valueNames[1], time);

        String deviceID = DeviceID.get(SensorDataCollectorService.getInstance());
        StepCounterSensorCollector.writeDBStorage(deviceID, newValues);
        StepCounterSensorCollector.updateLivePlotter(deviceID, values);
    }


    @Override
    public Plotter getPlotter(String deviceID)
    {
        if(!plotters.containsKey(deviceID)) {
            StepCounterSensorCollector.createNewPlotter(deviceID);
        }

        return plotters.get(deviceID);
    }


    @Override
    public int getType()
    {
        return type;
    }


    public static void createNewPlotter(String deviceID)
    {
        PlotConfiguration levelPlot = new PlotConfiguration();
        levelPlot.plotName = "LevelPlot";
        levelPlot.rangeMin = 0;
        levelPlot.rangeMax = 5;
        levelPlot.rangeName = "step";
        levelPlot.SeriesName = "Step";
        levelPlot.domainName = "Axis";
        levelPlot.domainValueNames = Arrays.copyOfRange(valueNames, 0, 1);
        levelPlot.tableName = SQLTableName.STEPCOUNTER;
        levelPlot.sensorName = "Step Counter";

        PlotConfiguration historyPlot = new PlotConfiguration();
        historyPlot.plotName = "HistoryPlot";
        historyPlot.rangeMin = 0;
        historyPlot.rangeMax = 5;
        historyPlot.domainMin = 0;
        historyPlot.domainMax = 50;
        historyPlot.rangeName = "step";
        historyPlot.SeriesName = "Step";
        historyPlot.domainName = "Step";
        historyPlot.seriesValueNames = Arrays.copyOfRange(valueNames, 0, 1);

        Plotter plotter = new Plotter(deviceID, levelPlot, historyPlot);
        plotters.put(deviceID, plotter);
    }


    public static void updateLivePlotter(String deviceID, float[] values)
    {
        Plotter plotter = plotters.get(deviceID);
        if(plotter == null) {
            StepCounterSensorCollector.createNewPlotter(deviceID);
            plotter = plotters.get(deviceID);
        }

        plotter.setDynamicPlotData(values);
    }


    public static void createDBStorage(String deviceID)
    {
        String sqlTable = "CREATE TABLE IF NOT EXISTS " + SQLTableName.PREFIX + deviceID + SQLTableName.STEPCOUNTER + " (id INTEGER PRIMARY KEY, " + valueNames[1] + " INTEGER UNIQUE, " + valueNames[0] + " REAL)";
        SQLDBController.getInstance().execSQL(sqlTable);
    }


    public static void writeDBStorage(String deviceID, ContentValues newValues)
    {
        String tableName = SQLTableName.PREFIX + deviceID + SQLTableName.STEPCOUNTER;

        if(Settings.DATABASE_DIRECT_INSERT) {
            SQLDBController.getInstance().insert(tableName, null, newValues);
            return;
        }

        List<String[]> clone = DBUtils.manageCache(deviceID, cache, newValues, (Settings.DATABASE_CACHE_SIZE + type * 200));
        if(clone != null) {
            SQLDBController.getInstance().bulkInsert(tableName, clone);
        }
    }


    public static void flushDBCache(String deviceID)
    {
        DBUtils.flushCache(SQLTableName.STEPCOUNTER, cache, deviceID);
    }
}
mobile/src/main/java/de/unima/ar/collector/sensors/GyroscopeSensorCollector.java
public class GyroscopeSensorCollector extends SensorCollector
{
    private static final int      type       = 4;
    private static final String[] valueNames = new String[]{ "attr_x", "attr_y", "attr_z", "attr_time" };

    private static Map<String, Plotter>        plotters = new HashMap<>();
    private static Map<String, List<String[]>> cache    = new HashMap<>();


    GyroscopeSensorCollector(Sensor sensor)
    {
        super(sensor);

        // create new plotter
        List<String> devices = DatabaseHelper.getStringResultSet("SELECT device FROM " + SQLTableName.DEVICES, null);
        for(String device : devices) {
            GyroscopeSensorCollector.createNewPlotter(device);
        }
    }


    @Override
    public void onAccuracyChanged(Sensor s, int i)
    {
    }


    @Override
    public void SensorChanged(float[] values, long time)
    {
        ContentValues newValues = new ContentValues();
        newValues.put(valueNames[0], values[0]);
        newValues.put(valueNames[1], values[1]);
        newValues.put(valueNames[2], values[2]);
        newValues.put(valueNames[3], time);

        String deviceID = DeviceID.get(SensorDataCollectorService.getInstance());
        GyroscopeSensorCollector.writeDBStorage(deviceID, newValues);
        GyroscopeSensorCollector.updateLivePlotter(deviceID, values);
    }


    @Override
    public Plotter getPlotter(String deviceID)
    {
        if(!plotters.containsKey(deviceID)) {
            GyroscopeSensorCollector.createNewPlotter(deviceID);
        }

        return plotters.get(deviceID);
    }


    @Override
    public int getType()
    {
        return type;
    }


    public static void createNewPlotter(String deviceID)
    {
        PlotConfiguration levelPlot = new PlotConfiguration();
        levelPlot.plotName = "LevelPlot";
        levelPlot.rangeMin = -15;
        levelPlot.rangeMax = 15;
        levelPlot.rangeName = "speed";
        levelPlot.SeriesName = "Gyroscope";
        levelPlot.domainName = "Axis";
        levelPlot.domainValueNames = Arrays.copyOfRange(valueNames, 0, 3);
        levelPlot.tableName = SQLTableName.GYROSCOPE;
        levelPlot.sensorName = "Gyroscope";


        PlotConfiguration historyPlot = new PlotConfiguration();
        historyPlot.plotName = "HistoryPlot";
        historyPlot.rangeMin = -15;
        historyPlot.rangeMax = 15;
        historyPlot.domainMin = 0;
        historyPlot.domainMax = 50;
        historyPlot.rangeName = "speed";
        historyPlot.SeriesName = "Gyroscope";
        historyPlot.domainName = "Axis";
        historyPlot.seriesValueNames = Arrays.copyOfRange(valueNames, 0, 3);

        Plotter plotter = new Plotter(deviceID, levelPlot, historyPlot);
        plotters.put(deviceID, plotter);
    }


    public static void updateLivePlotter(String deviceID, float[] values)
    {
        Plotter plotter = plotters.get(deviceID);
        if(plotter == null) {
            GyroscopeSensorCollector.createNewPlotter(deviceID);
            plotter = plotters.get(deviceID);
        }

        plotter.setDynamicPlotData(values);
    }


    public static void createDBStorage(String deviceID)
    {
        String sqlTable = "CREATE TABLE IF NOT EXISTS " + SQLTableName.PREFIX + deviceID + SQLTableName.GYROSCOPE + " (id INTEGER PRIMARY KEY, " + valueNames[3] + " INTEGER, " + valueNames[0] + " REAL, " + valueNames[1] + " REAL, " + valueNames[2] + " REAL)";
        SQLDBController.getInstance().execSQL(sqlTable);
    }


    public static void writeDBStorage(String deviceID, ContentValues newValues)
    {
        String tableName = SQLTableName.PREFIX + deviceID + SQLTableName.GYROSCOPE;

        if(Settings.DATABASE_DIRECT_INSERT) {
            SQLDBController.getInstance().insert(tableName, null, newValues);
            return;
        }

        List<String[]> clone = DBUtils.manageCache(deviceID, cache, newValues, (Settings.DATABASE_CACHE_SIZE + type * 200));
        if(clone != null) {
            SQLDBController.getInstance().bulkInsert(tableName, clone);
        }
    }


    public static void flushDBCache(String deviceID)
    {
        DBUtils.flushCache(SQLTableName.GYROSCOPE, cache, deviceID);
    }
}
mobile/src/main/java/de/unima/ar/collector/sensors/ProximitySensorCollector.java
public class ProximitySensorCollector extends SensorCollector
{
    private static final int      type       = 8;
    private static final String[] valueNames = new String[]{ "attr_cm", "attr_time" };

    private static Map<String, Plotter>        plotters = new HashMap<>();
    private static Map<String, List<String[]>> cache    = new HashMap<>();


    ProximitySensorCollector(Sensor sensor)
    {
        super(sensor);

        // create new plotter
        List<String> devices = DatabaseHelper.getStringResultSet("SELECT device FROM " + SQLTableName.DEVICES, null);
        for(String device : devices) {
            ProximitySensorCollector.createNewPlotter(device);
        }
    }


    @Override
    public void onAccuracyChanged(Sensor s, int i)
    {
    }


    @Override
    public void SensorChanged(float[] values, long time)
    {
        ContentValues newValues = new ContentValues();
        newValues.put(valueNames[0], values[0]);
        newValues.put(valueNames[1], time);

        String deviceID = DeviceID.get(SensorDataCollectorService.getInstance());
        ProximitySensorCollector.writeDBStorage(deviceID, newValues);
        ProximitySensorCollector.updateLivePlotter(deviceID, values);
    }


    @Override
    public Plotter getPlotter(String deviceID)
    {
        if(!plotters.containsKey(deviceID)) {
            ProximitySensorCollector.createNewPlotter(deviceID);
        }

        return plotters.get(deviceID);
    }


    @Override
    public int getType()
    {
        return type;
    }


    public static void createNewPlotter(String deviceID)
    {
        PlotConfiguration levelPlot = new PlotConfiguration();
        levelPlot.plotName = "LevelPlot";
        levelPlot.rangeMin = -100;
        levelPlot.rangeMax = 100;
        levelPlot.rangeName = "cm";
        levelPlot.SeriesName = "Proximity";
        levelPlot.domainName = "Axis";
        levelPlot.domainValueNames = Arrays.copyOfRange(valueNames, 0, 1);
        levelPlot.tableName = SQLTableName.PROXIMITY;
        levelPlot.sensorName = "Proximity";


        PlotConfiguration historyPlot = new PlotConfiguration();
        historyPlot.plotName = "HistoryPlot";
        historyPlot.rangeMin = -100;
        historyPlot.rangeMax = 100;
        historyPlot.domainMin = 0;
        historyPlot.domainMax = 50;
        historyPlot.rangeName = "millibar";
        historyPlot.SeriesName = "Proximity";
        historyPlot.domainName = "Proximity";
        historyPlot.seriesValueNames = Arrays.copyOfRange(valueNames, 0, 1);

        Plotter plotter = new Plotter(deviceID, levelPlot, historyPlot);
        plotters.put(deviceID, plotter);
    }


    public static void updateLivePlotter(String deviceID, float[] values)
    {
        Plotter plotter = plotters.get(deviceID);
        if(plotter == null) {
            ProximitySensorCollector.createNewPlotter(deviceID);
            plotter = plotters.get(deviceID);
        }

        plotter.setDynamicPlotData(values);
    }


    public static void createDBStorage(String deviceID)
    {
        String sqlTable = "CREATE TABLE IF NOT EXISTS " + SQLTableName.PREFIX + deviceID + SQLTableName.PROXIMITY + " (id INTEGER PRIMARY KEY, " + valueNames[1] + " INTEGER, " + valueNames[0] + " REAL)";
        SQLDBController.getInstance().execSQL(sqlTable);
    }


    public static void writeDBStorage(String deviceID, ContentValues newValues)
    {
        String tableName = SQLTableName.PREFIX + deviceID + SQLTableName.PROXIMITY;

        if(Settings.DATABASE_DIRECT_INSERT) {
            SQLDBController.getInstance().insert(tableName, null, newValues);
            return;
        }

        List<String[]> clone = DBUtils.manageCache(deviceID, cache, newValues, (Settings.DATABASE_CACHE_SIZE + type * 200));
        if(clone != null) {
            SQLDBController.getInstance().bulkInsert(tableName, clone);
        }
    }


    public static void flushDBCache(String deviceID)
    {
        DBUtils.flushCache(SQLTableName.PROXIMITY, cache, deviceID);
    }
}
mobile/src/main/java/de/unima/ar/collector/sensors/StepDetectorSensorCollector.java
public class StepDetectorSensorCollector extends SensorCollector
{
    private static final int      type       = 18;
    private static final String[] valueNames = new String[]{ "attr_step", "attr_time" };

    private static Map<String, Plotter>        plotters = new HashMap<>();
    private static Map<String, List<String[]>> cache    = new HashMap<>();


    StepDetectorSensorCollector(Sensor sensor)
    {
        super(sensor);

        // create new plotter
        List<String> devices = DatabaseHelper.getStringResultSet("SELECT device FROM " + SQLTableName.DEVICES, null);
        for(String device : devices) {
            StepDetectorSensorCollector.createNewPlotter(device);
        }
    }


    @Override
    public void onAccuracyChanged(Sensor s, int i)
    {
    }


    @Override
    public void SensorChanged(float[] values, long time)
    {
        ContentValues newValues = new ContentValues();
        newValues.put(valueNames[0], values[0]);
        newValues.put(valueNames[1], time);

        String deviceID = DeviceID.get(SensorDataCollectorService.getInstance());
        StepDetectorSensorCollector.writeDBStorage(deviceID, newValues);
        StepDetectorSensorCollector.updateLivePlotter(deviceID, values);
    }


    @Override
    public Plotter getPlotter(String deviceID)
    {
        if(!plotters.containsKey(deviceID)) {
            StepDetectorSensorCollector.createNewPlotter(deviceID);
        }

        return plotters.get(deviceID);
    }


    @Override
    public int getType()
    {
        return type;
    }


    public static void createNewPlotter(String deviceID)
    {
        PlotConfiguration levelPlot = new PlotConfiguration();
        levelPlot.plotName = "LevelPlot";
        levelPlot.rangeMin = 0;
        levelPlot.rangeMax = 5;
        levelPlot.rangeName = "step";
        levelPlot.SeriesName = "Step";
        levelPlot.domainName = "Axis";
        levelPlot.domainValueNames = Arrays.copyOfRange(valueNames, 0, 1);
        levelPlot.tableName = SQLTableName.STEP;
        levelPlot.sensorName = "Step Detector";

        PlotConfiguration historyPlot = new PlotConfiguration();
        historyPlot.plotName = "HistoryPlot";
        historyPlot.rangeMin = 0;
        historyPlot.rangeMax = 5;
        historyPlot.domainMin = 0;
        historyPlot.domainMax = 50;
        historyPlot.rangeName = "step";
        historyPlot.SeriesName = "Step";
        historyPlot.domainName = "Step";
        historyPlot.seriesValueNames = Arrays.copyOfRange(valueNames, 0, 1);

        Plotter plotter = new Plotter(deviceID, levelPlot, historyPlot);
        plotters.put(deviceID, plotter);
    }


    public static void updateLivePlotter(String deviceID, float[] values)
    {
        Plotter plotter = plotters.get(deviceID);
        if(plotter == null) {
            StepDetectorSensorCollector.createNewPlotter(deviceID);
            plotter = plotters.get(deviceID);
        }

        plotter.setDynamicPlotData(values);
    }


    public static void createDBStorage(String deviceID)
    {
        String sqlTable = "CREATE TABLE IF NOT EXISTS " + SQLTableName.PREFIX + deviceID + SQLTableName.STEP + " (id INTEGER PRIMARY KEY, " + valueNames[1] + " INTEGER UNIQUE, " + valueNames[0] + " REAL)";
        SQLDBController.getInstance().execSQL(sqlTable);
    }


    public static void writeDBStorage(String deviceID, ContentValues newValues)
    {
        String tableName = SQLTableName.PREFIX + deviceID + SQLTableName.STEP;

        if(Settings.DATABASE_DIRECT_INSERT) {
            SQLDBController.getInstance().insert(tableName, null, newValues);
            return;
        }

        List<String[]> clone = DBUtils.manageCache(deviceID, cache, newValues, (Settings.DATABASE_CACHE_SIZE + type * 200));
        if(clone != null) {
            SQLDBController.getInstance().bulkInsert(tableName, clone);
        }
    }


    public static void flushDBCache(String deviceID)
    {
        DBUtils.flushCache(SQLTableName.STEP, cache, deviceID);
    }
}
mobile/src/main/java/de/unima/ar/collector/sensors/SensorCollectorManager.java
public class SensorCollectorManager
{
    private Context                       context;
    private Map<Integer, SensorCollector> sensorCollectors;
    private Map<Integer, CustomCollector> customCollectors;
    private Set<Integer>                  enabledCollectors;
    private SensorManager                 sensorManager;

    private static final String LOG_TAG = "SensorCollectorManager";


    public SensorCollectorManager(Context context)
    {
        this.context = context;

        this.sensorCollectors = new HashMap<>();
        this.customCollectors = new HashMap<>();
        this.enabledCollectors = new HashSet<>();
        this.sensorManager = (SensorManager) this.context.getSystemService(Context.SENSOR_SERVICE);

        initSensors();
    }


    private void initSensors()
    {
        // Add all sensors
        SensorManager mSensorManager = (SensorManager) this.context.getSystemService(Activity.SENSOR_SERVICE);
        List<Sensor> allSensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);

        for(Sensor sensor : allSensors) {
            this.addSensorCollector(sensor.getType(), sensor);
        }

        for(int type : CollectorConstants.activatedCustomCollectors) {
            this.addCustomCollector(type, this.context);
        }
    }


    public int getRunningSensorAmount()
    {
        return enabledCollectors.size();
    }


    public float getPowerUsed()
    {
        float amount = 0;

        for(Integer type : enabledCollectors) {
            if(sensorCollectors.containsKey(type)) {
                amount += sensorCollectors.get(type).getSensor().getPower();
            } else {
                Log.d(LOG_TAG, "getPowerUsed for custom collector is not implemented");
            }
        }

        return amount;
    }


    public Map<Integer, SensorCollector> getSensorCollectors()
    {
        return sensorCollectors;
    }


    public Map<Integer, CustomCollector> getCustomCollectors()
    {
        return customCollectors;
    }


    public Set<Integer> getEnabledCollectors()
    {
        return this.enabledCollectors;
    }


    public boolean enableCollectors(int type)
    {
        if(!this.sensorCollectors.containsKey(type) && !this.customCollectors.containsKey(type)) {
            return false;
        }
        this.enabledCollectors.add(type);

        return true;
    }


    public boolean disableCollectors(int type)
    {
        return this.enabledCollectors.remove(type);
    }


    public boolean removeSensor(int type)
    {
        boolean result = unregisterSensorCollector(type);

        if(result) {
            disableCollectors(type);
        }

        return result;
    }


    private boolean addCustomCollector(int type, Context sensor)
    {
        CustomCollector cc = CustomCollectorFactory.getCollector(type, sensor);

        if(cc == null) {
            return false;
        }

        if(this.customCollectors.containsKey(cc.getType())) {
            return true;
        }

        this.customCollectors.put(cc.getType(), cc);

        return true;
    }


    private boolean addSensorCollector(int type, Sensor sensor)
    {
        SensorCollector sc = SensorCollectorFactory.getCollector(type, sensor);

        if(sc == null) {
            return false;
        }

        if(this.customCollectors.containsKey(sc.getType())) {
            return true;
        }

        this.sensorCollectors.put(sc.getType(), sc);

        return true;
    }


    public void registerSensorCollectors()
    {
        for(int type : this.sensorCollectors.keySet()) {
            registerSensorCollector(type);
        }
    }


    public void registerSensorCollector(int type)
    {
        SensorCollector sel = this.sensorCollectors.get(type);

        if(sel == null || !sel.registerCollector || sel.isRegistered || !enabledCollectors.contains(sel.getType())) {
            return;
        }

        if(sel.getSensor() != null) {
            this.sensorManager.registerListener(sel, sel.getSensor(), sel.getSensorRate());
            sel.isRegistered = true;
        } else {    // Fall 2: Es gibt einen Default Sensor für den Sensortyp
            if(this.sensorManager.getDefaultSensor(sel.getType()) != null) {
                this.sensorManager.registerListener(sel, this.sensorManager.getDefaultSensor(sel.getType()), sel.getSensorRate());
                sel.isRegistered = true;
            } else { // Fall 3: Es existiert kein Default Sensor für den Sensortyp
                Log.e(LOG_TAG, "Error! There is no default sensor.");
            }
        }
    }


    public void registerCustomCollectors()
    {
        for(CustomCollector cc : customCollectors.values()) {
            if(!cc.isRegistered() && enabledCollectors.contains(cc.getType())) {
                cc.register();
            }
        }
    }


    private boolean unregisterSensorCollector(int type)
    {
        for(SensorCollector sel : this.sensorCollectors.values()) {
            if(!(sel.isRegistered && sel.getType() == type && this.enabledCollectors.contains(sel.getType()))) {
                continue;
            }

            this.sensorManager.unregisterListener(sel);
            sel.isRegistered = false;
            return true;
        }

        return false;
    }


    public boolean unregisterCustomCollector(int type)
    {
        CustomCollector cc = customCollectors.get(type);
        if(!(cc != null && cc.isRegistered() && this.enabledCollectors.contains(cc.getType()))) {
            return false;
        }

        cc.deregister();
        return true;
    }


    public void unregisterSensorCollectors()
    {
        for(SensorCollector sel : this.sensorCollectors.values()) {
            if(sel.isRegistered) {
                this.sensorManager.unregisterListener(sel);
                sel.isRegistered = false;
            }
        }
    }


    public boolean isCustomCollectorRegistered(int type)
    {
        return this.enabledCollectors.contains(type);
    }
}
mobile/src/main/java/de/unima/ar/collector/sensors/LinearAccelerationSensorCollector.java
public class LinearAccelerationSensorCollector extends SensorCollector
{
    private static final int      type       = 10;
    private static final String[] valueNames = new String[]{ "attr_x", "attr_y", "attr_z", "attr_time" };

    private static Map<String, Plotter>        plotters = new HashMap<>();
    private static Map<String, List<String[]>> cache    = new HashMap<>();


    LinearAccelerationSensorCollector(Sensor sensor)
    {
        super(sensor);

        // create new plotter
        List<String> devices = DatabaseHelper.getStringResultSet("SELECT device FROM " + SQLTableName.DEVICES, null);
        for(String device : devices) {
            LinearAccelerationSensorCollector.createNewPlotter(device);
        }
    }


    @Override
    public void onAccuracyChanged(Sensor s, int i)
    {
    }


    @Override
    public void SensorChanged(float[] values, long time)
    {
        ContentValues newValues = new ContentValues();
        newValues.put(valueNames[0], values[0]);
        newValues.put(valueNames[1], values[1]);
        newValues.put(valueNames[2], values[2]);
        newValues.put(valueNames[3], time);

        String deviceID = DeviceID.get(SensorDataCollectorService.getInstance());
        LinearAccelerationSensorCollector.writeDBStorage(deviceID, newValues);
        LinearAccelerationSensorCollector.updateLivePlotter(deviceID, values);
    }


    @Override
    public Plotter getPlotter(String deviceID)
    {
        if(!plotters.containsKey(deviceID)) {
            LinearAccelerationSensorCollector.createNewPlotter(deviceID);
        }

        return plotters.get(deviceID);
    }

    @Override
    public int getType()
    {
        return type;
    }


    public static void createNewPlotter(String deviceID)
    {
        PlotConfiguration levelPlot = new PlotConfiguration();
        levelPlot.plotName = "LevelPlot";
        levelPlot.rangeMin = -15;
        levelPlot.rangeMax = 15;
        levelPlot.rangeName = "speed";
        levelPlot.SeriesName = "Linear Acceleration";
        levelPlot.domainName = "Axis";
        levelPlot.domainValueNames = Arrays.copyOfRange(valueNames, 0, 3);
        levelPlot.tableName = SQLTableName.LINEAR;
        levelPlot.sensorName = "Linear Acceleration";


        PlotConfiguration historyPlot = new PlotConfiguration();
        historyPlot.plotName = "HistoryPlot";
        historyPlot.rangeMin = -15;
        historyPlot.rangeMax = 15;
        historyPlot.domainMin = 0;
        historyPlot.domainMax = 50;
        historyPlot.rangeName = "speed";
        historyPlot.SeriesName = "Linear Acceleration";
        historyPlot.domainName = "Axis";
        historyPlot.seriesValueNames = Arrays.copyOfRange(valueNames, 0, 3);

        Plotter plotter = new Plotter(deviceID, levelPlot, historyPlot);
        plotters.put(deviceID, plotter);
    }


    public static void updateLivePlotter(String deviceID, float[] values)
    {
        Plotter plotter = plotters.get(deviceID);
        if(plotter == null) {
            LinearAccelerationSensorCollector.createNewPlotter(deviceID);
            plotter = plotters.get(deviceID);
        }

        plotter.setDynamicPlotData(values);
    }


    public static void createDBStorage(String deviceID)
    {
        String sqlTable = "CREATE TABLE IF NOT EXISTS " + SQLTableName.PREFIX + deviceID + SQLTableName.LINEAR + " (id INTEGER PRIMARY KEY, " + valueNames[3] + " INTEGER, " + valueNames[0] + " REAL, " + valueNames[1] + " REAL, " + valueNames[2] + " REAL)";
        SQLDBController.getInstance().execSQL(sqlTable);
    }


    public static void writeDBStorage(String deviceID, ContentValues newValues)
    {
        String tableName = SQLTableName.PREFIX + deviceID + SQLTableName.LINEAR;

        if(Settings.DATABASE_DIRECT_INSERT) {
            SQLDBController.getInstance().insert(tableName, null, newValues);
            return;
        }

        List<String[]> clone = DBUtils.manageCache(deviceID, cache, newValues, (Settings.DATABASE_CACHE_SIZE + type * 200));
        if(clone != null) {
            SQLDBController.getInstance().bulkInsert(tableName, clone);
        }
    }


    public static void flushDBCache(String deviceID)
    {
        DBUtils.flushCache(SQLTableName.LINEAR, cache, deviceID);
    }
}
mobile/src/main/java/de/unima/ar/collector/sensors/RotationVectorSensorCollector.java
public class RotationVectorSensorCollector extends SensorCollector
{
    private static final int      type       = 11;
    private static final String[] valueNames = new String[]{ "attr_x", "attr_y", "attr_z", "attr_time" };

    private static Map<String, Plotter>        plotters = new HashMap<>();
    private static Map<String, List<String[]>> cache    = new HashMap<>();


    RotationVectorSensorCollector(Sensor sensor)
    {
        super(sensor);

        // create new plotter
        List<String> devices = DatabaseHelper.getStringResultSet("SELECT device FROM " + SQLTableName.DEVICES, null);
        for(String device : devices) {
            RotationVectorSensorCollector.createNewPlotter(device);
        }
    }


    @Override
    public void onAccuracyChanged(Sensor s, int i)
    {
    }


    @Override
    public void SensorChanged(float[] values, long time)
    {
        ContentValues newValues = new ContentValues();
        newValues.put(valueNames[0], values[0]);
        newValues.put(valueNames[1], values[1]);
        newValues.put(valueNames[2], values[2]);
        newValues.put(valueNames[3], time);

        String deviceID = DeviceID.get(SensorDataCollectorService.getInstance());
        RotationVectorSensorCollector.writeDBStorage(deviceID, newValues);
        RotationVectorSensorCollector.updateLivePlotter(deviceID, values);
    }


    @Override
    public Plotter getPlotter(String deviceID)
    {
        if(!plotters.containsKey(deviceID)) {
            RotationVectorSensorCollector.createNewPlotter(deviceID);
        }

        return plotters.get(deviceID);
    }


    @Override
    public int getType()
    {
        return type;
    }


    public static void createNewPlotter(String deviceID)
    {
        PlotConfiguration levelPlot = new PlotConfiguration();
        levelPlot.plotName = "LevelPlot";
        levelPlot.rangeMin = -1;
        levelPlot.rangeMax = 1;
        levelPlot.rangeName = "rotation";
        levelPlot.SeriesName = "Rotation Vector";
        levelPlot.domainName = "Axis";
        levelPlot.domainValueNames = Arrays.copyOfRange(valueNames, 0, 3);
        levelPlot.tableName = SQLTableName.ROTATION;
        levelPlot.sensorName = "Rotation Vector";


        PlotConfiguration historyPlot = new PlotConfiguration();
        historyPlot.plotName = "HistoryPlot";
        historyPlot.rangeMin = -1;
        historyPlot.rangeMax = 1;
        historyPlot.domainMin = 0;
        historyPlot.domainMax = 50;
        historyPlot.rangeName = "rotation";
        historyPlot.SeriesName = "Rotation Vector";
        historyPlot.domainName = "Axis";
        historyPlot.seriesValueNames = Arrays.copyOfRange(valueNames, 0, 3);

        Plotter plotter = new Plotter(deviceID, levelPlot, historyPlot);
        plotters.put(deviceID, plotter);
    }


    public static void updateLivePlotter(String deviceID, float[] values)
    {
        Plotter plotter = plotters.get(deviceID);
        if(plotter == null) {
            RotationVectorSensorCollector.createNewPlotter(deviceID);
            plotter = plotters.get(deviceID);
        }

        plotter.setDynamicPlotData(values);
    }


    public static void createDBStorage(String deviceID)
    {
        String sqlTable = "CREATE TABLE IF NOT EXISTS " + SQLTableName.PREFIX + deviceID + SQLTableName.ROTATION + " (id INTEGER PRIMARY KEY, " + valueNames[3] + " INTEGER, " + valueNames[0] + " REAL, " + valueNames[1] + " REAL, " + valueNames[2] + " REAL)";
        SQLDBController.getInstance().execSQL(sqlTable);
    }


    public static void writeDBStorage(String deviceID, ContentValues newValues)
    {
        String tableName = SQLTableName.PREFIX + deviceID + SQLTableName.ROTATION;

        if(Settings.DATABASE_DIRECT_INSERT) {
            SQLDBController.getInstance().insert(tableName, null, newValues);
            return;
        }

        List<String[]> clone = DBUtils.manageCache(deviceID, cache, newValues, (Settings.DATABASE_CACHE_SIZE + type * 200));
        if(clone != null) {
            SQLDBController.getInstance().bulkInsert(tableName, clone);
        }
    }


    public static void flushDBCache(String deviceID)
    {
        DBUtils.flushCache(SQLTableName.ROTATION, cache, deviceID);
    }
}
mobile/src/main/java/de/unima/ar/collector/sensors/OrientationSensorCollector.java
public class OrientationSensorCollector extends SensorCollector
{
    private static final int      type       = 3;
    private static final String[] valueNames = new String[]{ "attr_azimuth", "attr_pitch", "attr_roll", "attr_time" };

    private static Map<String, Plotter>        plotters = new HashMap<>();
    private static Map<String, List<String[]>> cache    = new HashMap<>();


    OrientationSensorCollector(Sensor sensor)
    {
        super(sensor);

        // create new plotter
        List<String> devices = DatabaseHelper.getStringResultSet("SELECT device FROM " + SQLTableName.DEVICES, null);
        for(String device : devices) {
            OrientationSensorCollector.createNewPlotter(device);
        }
    }


    @Override
    public void onAccuracyChanged(Sensor s, int i)
    {
    }


    @Override
    public void SensorChanged(float[] values, long time)
    {
        ContentValues newValues = new ContentValues();
        newValues.put(valueNames[0], values[0]);
        newValues.put(valueNames[1], values[1]);
        newValues.put(valueNames[2], values[2]);
        newValues.put(valueNames[3], time);

        String deviceID = DeviceID.get(SensorDataCollectorService.getInstance());
        OrientationSensorCollector.writeDBStorage(deviceID, newValues);
        OrientationSensorCollector.updateLivePlotter(deviceID, values);
    }


    @Override
    public Plotter getPlotter(String deviceID)
    {
        if(!plotters.containsKey(deviceID)) {
            OrientationSensorCollector.createNewPlotter(deviceID);
        }

        return plotters.get(deviceID);
    }


    @Override
    public int getType()
    {
        return type;
    }


    public static void createNewPlotter(String deviceID)
    {
        PlotConfiguration levelPlot = new PlotConfiguration();
        levelPlot.plotName = "LevelPlot";
        levelPlot.rangeMin = -180;
        levelPlot.rangeMax = 359;
        levelPlot.rangeName = "orientation";
        levelPlot.SeriesName = "Orientation";
        levelPlot.domainName = "Axis";
        levelPlot.domainValueNames = Arrays.copyOfRange(valueNames, 0, 3);
        levelPlot.tableName = SQLTableName.ORIENTATION;
        levelPlot.sensorName = "Orientation";


        PlotConfiguration historyPlot = new PlotConfiguration();
        historyPlot.plotName = "HistoryPlot";
        historyPlot.rangeMin = -180;
        historyPlot.rangeMax = 359;
        historyPlot.domainMin = 0;
        historyPlot.domainMax = 50;
        historyPlot.rangeName = "orientation";
        historyPlot.SeriesName = "Orientation";
        historyPlot.domainName = "Axis";
        historyPlot.seriesValueNames = Arrays.copyOfRange(valueNames, 0, 3);

        Plotter plotter = new Plotter(deviceID, levelPlot, historyPlot);
        plotters.put(deviceID, plotter);
    }


    public static void updateLivePlotter(String deviceID, float[] values)
    {
        Plotter plotter = plotters.get(deviceID);
        if(plotter == null) {
            OrientationSensorCollector.createNewPlotter(deviceID);
            plotter = plotters.get(deviceID);
        }

        plotter.setDynamicPlotData(values);
    }


    public static void createDBStorage(String deviceID)
    {
        String sqlTable = "CREATE TABLE IF NOT EXISTS " + SQLTableName.PREFIX + deviceID + SQLTableName.ORIENTATION + " (id INTEGER PRIMARY KEY, " + valueNames[3] + " INTEGER, " + valueNames[0] + " REAL, " + valueNames[1] + " REAL, " + valueNames[2] + " REAL)";
        SQLDBController.getInstance().execSQL(sqlTable);
    }


    public static void writeDBStorage(String deviceID, ContentValues newValues)
    {
        String tableName = SQLTableName.PREFIX + deviceID + SQLTableName.ORIENTATION;

        if(Settings.DATABASE_DIRECT_INSERT) {
            SQLDBController.getInstance().insert(tableName, null, newValues);
            return;
        }

        List<String[]> clone = DBUtils.manageCache(deviceID, cache, newValues, (Settings.DATABASE_CACHE_SIZE + type * 200));
        if(clone != null) {
            SQLDBController.getInstance().bulkInsert(tableName, clone);
        }
    }


    public static void flushDBCache(String deviceID)
    {
        DBUtils.flushCache(SQLTableName.ORIENTATION, cache, deviceID);
    }
}
mobile/src/main/java/de/unima/ar/collector/sensors/AccelerometerSensorCollector.java
public class AccelerometerSensorCollector extends SensorCollector
{
    private static final int      type       = 1;
    private static final String[] valueNames = new String[]{ "attr_x", "attr_y", "attr_z", "attr_time" };
    private              float[]  gravity    = new float[]{ 0, 0, 0 };

    private static Map<String, Plotter>        plotters = new HashMap<>();
    private static Map<String, List<String[]>> cache    = new HashMap<>();


    AccelerometerSensorCollector(Sensor sensor)
    {
        super(sensor);

        // create new plotter
        List<String> devices = DatabaseHelper.getStringResultSet("SELECT device FROM " + SQLTableName.DEVICES, null);
        for(String device : devices) {
            AccelerometerSensorCollector.createNewPlotter(device);
        }
    }


    @Override
    public void onAccuracyChanged(Sensor sensor, int accuracy)
    {
    }


    @Override
    public void SensorChanged(float[] values, long time)
    {
        float x = values[0];
        float y = values[1];
        float z = values[2];

        if(Settings.ACCLOWPASS) { // low pass filter
            final float alpha = (float) 0.8;
            gravity[0] = alpha * gravity[0] + (1 - alpha) * values[0];
            gravity[1] = alpha * gravity[1] + (1 - alpha) * values[1];
            gravity[2] = alpha * gravity[2] + (1 - alpha) * values[2];

            x = values[0] - gravity[0];
            y = values[1] - gravity[1];
            z = values[2] - gravity[2];
        }

        ContentValues newValues = new ContentValues();
        newValues.put(valueNames[0], x);
        newValues.put(valueNames[1], y);
        newValues.put(valueNames[2], z);
        newValues.put(valueNames[3], time);

        String deviceID = DeviceID.get(SensorDataCollectorService.getInstance());
        AccelerometerSensorCollector.writeDBStorage(deviceID, newValues);
        AccelerometerSensorCollector.updateLivePlotter(deviceID, new float[]{ x, y, z });
    }


    @Override
    public Plotter getPlotter(String deviceID)
    {
        if(!plotters.containsKey(deviceID)) {
            AccelerometerSensorCollector.createNewPlotter(deviceID);
        }

        return plotters.get(deviceID);
    }


    @Override
    public int getType()
    {
        return type;
    }


    public static void createNewPlotter(String deviceID)
    {
        PlotConfiguration levelPlot = new PlotConfiguration();
        levelPlot.plotName = "LevelPlot";
        levelPlot.rangeMin = -10;
        levelPlot.rangeMax = 10;
        levelPlot.rangeName = "Speed";
        levelPlot.SeriesName = "Speed";
        levelPlot.domainName = "Axis";
        levelPlot.domainValueNames = Arrays.copyOfRange(valueNames, 0, 3);
        levelPlot.tableName = SQLTableName.ACCELEROMETER;
        levelPlot.sensorName = "Accelerometer";

        PlotConfiguration historyPlot = new PlotConfiguration();
        historyPlot.plotName = "HistoryPlot";
        historyPlot.rangeMin = -10;
        historyPlot.rangeMax = 10;
        historyPlot.domainMin = 0;
        historyPlot.domainMax = 80;
        historyPlot.rangeName = "Speed m/s";
        historyPlot.SeriesName = "Speed";
        historyPlot.domainName = "Time";
        historyPlot.seriesValueNames = Arrays.copyOfRange(valueNames, 0, 3);

        Plotter plotter = new Plotter(deviceID, levelPlot, historyPlot);
        plotters.put(deviceID, plotter);
    }


    public static void updateLivePlotter(String deviceID, float[] values)
    {
        Plotter plotter = plotters.get(deviceID);
        if(plotter == null) {   // this could be the case if the app was already running and a new, unknown devices established a connection
            AccelerometerSensorCollector.createNewPlotter(deviceID);
            plotter = plotters.get(deviceID);
        }

        plotter.setDynamicPlotData(values);
    }


    public static void createDBStorage(String deviceID)
    {
        String sqlTable = "CREATE TABLE IF NOT EXISTS " + SQLTableName.PREFIX + deviceID + SQLTableName.ACCELEROMETER + " (id INTEGER PRIMARY KEY, " + valueNames[3] + " INTEGER, " + valueNames[0] + " REAL, " + valueNames[1] + " REAL, " + valueNames[2] + " REAL)";
        SQLDBController.getInstance().execSQL(sqlTable);
    }


    public static void writeDBStorage(String deviceID, ContentValues newValues)
    {
        String tableName = SQLTableName.PREFIX + deviceID + SQLTableName.ACCELEROMETER;

        if(Settings.DATABASE_DIRECT_INSERT) {
            SQLDBController.getInstance().insert(tableName, null, newValues);
            return;
        }

        List<String[]> clone = DBUtils.manageCache(deviceID, cache, newValues, (Settings.DATABASE_CACHE_SIZE + type * 200));
        if(clone != null) {
            SQLDBController.getInstance().bulkInsert(tableName, clone);
        }
    }


    public static void flushDBCache(String deviceID)
    {
        DBUtils.flushCache(SQLTableName.ACCELEROMETER, cache, deviceID);
    }
}
mobile/src/main/java/de/unima/ar/collector/sensors/PressureSensorCollector.java
public class PressureSensorCollector extends SensorCollector
{
    private static final int      type       = 6;
    private static final String[] valueNames = new String[]{ "attr_millibar", "attr_time" };

    private static Map<String, Plotter>        plotters = new HashMap<>();
    private static Map<String, List<String[]>> cache    = new HashMap<>();


    PressureSensorCollector(Sensor sensor)
    {
        super(sensor);

        // create new plotter
        List<String> devices = DatabaseHelper.getStringResultSet("SELECT device FROM " + SQLTableName.DEVICES, null);
        for(String device : devices) {
            PressureSensorCollector.createNewPlotter(device);
        }
    }


    @Override
    public void onAccuracyChanged(Sensor s, int i)
    {
    }


    @Override
    public void SensorChanged(float[] values, long time)
    {
        ContentValues newValues = new ContentValues();
        newValues.put(valueNames[0], values[0]);
        newValues.put(valueNames[1], time);

        String deviceID = DeviceID.get(SensorDataCollectorService.getInstance());
        PressureSensorCollector.writeDBStorage(deviceID, newValues);
        PressureSensorCollector.updateLivePlotter(deviceID, values);
    }


    @Override
    public Plotter getPlotter(String deviceID)
    {
        if(!plotters.containsKey(deviceID)) {
            PressureSensorCollector.createNewPlotter(deviceID);
        }

        return plotters.get(deviceID);
    }


    @Override
    public int getType()
    {
        return type;
    }


    public static void createNewPlotter(String deviceID)
    {
        PlotConfiguration levelPlot = new PlotConfiguration();
        levelPlot.plotName = "LevelPlot";
        levelPlot.rangeMin = 0;
        levelPlot.rangeMax = 2000;
        levelPlot.rangeName = "millibar";
        levelPlot.SeriesName = "Pressure";
        levelPlot.domainName = "Axis";
        levelPlot.domainValueNames = Arrays.copyOfRange(valueNames, 0, 1);
        levelPlot.tableName = SQLTableName.PRESSURE;
        levelPlot.sensorName = "Pressure";

        PlotConfiguration historyPlot = new PlotConfiguration();
        historyPlot.plotName = "HistoryPlot";
        historyPlot.rangeMin = 0;
        historyPlot.rangeMax = 2000;
        historyPlot.domainMin = 0;
        historyPlot.domainMax = 50;
        historyPlot.rangeName = "millibar";
        historyPlot.SeriesName = "Temp";
        historyPlot.domainName = "Pressure";
        historyPlot.seriesValueNames = Arrays.copyOfRange(valueNames, 0, 1);

        Plotter plotter = new Plotter(deviceID, levelPlot, historyPlot);
        plotters.put(deviceID, plotter);
    }


    public static void updateLivePlotter(String deviceID, float[] values)
    {
        Plotter plotter = plotters.get(deviceID);
        if(plotter == null) {
            PressureSensorCollector.createNewPlotter(deviceID);
            plotter = plotters.get(deviceID);
        }

        plotter.setDynamicPlotData(values);
    }


    public static void createDBStorage(String deviceID)
    {
        String sqlTable = "CREATE TABLE IF NOT EXISTS " + SQLTableName.PREFIX + deviceID + SQLTableName.PRESSURE + " (id INTEGER PRIMARY KEY, " + valueNames[1] + " INTEGER, " + valueNames[0] + " REAL)";
        SQLDBController.getInstance().execSQL(sqlTable);
    }


    public static void writeDBStorage(String deviceID, ContentValues newValues)
    {
        String tableName = SQLTableName.PREFIX + deviceID + SQLTableName.PRESSURE;

        if(Settings.DATABASE_DIRECT_INSERT) {
            SQLDBController.getInstance().insert(tableName, null, newValues);
            return;
        }

        List<String[]> clone = DBUtils.manageCache(deviceID, cache, newValues, (Settings.DATABASE_CACHE_SIZE + type * 200));
        if(clone != null) {
            SQLDBController.getInstance().bulkInsert(tableName, clone);
        }
    }


    public static void flushDBCache(String deviceID)
    {
        DBUtils.flushCache(SQLTableName.PRESSURE, cache, deviceID);
    }
}
mobile/src/main/java/de/unima/ar/collector/sensors/LightSensorCollector.java
public class LightSensorCollector extends SensorCollector
{
    private static final int      type       = 5;
    private static final String[] valueNames = new String[]{ "attr_light", "attr_time" };

    private static Map<String, Plotter>        plotters = new HashMap<>();
    private static Map<String, List<String[]>> cache    = new HashMap<>();


    LightSensorCollector(Sensor sensor)
    {
        super(sensor);

        // create new plotter
        List<String> devices = DatabaseHelper.getStringResultSet("SELECT device FROM " + SQLTableName.DEVICES, null);
        for(String device : devices) {
            LightSensorCollector.createNewPlotter(device);
        }
    }


    @Override
    public void onAccuracyChanged(Sensor s, int i)
    {
    }


    @Override
    public void SensorChanged(float[] values, long time)
    {
        ContentValues newValues = new ContentValues();
        newValues.put(valueNames[0], values[0]);
        newValues.put(valueNames[1], time);

        String deviceID = DeviceID.get(SensorDataCollectorService.getInstance());
        LightSensorCollector.writeDBStorage(deviceID, newValues);
        LightSensorCollector.updateLivePlotter(deviceID, values);
    }


    @Override
    public Plotter getPlotter(String deviceID)
    {
        if(!plotters.containsKey(deviceID)) {
            LightSensorCollector.createNewPlotter(deviceID);
        }

        return plotters.get(deviceID);
    }

    @Override
    public int getType()
    {
        return type;
    }


    public static void createNewPlotter(String deviceID)
    {
        PlotConfiguration levelPlot = new PlotConfiguration();
        levelPlot.plotName = "LevelPlot";
        levelPlot.rangeMin = 0;
        levelPlot.rangeMax = 50;
        levelPlot.rangeName = "Light Intensitiy";
        levelPlot.SeriesName = "Light";
        levelPlot.domainName = "Axis";
        levelPlot.domainValueNames = Arrays.copyOfRange(valueNames, 0, 1);
        levelPlot.tableName = SQLTableName.LIGHT;
        levelPlot.sensorName = "Light";


        PlotConfiguration historyPlot = new PlotConfiguration();
        historyPlot.plotName = "HistoryPlot";
        historyPlot.rangeMin = 0;
        historyPlot.rangeMax = 50;
        historyPlot.domainMin = 0;
        historyPlot.domainMax = 50;
        historyPlot.rangeName = "Light Intensitiy";
        historyPlot.SeriesName = "Light";
        historyPlot.domainName = "Time";
        historyPlot.seriesValueNames = Arrays.copyOfRange(valueNames, 0, 1);

        Plotter plotter = new Plotter(deviceID, levelPlot, historyPlot);
        plotters.put(deviceID, plotter);
    }


    public static void updateLivePlotter(String deviceID, float[] values)
    {
        Plotter plotter = plotters.get(deviceID);
        if(plotter == null) {
            LightSensorCollector.createNewPlotter(deviceID);
            plotter = plotters.get(deviceID);
        }

        plotter.setDynamicPlotData(values);
    }


    public static void createDBStorage(String deviceID)
    {
        String sqlTable = "CREATE TABLE IF NOT EXISTS " + SQLTableName.PREFIX + deviceID + SQLTableName.LIGHT + " (id INTEGER PRIMARY KEY, " + valueNames[1] + " INTEGER, " + valueNames[0] + " REAL)";
        SQLDBController.getInstance().execSQL(sqlTable);
    }


    public static void writeDBStorage(String deviceID, ContentValues newValues)
    {
        String tableName = SQLTableName.PREFIX + deviceID + SQLTableName.LIGHT;

        if(Settings.DATABASE_DIRECT_INSERT) {
            SQLDBController.getInstance().insert(tableName, null, newValues);
            return;
        }

        List<String[]> clone = DBUtils.manageCache(deviceID, cache, newValues, (Settings.DATABASE_CACHE_SIZE + type * 200));
        if(clone != null) {
            SQLDBController.getInstance().bulkInsert(tableName, clone);
        }
    }


    public static void flushDBCache(String deviceID)
    {
        DBUtils.flushCache(SQLTableName.LIGHT, cache, deviceID);
    }
}


Question: import android.graphics.Color;
import android.graphics.Paint;
import android.location.Location;
import com.androidplot.ui.AnchorPosition;
import com.androidplot.ui.DynamicTableModel;
import com.androidplot.ui.SizeLayoutType;
import com.androidplot.ui.SizeMetrics;
import com.androidplot.ui.XLayoutStyle;
import com.androidplot.ui.YLayoutStyle;
import com.androidplot.util.PixelUtils;
import com.androidplot.xy.BoundaryMode;
import com.androidplot.xy.XYPlot;
import com.androidplot.xy.XYStepMode;
import java.text.FieldPosition;
import java.text.Format;
import java.text.ParsePosition;
import java.util.Set;
import java.util.TreeSet;
import de.unima.ar.collector.SensorDataCollectorService;
import de.unima.ar.collector.sensors.AccelerometerSensorCollector;
import de.unima.ar.collector.sensors.AmbientTemperatureSensorCollector;
import de.unima.ar.collector.sensors.GravitySensorCollector;
import de.unima.ar.collector.sensors.GyroscopeSensorCollector;
import de.unima.ar.collector.sensors.LightSensorCollector;
import de.unima.ar.collector.sensors.LinearAccelerationSensorCollector;
import de.unima.ar.collector.sensors.MagneticFieldSensorCollector;
import de.unima.ar.collector.sensors.OrientationSensorCollector;
import de.unima.ar.collector.sensors.PressureSensorCollector;
import de.unima.ar.collector.sensors.ProximitySensorCollector;
import de.unima.ar.collector.sensors.RelativeHumiditySensorCollector;
import de.unima.ar.collector.sensors.RotationVectorSensorCollector;
import de.unima.ar.collector.sensors.SensorCollectorManager;
import de.unima.ar.collector.sensors.StepCounterSensorCollector;
import de.unima.ar.collector.sensors.StepDetectorSensorCollector;
            case 14:
                return "TYPE_MAGNETIC_FIELD_UNCALIBRATED";
            case 3:
                return "TYPE_ORIENTATION";
            case 6:
                return "TYPE_PRESSURE";
            case 8:
                return "TYPE_PROXIMITY";
            case 12:
                return "TYPE_RELATIVE_HUMIDITY";
            case 11:
                return "TYPE_ROTATION_VECTOR";
            case 17:
                return "TYPE_SIGNIFICANT_MOTION";
            case 19:
                return "TYPE_STEP_COUNTER";
            case 18:
                return "TYPE_STEP_DETECTOR";
            case 7:
                return "TYPE_TEMPERATURE";
            case -2:
                return "TYPE_MICROPHONE";
            case -3:
                return "TYPE_GPS";
            case -4:
                return "TYPE_VIDEO";
            default:
                return "TYPE_" + type;
        }
    }


    /**
     * Returns the int from an string type
     */
    public static int getSensorTypeInt(String type)
    {
        switch(type) {
            case "TYPE_ACCELEROMETER":
                return 1;
            case "TYPE_AMBIENT_TEMPERATURE":
                return 13;
            case "TYPE_GAME_ROTATION_VECTOR":
                return 15;
            case "TYPE_GEOMAGNETIC_ROTATION_VECTOR":
                return 20;
            case "TYPE_GRAVITY":
                return 9;
            case "TYPE_GYROSCOPE":
                return 4;
            case "TYPE_GYROSCOPE_UNCALIBRATED":
                return 16;
            case "TYPE_LIGHT":
                return 5;
            case "TYPE_LINEAR_ACCELERATION":
                return 10;
            case "TYPE_MAGNETIC_FIELD":
                return 2;
            case "TYPE_MAGNETIC_FIELD_UNCALIBRATED":
                return 14;
            case "TYPE_ORIENTATION":
                return 3;
            case "TYPE_PRESSURE":
                return 6;
            case "TYPE_PROXIMITY":
                return 8;
            case "TYPE_RELATIVE_HUMIDITY":
                return 12;
            case "TYPE_ROTATION_VECTOR":
                return 11;
            case "TYPE_SIGNIFICANT_MOTION":
                return 17;
            case "TYPE_STEP_COUNTER":
                return 19;
            case "TYPE_STEP_DETECTOR":
                return 18;
            case "TYPE_TEMPERATURE":
                return 7;
            case "TYPE_MICROPHONE":
                return -2;
            case "TYPE_GPS":
                return -3;
            case "TYPE_VIDEO":
                return -4;
            default:
                return -1;
        }
    }


    public static void flushSensorDataCache(final int type, final String deviceID)
    {
        if(type == 1 || type == 0) {
            AccelerometerSensorCollector.flushDBCache(deviceID);
        }
        if(type == 2 || type == 0) {
            MagneticFieldSensorCollector.flushDBCache(deviceID);
        }
        if(type == 3 || type == 0) {
            OrientationSensorCollector.flushDBCache(deviceID);
        }
        if(type == 4 || type == 0) {
            GyroscopeSensorCollector.flushDBCache(deviceID);
        }
        if(type == 5 || type == 0) {
            LightSensorCollector.flushDBCache(deviceID);
        }
        if(type == 6 || type == 0) {
            PressureSensorCollector.flushDBCache(deviceID);
        }
        if(type == 8 || type == 0) {
            ProximitySensorCollector.flushDBCache(deviceID);
        }
        if(type == 9 || type == 0) {
            GravitySensorCollector.flushDBCache(deviceID);
        }
        if(type == 10 || type == 0) {
            LinearAccelerationSensorCollector.flushDBCache(deviceID);
        }
        if(type == 11 || type == 0) {
Answer:             RotationVectorSensorCollector.flushDBCache(deviceID);