org.android.activityminer.logic.timeseries
Class SensorObservationTask

Package class diagram package SensorObservationTask
java.lang.Object
  extended by org.android.activityminer.logic.util.AbstractActivatableComponentImpl
      extended by org.android.activityminer.logic.timeseries.SensorObservationTask
All Implemented Interfaces:
Runnable, TimerTask, ActivatableComponent

public final class SensorObservationTask
extends AbstractActivatableComponentImpl
implements TimerTask

This class does implement a runnable task to be executed delayed by an OS handler.

Every time this runnable is executed, it will post itself for another delayed execution according to the configured frequency. Each time the task is executed the sample taking method of the linked sensor scanner component is invoked. In case of delayed execution by the OS this task will calculate the optimal next execution time to stay in sync.


Field Summary
private  long frequency
          The execution time interval in milliseconds.
private  long initialDelay
          The initial delay.
private  LooperThread looperThread
          The looper thread with the handler to repost the task to, for delayed runnable execution.
private  long nextExpectedTime
          The last call time
private  SensorScanner sensorScanner
          The sensor observer.
 
Constructor Summary
SensorObservationTask(SensorScanner sensorScanner, LooperThread looperThread, long frequency, long initialDelay)
          Constructor
 
Method Summary
 long getFrequency()
          Getter for the frequency
protected  void onActivationStateChange(boolean active)
          Handler for activation state changes
 void run()
           
 
Methods inherited from class org.android.activityminer.logic.util.AbstractActivatableComponentImpl
isActive, setActivationState
 
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.util.ActivatableComponent
isActive, setActivationState
 

Field Detail

sensorScanner

private final SensorScanner sensorScanner
The sensor observer.


looperThread

private final LooperThread looperThread
The looper thread with the handler to repost the task to, for delayed runnable execution.


frequency

private final long frequency
The execution time interval in milliseconds.


initialDelay

private final long initialDelay
The initial delay.


nextExpectedTime

private long nextExpectedTime
The last call time

Constructor Detail

SensorObservationTask

public SensorObservationTask(SensorScanner sensorScanner,
                             LooperThread looperThread,
                             long frequency,
                             long initialDelay)
Constructor

Parameters:
sensorScanner - the sensor scanner instance
looperThread - the looperThread with the handler to repost the task to for delayed runnable execution
frequency - the execution frequency in milliseconds
initialDelay - the initial delay
Method Detail

getFrequency

public final long getFrequency()
Description copied from interface: TimerTask
Getter for the frequency

Specified by:
getFrequency in interface TimerTask
Returns:
the frequency

run

public final void run()
Specified by:
run in interface Runnable

onActivationStateChange

protected final void onActivationStateChange(boolean active)
Description copied from class: AbstractActivatableComponentImpl
Handler for activation state changes

Specified by:
onActivationStateChange in class AbstractActivatableComponentImpl
Parameters:
active - the new activation state