com.drismo.logic
Class TripLogger

java.lang.Object
  extended by java.lang.Thread
      extended by com.drismo.logic.TripLogger
All Implemented Interfaces:
NewLocationListener, QualityListener, java.lang.Runnable

public class TripLogger
extends java.lang.Thread
implements QualityListener, NewLocationListener

Class for making/updating log file. Logs the quality when monitoring, and location if specified.

See Also:
MonitorController

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private  android.content.Context context
           
private  android.location.Location currentLocation
           
private  boolean isLogging
           
private  java.lang.String logFileName
           
private  long mStartTime
           
private  java.io.OutputStreamWriter osw
           
private  java.util.ArrayList<java.lang.Integer> scoreList
           
private  int update_ms
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
TripLogger(android.content.Context con)
          The constructor
 
Method Summary
private  int calculateAverageScore()
          Calculates the avg. score
 void closeLogFile()
          closes the log file, so the application can startMonitoring a new one.
 java.lang.String getFileName()
          Get the file name for this log.
 void interrupt()
          Called when we want to stop logging.
 void newLogFile()
          makes a new log file.
 void onNewLocation(android.location.Location loc)
          This method is called when there is a location update.
 void onQualityUpdate(int newScore)
          This method is called when the score changes.
 void run()
           
 void start()
          Start the logging
private  void updateFile()
          Updates the log file with a new line of info.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

update_ms

private int update_ms

osw

private java.io.OutputStreamWriter osw

mStartTime

private long mStartTime

logFileName

private java.lang.String logFileName

context

private android.content.Context context

isLogging

private boolean isLogging

scoreList

private volatile java.util.ArrayList<java.lang.Integer> scoreList

currentLocation

private android.location.Location currentLocation
Constructor Detail

TripLogger

public TripLogger(android.content.Context con)
The constructor

Parameters:
con - the application context. This is used when we make/write a log file.
Method Detail

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

interrupt

public void interrupt()
Called when we want to stop logging.

Overrides:
interrupt in class java.lang.Thread

start

public void start()
Start the logging

Overrides:
start in class java.lang.Thread

newLogFile

public void newLogFile()
makes a new log file.


closeLogFile

public void closeLogFile()
closes the log file, so the application can startMonitoring a new one.


updateFile

private void updateFile()
Updates the log file with a new line of info.


calculateAverageScore

private int calculateAverageScore()
Calculates the avg. score

Returns:
the avg. score since last write to the log file.
See Also:
updateFile()

onQualityUpdate

public void onQualityUpdate(int newScore)
This method is called when the score changes. adds the new score to the scorelist.

Specified by:
onQualityUpdate in interface QualityListener
Parameters:
newScore - the new score
See Also:
Quality

onNewLocation

public void onNewLocation(android.location.Location loc)
This method is called when there is a location update.

Specified by:
onNewLocation in interface NewLocationListener
Parameters:
loc - the new location.

getFileName

public java.lang.String getFileName()
Get the file name for this log.

Returns:
the file name.