de.unikassel.android.sdcframework.devices
Class SampleTakingDeviceScanner

Package class diagram package SampleTakingDeviceScanner
java.lang.Object
  extended by de.unikassel.android.sdcframework.util.ObservableEventSourceImpl<Sample>
      extended by de.unikassel.android.sdcframework.devices.AbstractSensorDeviceScanner
          extended by de.unikassel.android.sdcframework.devices.SampleTakingDeviceScanner
All Implemented Interfaces:
SensorDeviceScanner, ObservableEventSource<Sample>, ObserverRegistration<Sample>
Direct Known Subclasses:
AccelerometerDeviceScanner, GPSDeviceScanner, GSMDeviceScanner, GyroscopeDeviceScanner, MagneticFieldDeviceScanner, NetworkLocationDeviceScanner, OrientationDeviceScanner, PassiveSampleTakingDeviceScanner, PressureDeviceScanner, TemperatureDeviceScanner

public abstract class SampleTakingDeviceScanner
extends AbstractSensorDeviceScanner

Base class for sensor device scanner types, which do active take a sample of the associated device in the configured frequency.

The timing is done by the usage of an OS handler to schedule the timed task.
This scanner is designed to work together with devices implementing the SampleProvidingSensorDevice interface.

See Also:
SampleProvidingSensorDevice, AccelerometerDeviceScanner, GSMDeviceScanner, GPSDeviceScanner

Field Summary
private  Handler handler
          The handler used for timing instead of a timer object
private  SampleTakingTask timerTask
          The timer task to be executed on timer event
 
Constructor Summary
SampleTakingDeviceScanner()
          Constructor
 
Method Summary
protected  Handler getHandler()
          Getter for the handler
protected  SampleTakingTask getTimerTask()
          Getter for the timer task
protected  boolean isCompatibleDevice(SensorDevice device)
          Validation method for a compatible device type
 void onDestroy(Context context)
          Is called when the owner destroys this scanner
private  void setHandler(Handler handler)
          Setter for the handler
private  void setTimerTask(SampleTakingTask timerTask)
          Setter for the timer task
 boolean start(Context context)
          Does start sampling
 boolean stop(Context context)
          Does stop sampling
 void takeSample()
          The cyclic executed method to take a sample from the device
 
Methods inherited from class de.unikassel.android.sdcframework.devices.AbstractSensorDeviceScanner
enable, getDevice, isActive, isEnabled, setActive, setDevice
 
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 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

handler

private Handler handler
The handler used for timing instead of a timer object


timerTask

private SampleTakingTask timerTask
The timer task to be executed on timer event

Constructor Detail

SampleTakingDeviceScanner

public SampleTakingDeviceScanner()
Constructor

Method Detail

isCompatibleDevice

protected boolean isCompatibleDevice(SensorDevice device)
Description copied from class: AbstractSensorDeviceScanner
Validation method for a compatible device type

Specified by:
isCompatibleDevice in class AbstractSensorDeviceScanner
Parameters:
device - the device to test for compatibility

takeSample

public void takeSample()
The cyclic executed method to take a sample from the device


getHandler

protected final Handler getHandler()
Getter for the handler

Returns:
the handler

setHandler

private final void setHandler(Handler handler)
Setter for the handler

Parameters:
handler - the handler to set

getTimerTask

protected final SampleTakingTask getTimerTask()
Getter for the timer task

Returns:
the timer task

setTimerTask

private final void setTimerTask(SampleTakingTask timerTask)
Setter for the timer task

Parameters:
timerTask - the timer task to set

start

public boolean start(Context context)
Description copied from interface: SensorDeviceScanner
Does start sampling

Parameters:
context - the application context
Returns:
true if successful started, false otherwise

stop

public boolean stop(Context context)
Description copied from interface: SensorDeviceScanner
Does stop sampling

Parameters:
context - the application context
Returns:
true if successful started, false otherwise

onDestroy

public void onDestroy(Context context)
Description copied from interface: SensorDeviceScanner
Is called when the owner destroys this scanner

Specified by:
onDestroy in interface SensorDeviceScanner
Overrides:
onDestroy in class AbstractSensorDeviceScanner
Parameters:
context - the application context