Android Open Source - GreenerGasPedal Log Line






From Project

Back to project page GreenerGasPedal.

License

The source code is released under:

GNU General Public License

If you think the Android project GreenerGasPedal listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package name.nanek.greenerpedal.activity.support;
//w w  w  .ja va 2  s.c o m
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import android.util.Log;

public class LogLine {

  private static final String LOG_TAG = "GreenerPedal";
  
  private static final DateFormat TIME_FORMAT = new SimpleDateFormat("hh:mm:ss:SSS");

  private static final DateFormat DATE_FORMAT = DateFormat.getDateInstance(DateFormat.SHORT);

  //private static final DateFormat TIME_FORMAT = DateFormat.getTimeInstance(DateFormat.SHORT);

  private Date date;

  private float[] accelerometervalues;

  float tiltDegrees;

  float acceleration;
  
  float breaking;
  
  float cornering; 
  
  String screen;
  
  Float calculatedAcceleration;
  
  Float calculatedBreaking;
  
  Float calculatedCornering; 
  
  //date time x y z tilt accel deaccel corner screen
  public LogLine() {
    date = new Date();    
  }
  
  public void updateRawXYZ(float[] accelerometervalues) {
    this.accelerometervalues = accelerometervalues.clone();
  }

  public void updateRawMeasurements(float acceleration, float breaking, float cornering, float tiltDegrees) {
    this.acceleration = acceleration;
    this.breaking = breaking;
    this.cornering = cornering;
    this.tiltDegrees = tiltDegrees;
  }
  
  public void updateScreen(String screen) {
    this.screen = screen;
  }
  
  public void updateCalculatedMeasurements(Float acceleration, Float breaking, Float cornering) {
    this.calculatedAcceleration = acceleration;
    this.calculatedBreaking = breaking;
    this.calculatedCornering = cornering;
  }
  
  public void log() {
    
    StringBuilder logStringBuilder = new StringBuilder();
    
    logStringBuilder.append(DATE_FORMAT.format(date)).append(", ");
    logStringBuilder.append(TIME_FORMAT.format(date)).append(", ");
    //logStringBuilder.append(SystemClock.uptimeMillis()).append(", ");

    logStringBuilder.append(formatFloat(accelerometervalues[0])).append(", ");
    logStringBuilder.append(formatFloat(accelerometervalues[1])).append(", ");
    logStringBuilder.append(formatFloat(accelerometervalues[2])).append(", ");

    logStringBuilder.append(tiltDegrees).append(", ");

    logStringBuilder.append(formatFloat(acceleration)).append(", ");
    logStringBuilder.append(formatFloat(breaking)).append(", ");
    logStringBuilder.append(formatFloat(cornering)).append(", ");

    logStringBuilder.append(screen).append(", ");

    logStringBuilder.append(formatFloat(calculatedAcceleration)).append(", ");
    logStringBuilder.append(formatFloat(calculatedBreaking)).append(", ");
    logStringBuilder.append(formatFloat(calculatedCornering));

    final String logString = logStringBuilder.toString();
    Log.i(LOG_TAG, logString);
    
  }

  private String formatFloat(Float f) {
    if ( null == f ) {
      return "null";
    }
    return String.format("%.2f", f);
  }
  
}




Java Source Code List

name.nanek.greenerpedal.GreenerPedalApp.java
name.nanek.greenerpedal.activity.DisplayReadingsActivity.java
name.nanek.greenerpedal.activity.EditPrefsActivity.java
name.nanek.greenerpedal.activity.GraphAndShareActivity.java
name.nanek.greenerpedal.activity.support.APISafeKeyguardHider.java
name.nanek.greenerpedal.activity.support.BitmapUtil.java
name.nanek.greenerpedal.activity.support.LogLine.java
name.nanek.greenerpedal.activity.support.LowPassFilter.java
name.nanek.greenerpedal.activity.support.MessageOnlyFormatter.java
name.nanek.greenerpedal.activity.support.Prefs.java
name.nanek.greenerpedal.activity.support.ScreenLock.java
name.nanek.greenerpedal.activity.support.Sensors.java
name.nanek.greenerpedal.activity.support.ShareUtil.java
name.nanek.greenerpedal.activity.support.Trigger.java
name.nanek.greenerpedal.activity.support.TriggersResult.java
name.nanek.greenerpedal.activity.support.Views.java
name.nanek.greenerpedal.db.model.Reading.java
name.nanek.greenerpedal.db.model.dao.DataHelper.java
name.nanek.greenerpedal.db.model.dao.ReadingDao.java
name.nanek.greenerpedal.db.model.dao.support.DateUtil.java
name.nanek.greenerpedal.db.model.dao.support.DbUtil.java