|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfrog.plugin.Device
public final class Device
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.
| Field Summary | |
|---|---|
String |
id
unique identifier for this device |
String |
type
what kind of device this is (SPOT, ANDROID, ...) |
| Constructor Summary | |
|---|---|
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 |
|
| Method Summary | |
|---|---|
void |
addDeviceListener(DeviceListener dl)
Adds a new listener for this device. |
void |
addFilter(int id,
String arg)
Instruct the device to add a new filter to its filtering pipeline. |
void |
calibrate()
Calibrates the accelerometers of the device. |
void |
connect(DeviceListener dl)
Formally connect to a specified device. |
void |
disconnect()
Disconnect a formally connected device. |
boolean |
equals(Object other)
A Device is considered equal to another Device if and only if: Other object is an instance of Device Other Device has equal id Other Device has equal type |
String[] |
getActiveFilters()
Returns a list of filters currently active on the device. |
String[] |
getAvailFilters()
Returns a list of available filters that this device supports. |
int |
getSampleRate()
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)
Removes a Filter from the list of active filters on this Device. |
void |
resetFilters()
Sends a message to the Device removing any filters currently in use. |
void |
setSamplingRate(int rate)
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public final String id
public final String type
| Constructor Detail |
|---|
public Device(String id,
String type,
Plugin plugin)
id - a unique identifier for this Devicetype - the type of Device (SPOT, ANDROID, ...)plugin - creator of this Device object
public Device(String id,
String type,
String shortName,
Plugin plugin)
id - a unique identifier for this Devicetype - the type of Device (SPOT, ANDROID, ...)shortName - a short name for this Device. Preferably less than 8
characters.plugin - creator of this Device object| Method Detail |
|---|
public void addFilter(int id,
String arg)
throws IOException
id - the filter desired. This should be the index from the array
of filters.arg - the argument String for this filter
IOException - if any communication error occursPlugin.addFilter(Device, int, String)public void addDeviceListener(DeviceListener dl)
dl - the DeviceListener you wish to add.DeviceListener
public void calibrate()
throws IOException
IOException - if any communication error occursPlugin.calibrate(Device)
public void connect(DeviceListener dl)
throws IOException
dl - a DeviceListener to listen to this connection. Could be
null but not recommended.
IOException - if any communication error occurs. It should be
assumed that if this exception is thrown, the
device is NOT connected.Plugin.connect(Device)
public void disconnect()
throws IOException
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.Plugin.disconnect(Device)public boolean equals(Object other)
equals in class Object
public String[] getActiveFilters()
throws IOException
null or empty array
may be returned.
IOExceptionPlugin.getActiveFilters(Device)public String[] getAvailFilters()
Plugin.getAvailFilters()
public int getSampleRate()
throws IOException
IOExceptionPlugin.getSampleRate(Device)public String getShortName()
public boolean isConnected()
connect(DeviceListener) method.
true for connected. false if not.public void notifyAcceleration(Accel3D acc)
acc - a single XYZ sample from the device's accelerometersDeviceListener,
AccelEventpublic void notifyDisconnect()
public void notifyGestureEnd(boolean good)
good - true for a complete gesture, false
if something went wrongDeviceListener.gestureComplete(boolean, Device)public void removeDeviceListener(DeviceListener dl)
dl - the DeviceListener to removeDeviceListener
public void removeFilter(int index)
throws IOException
index - the index on the array of active filters to remove
IOException
public void resetFilters()
throws IOException
IOException - if any communication error occursaddFilter(int, String),
Plugin.resetFilters(Device)
public void setSamplingRate(int rate)
throws IOException
rate - the rate to sample, in hertz
IOExceptionPlugin.setSampleRate(Device, int)public void setShortName(String name)
name - the new short name for this devicepublic String toString()
toString in class ObjectObject.toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||