org.android.activityminer.logic.util
Class RawRecordingDataExportThread<T extends Enum<T> & Dimensions>

Package class diagram package RawRecordingDataExportThread
java.lang.Object
  extended by java.lang.Thread
      extended by de.unikassel.android.sdcframework.util.AbstractWorkerThread
          extended by org.android.activityminer.app.util.ObservableWorkerThreadWithProgressNotification
              extended by org.android.activityminer.logic.util.AbstractLinearAccelerationUpdateThread<T>
                  extended by org.android.activityminer.logic.util.RawRecordingDataExportThread<T>
Type Parameters:
T - the enumeration type for the dimensions
All Implemented Interfaces:
ObservableEventSource<TaskFinishedEvent>, ObserverRegistration<TaskFinishedEvent>, WorkerThread, Runnable

public class RawRecordingDataExportThread<T extends Enum<T> & Dimensions>
extends AbstractLinearAccelerationUpdateThread<T>

The thread for raw recording data export to csv file.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
private  DBManager dbManager
          The database manger reference
private  T[] dimensions
          The sensor observation dimensions
private  String fileName
          The destination file name
private  String lastError
          The last error message
private  PreparationCalculator<T> preCalculator
          The sensor observation preparation calculator normally applied to raw data before feature extraction
private static int RAW_RECORDING_DATA_EXPORT_NOTIFICATION
          the notification identifier
 
Fields inherited from class org.android.activityminer.logic.util.AbstractLinearAccelerationUpdateThread
context, isUseOwnLinAcc
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
private RawRecordingDataExportThread(Context context, DBManager dbManager, RuntimeConfiguration config, AbstractFeatureFactory<T> factory, String fileName, T[] dimensions, PreparationCalculator<T> preCalculator, Class<? extends Activity> intentReceiver)
          Constructor
 
Method Summary
private  void applyPreparationCalculator(SensorObservationCutout<T,Double> cutOut)
          Does apply the usual data preparation to a cut-out
static ObservableWorkerThreadWithProgressNotification create(Context context, DBManager dbManager, RuntimeConfiguration config, String fileName, EventObserver<TaskFinishedEvent> finishedObserver, Class<? extends Activity> intentReceiver)
          Does create and execute a feature vector export thread
static ObservableWorkerThreadWithProgressNotification createAndRun(Context context, DBManager dbManager, RuntimeConfiguration config, String fileName, EventObserver<TaskFinishedEvent> finishedObserver, Class<? extends Activity> intentReceiver)
          Does create and execute a feature vector export thread
protected  void doWork()
           
 String getErrorNotificationMsg()
          Getter for the error notification message
 int getNotificationId()
          Getter for the notification identifier
 String getResultNotificationMsg()
          Getter for the result notification message
 boolean hasSucceeded()
          Test method for success in case of termination
private  void writeCSVHeader(PrintWriter writer)
          Does generate a CSV header
private  void writeCSVRow(LabeledRecording<T> recording, PrintWriter writer)
          Does generate a CSV header from a training sample.
 
Methods inherited from class org.android.activityminer.logic.util.AbstractLinearAccelerationUpdateThread
updateLinearAccelerations
 
Methods inherited from class org.android.activityminer.app.util.ObservableWorkerThreadWithProgressNotification
broadcastProgress, doCleanUp, getApplicationContext, getFinalResult, getMaxProgress, getNotification, getTaskTitle, hasObservers, incrementAndNotifyProgress, incrementAndNotifyProgress, notify, notifyProgress, notifyProgress, registerEventObserver, removeAllObservers, setMaxProgress, unregisterEventObserver
 
Methods inherited from class de.unikassel.android.sdcframework.util.AbstractWorkerThread
doTerminate, hasTerminated, isLogging, isWorking, logMessage, run, setLogging, start, startWork, stopWork
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, 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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RAW_RECORDING_DATA_EXPORT_NOTIFICATION

private static final int RAW_RECORDING_DATA_EXPORT_NOTIFICATION
the notification identifier

See Also:
Constant Field Values

fileName

