|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.phidgets.Phidget
public class Phidget
This is the base class from which all Phidget device classes derive. Don't create phidget devices directly using this class. Use the specific class for the device that you wish to access.
Constructor Summary | |
---|---|
Phidget(long handle)
Class constructor specifying a handle. |
Method Summary | |
---|---|
void |
addAttachListener(AttachListener l)
Adds an attach listener. |
void |
addDetachListener(DetachListener l)
Adds a detach listener. |
void |
addErrorListener(ErrorListener l)
Adds an error listener. |
void |
close()
Closes this Phidget. |
boolean |
equals(java.lang.Object comp)
Compares two Phidgets. |
java.lang.String |
getDeviceName()
Return the name of this Phidget. |
java.lang.String |
getDeviceType()
Return the device type of this Phidget. |
long |
getDeviceVersion()
Returns the device version of this Phidget. |
static java.lang.String |
getLibraryVersion()
Returns the library version. |
long |
getSerialNumber()
Returns the unique serial number of this Phidget. |
java.lang.String |
getTag()
Returns the tag associated with this Phidget. |
boolean |
isAttached()
Returns the attached status of this Phidget. |
void |
open(int serial)
Open this Phidget with a specific serial number. |
void |
openAny()
Open a this Phidget without a serial number. |
void |
removeAttachListener(AttachListener l)
Removes an attach listener. |
void |
removeDetachListener(DetachListener l)
Removes a detach listener. |
void |
removeErrorListener(ErrorListener l)
Removes an error listener. |
void |
setTag(java.lang.String tag)
Sets the Tag associated with this Phidget. |
java.lang.String |
toString()
Return a Sring describing this Phidget. |
void |
waitForAttachment()
Waits for this Phidget to become available. |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Phidget(long handle)
handle
- A native Handle points to the underlying phidget structure in the base phidget21 C library.Method Detail |
---|
public static final java.lang.String getLibraryVersion()
The version is retured at a string which contains the version number and build date.
public final long getSerialNumber() throws PhidgetException
open
to specify this specific Phidget to be opened.
PhidgetException
- If this Phidget is not opened and attached. See open
for information on determining if a device is attached.public final long getDeviceVersion() throws PhidgetException
PhidgetException
- If this Phidget is not opened and attached. See open
for information on determining if a device is attached.public final java.lang.String getDeviceType() throws PhidgetException
This function is mostly usefull if you are using the Phidget Manager
because it's attach and detach handlers
return {link com.phidgets.phidget phidget} objects, and you can use this method to determine their proper type.
PhidgetException
- If this Phidget is not opened and attached. See open
for information on determining if a device is attached.public final java.lang.String getDeviceName() throws PhidgetException
This lets you determine the specific type of a Phidget, within the broader classes of Phidgets, such as PhidgetInterfaceKit, or PhidgetServo
PhidgetException
- If this Phidget is not opened and attached. See open
for information on determining if a device is attached.public final boolean isAttached() throws PhidgetException
PhidgetException
- If this Phidget is not opened.public final java.lang.String getTag() throws PhidgetException
setTag
), and is non-volatile - so it is remembered
even if the Phidget is unplugged.
PhidgetException
- If this Phidget is not opened and attached, or if this Phidget does not support tags.
See open
for determining if a device is attached.public final void setTag(java.lang.String tag) throws PhidgetException
Tags can not currently be set from Windows because of driver incompatibility. Tags can be set from MacOS, Linux and Windows CE.
tag
- Tag
PhidgetException
- If this Phidget is not opened and attached, or if this Phidget does not support tags, or if this is
called from Windows. See open
for determining if a device is attached.public final void open(int serial) throws PhidgetException
Open is pervasive. What this means is that you can call open on a device before it is plugged in, and keep the device opened across device dis- and re-connections.
Open is Asynchronous. What this means is that open will return immediately –
before the device being opened is actually available, so you need to use either the attach event
or the waitForAttachment
method to determine if a device
is available before using it.
This version of open specifies a serial number - The serial number is a unique number assinged to each Phidget
during production and can be used to uniquely identify specific phidgets.
use openAny
to open a device without specifying the serial number.
serial
- Serial Number
PhidgetException
public final void openAny() throws PhidgetException
open
, except that it specifies no serial number. Therefore, the first available
Phidget will be opened. If there are two Phidgets of the same type attached to the system, you should specify a serial number, as
there is no guarantee which Phidget will be selected by the call to openAny().
PhidgetException
public final void close() throws PhidgetException
PhidgetException
- If this Phidget is not opened.public void waitForAttachment() throws PhidgetException
This method blocks indefinitely until the Phidget becomes available. This can be quite some time (forever), if the Phidget is never plugged in.
This method uses the attach handler internally to determine when the Phidget becomes available.
PhidgetException
- If this Phidget is not opened.public final void addAttachListener(AttachListener l)
There is no limit on the number of attach handlers that can be registered for a particular Phidget.
l
- An implemetation of the AttachListener
interfacepublic final void removeAttachListener(AttachListener l)
public final void addErrorListener(ErrorListener l)
There is no limit on the number of error handlers that can be registered for a particular Phidget.
l
- An implemetation of the ErrorListener
interfacepublic final void removeErrorListener(ErrorListener l)
public final void addDetachListener(DetachListener l)
Remember that many of the methods, if called on an unattached device, will throw a PhidgetException. This Exception can be checked to see if it was caused by a device being unattached, but a better method would be to regiter the detach handler, which could notify the main program logic that the device is no longer available, disable GUI controls, etc.
There is no limit on the number of detach handlers that can be registered for a particular Phidget.
l
- An implemetation of the DetachListener
interfacepublic final void removeDetachListener(DetachListener l)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object comp)
equals
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |