org.android.activityminer.logic.timeseries
Class AbstractObservableSensorScanner<T extends Enum<T> & Dimensions,U>

Package class diagram package AbstractObservableSensorScanner
java.lang.Object
  extended by de.unikassel.android.sdcframework.util.ObservableEventSourceImpl<SensorObservation<T,U>>
      extended by org.android.activityminer.logic.timeseries.AbstractObservableSensorScanner<T,U>
Type Parameters:
T - the enumeration type for the dimensions
U - the data type for the dimension values
All Implemented Interfaces:
ObservableEventSource<SensorObservation<T,U>>, ObserverRegistration<SensorObservation<T,U>>, ObservableSensorScanner<T,U>, SensorScanner, ActivatableComponent
Direct Known Subclasses:
ObservableAccSensorScanner, ObservableSensorScannerImpl

public abstract class AbstractObservableSensorScanner<T extends Enum<T> & Dimensions,U>
extends ObservableEventSourceImpl<SensorObservation<T,U>>
implements ObservableSensorScanner<T,U>

Generic and abstract implementation of an observable sensor scanner.


Field Summary
private  ActivatableComponent activationDelegation
          activatable component implementation to delegate to
private  LooperThread looperThread
          The looper tread with the associated handler.
private  TimerTask timerTask
          The timer task for sensor observation.
 
Constructor Summary
AbstractObservableSensorScanner(long sampleRate, long initialDelay)
          Constructor
 
Method Summary
 boolean doScan(Long ts)
          Method to trigger the scanning of connected data sources.
 void doTerminate()
          Does terminate the associated thread.
 long getFrequency()
          Getter for the sample frequency in milliseconds
protected abstract  SensorObservation<T,U> getNewSensorObservation(Long ts)
          Does take samples from sources and creates a new sensor observation.
private  TimerTask getTimerTask(long samplingFrequency, LooperThread looperThread, long initialDelay)
          Getter for the timer task
 boolean isActive()
          Test method for the actiation state.
protected  void onActivationStateChange(boolean active)
          Handler for activation state changes
 void setActivationState(boolean active)
          Method to set the activation state of the component
protected  void setInitilized()
          Must be called in Constructor of extending classes when construction is finished
 
Methods inherited from class de.unikassel.android.sdcframework.util.ObservableEventSourceImpl
getObservers, hasObservers, notify, onObserverRegistration, onObserverUnregistration, registerEventObserver, removeAllObservers, unregisterEventObserver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.android.activityminer.logic.timeseries.ObservableSensorScanner
getAccSource
 
Methods inherited from interface org.android.activityminer.logic.timeseries.SensorScanner
delegateNotify
 
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
 

Field Detail

activationDelegation

private final ActivatableComponent activationDelegation
activatable component implementation to delegate to


timerTask

private final TimerTask timerTask
The timer task for sensor observation.


looperThread

private final LooperThread looperThread
The looper tread with the associated handler.

Constructor Detail

AbstractObservableSensorScanner

public AbstractObservableSensorScanner(long sampleRate,
                                       long initialDelay)
Constructor

Parameters:
sampleRate - the rate in milliseconds samples are taken with
initialDelay - the initial start delay
Method Detail

getTimerTask

private final TimerTask getTimerTask(long samplingFrequency,
                                     LooperThread looperThread,
                                     long initialDelay)
Getter for the timer task

Parameters:
samplingFrequency - the frequency in milliseconds samples are taken with
looperThread - the looper thread to use
initialDelay - the initial delay
Returns:
the timer task

setInitilized

protected void setInitilized()
Must be called in Constructor of extending classes when construction is finished


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

onActivationStateChange

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

Parameters:
active - the new activation state

doTerminate

public final void doTerminate()
Description copied from interface: ObservableSensorScanner
Does terminate the associated thread.

Specified by:
doTerminate in interface ObservableSensorScanner<T extends Enum<T> & Dimensions,U>

doScan

public final boolean doScan(Long ts)
Description copied from interface: SensorScanner
Method to trigger the scanning of connected data sources.

Specified by:
doScan in interface SensorScanner
Parameters:
ts - the requested time stamp
Returns:
true if a sample was taken, false otherwise

getNewSensorObservation

protected abstract SensorObservation<T,U> getNewSensorObservation(Long ts)
Does take samples from sources and creates a new sensor observation.

Parameters:
ts - the time stamp for the observation
Returns:
a new sensor observation, or null in case of an error

getFrequency

public final long getFrequency()
Getter for the sample frequency in milliseconds

Returns:
the sample frequency.