de.Android_Seminar.backend.impl
Class SensorControllerImpl

java.lang.Object
  extended by de.Android_Seminar.backend.impl.SensorControllerImpl
All Implemented Interfaces:
SensorController

public class SensorControllerImpl
extends java.lang.Object
implements SensorController


Constructor Summary
SensorControllerImpl(SensorManager manager, Activity activity)
          standard constructor
 
Method Summary
 void activateSensor(SensorType sensor)
          Activates a sensor and makes it ready to record data.
 void activateSensor(SensorType sensor, int bufferSize)
           
 void close()
          closes the SensorController and disables all sensors.
 void deactivateSensor(SensorType sensor)
          Disables a sensor and prevents it from recording data.
 java.util.List<SensorType> getActiveSensors()
           
 SensorData[] getBufferedData(SensorType sensor, int amount)
           
 SensorData getCurrentData(SensorType sensor)
           
 int getDeviceSensorNumber()
           
 java.util.List<SensorType> getDeviceSensors()
           
 FileTransmitter getFileTransmitter()
           
 double getMaxValue(SensorType sensor)
          returns an sensor specific, expected maximum value.
 double getMinValue(SensorType sensor)
          returns an sensor specific, expected minimum value.
 SensorConfiguration getSensorConfiguration()
           
 XmlCreator getXmlCreator()
           
 boolean hasSensor(SensorType sensor)
          Determines if the device has a specific sensor
 boolean isRecordin()
          Determines if a recording is running
 boolean sensorIsActive(SensorType sensor)
          Checks, if a sensor is active or not
 void startRecording(java.lang.String tag, java.lang.String file)
          Starts a data recording.
 void stopRecording()
          Stops a recording immediately.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SensorControllerImpl

public SensorControllerImpl(SensorManager manager,
                            Activity activity)
standard constructor

Method Detail

activateSensor

public void activateSensor(SensorType sensor)
Description copied from interface: SensorController
Activates a sensor and makes it ready to record data. Before a sensor is activated, its sample rate should be set up in the SensorConfiguration corresponding to this SensorController object. Otherwise the default sample rate determined by the SensorConfiguration class will be used.

Specified by:
activateSensor in interface SensorController
Parameters:
sensor - the sensor which should be activated
See Also:
SensorController#startRecording(String, String, float), SensorController.deactivateSensor(SensorType)

activateSensor

public void activateSensor(SensorType sensor,
                           int bufferSize)
Specified by:
activateSensor in interface SensorController
Parameters:
sensor - the sensor which should be activated
bufferSize - the size of the sensor's buffer. If the size is smaller than one, the default size will be used
See Also:
SensorController.activateSensor(SensorType)

close

public void close()
Description copied from interface: SensorController
closes the SensorController and disables all sensors.

Specified by:
close in interface SensorController
See Also:
SensorController.deactivateSensor(SensorType)

deactivateSensor

public void deactivateSensor(SensorType sensor)
Description copied from interface: SensorController
Disables a sensor and prevents it from recording data.

Specified by:
deactivateSensor in interface SensorController
See Also:
SensorController#startRecording(String, String, float), SensorController.activateSensor(SensorType), SensorType

getActiveSensors

public java.util.List<SensorType> getActiveSensors()
Specified by:
getActiveSensors in interface SensorController
Returns:
a list of all sensors that are active.
See Also:
SensorController.activateSensor(SensorType), SensorType

getBufferedData

public SensorData[] getBufferedData(SensorType sensor,
                                    int amount)
Specified by:
getBufferedData in interface SensorController
Parameters:
sensor - the sensor where the data should be obtained from
amount - the number of data sets that should be returned. If 'amount' is greater than the sernsor's buffer size, all buffered data will be returned.
Returns:
an array with latest 'amount' sensor data; null if no sensor of type SensorType was activated: (SensorController.activateSensor(SensorType)). An empty array if no data were received from the sensor
See Also:
SensorType, SensorData

getCurrentData

