예제 #1
0
  public void onSensorChanged(SensorEvent event) {
    String valuesString = "";
    int counter = 0;
    for (float value : event.values) {
      valuesString += String.format("%d) %f ", counter++, value);
    }
    valuesString += " , " + pressureHistory.size();
    textViewPressure.setText(valuesString);

    double value = pressureSmoothingWin.push((double) event.values[0]);
    // Number[] series1Numbers = {event.values[0], event.values[1],
    // event.values[2]};
    // get rid the oldest sample in history:
    if (pressureHistory.size() > HISTORY_SIZE) {
      pressureHistory.removeFirst();
    }
    // add the latest history sample:
    pressureHistory.addLast(value); // event.values[0]);

    value = altitudeSmoothingWin.push((double) event.values[1]);
    if (altitudeHistory.size() > HISTORY_SIZE) {
      altitudeHistory.removeFirst();
    }
    altitudeHistory.addLast(value); // event.values[0]);

    value = tempSmoothingWin.push((double) event.values[2]);
    if (tempHistory.size() > HISTORY_SIZE) {
      tempHistory.removeFirst();
    }
    tempHistory.addLast(value);
    if (cooler++ % 2 == 0) return;
    // update the plot with the updated history Lists:
    if (sensorId == 0) {
      pressureHistorySeries.setModel(pressureHistory, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY);
      preHistoryPlot.setRangeLabel("Pressure (hPa)");
    } else if (sensorId == 1) {
      pressureHistorySeries.setModel(altitudeHistory, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY);
      preHistoryPlot.setRangeLabel("Altitude (m)");
    } else {
      pressureHistorySeries.setModel(tempHistory, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY);
      preHistoryPlot.setRangeLabel("Temperature (ºC)");
    }

    // redraw the Plots:
    preHistoryPlot.redraw();
  }
예제 #2
0
  @Override
  protected void onSaveInstanceState(Bundle outState) {
    float[] data = new float[pressureHistory.size()];
    for (int i = 0; i < pressureHistory.size(); i++) {
      data[i] = pressureHistory.get(i).floatValue();
    }
    outState.putFloatArray("Pressure", data);

    data = new float[pressureSmoothingWin.size()];
    for (int i = 0; i < pressureSmoothingWin.size(); i++) {
      data[i] = pressureSmoothingWin.get(i).floatValue();
    }
    outState.putFloatArray("Pressure Smoothing Window", data);

    data = new float[altitudeHistory.size()];
    for (int i = 0; i < altitudeHistory.size(); i++) {
      data[i] = altitudeHistory.get(i).floatValue();
    }
    outState.putFloatArray("Altitude", data);

    data = new float[altitudeSmoothingWin.size()];
    for (int i = 0; i < altitudeSmoothingWin.size(); i++) {
      data[i] = altitudeSmoothingWin.get(i).floatValue();
    }
    outState.putFloatArray("Altitude Smoothing Window", data);

    data = new float[tempHistory.size()];
    for (int i = 0; i < tempHistory.size(); i++) {
      data[i] = tempHistory.get(i).floatValue();
    }
    outState.putFloatArray("Temperature", data);

    data = new float[tempSmoothingWin.size()];
    for (int i = 0; i < tempSmoothingWin.size(); i++) {
      data[i] = tempSmoothingWin.get(i).floatValue();
    }
    outState.putFloatArray("Temperature Smoothing Window", data);
  }
예제 #3
0
  @Override
  protected void onRestoreInstanceState(Bundle inState) {
    float[] data = inState.getFloatArray("Pressure");
    if (data != null) {
      pressureHistory.clear();
      for (float f : data) {
        pressureHistory.add((double) f);
      }
    }
    data = inState.getFloatArray("Pressure Smoothing Window");
    if (data != null) {
      pressureSmoothingWin.clear();
      for (float f : data) {
        pressureSmoothingWin.push((double) f);
      }
    }

    data = inState.getFloatArray("Altitude");
    if (data != null) {
      altitudeHistory.clear();
      for (float f : data) {
        altitudeHistory.add((double) f);
      }
    }
    data = inState.getFloatArray("Altitude Smoothing Window");
    if (data != null) {
      altitudeSmoothingWin.clear();
      for (float f : data) {
        altitudeSmoothingWin.push((double) f);
      }
    }

    data = inState.getFloatArray("Temperature");
    if (data != null) {
      tempHistory.clear();
      for (float f : data) {
        tempHistory.add((double) f);
      }
    }
    data = inState.getFloatArray("Temperature Smoothing Window");
    if (data != null) {
      tempSmoothingWin.clear();
      for (float f : data) {
        tempSmoothingWin.push((double) f);
      }
    }
    plotLongHistory();
  }
 // methods
 public String getBed5(int scoreIndex) {
   float score = bestWindow.getScores()[scoreIndex];
   return chromosome + "\t" + start + "\t" + stop + "\t.\t" + score + "\t.";
 }
 public EnrichedRegion(SmoothingWindow window) {
   start = window.getStart();
   stop = window.getStop();
 }
 // constructors
 public EnrichedRegion(SmoothingWindow window, String chromosome) {
   chromosome = this.chromosome = chromosome;
   start = window.getStart();
   stop = window.getStop();
   bestWindow = window;
 }