package com.github.pocmo.sensordashboard.data;

import android.content.Context;

import java.util.LinkedList;

/**
 * Created by juhani on 01/11/14.
 */
public class DataController {

    private LinkedList<Sensor> sensors = new LinkedList<Sensor>();
    private Context context;

    private static DataController instance = null;


    private DataController(Context context) {
        this.context = context.getApplicationContext();

        generateDymmyData();
    }


    public Sensor getSensor(long id) {
        for (Sensor sensor : this.sensors) {
            if (sensor.getId() == id) {
                return sensor;
            }
        }
        return null;
    }

    private void generateDymmyData() {

        Sensor sensor = new Sensor(1, "motion");
        sensor.addDataPoint(new SensorDataPoint(System.currentTimeMillis() - 2000, 20f));
        sensor.addDataPoint(new SensorDataPoint(System.currentTimeMillis() - 1000, 24f));
        sensor.addDataPoint(new SensorDataPoint(System.currentTimeMillis() - 0, 22f));
        sensors.add(sensor);

        sensor = new Sensor(2, "temperature");
        sensor.addDataPoint(new SensorDataPoint(System.currentTimeMillis() - 2000, 20f));
        sensor.addDataPoint(new SensorDataPoint(System.currentTimeMillis() - 1000, 10f));
        sensor.addDataPoint(new SensorDataPoint(System.currentTimeMillis() - 0, 2f));
        sensors.add(sensor);

        sensor = new Sensor(3, "speed");
        sensor.addDataPoint(new SensorDataPoint(System.currentTimeMillis() - 2000, 70f));
        sensor.addDataPoint(new SensorDataPoint(System.currentTimeMillis() - 1000, 20f));
        sensor.addDataPoint(new SensorDataPoint(System.currentTimeMillis() - 500, 30f));
        sensors.add(sensor);

    }

    public static DataController getInstance(Context context) {
        if (instance == null) {
            instance = new DataController(context);
        }
        return instance;
    }


    public LinkedList<Sensor> getSensors() {
        return sensors;
    }
}

@@ -837,36 +837,55 @@
 Millis() - 2000,
+ 1, new float%5B%5D %7B
  20f
+ %7D
 ));%0A        sens
@@ -958,12 +958,31 @@
 000,
+ 1, new float%5B%5D %7B
  24f
+ %7D
 ));%0A
@@ -1064,12 +1064,31 @@
 - 0,
+ 1, new float%5B%5D %7B
  22f
+ %7D
 ));%0A
@@ -1242,28 +1242,47 @@
 is() - 2000,
+ 1, new float%5B%5D %7B
  20f
+ %7D
 ));%0A        
@@ -1357,18 +1357,37 @@
  1000, 1
-0f
+, new float%5B%5D %7B 10f %7D
 ));%0A    
@@ -1462,18 +1462,37 @@
 () - 0, 
-2f
+1, new float%5B%5D %7B 2f %7D
 ));%0A    
@@ -1644,12 +1644,31 @@
 000,
+ 1, new float%5B%5D %7B
  70f
+ %7D
 ));%0A
@@ -1749,20 +1749,39 @@
  - 1000,
+ 1, new float%5B%5D %7B
  20f
+ %7D
 ));%0A    
@@ -1861,12 +1861,31 @@
 500,
+ 1, new float%5B%5D %7B
  30f
+ %7D
 ));%0A

Fix dummy data.