Retrieving data from sensor

Retrieving data from a sensor in synchronous mode is done with SensorConnection.getData() method.

int bufferSize = 10;
Data[] data = sensorConnection.getData( bufferSize );

int bufferingPeriod = 1000;
boolean includeTimestamps = true;
boolean includeUncertainities = true;
boolean includeValidities = true;
Data[] data = sensorConnection.getData( bufferSize, bufferingPeriod, 
includeTimestamps, includeUncertainities, 
includeValidities );

SensorConnection.getData() returns the collected data of all the channels of the sensor, so the returned array will contain as many Data objects as there are channels. Data values can be accessed by using getIntValues(), getDoubleValues() or getObjectValues() methods of the Data object. Data object returns only the value type defined by the channel, otherwise it throws an IllegalStateException.

double[] doubleValues;
int[] intValues;
Data[] data = sensorConnection.getData( bufferSize );
if( data[0].getChannelInfo().getDataType() == ChannelInfo.TYPE_DOUBLE )
	{
	// Get double values
	doubleValues = data[0].getDoubleValues();
	}
else if( data[0].getChannelInfo().getDataType() == ChannelInfo.TYPE_INT )
	{
	// Get int values
	intValues = data[0].getIntValues();
	}