private final String fileName
The destination file name


lastError

private String lastError
The last error message


dbManager

private final DBManager dbManager
The database manger reference


dimensions

private final T extends Enum<T> & Dimensions[] dimensions
The sensor observation dimensions


preCalculator

private final PreparationCalculator<T extends Enum<T> & Dimensions> preCalculator
The sensor observation preparation calculator normally applied to raw data before feature extraction

Constructor Detail

RawRecordingDataExportThread

private RawRecordingDataExportThread(Context context,
                                     DBManager dbManager,
                                     RuntimeConfiguration config,
                                     AbstractFeatureFactory<T> factory,
                                     String fileName,
                                     T[] dimensions,
                                     PreparationCalculator<T> preCalculator,
                                     Class<? extends Activity> intentReceiver)
Constructor

Parameters:
context - the application context
dbManager - a reference to the database manager
config - the runtime configuration
factory - the feature factory
fileName - the filename
dimensions - the sensor observation dimensions
preCalculator - the preparation calculator
intentReceiver - the intent receiver class
Method Detail

getErrorNotificationMsg

public final String getErrorNotificationMsg()
Description copied from class: ObservableWorkerThreadWithProgressNotification
Getter for the error notification message

Specified by:
getErrorNotificationMsg in class ObservableWorkerThreadWithProgressNotification
Returns:
the error notification message

getResultNotificationMsg

public final String getResultNotificationMsg()
Description copied from class: ObservableWorkerThreadWithProgressNotification
Getter for the result notification message

Specified by:
getResultNotificationMsg in class ObservableWorkerThreadWithProgressNotification
Returns:
the result notification message

getNotificationId

public final int getNotificationId()
Description copied from class: ObservableWorkerThreadWithProgressNotification
Getter for the notification identifier

Specified by:
getNotificationId in class ObservableWorkerThreadWithProgressNotification
Returns:
the notification identifier

hasSucceeded

public final boolean hasSucceeded()
Description copied from class: ObservableWorkerThreadWithProgressNotification
Test method for success in case of termination

Specified by:
hasSucceeded in class ObservableWorkerThreadWithProgressNotification
Returns:
true if thread has successfully finished it's task, false in case of errors

doWork

protected final void doWork()
Specified by:
doWork in class AbstractWorkerThread

applyPreparationCalculator

private final void applyPreparationCalculator(SensorObservationCutout<T,Double> cutOut)
Does apply the usual data preparation to a cut-out

Parameters:
cutOut - the cut-out

writeCSVRow

private void writeCSVRow(LabeledRecording<T> recording,
                         PrintWriter writer)
Does generate a CSV header from a training sample.

Parameters:
recording - the training sample to generate CSV header from
writer - the writer to use

writeCSVHeader

private void writeCSVHeader(PrintWriter writer)
Does generate a CSV header

Parameters:
writer - the writer to use

createAndRun

public static final ObservableWorkerThreadWithProgressNotification createAndRun(Context context,
                                                                                DBManager dbManager,
                                                                                RuntimeConfiguration config,
                                                                                String fileName,
                                                                                EventObserver<TaskFinishedEvent> finishedObserver,
                                                                                Class<? extends Activity> intentReceiver)
Does create and execute a feature vector export thread

Parameters:
context - the context of the caller
dbManager - the database manager to use
config - the configuration to use
fileName - the destination file name
finishedObserver - the finished event observer
intentReceiver - the intent receiver class
Returns:
the created and started feature extraction thread

create

public static final ObservableWorkerThreadWithProgressNotification create(Context context,
                                                                          DBManager dbManager,
                                                                          RuntimeConfiguration config,
                                                                          String fileName,
                                                                          EventObserver<TaskFinishedEvent> finishedObserver,
                                                                          Class<? extends Activity> intentReceiver)
Does create and execute a feature vector export thread

Parameters:
context - the context of the caller
dbManager - the database manager to use
config - the configuration to use
fileName - the destination file name
finishedObserver - the finished event observer
intentReceiver - the intent receiver class
Returns:
the created feature extraction thread