public SensorData getCurrentData(SensorType sensor)
Specified by:
getCurrentData in interface SensorController
Parameters:
sensor - the sensor where the data should be obtained from
Returns:
the latest data set the sensor has recorded; null if no sensor of type SensorType was activated (SensorController.activateSensor(SensorType)), or no data have been received already.
See Also:
SensorType, SensorData

getDeviceSensorNumber

public int getDeviceSensorNumber()
Specified by:
getDeviceSensorNumber in interface SensorController
Returns:
number of sensors that are active.
See Also:
SensorController.activateSensor(SensorType), SensorType

getDeviceSensors

public java.util.List<SensorType> getDeviceSensors()
Specified by:
getDeviceSensors in interface SensorController
Returns:
a list of all available sensors of the device
See Also:
SensorType

getMaxValue

public double getMaxValue(SensorType sensor)
Description copied from interface: SensorController
returns an sensor specific, expected maximum value. The sensor has to be activated.

Specified by:
getMaxValue in interface SensorController
Parameters:
sensor - the sensor where the maximal value should be obtained from
Returns:
the maximal value the sensor can deliver
See Also:
SensorType

getMinValue

public double getMinValue(SensorType sensor)
Description copied from interface: SensorController
returns an sensor specific, expected minimum value. The sensor has to be activated.

Specified by:
getMinValue in interface SensorController
Parameters:
sensor - the sensor where the minimal value should be obtained from
Returns:
the minimal value the sensor can deliver
See Also:
SensorType

getSensorConfiguration

public SensorConfiguration getSensorConfiguration()
Specified by:
getSensorConfiguration in interface SensorController
Returns:
a SensorConfiguration for this SensorController
See Also:
SensorConfiguration

hasSensor

public boolean hasSensor(SensorType sensor)
Description copied from interface: SensorController
Determines if the device has a specific sensor

Specified by:
hasSensor in interface SensorController
Parameters:
sensor - the sensor which should be checked for availability
Returns:
true, if the device has such a sensor, false otherwise.
See Also:
SensorType

isRecordin

public boolean isRecordin()
Description copied from interface: SensorController
Determines if a recording is running

Specified by:
isRecordin in interface SensorController
Returns:
true if data is recorded, false otherwise
See Also:
SensorController#startRecording(String, String, float), SensorController.stopRecording()

sensorIsActive

public boolean sensorIsActive(SensorType sensor)
Description copied from interface: SensorController
Checks, if a sensor is active or not

Specified by:
sensorIsActive in interface SensorController
Parameters:
sensor - the sensor which should be checked
Returns:
true, if the sensor is active, false otherwise
See Also:
SensorType

startRecording

public void startRecording(java.lang.String tag,
                           java.lang.String file)
Description copied from interface: SensorController
Starts a data recording. Data will be collected from all 'active' sensors. A recording will continue until the SensorConfiguration.getLastTimeout() value is reached. A recording will start after SensorConfiguration.getLastStartDelay() seconds.

Specified by:
startRecording in interface SensorController
Parameters:
tag - determines how a data set will be tagged. If the tag is a null value
file - the path and name of the xml file (audio file) the data will be saved to. If audio data will be recorded, for this data type a audio file (mp3) will be created. Thus all data, except audio data will be saved in a single xml file with path and name specified in the 'file' attribute. For audio data, a mp3 file will be created with path and name specified in the 'file' attribute. If no tag should be set, an empty string or a null value can be delivered.
See Also:
SensorController.stopRecording(), SensorController.activateSensor(SensorType), SensorController.deactivateSensor(SensorType)

stopRecording

public void stopRecording()
Description copied from interface: SensorController
Stops a recording immediately. Sensors will stay 'active' but no data will be recorded.

Specified by:
stopRecording in interface SensorController
See Also:
SensorController#startRecording(String, String, float), SensorController.activateSensor(SensorType), SensorController.deactivateSensor(SensorType)

getXmlCreator

public XmlCreator getXmlCreator()
Specified by:
getXmlCreator in interface SensorController
Returns:
a XmlCreator that gives you some xml creating/manipulation features for activities

getFileTransmitter

public FileTransmitter getFileTransmitter()
Specified by:
getFileTransmitter in interface SensorController
Returns:
a that supplies features for transmitting a file to a server