Package se.hendeby.sensordata
Class StreamSensorDataReader
java.lang.Object
se.hendeby.sensordata.SensorDataReader
se.hendeby.sensordata.StreamSensorDataReader
Read data streamed from the Sensor Fusion Android app.
This class is responsible for setting up a server and to extract measurement
information streamed from the Sensor Fusion Android app. This is a
specialization of the
SensorDataReader class.-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.StreamSensorDataReader(int port) Constructor accepting setting the port to create a server on. -
Method Summary
Modifier and TypeMethodDescriptionprotected double[]get(long maxDiff) Get a set of data with matching time stamp.Extract the next received SensorData object Extracts a SensorData object from the receiver queue.voidreset()Resets the data stream This merely clears all outstanding SensorData objects so for not handled.static voidshowIPs()Show IP addresses of available interfaces This is a convenience function to determine the IP address of all available interfaces.voidstart()Start up a server to which the Sensor Fusion app can connect.voidstart(int n) Start up a server to which the Sensor Fusion app can connect.voidstart(InetAddress bindAddr) Start up a server to which the Sensor Fusion app can connect.booleanstatus()The status of the current connection.voidstop()Stop the server.Methods inherited from class se.hendeby.sensordata.SensorDataReader
finalize, getAll, getNext
-
Constructor Details
-
StreamSensorDataReader
public StreamSensorDataReader()Default constructor. -
StreamSensorDataReader
public StreamSensorDataReader(int port) Constructor accepting setting the port to create a server on.- Parameters:
port- Port to use for the connection.
-
-
Method Details
-
start
Start up a server to which the Sensor Fusion app can connect.- Specified by:
startin classSensorDataReader- Throws:
IOException- If an I/O error is encountered an exception is thrown.
-
start
Start up a server to which the Sensor Fusion app can connect.- Parameters:
n- Interface number to bind to.- Throws:
IOException- Throws an IOException on error conditions.
-
start
Start up a server to which the Sensor Fusion app can connect.- Parameters:
bindAddr- Which is the interface to bind.- Throws:
IOException- Throws an IOException on error conditions.
-
stop
public void stop()Stop the server. This cases all current connections to be closed down.- Specified by:
stopin classSensorDataReader
-
get
protected double[] get(long maxDiff) Get a set of data with matching time stamp. Reads the next available SensorData objects and return the measurements less than maxDiff milliseconds apart in a double vector, where the index in the vector is given by the SensorDatas offset value.- Specified by:
getin classSensorDataReader- Parameters:
maxDiff- Milliseconds between measurements to be considered from the same sample time.- Returns:
- A double array containing the measurements from the next available timestamp
-
getSensorData
Description copied from class:SensorDataReaderExtract the next received SensorData object Extracts a SensorData object from the receiver queue.- Specified by:
getSensorDatain classSensorDataReader- Returns:
- A SensorData object of null if there is no more queued objects.
-
reset
public void reset()Resets the data stream This merely clears all outstanding SensorData objects so for not handled.- Specified by:
resetin classSensorDataReader
-
status
public boolean status()The status of the current connection.- Specified by:
statusin classSensorDataReader- Returns:
- True if the connection is alive and expected to successfully perform its next request.
-
showIPs
Show IP addresses of available interfaces This is a convenience function to determine the IP address of all available interfaces. The output is printed to the standard output stream.- Throws:
SocketException- Throws a SocketException on error conditions.
-