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

Package class diagram package AbstractFeatureExtractor
java.lang.Object
  extended by java.lang.Thread
      extended by de.unikassel.android.sdcframework.util.AbstractWorkerThread
          extended by de.unikassel.android.sdcframework.util.AbstractEventDispatcherImpl<SensorObservationCutout<T,Double>,FeatureVector>
              extended by org.android.activityminer.logic.features.AbstractFeatureExtractor<T>
Type Parameters:
T - the enumeration type for the dimensions
All Implemented Interfaces:
EventDispatcher<SensorObservationCutout<T,Double>,FeatureVector>, ObservableEventSource<FeatureVector>, ObserverRegistration<FeatureVector>, WorkerThread, Runnable, ActivatableComponent
Direct Known Subclasses:
AbstractCutoutFeatureExtractor, FeatureExtractorForAccSensorObservation, FeatureExtractorForSensorObservation

public abstract class AbstractFeatureExtractor<T extends Enum<T> & Dimensions>
extends AbstractEventDispatcherImpl<SensorObservationCutout<T,Double>,FeatureVector>
implements ObservableEventSource<FeatureVector>, ActivatableComponent

The feature extractor for sensor observations is a thread based component. It can be attached to an observable source for sensor observation cut-outs. Incoming cut-outs are cache in an internal Thread-safe queue.

On activation the thread removes the cut-outs one by one from the queue and features will be extracted. The created feature vectors will be notified to registered observers.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
private  ActivatableComponent activationDelegation
          activatable component implementation to delegate to
private  Context context
          The context.
private  FeatureExtractionConfiguration<T> featureConfiguration
          The feature configuration composed of the features and the associated shared calculators.
private  AtomicBoolean isExtracting
          Flag if the thread is active while extracting samples.
private  List<ObservationBasedCalulator<T>> observationBasedCalculators
          The list of the observationBasedCalculators for feature extraction.
private  AtomicLong totalExtractionTimeNeeded
          The total time needed for extraction.
 
Fields inherited from class de.unikassel.android.sdcframework.util.AbstractEventDispatcherImpl
collector
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
AbstractFeatureExtractor(FeatureTypes[] featureTypes, long sampleRate, Context context)
          Constructor
 
Method Summary
protected  void doWork()
           
 void featureTypeConfiguration(FeatureTypes[] featureTypes, long sampleRate)
          Configuration method.
 double getExtractionTime()
          Getter for the time to extract the features from cut-outs.
protected abstract  AbstractFeatureFactory<T> getFactory(Context context)
          Getter for the feature factory
protected  int getQueuedCutoutCount()
          Getter for the remaining count of queued cut-outs.
 boolean isActive()
          Test method for the actiation state.
protected  boolean isEctracting()
          Test method if the extractor is active while extracting features.
protected  void onActivationStateChange(boolean active)
          Handler for activation state changes
 void onDestroy()
          Destruction.
 void setActivationState(boolean active)
          Method to set the activation state of the component
 
Methods inherited from class de.unikassel.android.sdcframework.util.AbstractEventDispatcherImpl
doCleanUp, getCollector, getEventSource, hasObservers, notify, registerEventObserver, removeAllObservers, 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
 
Methods inherited from interface de.unikassel.android.sdcframework.util.facade.ObservableEventSource
hasObservers, notify
 
Methods inherited from interface de.unikassel.android.sdcframework.util.facade.ObserverRegistration
registerEventObserver, removeAllObservers, unregisterEventObserver
 
Methods inherited from interface de.unikassel.android.sdcframework.util.facade.WorkerThread
doTerminate, hasTerminated, isLogging, isWorking, setLogging, startWork, stopWork
 

Field Detail

activationDelegation

private final ActivatableComponent activationDelegation
activatable component implementation to delegate to


isExtracting

private final AtomicBoolean isExtracting
Flag if the thread is active while extracting samples.


totalExtractionTimeNeeded

private final AtomicLong totalExtractionTimeNeeded
The total time needed for extraction.


observationBasedCalculators

private final List<ObservationBasedCalulator<T extends Enum<T> & Dimensions>> observationBasedCalculators
The list of the observationBasedCalculators for feature extraction.


featureConfiguration

private FeatureExtractionConfiguration<T extends Enum<T> & Dimensions> featureConfiguration
The feature configuration composed of the features and the associated shared calculators.


context

private final Context context
The context.

Constructor Detail

AbstractFeatureExtractor

public AbstractFeatureExtractor(FeatureTypes[] featureTypes,
                                long sampleRate,
                                Context context)
Constructor

Parameters:
featureTypes - the types of the features to extract from the time series data
sampleRate - the configured sample rate
context - the context
Method Detail

featureTypeConfiguration

public void featureTypeConfiguration(FeatureTypes[] featureTypes,
                                     long sampleRate)
Configuration method.

Parameters:
featureTypes - the feature types for configuration
sampleRate - the configured sample rate

getFactory

protected abstract AbstractFeatureFactory<T> getFactory(Context context)
Getter for the feature factory

Parameters:
context - the context
Returns:
the feature factory to use

onActivationStateChange

protected void onActivationStateChange(boolean active)
Handler for activation state changes

Parameters:
active - the new activation state

setActivationState

public final void setActivationState(boolean active)
Description copied from interface: ActivatableComponent
Method to set the activation state of the component

Specified by:
setActivationState in interface ActivatableComponent
Parameters:
active - the activation sate flag

isActive

public final boolean isActive()
Description copied from interface: ActivatableComponent
Test method for the actiation state.

Specified by:
isActive in interface ActivatableComponent
Returns:
true if active, false otherwise

onDestroy

public void onDestroy()
Destruction.


getQueuedCutoutCount

protected final int getQueuedCutoutCount()
Getter for the remaining count of queued cut-outs.

Returns:
the remaining count of queued cut-outs

doWork

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

getExtractionTime

public final double getExtractionTime()
Getter for the time to extract the features from cut-outs.

Returns:
the time in milliseconds.

isEctracting

protected boolean isEctracting()
Test method if the extractor is active while extracting features.

Returns:
true if the extractor is active while extracting features