Class StreamSensorDataReader

java.lang.Object
se.hendeby.sensordata.SensorDataReader
se.hendeby.sensordata.StreamSensorDataReader

public class StreamSensorDataReader extends SensorDataReader
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

    Constructors
    Constructor
    Description
    Default constructor.
    Constructor accepting setting the port to create a server on.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected 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.
    void
    Resets the data stream This merely clears all outstanding SensorData objects so for not handled.
    static void
    Show IP addresses of available interfaces This is a convenience function to determine the IP address of all available interfaces.
    void
    Start up a server to which the Sensor Fusion app can connect.
    void
    start(int n)
    Start up a server to which the Sensor Fusion app can connect.
    void
    start(InetAddress bindAddr)
    Start up a server to which the Sensor Fusion app can connect.
    boolean
    The status of the current connection.
    void
    Stop the server.

    Methods inherited from class se.hendeby.sensordata.SensorDataReader

    finalize, getAll, getNext

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public void start() throws IOException
      Start up a server to which the Sensor Fusion app can connect.
      Specified by:
      start in class SensorDataReader
      Throws:
      IOException - If an I/O error is encountered an exception is thrown.
    • start

      public void start(int n) throws IOException
      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

      public void start(InetAddress bindAddr) throws IOException
      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:
      stop in class SensorDataReader
    • 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:
      get in class SensorDataReader
      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

      public SensorData getSensorData()
      Description copied from class: SensorDataReader
      Extract the next received SensorData object Extracts a SensorData object from the receiver queue.
      Specified by:
      getSensorData in class SensorDataReader
      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:
      reset in class SensorDataReader
    • status

      public boolean status()
      The status of the current connection.
      Specified by:
      status in class SensorDataReader
      Returns:
      True if the connection is alive and expected to successfully perform its next request.
    • showIPs

      public static void showIPs() throws SocketException
      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.