Device Class Reference
A Device object represents everything a Plugin should need to perform operations between a host and device. More...
Public Member Functions | |
Device (String id, String type, Plugin plugin) | |
A new Device with no short name. | |
Device (String id, String type, String shortName, Plugin plugin) | |
A new Device with a GUI-friendly short name. | |
void | addFilter (int id, String arg) throws IOException |
Instruct the device to add a new filter to its filtering pipeline. | |
void | addDeviceListener (DeviceListener dl) |
Adds a new listener for this device. | |
void | calibrate () throws IOException |
Calibrates the accelerometers of the device. | |
void | connect (DeviceListener dl) throws IOException |
Formally connect to a specified device. | |
void | disconnect () throws IOException |
Disconnect a formally connected device. | |
boolean | equals (Object other) |
A Device is considered equal to another Device if and only if:. | |
String[] | getActiveFilters () throws IOException |
Returns a list of filters currently active on the device. | |
String[] | getAvailFilters () |
Returns a list of available filters that this device supports. | |
int | getSampleRate () throws IOException |
Returns the current sample rate of this device in hertz. | |
String | getShortName () |
Return the GUI-friendly name of this device. | |
boolean | isConnected () |
Determines if this Device is currently connected or just discoverable. | |
void | notifyAcceleration (Accel3D acc) |
Give the Device the most recent acceleration performed so it can notify anything listening on it. | |
void | notifyDisconnect () |
Used to notify the DeviceListeners that the device has unexpectedly disconnected from the host. | |
void | notifyGestureEnd (boolean good) |
Notifies listeners that a gesture has ended. | |
void | removeDeviceListener (DeviceListener dl) |
Removes a DeviceListener from this Device. | |
void | removeFilter (int index) throws IOException |
Removes a Filter from the list of active filters on this Device. | |
void | resetFilters () throws IOException |
Sends a message to the Device removing any filters currently in use. | |
void | setSamplingRate (int rate) throws IOException |
Sets the sampling rate, in hertz, of this Device. | |
void | setShortName (String name) |
Declare a new short name for this device. | |
String | toString () |
Converts this object to a String. | |
Public Attributes | |
final String | id |
unique identifier for this device | |
final String | type |
what kind of device this is (SPOT, ANDROID, . |
Detailed Description
A Device object represents everything a Plugin should need to perform operations between a host and device.
Devices are set up such that the FROG platform does not have to keep track of which Plugin a Device belongs to, but rather, can just call methods on Devices which pass the command on to their respective Plugin.
Constructor & Destructor Documentation
Member Function Documentation
void addDeviceListener | ( | DeviceListener | dl | ) |
Adds a new listener for this device.
When Gestures are performed they should be notified and given the gestures from that event.
- Parameters:
-
dl the DeviceListener you wish to add.
- See also:
- DeviceListener
void addFilter | ( | int | id, | |
String | arg | |||
) | throws IOException |
Instruct the device to add a new filter to its filtering pipeline.
If the device supports on-board filtering, this method should communicate both what type of filter to use as well as an argument string for that filter. The id should come from the getAvailFilters method (it is the index of the array of the desired filter).
- Parameters:
-
id the filter desired. This should be the index from the array of filters. arg the argument String for this filter
- Exceptions:
-
IOException if any communication error occurs
void calibrate | ( | ) | throws IOException |
Calibrates the accelerometers of the device.
If the device requires calibration or any adjustment before use, this method can be called to provide a custom GUI instructing the user on how to set up their device (such as setting it flat on a table or throwing it out a window).
- Exceptions:
-
IOException if any communication error occurs
- See also:
- Plugin.calibrate(Device)
void connect | ( | DeviceListener | dl | ) | throws IOException |
Formally connect to a specified device.
After the user has been presented with a list of discovered devices, the one they pick must be connected to so that a formal connection (and probably a new Thread) can be established and they can begin using the device.
- Parameters:
-
dl a DeviceListener to listen to this connection. Could be null but not recommended.
- Exceptions:
-
IOException if any communication error occurs. It should be assumed that if this exception is thrown, the device is NOT connected.
- See also:
- Plugin.connect(Device)
void disconnect | ( | ) | throws IOException |
Disconnect a formally connected device.
This method should tear down any facilities that were set up to support the device. This can be called by the user when they no longer wish to use the device, but you may also wish to use this method as a clean-up method in the event of an IOException so that the device could be connected to again. A successful disconnect causes all listeners to be removed.
- Exceptions:
-
IOException if the device cannot be sent a disconnect signal. Regardless, a best attempt must be made to tear down any local resources tied to this device.
- See also:
- Plugin.disconnect(Device)
boolean equals | ( | Object | other | ) |
String [] getActiveFilters | ( | ) | throws IOException |
Returns a list of filters currently active on the device.
If the Device does not support on-device filtering, a null
or empty array may be returned.
- Returns:
- the list of currently active filters on the device in the order in which they were instantiated
- See also:
- Plugin.getActiveFilters(Device)
String [] getAvailFilters | ( | ) |
Returns a list of available filters that this device supports.
The array of strings returned by this method should be in a specific order as the index of the array will be used to communicate with the device later.
- Returns:
- a list of Strings containing the names of the filters supported
- See also:
- Plugin.getAvailFilters()
int getSampleRate | ( | ) | throws IOException |
Returns the current sample rate of this device in hertz.
- Returns:
- the current sample rate in hertz
- See also:
- Plugin.getSampleRate(Device)
String getShortName | ( | ) |
Return the GUI-friendly name of this device.
Usually this name is a shortened version of the id.
- Returns:
- the short name of this device
boolean isConnected | ( | ) |
Determines if this Device is currently connected or just discoverable.
This is set by the Device#connect(DeviceListener) method.
- Returns:
true
for connected.false
if not.
void notifyAcceleration | ( | Accel3D | acc | ) |
Give the Device the most recent acceleration performed so it can notify anything listening on it.
- Parameters:
-
acc a single XYZ sample from the device's accelerometers
- See also:
- DeviceListener
- AccelEvent
void notifyDisconnect | ( | ) |
Used to notify the DeviceListeners that the device has unexpectedly disconnected from the host.
It should not be called when the disconnect was planned (i.e. called by the disconnect() method).
void notifyGestureEnd | ( | boolean | good | ) |
Notifies listeners that a gesture has ended.
- Parameters:
-
good true
for a complete gesture,false
if something went wrong
void removeDeviceListener | ( | DeviceListener | dl | ) |
Removes a DeviceListener from this Device.
The listener will no longer be notified of AccelEvents.
- Parameters:
-
dl the DeviceListener to remove
- See also:
- DeviceListener
void removeFilter | ( | int | index | ) | throws IOException |
void resetFilters | ( | ) | throws IOException |
Sends a message to the Device removing any filters currently in use.
This method makes it possible for the user to edit or remove filters the Device is performing. This method does nothing if on-board filtering cannot be done by this type of Device.
- Exceptions:
-
IOException if any communication error occurs
void setSamplingRate | ( | int | rate | ) | throws IOException |
Sets the sampling rate, in hertz, of this Device.
If the Device is not compatible with changing the sampling frequency, this method should return immediately.
- Parameters:
-
rate the rate to sample, in hertz
- See also:
- Plugin.setSampleRate(Device, int)
void setShortName | ( | String | name | ) |
Declare a new short name for this device.
It is recommended that the name be kept under 8 characters in length and be closely related to the id of this device.
- Parameters:
-
name the new short name for this device
String toString | ( | ) |
Converts this object to a String.
- Returns:
- type followed by the id
- See also:
- Object.toString()
Member Data Documentation
final String id |
unique identifier for this device
final String type |
what kind of device this is (SPOT, ANDROID, .
..)
The documentation for this class was generated from the following file:
- /Users/dev/Documents/SVN brazos.cs.tcu.edu/trunk/FROG/src/frog/plugin/Device.java