org.android.activityminer.logic.features
Class FeatureExtractionThread<T extends Enum<T> & Dimensions>

Package class diagram package FeatureExtractionThread
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.features.FeatureExtractionThread<T>
Type Parameters:
T - the enumeration type for the dimensions
All Implemented Interfaces:
EventObserver<FeatureExtractionHelper.ProgressEvent>, ObservableEventSource<TaskFinishedEvent>, ObserverRegistration<TaskFinishedEvent>, WorkerThread, Runnable

public class FeatureExtractionThread<T extends Enum<T> & Dimensions>
extends ObservableWorkerThreadWithProgressNotification
implements EventObserver<FeatureExtractionHelper.ProgressEvent>

The feature extraction thread.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
private  double avgTimeForFeatureExtraction
          The average extraction time per cut-out.
private  Context context
          The activity context.
private  int extractedSampleCount
          The count of extracted samples.
private  List<Long> failedIds
          The recoding identifiers which failed to process.
private static int FEATURE_EXTRACTION_NOTIFICATION
          the feature extraction notification identifier
private  FeatureExtractionHelper<T> helper
          Helper to delegate feature extraction to
private  double processingTime
          The total processing time in seconds.
private  long[] sequenceIds
          The continuous recoding sequence identifiers to process.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
private FeatureExtractionThread(Context context, long[] sequenceIds, FeatureExtractionHelper<T> featureExtractionHelper, Class<? extends Activity> intentReceiver)
          Constructor
 
Method Summary
static ObservableWorkerThreadWithProgressNotification create(Context context, DBManager dbManager, Configuration config, long[] sequenceIds, boolean hasToAdaptToConfiguration, EventObserver<TaskFinishedEvent> finishedObserver, Class<? extends Activity> intentReceiver)
          Does create a feature extraction thread for the given configuration and recording identifiers.
static ObservableWorkerThreadWithProgressNotification createAndRun(Context context, DBManager dbManager, Configuration config, long[] sequenceIds, boolean hasToAdaptToConfiguration, EventObserver<TaskFinishedEvent> finishedObserver, Class<? extends Activity> intentReceiver)
          Does create and execute a feature extraction thread for the given configuration and recording identifiers.
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
 void onEvent(ObservableEventSource<? extends FeatureExtractionHelper.ProgressEvent> eventSource, FeatureExtractionHelper.ProgressEvent observedEvent)
           
 
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

FEATURE_EXTRACTION_NOTIFICATION

private static final int FEATURE_EXTRACTION_NOTIFICATION
the feature extraction notification identifier

See Also:
Constant Field Values

context

private final Context context
The activity context.


helper

private final FeatureExtractionHelper<T extends Enum<T> & Dimensions> helper
Helper to delegate feature extraction to


sequenceIds

private final long[] sequenceIds
The continuous recoding sequence identifiers to process.


failedIds

private final List<Long> failedIds
The recoding identifiers which failed to process.


avgTimeForFeatureExtraction

private double avgTimeForFeatureExtraction
The average extraction time per cut-out.


extractedSampleCount

private int extractedSampleCount
The count of extracted samples.


processingTime

private double processingTime
The total processing time in seconds.

Constructor Detail

FeatureExtractionThread

private FeatureExtractionThread(Context context,
                                long[] sequenceIds,
                                FeatureExtractionHelper<T> featureExtractionHelper,
                                Class<? extends Activity> intentReceiver)
Constructor

Parameters:
context - the application context
sequenceIds - a list with the sequence identifiers to process
featureExtractionHelper - the feature extraction helper
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

createAndRun

public static final ObservableWorkerThreadWithProgressNotification createAndRun(Context context,
                                                                                DBManager dbManager,
                                                                                Configuration config,
                                                                                long[] sequenceIds,
                                                                                boolean hasToAdaptToConfiguration,
                                                                                EventObserver<TaskFinishedEvent> finishedObserver,
                                                                                Class<? extends Activity> intentReceiver)
Does create and execute a feature extraction thread for the given configuration and recording identifiers.

Parameters:
context - the context of the caller
dbManager - the database manager to use
config - the configuration to use
sequenceIds - the list with the continuous recoding sequence identifiers to process
hasToAdaptToConfiguration - flag if adaption is required (can only happen in batch export mode)
finishedObserver - the finished event observer
intentReceiver - the intent receiver class
Returns:
the created and started feature extraction thread

create

public static ObservableWorkerThreadWithProgressNotification create(Context context,
                                                                    DBManager dbManager,
                                                                    Configuration config,
                                                                    long[] sequenceIds,
                                                                    boolean hasToAdaptToConfiguration,
                                                                    EventObserver<TaskFinishedEvent> finishedObserver,
                                                                    Class<? extends Activity> intentReceiver)
Does create a feature extraction thread for the given configuration and recording identifiers.

Parameters:
context - the context of the caller
dbManager - the database manager to use
config - the configuration to use
sequenceIds - the list with the continuous recoding sequence identifiers to process
hasToAdaptToConfiguration - flag if adaption is required (can only happen in batch export mode)
finishedObserver - the finished event observer
intentReceiver - the intent receiver class
Returns:
the created feature extraction thread

onEvent

public void onEvent(ObservableEventSource<? extends FeatureExtractionHelper.ProgressEvent> eventSource,
                    FeatureExtractionHelper.ProgressEvent observedEvent)
Specified by:
onEvent in interface EventObserver<FeatureExtractionHelper.ProgressEvent>