org.android.activityminer.app.db
Class FeatureExtractionTask<T extends Enum<T> & Dimensions>

Package class diagram package FeatureExtractionTask
java.lang.Object
  extended by android.os.AsyncTask<Void,Integer,Long>
      extended by org.android.activityminer.app.db.FeatureExtractionTask<T>
Type Parameters:
T - the enumeration type for the dimensions
All Implemented Interfaces:
EventObserver<FeatureExtractionHelper.ProgressEvent>, ObservableEventSource<TaskFinishedEvent>, ObserverRegistration<TaskFinishedEvent>

public class FeatureExtractionTask<T extends Enum<T> & Dimensions>
extends AsyncTask<Void,Integer,Long>
implements ObservableEventSource<TaskFinishedEvent>, EventObserver<FeatureExtractionHelper.ProgressEvent>

The asynchronous feature extraction task.


Nested Class Summary
 
Nested classes/interfaces inherited from class android.os.AsyncTask
AsyncTask.Status
 
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  FeatureExtractionHelper<T> helper
          Helper to delegate feature extraction to
private  ObservableEventSource<TaskFinishedEvent> observableEventSource
          The observable event source for delegation.
private  double processingTime
          The total processing time in seconds.
private  Integer[] progress
          The progress counter.
private  ProgressDialog progressDialog
          The progress dialog.
private  DBRecordingStatisticSequenceEntry sequenceStatistics
          The sequence statistic to process.
 
Fields inherited from class android.os.AsyncTask
SERIAL_EXECUTOR, THREAD_POOL_EXECUTOR
 
Constructor Summary
private FeatureExtractionTask(Context context, DBRecordingStatisticSequenceEntry sequenceStatistics, FeatureExtractionHelper<T> featureExtractionHelper)
          Constructor
 
Method Summary
static void createAndRunTask(Context context, DBManager dbManager, Configuration config, DBRecordingStatisticSequenceEntry sequenceStatistic, EventObserver<? extends TaskFinishedEvent> finishedObserver)
          Does create and execute a feature extraction Task for the given configuration and recording identifiers.
protected  Long doInBackground(Void... params)
           
 void execute()
          An execution wrapper.
 boolean hasObservers()
           
 void notify(TaskFinishedEvent data)
           
private  void notifyForErrors()
          Does notify the user about the errors.
private  void notifyForResult()
          Does notify the average extraction time needed per cut-out.
 void onEvent(ObservableEventSource<? extends FeatureExtractionHelper.ProgressEvent> eventSource, FeatureExtractionHelper.ProgressEvent observedEvent)
           
protected  void onPostExecute(Long result)
           
protected  void onPreExecute()
           
protected  void onProgressUpdate(Integer... values)
           
 void registerEventObserver(EventObserver<? extends TaskFinishedEvent> observer)
           
 void removeAllObservers()
           
 void unregisterEventObserver(EventObserver<? extends TaskFinishedEvent> observer)
           
 
Methods inherited from class android.os.AsyncTask
cancel, execute, execute, executeOnExecutor, get, get, getStatus, isCancelled, onCancelled, onCancelled, publishProgress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

private final Context context
The activity context.


helper

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


progressDialog

private ProgressDialog progressDialog
The progress dialog.


sequenceStatistics

private final DBRecordingStatisticSequenceEntry sequenceStatistics
The sequence statistic to process.


failedIds

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


progress

private final Integer[] progress
The progress counter.


observableEventSource

private final ObservableEventSource<TaskFinishedEvent> observableEventSource
The observable event source for delegation.


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

FeatureExtractionTask

private FeatureExtractionTask(Context context,
                              DBRecordingStatisticSequenceEntry sequenceStatistics,
                              FeatureExtractionHelper<T> featureExtractionHelper)
Constructor

Parameters:
context - the application context
sequenceStatistics - the sequence statistics to process
featureExtractionHelper - the feature extraction helper
Method Detail

onPreExecute

protected void onPreExecute()
Overrides:
onPreExecute in class AsyncTask<Void,Integer,Long>

onPostExecute

protected void onPostExecute(Long result)
Overrides:
onPostExecute in class AsyncTask<Void,Integer,Long>

notifyForResult

private void notifyForResult()
Does notify the average extraction time needed per cut-out.


notifyForErrors

private void notifyForErrors()
Does notify the user about the errors.


onProgressUpdate

protected void onProgressUpdate(Integer... values)
Overrides:
onProgressUpdate in class AsyncTask<Void,Integer,Long>

doInBackground

protected Long doInBackground(Void... params)
Specified by:
doInBackground in class AsyncTask<Void,Integer,Long>

execute

public void execute()
An execution wrapper.


createAndRunTask

public static final void createAndRunTask(Context context,
                                          DBManager dbManager,
                                          Configuration config,
                                          DBRecordingStatisticSequenceEntry sequenceStatistic,
                                          EventObserver<? extends TaskFinishedEvent> finishedObserver)
Does create and execute a feature extraction Task 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
sequenceStatistic - the sequence statistics to process
finishedObserver - the finished event observer

registerEventObserver

public void registerEventObserver(EventObserver<? extends TaskFinishedEvent> observer)
Specified by:
registerEventObserver in interface ObserverRegistration<TaskFinishedEvent>

unregisterEventObserver

public void unregisterEventObserver(EventObserver<? extends TaskFinishedEvent> observer)
Specified by:
unregisterEventObserver in interface ObserverRegistration<TaskFinishedEvent>

removeAllObservers

public void removeAllObservers()
Specified by:
removeAllObservers in interface ObserverRegistration<TaskFinishedEvent>

notify

public void notify(TaskFinishedEvent data)
Specified by:
notify in interface ObservableEventSource<TaskFinishedEvent>

hasObservers

public boolean hasObservers()
Specified by:
hasObservers in interface ObservableEventSource<TaskFinishedEvent>

onEvent

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