de.Android_Seminar.backend
Interface SensorController

All Known Implementing Classes:
SensorControllerImpl

public interface SensorController

An interface to control the devices sensors, start a recording for different sensors and obtain data from them.

Author:
jonas

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.
 

Method Detail

startRecording

void startRecording(java.lang.String tag,
                    java.lang.String file)
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.

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:
stopRecording(), activateSensor(SensorType), deactivateSensor(SensorType)

stopRecording

void stopRecording()
Stops a recording immediately. Sensors will stay 'active' but no data will be recorded.

See Also:
SensorController#startRecording(String, String, float), activateSensor(SensorType), deactivateSensor(SensorType)

isRecordin

boolean isRecordin()
Determines if a recording is running

Returns:
true if data is recorded, false otherwise
See Also:
SensorController#startRecording(String, String, float), stopRecording()

activateSensor

void activateSensor(SensorType sensor)
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.

Parameters:
sensor - the sensor which should be activated
See Also:
SensorController#startRecording(String, String, float), deactivateSensor(SensorType)

activateSensor

void activateSensor(SensorType sensor,
                    int bufferSize)
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:
activateSensor(SensorType)

deactivateSensor

void deactivateSensor(SensorType sensor)
Disables a sensor and prevents it from recording data.

See Also:
SensorController#startRecording(String, String, float), activateSensor(SensorType), SensorType

getActiveSensors

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

getDeviceSensorNumber

int getDeviceSensorNumber()
Returns:
number of sensors that are active.
See Also:
activateSensor(SensorType), SensorType

getDeviceSensors

java.util.List<SensorType> getDeviceSensors()
Returns:
a list of all available sensors of the device
See Also:
SensorType

getSensorConfiguration

SensorConfiguration getSensorConfiguration()
Returns:
a SensorConfiguration for this SensorController
See Also:
SensorConfiguration

hasSensor

boolean hasSensor(SensorType sensor)
Determines if the device has a specific sensor

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

sensorIsActive

boolean sensorIsActive(SensorType sensor)
Checks, if a sensor is active or not

Parameters:
sensor - the sensor which should be checked
Returns:
true, if the sensor is active, false otherwise
See Also:
SensorType

getMaxValue

double getMaxValue(SensorType sensor)
returns an sensor specific, expected maximum value. The sensor has to be activated.

Parameters:
sensor - the sensor where the maximal value should be obtained from
Returns:
the maximal value the sensor can deliver
See Also:
SensorType

getMinValue

double getMinValue(SensorType sensor)
returns an sensor specific, expected minimum value. The sensor has to be activated.

Parameters:
sensor - the sensor where the minimal value should be obtained from
Returns:
the minimal value the sensor can deliver
See Also:
SensorType

getCurrentData

SensorData getCurrentData(SensorType sensor)
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 (activateSensor(SensorType)), or no data have been received already.
See Also:
SensorType, SensorData

getBufferedData

SensorData[] getBufferedData(SensorType sensor,
                             int amount)
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: (activateSensor(SensorType)). An empty array if no data were received from the sensor
See Also:
SensorType, SensorData

close

void close()
closes the SensorController and disables all sensors.

See Also:
deactivateSensor(SensorType)

getXmlCreator

XmlCreator getXmlCreator()
Returns:
a XmlCreator that gives you some xml creating/manipulation features for activities

getFileTransmitter

FileTransmitter getFileTransmitter()
Returns:
a that supplies features for transmitting a file to a server