|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.phidgets.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 |
addServerConnectListener(ServerConnectListener l)
Adds an serverConnect listener. |
void |
addServerDisconnectListener(ServerDisconnectListener l)
Adds an serverDisconnect listener. |
void |
close()
Closes this Phidget. |
static void |
disableLogging()
Turns off logging in the native C Library. |
static void |
enableLogging(int level,
java.lang.String file)
Turns on logging in the native C Library. |
boolean |
equals(java.lang.Object comp)
Compares two Phidgets. |
int |
getDeviceClass()
Returns the Device Class of this Phidget. |
int |
getDeviceID()
Returns the Device ID of this Phidget. |
java.lang.String |
getDeviceLabel()
Returns the label associated with this Phidget. |
java.lang.String |
getDeviceName()
Return the name of this Phidget. |
java.lang.String |
getDeviceType()
Return the device type of this Phidget. |
int |
getDeviceVersion()
Returns the device version of this Phidget. |
static java.lang.String |
getLibraryVersion()
Returns the library version. |
int |
getSerialNumber()
Returns the unique serial number of this Phidget. |
java.lang.String |
getServerAddress()
Returns the Address of a Phidget Webservice when this Phidget was opened as remote. |
java.lang.String |
getServerID()
Returns the Server ID of a Phidget Webservice when this Phidget was opened as remote. |
int |
getServerPort()
Returns the Port of a Phidget Webservice when this Phidget was opened as remote. |
boolean |
isAttached()
Returns the attached status of this Phidget. |
boolean |
isAttachedToServer()
Returns the network attached status for remotely opened Phidgets. |
static void |
log(int level,
java.lang.String id,
java.lang.String log)
Adds a log entry into the phidget log. |
void |
open(int serial)
Open this Phidget with a specific serial number. |
void |
open(int serial,
java.lang.String serverID)
Open this Phidget remotely using a Server ID, and a specific serial number. |
void |
open(int serial,
java.lang.String ipAddress,
int port)
Open this Phidget remotely using an IP Address, and a specific serial number. |
void |
open(int serial,
java.lang.String ipAddress,
int port,
java.lang.String password)
Open this Phidget remotely and securely, using an IP Address, and a specific serial number. |
void |
open(int serial,
java.lang.String serverID,
java.lang.String password)
Open this Phidget remotely and securely, using a Server ID, and a specific serial number. |
void |
openAny()
Open a this Phidget without a serial number. |
void |
openAny(java.lang.String serverID)
Open this Phidget remotely using a Server ID, without a serial number. |
void |
openAny(java.lang.String ipAddress,
int port)
Open this Phidget remotely using an IP Address, without a serial number. |
void |
openAny(java.lang.String ipAddress,
int port,
java.lang.String password)
Open this Phidget remotely and securely, using an IP Address, without a serial number. |
void |
openAny(java.lang.String serverID,
java.lang.String password)
Open this Phidget remotely and securely, using a Server ID, without a serial number. |
void |
openLabel(java.lang.String label)
Open this Phidget with a specific label. |
void |
openLabel(java.lang.String label,
java.lang.String serverID)
Open this Phidget remotely using a Server ID, and a specific label. |
void |
openLabel(java.lang.String label,
java.lang.String ipAddress,
int port)
Open this Phidget remotely using an IP Address, and a specific label. |
void |
openLabel(java.lang.String label,
java.lang.String ipAddress,
int port,
java.lang.String password)
Open this Phidget remotely and securely, using an IP Address, and a specific label. |
void |
openLabel(java.lang.String label,
java.lang.String serverID,
java.lang.String password)
Open this Phidget remotely and securely, using a Server ID, and a specific label. |
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 |
removeServerConnectListener(ServerConnectListener l)
Removes an serverConnect listener. |
void |
removeServerDisconnectListener(ServerDisconnectListener l)
Removes an serverDisconnect listener. |
void |
setDeviceLabel(java.lang.String label)
Sets the Label associated with this Phidget. |
java.lang.String |
toString()
Return a Sring describing this Phidget. |
void |
waitForAttachment()
Waits for this Phidget to become available. |
void |
waitForAttachment(int timeout)
Waits for this Phidget to become available. |
Methods inherited from class java.lang.Object |
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int PHIDGET_LOG_CRITICAL
enableLogging
and log
This is the lowest logging level. Errors at this level are generally non-recoverable and indicate either hardware problems, library bugs, or other serious issues.
If logging is enabled at this level, only PHIDGET_LOG_CRITICAL
messages are logged.
public static final int PHIDGET_LOG_ERROR
enableLogging
and log
Errors at this level are generally automatically recoverable, but may help to track down issues.
If logging is enabled at this level, PHIDGET_LOG_ERROR
as well as
PHIDGET_LOG_CRITICAL
messages are logged.
public static final int PHIDGET_LOG_WARNING
enableLogging
and log
Warnings are used to log behaviour that is not neccessarily in error, but is nevertheless odd or unexpected.
If logging is enabled at this level, PHIDGET_LOG_WARNING
as well as
PHIDGET_LOG_ERROR
and PHIDGET_LOG_CRITICAL
messages are logged.
public static final int PHIDGET_LOG_DEBUG
enableLogging
and log
Debug messages are generally used for debugging at Phdigets Inc.
Note: PHIDGET_LOG_DEBUG
messages are only logged in the debug version of the library, regardless of logging level.
Thus, these logs should never be seen outside of Phidgets Inc.
If logging is enabled at this level, PHIDGET_LOG_DEBUG
as well as
PHIDGET_LOG_WARNING
, PHIDGET_LOG_ERROR
and PHIDGET_LOG_CRITICAL
messages are logged.
public static final int PHIDGET_LOG_INFO
enableLogging
and log
Informational messages track key happenings within phidget21 - mostly to do with threads starting and shutting down, and the internals of the USB code.
If logging is enabled at this level, PHIDGET_LOG_INFO
as well as
PHIDGET_LOG_DEBUG
, PHIDGET_LOG_WARNING
, PHIDGET_LOG_ERROR
and PHIDGET_LOG_CRITICAL
messages are logged.
public static final int PHIDGET_LOG_VERBOSE
enableLogging
and log
This is the highest logging level. Verbose messages are informational messages that are expected to happen so frequently that they tend to drown out other log messages.
If logging is enabled at this level, PHIDGET_LOG_VERBOSE
as well as
PHIDGET_LOG_INFO
, PHIDGET_LOG_DEBUG
,
PHIDGET_LOG_WARNING
, PHIDGET_LOG_ERROR
and PHIDGET_LOG_CRITICAL
messages are logged.
public static final int PHIDID_NOTHING
public static final int PHIDID_ACCELEROMETER_3AXIS
public static final int PHIDID_ADVANCEDSERVO_1MOTOR
public static final int PHIDID_ADVANCEDSERVO_8MOTOR
public static final int PHIDID_ANALOG_4OUTPUT
public static final int PHIDID_BIPOLAR_STEPPER_1MOTOR
public static final int PHIDID_BRIDGE_4INPUT
public static final int PHIDID_ENCODER_1ENCODER_1INPUT
public static final int PHIDID_ENCODER_HS_1ENCODER
public static final int PHIDID_ENCODER_HS_4ENCODER_4INPUT
public static final int PHIDID_FREQUENCYCOUNTER_2INPUT
public static final int PHIDID_GPS
public static final int PHIDID_INTERFACEKIT_0_0_4
public static final int PHIDID_INTERFACEKIT_0_0_8
public static final int PHIDID_INTERFACEKIT_0_16_16
public static final int PHIDID_INTERFACEKIT_2_2_2
public static final int PHIDID_INTERFACEKIT_8_8_8
public static final int PHIDID_INTERFACEKIT_8_8_8_w_LCD
public static final int PHIDID_IR
public static final int PHIDID_LED_64_ADV
public static final int PHIDID_LINEAR_TOUCH
public static final int PHIDID_MOTORCONTROL_1MOTOR
public static final int PHIDID_MOTORCONTROL_HC_2MOTOR
public static final int PHIDID_RFID_2OUTPUT
public static final int PHIDID_RFID_2OUTPUT_READ_WRITE
public static final int PHIDID_ROTARY_TOUCH
public static final int PHIDID_SPATIAL_ACCEL_3AXIS
public static final int PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
public static final int PHIDID_TEMPERATURESENSOR
public static final int PHIDID_TEMPERATURESENSOR_4
public static final int PHIDID_TEMPERATURESENSOR_IR
public static final int PHIDID_TEXTLCD_2x20_w_8_8_8
public static final int PHIDID_TEXTLCD_ADAPTER
public static final int PHIDID_UNIPOLAR_STEPPER_4MOTOR
public static final int PHIDID_ACCELEROMETER_2AXIS
public static final int PHIDID_INTERFACEKIT_0_8_8_w_LCD
public static final int PHIDID_INTERFACEKIT_4_8_8
public static final int PHIDID_LED_64
public static final int PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
public static final int PHIDID_PHSENSOR
public static final int PHIDID_RFID
public static final int PHIDID_SERVO_1MOTOR
public static final int PHIDID_SERVO_1MOTOR_OLD
public static final int PHIDID_SERVO_4MOTOR
public static final int PHIDID_SERVO_4MOTOR_OLD
public static final int PHIDID_TEXTLCD_2x20
public static final int PHIDID_TEXTLCD_2x20_w_0_8_8
public static final int PHIDID_TEXTLED_1x8
public static final int PHIDID_TEXTLED_4x8
public static final int PHIDID_WEIGHTSENSOR
public static final int PHIDCLASS_NOTHING
public static final int PHIDCLASS_ACCELEROMETER
public static final int PHIDCLASS_ADVANCEDSERVO
public static final int PHIDCLASS_ANALOG
public static final int PHIDCLASS_BRIDGE
public static final int PHIDCLASS_ENCODER
public static final int PHIDCLASS_FREQUENCYCOUNTER
public static final int PHIDCLASS_GPS
public static final int PHIDCLASS_INTERFACEKIT
public static final int PHIDCLASS_LED
public static final int PHIDCLASS_MOTORCONTROL
public static final int PHIDCLASS_PHSENSOR
public static final int PHIDCLASS_RFID
public static final int PHIDCLASS_SERVO
public static final int PHIDCLASS_STEPPER
public static final int PHIDCLASS_TEMPERATURESENSOR
public static final int PHIDCLASS_TEXTLCD
public static final int PHIDCLASS_TEXTLED
public static final int PHIDCLASS_WEIGHTSENSOR
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 static final void enableLogging(int level, java.lang.String file)
Logging may be usefull for users trying to debug their own problems, as logs can be inserted by the user using log
.
The level can be one of: PHIDGET_LOG_VERBOSE
,
PHIDGET_LOG_INFO
, PHIDGET_LOG_DEBUG
,
PHIDGET_LOG_WARNING
, PHIDGET_LOG_ERROR
or PHIDGET_LOG_CRITICAL
level
- highest level of logging that will be outputfile
- file to output log to. specify 'null' to output to the consolepublic static final void disableLogging()
public static final void log(int level, java.lang.String id, java.lang.String log)
enableLogging
and this allows the entry of user logs in amongst the phidget library logs.
The level can be one of: PHIDGET_LOG_VERBOSE
,
PHIDGET_LOG_INFO
, PHIDGET_LOG_DEBUG
,
PHIDGET_LOG_WARNING
, PHIDGET_LOG_ERROR
or PHIDGET_LOG_CRITICAL
Note: PHIDGET_LOG_DEBUG
should not be used, as these logs are only printed when using the debug library,
which is not generally available.
level
- level to enter the log atid
- an arbitrary identifier for this log. This can be NULL. The C library uses this field for source filename and line numberlog
- the message to logpublic final int getDeviceID() throws PhidgetException
PhidgetException
- If this Phidget is not opened and attached. See open
for information on determining if a device is attached.public final int getDeviceClass() throws PhidgetException
PhidgetException
- If this Phidget is not opened and attached. See open
for information on determining if a device is attached.public final int 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 int 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 boolean isAttachedToServer() throws PhidgetException
PhidgetException
- If this Phidget is not opened.public final java.lang.String getDeviceLabel() throws PhidgetException
setDeviceLabel
), 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 labels.
See open
for determining if a device is attached.public final void setDeviceLabel(java.lang.String label) throws PhidgetException
Labels can not currently be set from Windows because of driver incompatibility. Labels can be set from MacOS, Linux and Windows CE.
label
- Label
PhidgetException
- If this Phidget is not opened and attached, or if this Phidget does not support labels, or if this is
called from Windows. See open
for determining if a device is attached.public final java.lang.String getServerAddress() throws PhidgetException
PhidgetException
- if this Phidget was open opened as a remote Phidget.public final java.lang.String getServerID() throws PhidgetException
PhidgetException
- if this Phidget was open opened as a remote Phidget.public final int getServerPort() throws PhidgetException
PhidgetException
- if this Phidget was open opened as a remote Phidget.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 assigned 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 open(int serial, java.lang.String ipAddress, int port) throws PhidgetException
This version of open is network based.
Open is pervasive. What this means is that you can call open on a device before it is plugged in, and on a server before it is running, and keep the device opened across device, and server 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 assigned to each Phidget
during production and can be used to uniquely identify specific phidgets.
use openAny(String ipAddress, int port)
to open a device without specifying the serial number.
serial
- Serial NumberipAddress
- IP Address or hostname of the Phidget Webserviceport
- Port of the Phidget Webservice
PhidgetException
- if the Phidget Webservice cannot be contactedpublic final void open(int serial, java.lang.String ipAddress, int port, java.lang.String password) throws PhidgetException
This method is the same as open(int serial, String ipAddress, int port)
, except that it specifies a password.
This password can be set as a parameter when starting the Phidget Webservice.
PhidgetException
public final void open(int serial, java.lang.String serverID) throws PhidgetException
This version of open is network based.
Open is pervasive. What this means is that you can call open on a device before it is plugged in, and on a server before it is running, and keep the device opened across device, and server 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 assigned to each Phidget
during production and can be used to uniquely identify specific phidgets.
use openAny(String serverID)
to open a device without specifying the serial number.
ServerID can be set to null, if the ServerID does not matter. In this case, the specified Phidget (by serial number) will be opened whenever it is seen on the network, regardless of which server it appears on. This also applies when not specifying a serial number.
Note: All open methods that specify a ServerID rather then an IP Addresss and Port require that both the client and host sides of the connection be running an implementation of zeroconf:
serial
- Serial NumberserverID
- ServerID of the Phidget Webservice
PhidgetException
public final void open(int serial, java.lang.String serverID, java.lang.String password) throws PhidgetException
This method is the same as open(int serial, String serverID)
, except that it specifies a password.
This password can be set as a parameter when starting the Phidget Webservice.
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 openAny(java.lang.String ipAddress, int port) throws PhidgetException
open(int serial, String ipAddress, int port)
,
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 openAny(java.lang.String ipAddress, int port, java.lang.String password) throws PhidgetException
open(int serial, String ipAddress, int port, String password)
,
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 openAny(java.lang.String serverID) throws PhidgetException
open(int serial, String serverID)
,
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 openAny(java.lang.String serverID, java.lang.String password) throws PhidgetException
open(int serial, String serverID, String password)
,
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 openLabel(java.lang.String label) 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 label - The label can be set and changed by using the setLabel method (setLabel is unsupported on Windows).
use openAny
to open a device without specifying the label.
label
- The Label
PhidgetException
public final void openLabel(java.lang.String label, java.lang.String ipAddress, int port) throws PhidgetException
This version of open is network based.
Open is pervasive. What this means is that you can call open on a device before it is plugged in, and on a server before it is running, and keep the device opened across device, and server 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 label - The label can be set and changed by using the setLabel method (setLabel is unsupported on Windows).
use openAny(String ipAddress, int port)
to open a device without specifying the label.
label
- The LabelipAddress
- IP Address or hostname of the Phidget Webserviceport
- Port of the Phidget Webservice
PhidgetException
- if the Phidget Webservice cannot be contactedpublic final void openLabel(java.lang.String label, java.lang.String ipAddress, int port, java.lang.String password) throws PhidgetException
This method is the same as openLabel(String label, String ipAddress, int port)
, except that it specifies a password.
This password can be set as a parameter when starting the Phidget Webservice.
PhidgetException
public final void openLabel(java.lang.String label, java.lang.String serverID) throws PhidgetException
This version of open is network based.
Open is pervasive. What this means is that you can call open on a device before it is plugged in, and on a server before it is running, and keep the device opened across device, and server 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 label - The label can be set and changed by using the setLabel method (setLabel is unsupported on Windows).
use openAny(String serverID)
to open a device without specifying the label.
ServerID can be set to null, if the ServerID does not matter. In this case, the specified Phidget (by label) will be opened whenever it is seen on the network, regardless of which server it appears on. This also applies when not specifying a label.
Note: All open methods that specify a ServerID rather then an IP Addresss and Port require that both the client and host sides of the connection be running an implementation of zeroconf:
label
- The LabelserverID
- ServerID of the Phidget Webservice
PhidgetException
public final void openLabel(java.lang.String label, java.lang.String serverID, java.lang.String password) throws PhidgetException
This method is the same as openLabel(String label, String serverID)
, except that it specifies a password.
This password can be set as a parameter when starting the Phidget Webservice.
PhidgetException
public final void close() throws PhidgetException
PhidgetException
- If this Phidget is not opened.public final void waitForAttachment(int timeout) throws PhidgetException
This method blocks for up to the timeout, at which point it will throw a PhidgetException. Otherwise, it returns when the phidget is attached and initialized.
A timeout of 0 is infinite.
timeout
- Timeout in milliseconds
PhidgetException
- If this Phidget is not opened.public final 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.
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 final void addServerConnectListener(ServerConnectListener l)
There is no limit on the number of serverConnect handlers that can be registered for a particular Phidget.
l
- An implemetation of the ServerConnectListener
interfacepublic final void removeServerConnectListener(ServerConnectListener l)
public final void addServerDisconnectListener(ServerDisconnectListener l)
There is no limit on the number of serverDisconnect handlers that can be registered for a particular Phidget.
l
- An implemetation of the ServerDisconnectListener
interfacepublic final void removeServerDisconnectListener(ServerDisconnectListener l)
public java.lang.String toString()
public boolean equals(java.lang.Object comp)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |