de.unikassel.android.sdcframework.devices
Class SensorDeviceManagerImpl

Package class diagram package SensorDeviceManagerImpl
java.lang.Object
  extended by de.unikassel.android.sdcframework.util.LifeCycleObjectImpl
      extended by de.unikassel.android.sdcframework.devices.SensorDeviceManagerImpl
All Implemented Interfaces:
SensorDeviceManager, VisitableDevice, LifeCycleObject, ObserverRegistration<Sample>

public final class SensorDeviceManagerImpl
extends LifeCycleObjectImpl
implements SensorDeviceManager

Implementation of the sensor device manager implementation. It does create and supervises all sensor devices for available supported sensor types and is managing the sample observation and configuration updates for the device module.

The sensor device manager is the main interface to the device module.
To receive sensor samples an observer for the type Sample must register here.

See Also:
SensorDeviceFactory, ObservableEventSource

Field Summary
private  SensorDeviceFactory deviceFactory
          the sensor device factory
private  Map<SensorDeviceIdentifier,SensorDevice> mapDevices
          The sensor device map
private  ApplicationPreferenceManager preferenceManager
          The preference manager
 
Constructor Summary
SensorDeviceManagerImpl(ApplicationPreferenceManager preferenceManager)
          Constructor
 
Method Summary
 boolean accept(SensorDeviceVisitor visitor)
          Method to accept a visitor
private  void configureDevices(Context applicationContext)
          Does configure all devices with preference settings.
private  void configureLocationTracker(boolean active)
          Method to configure the location tracker
private  void createSensorDevices(Context applicationContext)
          Does create sensor device for all known available sensors
private  void destroyDevices(Context applicationContext)
          Does destroy the devices and scanner
private  void disableDeviceScanning(Context context)
          Does disable all running device scanners
 void enableLocationInfoPerSample(boolean enable)
          Method to enable location information per sample
private  SensorDeviceConfiguration getConfiguration(SensorDeviceIdentifier deviceIdentifier, Context applicationContext)
          Does determine the current device configuration
 SensorDeviceFactory getDeviceFactory()
          Getter for the device factory
 Collection<SensorDevice> getDevices()
          Getter for the devices
private  Map<SensorDeviceIdentifier,SensorDevice> getMapDevices()
          Getter for the devices map
 ApplicationPreferenceManager getPreferenceManager()
          Getter for the application preference manager
 void onCreate(Context applicationContext)
          Creation method
 void onDestroy(Context applicationContext)
          Destroy method
 void onPause(Context applicationContext)
          Pause method
 void onResume(Context applicationContext)
          Resume method
 void registerEventObserver(EventObserver<? extends Sample> observer)
          Does register an observer
 void removeAllObservers()
          Does remove all registered observers
private  void setMapDevices(Map<SensorDeviceIdentifier,SensorDevice> mapDevices)
          Setter for the devices map
 void unregisterEventObserver(EventObserver<? extends Sample> observer)
          Does delete a registered observer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

deviceFactory

private final SensorDeviceFactory deviceFactory
the sensor device factory


preferenceManager

private final ApplicationPreferenceManager preferenceManager
The preference manager


mapDevices

private Map<SensorDeviceIdentifier,SensorDevice> mapDevices
The sensor device map

Constructor Detail

SensorDeviceManagerImpl

public SensorDeviceManagerImpl(ApplicationPreferenceManager preferenceManager)
                        throws InvalidParameterException
Constructor

Parameters:
preferenceManager - the application preference manager
Throws:
InvalidParameterException - in case of invalid parameters
Method Detail

getDeviceFactory

public SensorDeviceFactory getDeviceFactory()
Getter for the device factory

Returns:
the device factory

getPreferenceManager

public final ApplicationPreferenceManager getPreferenceManager()
Getter for the application preference manager

Returns:
the application preference manager

getMapDevices

private Map<SensorDeviceIdentifier,SensorDevice> getMapDevices()
Getter for the devices map

Returns:
the devices map

setMapDevices

private void setMapDevices(Map<SensorDeviceIdentifier,SensorDevice> mapDevices)
Setter for the devices map

Parameters:
mapDevices - the devices map to set

getDevices

public Collection<SensorDevice> getDevices()
Getter for the devices

Returns:
the device maintained by the manager

createSensorDevices

private void createSensorDevices(Context applicationContext)
Does create sensor device for all known available sensors

Parameters:
applicationContext - the application context

disableDeviceScanning

private void disableDeviceScanning(Context context)
Does disable all running device scanners

Parameters:
context - the application context

configureDevices

private void configureDevices(Context applicationContext)
Does configure all devices with preference settings. This will automatically enable scanning of devices if configured.

Parameters:
applicationContext - the application context

getConfiguration

private SensorDeviceConfiguration getConfiguration(SensorDeviceIdentifier deviceIdentifier,
                                                   Context applicationContext)
Does determine the current device configuration

Parameters:
deviceIdentifier - the device identifier
applicationContext - the application context
Returns:
a configuration for the sensor device created from it's preferences

onCreate

public void onCreate(Context applicationContext)
Description copied from interface: LifeCycleObject
Creation method

Specified by:
onCreate in interface LifeCycleObject
Overrides:
onCreate in class LifeCycleObjectImpl
Parameters:
applicationContext - the application context

onResume

public void onResume(Context applicationContext)
Description copied from interface: LifeCycleObject
Resume method

Specified by:
onResume in interface LifeCycleObject
Overrides:
onResume in class LifeCycleObjectImpl
Parameters:
applicationContext - the application context

configureLocationTracker

private void configureLocationTracker(boolean active)
Method to configure the location tracker

Parameters:
active - flag is location tracker is active or not

onPause

public void onPause(Context applicationContext)
Description copied from interface: LifeCycleObject
Pause method

Specified by:
onPause in interface LifeCycleObject
Overrides:
onPause in class LifeCycleObjectImpl
Parameters:
applicationContext - the application context

onDestroy

public void onDestroy(Context applicationContext)
Description copied from interface: LifeCycleObject
Destroy method

Specified by:
onDestroy in interface LifeCycleObject
Overrides:
onDestroy in class LifeCycleObjectImpl
Parameters:
applicationContext - the application context

destroyDevices

private void destroyDevices(Context applicationContext)
Does destroy the devices and scanner

Parameters:
applicationContext - the application context

accept

public boolean accept(SensorDeviceVisitor visitor)
Description copied from interface: VisitableDevice
Method to accept a visitor

Specified by:
accept in interface VisitableDevice
Parameters:
visitor - the visitor to accept
Returns:
true if visitation has to continue, false otherwise

registerEventObserver

public void registerEventObserver(EventObserver<? extends Sample> observer)
Description copied from interface: ObserverRegistration
Does register an observer

Specified by:
registerEventObserver in interface ObserverRegistration<Sample>
Parameters:
observer - the observer to add

unregisterEventObserver

public void unregisterEventObserver(EventObserver<? extends Sample> observer)
Description copied from interface: ObserverRegistration
Does delete a registered observer

Specified by:
unregisterEventObserver in interface ObserverRegistration<Sample>
Parameters:
observer - the observer to delete

removeAllObservers

public void removeAllObservers()
Description copied from interface: ObserverRegistration
Does remove all registered observers

Specified by:
removeAllObservers in interface ObserverRegistration<Sample>

enableLocationInfoPerSample

public void enableLocationInfoPerSample(boolean enable)
Description copied from interface: SensorDeviceManager
Method to enable location information per sample

Specified by:
enableLocationInfoPerSample in interface SensorDeviceManager
Parameters:
enable - if true, location information will be added to each sample