Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## eu.ensam.ii.vrpn
Class VrpnClient

    java.lang.Object
      eu.ensam.ii.vrpn.VrpnClient

    public class VrpnClient

extends Object

Send updates button, analog and tracker updates to the JsonNet Vrpn server.

A application that uses the Vrpn widgets must initialize the unique instance of this class by calling `setUri` before the widgets are used.

This class is not thread-safe. The methods `sendButton` and `sendAnalog` must be called from the main UI thread

Currently the messages neither include a timestamp nor a sequence number

TODO Add timestamps and sequence numbers Add a method to allow sending TODO tracker updates from the widgets

Method Summary
`void` | `enableTiltTracker(boolean enable)` Enables or disable the tilt tracker.
`static VrpnClient` | `getInstance()` Returns the unique VrpnClient instance
`void` | `onAccuracyChanged(Sensor sensor, int accuracy)` Called by the system when the sensor accuracy changes This method is empty and should not be called by widgets
`void` | `onSensorChanged(SensorEvent event)` Called by the system when a sensor data changes.
`void` | `sendAnalog(int channelId, double channelValue)` Send an update to a Vrpn Analog channel.
`void` | `sendButton(int buttonId, boolean buttonState)` Send an update to a Vrpn Button.
`void` | `setupVrpnServer(InetAddress hostAddress, int port)` Initializes the address and port of the VRPN server.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### getInstance

    public static VrpnClient getInstance()

  Returns the unique VrpnClient instance

### setupVrpnServer

    public void setupVrpnServer(InetAddress hostAddress,
                                int port)

  Initializes the address and port of the VRPN server.

  This method must be called before sending any update to the server.

  Note that the widgets trigger updates when they they are displayed for the first time. So this method must be called before calling `setContentView` in the main `activity` `setContentView` `onCreate` method

  Parameters:
    `host` - a string that is a valid host name or IP address
    `port` - the port number of the VRPN server

### sendButton

    public void sendButton(int buttonId,
                           boolean buttonState)

  Send an update to a Vrpn Button. This update will trigger a button callback on the application side

  Parameters:
    `buttonId` - the button number. Invalid button numbers are ignored on this side, but may trigger an error message on the Vrpn server
    `buttonState` - the new status of the button

### sendAnalog

    public void sendAnalog(int channelId,
                           double channelValue)

  Send an update to a Vrpn Analog channel. This update will trigger an analog callback on the application side

  Parameters:
    `channelId` - The channel number. Invalid channel numbers are ignored on this side but, they may trigger an error message on the Vrpn server
    `channelValue` - the data that will be sent on the analog channel

### enableTiltTracker

    public void enableTiltTracker(boolean enable)

  Enables or disable the tilt tracker. The tilt tracker send a tracker update with a quaternion that rotates the "earth vertical up" vector to the +Z vector in device coordinates. See `SensorEvent` for a description of the device coordinate system. This quaternion can be used to retrieve the roll and pitch of the device.

  Parameters:
    `enable` - `true` enables the tilt tracker updates and `false` disable the tilt tracker updates

### onAccuracyChanged

    public void onAccuracyChanged(Sensor sensor,
                                  int accuracy)

  Called by the system when the sensor accuracy changes This method is empty and should not be called by widgets

### onSensorChanged

    public void onSensorChanged(SensorEvent event)

  Called by the system when a sensor data changes. This method retrieves the Android sensor object. If an vrpn Tracker is active that involves this sensor object this method sends a Vrpn tracker update to the appropriate tracker. packages the sensor data into a JSON object then send the JSON object onto an UDP socket. The target socket endpoint configuration is configured by calling setupVrpnServer

Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD