com.phidgets
Class Phidget

java.lang.Object
  extended bycom.phidgets.Phidget
Direct Known Subclasses:
AccelerometerPhidget, AdvancedServoPhidget, AnalogPhidget, BridgePhidget, EncoderPhidget, FrequencyCounterPhidget, GPSPhidget, InterfaceKitPhidget, IRPhidget, LEDPhidget, MotorControlPhidget, PHSensorPhidget, RFIDPhidget, ServoPhidget, SpatialPhidget, StepperPhidget, TemperatureSensorPhidget, TextLCDPhidget, TextLEDPhidget, WeightSensorPhidget

public class Phidget
extends java.lang.Object

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.

Version:
2.1.7
Author:
Phidgets Inc.

Field Summary
static int PHIDCLASS_ACCELEROMETER
           
static int PHIDCLASS_ADVANCEDSERVO
           
static int PHIDCLASS_ANALOG
           
static int PHIDCLASS_BRIDGE
           
static int PHIDCLASS_ENCODER
           
static int PHIDCLASS_FREQUENCYCOUNTER
           
static int PHIDCLASS_GPS
           
static int PHIDCLASS_INTERFACEKIT
           
static int PHIDCLASS_LED
           
static int PHIDCLASS_MOTORCONTROL
           
static int PHIDCLASS_NOTHING
           
static int PHIDCLASS_PHSENSOR
           
static int PHIDCLASS_RFID
           
static int PHIDCLASS_SERVO
           
static int PHIDCLASS_STEPPER
           
static int PHIDCLASS_TEMPERATURESENSOR
           
static int PHIDCLASS_TEXTLCD
           
static int PHIDCLASS_TEXTLED
           
static int PHIDCLASS_WEIGHTSENSOR
           
static int PHIDGET_LOG_CRITICAL
          Critial error messages.
static int PHIDGET_LOG_DEBUG
          Debug messages.
static int PHIDGET_LOG_ERROR
          Non-critical error messages.
static int PHIDGET_LOG_INFO
          Informational messages.
static int PHIDGET_LOG_VERBOSE
          Verbose messages.
static int PHIDGET_LOG_WARNING
          Warning messages.
static int PHIDID_ACCELEROMETER_2AXIS
           
static int PHIDID_ACCELEROMETER_3AXIS
           
static int PHIDID_ADVANCEDSERVO_1MOTOR
           
static int PHIDID_ADVANCEDSERVO_8MOTOR
           
static int PHIDID_ANALOG_4OUTPUT
           
static int PHIDID_BIPOLAR_STEPPER_1MOTOR
           
static int PHIDID_BRIDGE_4INPUT
           
static int PHIDID_ENCODER_1ENCODER_1INPUT
           
static int PHIDID_ENCODER_HS_1ENCODER
           
static int PHIDID_ENCODER_HS_4ENCODER_4INPUT
           
static int PHIDID_FREQUENCYCOUNTER_2INPUT
           
static int PHIDID_GPS
           
static int PHIDID_INTERFACEKIT_0_0_4
           
static int PHIDID_INTERFACEKIT_0_0_8
           
static int PHIDID_INTERFACEKIT_0_16_16
           
static int PHIDID_INTERFACEKIT_0_8_8_w_LCD
           
static int PHIDID_INTERFACEKIT_2_2_2
           
static int PHIDID_INTERFACEKIT_4_8_8
           
static int PHIDID_INTERFACEKIT_8_8_8
           
static int PHIDID_INTERFACEKIT_8_8_8_w_LCD
           
static int PHIDID_IR
           
static int PHIDID_LED_64
           
static int PHIDID_LED_64_ADV
           
static int PHIDID_LINEAR_TOUCH
           
static int PHIDID_MOTORCONTROL_1MOTOR
           
static int PHIDID_MOTORCONTROL_HC_2MOTOR
           
static int PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
           
static int PHIDID_NOTHING
           
static int PHIDID_PHSENSOR
           
static int PHIDID_RFID
           
static int PHIDID_RFID_2OUTPUT
           
static int PHIDID_RFID_2OUTPUT_READ_WRITE
           
static int PHIDID_ROTARY_TOUCH
           
static int PHIDID_SERVO_1MOTOR
           
static int PHIDID_SERVO_1MOTOR_OLD
           
static int PHIDID_SERVO_4MOTOR
           
static int PHIDID_SERVO_4MOTOR_OLD
           
static int PHIDID_SPATIAL_ACCEL_3AXIS
           
static int PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
           
static int PHIDID_TEMPERATURESENSOR
           
static int PHIDID_TEMPERATURESENSOR_4
           
static int PHIDID_TEMPERATURESENSOR_IR
           
static int PHIDID_TEXTLCD_2x20
           
static int PHIDID_TEXTLCD_2x20_w_0_8_8
           
static int PHIDID_TEXTLCD_2x20_w_8_8_8
           
static int PHIDID_TEXTLCD_ADAPTER
           
static int PHIDID_TEXTLED_1x8
           
static int PHIDID_TEXTLED_4x8
           
static int PHIDID_UNIPOLAR_STEPPER_4MOTOR
           
static int PHIDID_WEIGHTSENSOR
           
 
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

PHIDGET_LOG_CRITICAL

public static final int PHIDGET_LOG_CRITICAL
Critial error messages. This is used with 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.

See Also:
Constant Field Values

PHIDGET_LOG_ERROR

public static final int PHIDGET_LOG_ERROR
Non-critical error messages. This is used with 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.

See Also:
Constant Field Values

PHIDGET_LOG_WARNING

public static final int PHIDGET_LOG_WARNING
Warning messages. This is used with 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.

See Also:
Constant Field Values

PHIDGET_LOG_DEBUG

public static final int PHIDGET_LOG_DEBUG
Debug messages. This is used with 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.

See Also:
Constant Field Values

PHIDGET_LOG_INFO

public static final int PHIDGET_LOG_INFO
Informational messages. This is used with 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.

See Also:
Constant Field Values

PHIDGET_LOG_VERBOSE

public static final int PHIDGET_LOG_VERBOSE
Verbose messages. This is used with 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.

See Also:
Constant Field Values

PHIDID_NOTHING

public static final int PHIDID_NOTHING
See Also:
Constant Field Values

PHIDID_ACCELEROMETER_3AXIS

public static final int PHIDID_ACCELEROMETER_3AXIS
See Also:
Constant Field Values

PHIDID_ADVANCEDSERVO_1MOTOR

public static final int PHIDID_ADVANCEDSERVO_1MOTOR
See Also:
Constant Field Values

PHIDID_ADVANCEDSERVO_8MOTOR

public static final int PHIDID_ADVANCEDSERVO_8MOTOR
See Also:
Constant Field Values

PHIDID_ANALOG_4OUTPUT

public static final int PHIDID_ANALOG_4OUTPUT
See Also:
Constant Field Values

PHIDID_BIPOLAR_STEPPER_1MOTOR

public static final int PHIDID_BIPOLAR_STEPPER_1MOTOR
See Also:
Constant Field Values

PHIDID_BRIDGE_4INPUT

public static final int PHIDID_BRIDGE_4INPUT
See Also:
Constant Field Values

PHIDID_ENCODER_1ENCODER_1INPUT

public static final int PHIDID_ENCODER_1ENCODER_1INPUT
See Also:
Constant Field Values

PHIDID_ENCODER_HS_1ENCODER

public static final int PHIDID_ENCODER_HS_1ENCODER
See Also:
Constant Field Values

PHIDID_ENCODER_HS_4ENCODER_4INPUT

public static final int PHIDID_ENCODER_HS_4ENCODER_4INPUT
See Also:
Constant Field Values

PHIDID_FREQUENCYCOUNTER_2INPUT

public static final int PHIDID_FREQUENCYCOUNTER_2INPUT
See Also:
Constant Field Values

PHIDID_GPS

public static final int PHIDID_GPS
See Also:
Constant Field Values

PHIDID_INTERFACEKIT_0_0_4

public static final int PHIDID_INTERFACEKIT_0_0_4
See Also:
Constant Field Values

PHIDID_INTERFACEKIT_0_0_8

public static final int PHIDID_INTERFACEKIT_0_0_8
See Also:
Constant Field Values

PHIDID_INTERFACEKIT_0_16_16

public static final int PHIDID_INTERFACEKIT_0_16_16
See Also:
Constant Field Values

PHIDID_INTERFACEKIT_2_2_2

public static final int PHIDID_INTERFACEKIT_2_2_2
See Also:
Constant Field Values

PHIDID_INTERFACEKIT_8_8_8

public static final int PHIDID_INTERFACEKIT_8_8_8
See Also:
Constant Field Values

PHIDID_INTERFACEKIT_8_8_8_w_LCD

public static final int PHIDID_INTERFACEKIT_8_8_8_w_LCD
See Also:
Constant Field Values

PHIDID_IR

public static final int PHIDID_IR
See Also:
Constant Field Values

PHIDID_LED_64_ADV

public static final int PHIDID_LED_64_ADV
See Also:
Constant Field Values

PHIDID_LINEAR_TOUCH

public static final int PHIDID_LINEAR_TOUCH
See Also:
Constant Field Values

PHIDID_MOTORCONTROL_1MOTOR

public static final int PHIDID_MOTORCONTROL_1MOTOR
See Also:
Constant Field Values

PHIDID_MOTORCONTROL_HC_2MOTOR

public static final int PHIDID_MOTORCONTROL_HC_2MOTOR
See Also:
Constant Field Values

PHIDID_RFID_2OUTPUT

public static final int PHIDID_RFID_2OUTPUT
See Also:
Constant Field Values

PHIDID_RFID_2OUTPUT_READ_WRITE

public static final int PHIDID_RFID_2OUTPUT_READ_WRITE
See Also:
Constant Field Values

PHIDID_ROTARY_TOUCH

public static final int PHIDID_ROTARY_TOUCH
See Also:
Constant Field Values

PHIDID_SPATIAL_ACCEL_3AXIS

public static final int PHIDID_SPATIAL_ACCEL_3AXIS
See Also:
Constant Field Values

PHIDID_SPATIAL_ACCEL_GYRO_COMPASS

public static final int PHIDID_SPATIAL_ACCEL_GYRO_COMPASS
See Also:
Constant Field Values

PHIDID_TEMPERATURESENSOR

public static final int PHIDID_TEMPERATURESENSOR
See Also:
Constant Field Values

PHIDID_TEMPERATURESENSOR_4

public static final int PHIDID_TEMPERATURESENSOR_4
See Also:
Constant Field Values

PHIDID_TEMPERATURESENSOR_IR

public static final int PHIDID_TEMPERATURESENSOR_IR
See Also:
Constant Field Values

PHIDID_TEXTLCD_2x20_w_8_8_8

public static final int PHIDID_TEXTLCD_2x20_w_8_8_8
See Also:
Constant Field Values

PHIDID_TEXTLCD_ADAPTER

public static final int PHIDID_TEXTLCD_ADAPTER
See Also:
Constant Field Values

PHIDID_UNIPOLAR_STEPPER_4MOTOR

public static final int PHIDID_UNIPOLAR_STEPPER_4MOTOR
See Also:
Constant Field Values

PHIDID_ACCELEROMETER_2AXIS

public static final int PHIDID_ACCELEROMETER_2AXIS
See Also:
Constant Field Values

PHIDID_INTERFACEKIT_0_8_8_w_LCD

public static final int PHIDID_INTERFACEKIT_0_8_8_w_LCD
See Also:
Constant Field Values

PHIDID_INTERFACEKIT_4_8_8

public static final int PHIDID_INTERFACEKIT_4_8_8
See Also:
Constant Field Values

PHIDID_LED_64

public static final int PHIDID_LED_64
See Also:
Constant Field Values

PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT

public static final int PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT
See Also:
Constant Field Values

PHIDID_PHSENSOR

public static final int PHIDID_PHSENSOR
See Also:
Constant Field Values

PHIDID_RFID

public static final int PHIDID_RFID
See Also:
Constant Field Values

PHIDID_SERVO_1MOTOR

public static final int PHIDID_SERVO_1MOTOR
See Also:
Constant Field Values

PHIDID_SERVO_1MOTOR_OLD

public static final int PHIDID_SERVO_1MOTOR_OLD
See Also:
Constant Field Values

PHIDID_SERVO_4MOTOR

public static final int PHIDID_SERVO_4MOTOR
See Also:
Constant Field Values

PHIDID_SERVO_4MOTOR_OLD

public static final int PHIDID_SERVO_4MOTOR_OLD
See Also:
Constant Field Values

PHIDID_TEXTLCD_2x20

public static final int PHIDID_TEXTLCD_2x20
See Also:
Constant Field Values

PHIDID_TEXTLCD_2x20_w_0_8_8

public static final int PHIDID_TEXTLCD_2x20_w_0_8_8
See Also:
Constant Field Values

PHIDID_TEXTLED_1x8

public static final int PHIDID_TEXTLED_1x8
See Also:
Constant Field Values

PHIDID_TEXTLED_4x8

public static final int PHIDID_TEXTLED_4x8
See Also:
Constant Field Values

PHIDID_WEIGHTSENSOR

public static final int PHIDID_WEIGHTSENSOR
See Also:
Constant Field Values

PHIDCLASS_NOTHING

public static final int PHIDCLASS_NOTHING
See Also:
Constant Field Values

PHIDCLASS_ACCELEROMETER

public static final int PHIDCLASS_ACCELEROMETER
See Also:
Constant Field Values

PHIDCLASS_ADVANCEDSERVO

public static final int PHIDCLASS_ADVANCEDSERVO
See Also:
Constant Field Values

PHIDCLASS_ANALOG

public static final int PHIDCLASS_ANALOG
See Also:
Constant Field Values

PHIDCLASS_BRIDGE

public static final int PHIDCLASS_BRIDGE
See Also:
Constant Field Values

PHIDCLASS_ENCODER

public static final int PHIDCLASS_ENCODER
See Also:
Constant Field Values

PHIDCLASS_FREQUENCYCOUNTER

public static final int PHIDCLASS_FREQUENCYCOUNTER
See Also:
Constant Field Values

PHIDCLASS_GPS

public static final int PHIDCLASS_GPS
See Also:
Constant Field Values

PHIDCLASS_INTERFACEKIT

public static final int PHIDCLASS_INTERFACEKIT
See Also:
Constant Field Values

PHIDCLASS_LED

public static final int PHIDCLASS_LED
See Also:
Constant Field Values

PHIDCLASS_MOTORCONTROL

public static final int PHIDCLASS_MOTORCONTROL
See Also:
Constant Field Values

PHIDCLASS_PHSENSOR

public static final int PHIDCLASS_PHSENSOR
See Also:
Constant Field Values

PHIDCLASS_RFID

public static final int PHIDCLASS_RFID
See Also:
Constant Field Values

PHIDCLASS_SERVO

public static final int PHIDCLASS_SERVO
See Also:
Constant Field Values

PHIDCLASS_STEPPER

public static final int PHIDCLASS_STEPPER
See Also:
Constant Field Values

PHIDCLASS_TEMPERATURESENSOR

public static final int PHIDCLASS_TEMPERATURESENSOR
See Also:
Constant Field Values

PHIDCLASS_TEXTLCD

public static final int PHIDCLASS_TEXTLCD
See Also:
Constant Field Values

PHIDCLASS_TEXTLED

public static final int PHIDCLASS_TEXTLED
See Also:
Constant Field Values

PHIDCLASS_WEIGHTSENSOR

public static final int PHIDCLASS_WEIGHTSENSOR
See Also:
Constant Field Values
Constructor Detail

Phidget

public Phidget(long handle)
Class constructor specifying a handle. This constructor is to be used only by subclasses, as the Phidget calss should never need to be instatiated directly by the user.

Parameters:
handle - A native Handle points to the underlying phidget structure in the base phidget21 C library.
Method Detail

getLibraryVersion

public static final java.lang.String getLibraryVersion()
Returns the library version. This is the library version of the underlying phidget21 C library and not the version of the JNI wrapper implementation.

The version is retured at a string which contains the version number and build date.

Returns:
Library Version

enableLogging

public static final void enableLogging(int level,
                                       java.lang.String file)
Turns on logging in the native C Library. This is mostly usefull for debugging purposes - when an issue needs to be resolved by Phidgets Inc. The output is mostly low-level library information, that won't be usefull for most users.

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

Parameters:
level - highest level of logging that will be output
file - file to output log to. specify 'null' to output to the console

disableLogging

public static final void disableLogging()
Turns off logging in the native C Library. This only needs to be called if enableLogging was called to turn logging on. This will turn logging back off.


log

public static final void log(int level,
                             java.lang.String id,
                             java.lang.String log)
Adds a log entry into the phidget log. This log is enabled by calling 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.

Parameters:
level - level to enter the log at
id - an arbitrary identifier for this log. This can be NULL. The C library uses this field for source filename and line number
log - the message to log

getDeviceID

public final int getDeviceID()
                      throws PhidgetException
Returns the Device ID of this Phidget. This is one of the PHIDID_(...) constants defined above. This uniquely identifies a specific type of Phidget.

Returns:
Device ID
Throws:
PhidgetException - If this Phidget is not opened and attached. See open for information on determining if a device is attached.

getDeviceClass

public final int getDeviceClass()
                         throws PhidgetException
Returns the Device Class of this Phidget. This is one of the PHIDCLASS_(...) constants defined above. This represents a class of Phidgets - ie Interface Kit.

Returns:
Device ID
Throws:
PhidgetException - If this Phidget is not opened and attached. See open for information on determining if a device is attached.

getSerialNumber

public final int getSerialNumber()
                          throws PhidgetException
Returns the unique serial number of this Phidget. This number is set during manufacturing, and is unique across all Phidgets. This number can be used in calls to open to specify this specific Phidget to be opened.

Returns:
Serial Number
Throws:
PhidgetException - If this Phidget is not opened and attached. See open for information on determining if a device is attached.

getDeviceVersion

public final int getDeviceVersion()
                           throws PhidgetException
Returns the device version of this Phidget. This number is simply a way of distinguishing between different revisions of a specific type of Phidget, and is only really of use if you need to troubleshoot device problems with Phidgets Inc.

Returns:
Version
Throws:
PhidgetException - If this Phidget is not opened and attached. See open for information on determining if a device is attached.

getDeviceType

public final java.lang.String getDeviceType()
                                     throws PhidgetException
Return the device type of this Phidget. This is a string that describes the device as a class of devices. For example, all PhidgetInterfaceKit Phidgets will returns the String "PhidgetInterfaceKit".

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.

Returns:
Device Type
Throws:
PhidgetException - If this Phidget is not opened and attached. See open for information on determining if a device is attached.

getDeviceName

public final java.lang.String getDeviceName()
                                     throws PhidgetException
Return the name of this Phidget. This is a string that describes the device. For example, a PhidgetInterfaceKit could be described as "Phidget InterfaceKit 8/8/8", or "Phidget InterfaceKit 0/0/4", among others, depending on the specific device.

This lets you determine the specific type of a Phidget, within the broader classes of Phidgets, such as PhidgetInterfaceKit, or PhidgetServo

Returns:
Name
Throws:
PhidgetException - If this Phidget is not opened and attached. See open for information on determining if a device is attached.

isAttached

public final boolean isAttached()
                         throws PhidgetException
Returns the attached status of this Phidget. This method returns True or False, depending on whether the Phidget is phisically plugged into the computer, initialized, and ready to use - or not. If a Phidget is not attached, many functions calls will fail with a PhidgetException, so either checking this function, or using the Attach and Detach events, is recommended, if a device is likely to be attached or detached during use.

Returns:
Status
Throws:
PhidgetException - If this Phidget is not opened.

isAttachedToServer

public final boolean isAttachedToServer()
                                 throws PhidgetException
Returns the network attached status for remotely opened Phidgets. This method returns True or False, depending on whether a connection to the Phidget WebService is open - or not. If this is false for a remote Phidget then the connection is not active - either because a connection has not yet been established, or because the connection was terminated.

Returns:
Status
Throws:
PhidgetException - If this Phidget is not opened.

getDeviceLabel

public final java.lang.String getDeviceLabel()
                                      throws PhidgetException
Returns the label associated with this Phidget. This label is a String - up to ten digits - that is stored in the Flash memory of newer Phidgets. This label can be set programatically (see setDeviceLabel), and is non-volatile - so it is remembered even if the Phidget is unplugged.

Returns:
Label
Throws:
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.

setDeviceLabel

public final void setDeviceLabel(java.lang.String label)
                          throws PhidgetException
Sets the Label associated with this Phidget. Labels are user defined Strings that persist in a Phidget's Flash. They are only supported in the newer Phidgets. The maximum length is 10 characters.

Labels can not currently be set from Windows because of driver incompatibility. Labels can be set from MacOS, Linux and Windows CE.

Parameters:
label - Label
Throws:
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.

getServerAddress

public final java.lang.String getServerAddress()
                                        throws PhidgetException
Returns the Address of a Phidget Webservice when this Phidget was opened as remote. This may be an IP Address or a hostname.

Returns:
Server Address
Throws:
PhidgetException - if this Phidget was open opened as a remote Phidget.

getServerID

public final java.lang.String getServerID()
                                   throws PhidgetException
Returns the Server ID of a Phidget Webservice when this Phidget was opened as remote. This is an arbitrary server identifier, independant of IP address and Port.

Returns:
Server ID
Throws:
PhidgetException - if this Phidget was open opened as a remote Phidget.

getServerPort

public final int getServerPort()
                        throws PhidgetException
Returns the Port of a Phidget Webservice when this Phidget was opened as remote.

Returns:
Server Port
Throws:
PhidgetException - if this Phidget was open opened as a remote Phidget.

open

public final void open(int serial)
                throws PhidgetException
Open this Phidget with a specific serial number.

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.

Parameters:
serial - Serial Number
Throws:
PhidgetException

open

public final void open(int serial,
                       java.lang.String ipAddress,
                       int port)
                throws PhidgetException
Open this Phidget remotely using an IP Address, and a specific serial number.

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.

Parameters:
serial - Serial Number
ipAddress - IP Address or hostname of the Phidget Webservice
port - Port of the Phidget Webservice
Throws:
PhidgetException - if the Phidget Webservice cannot be contacted

open

public final void open(int serial,
                       java.lang.String ipAddress,
                       int port,
                       java.lang.String password)
                throws PhidgetException
Open this Phidget remotely and securely, using an IP Address, and a specific serial number.

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.

Throws:
PhidgetException

open

public final void open(int serial,
                       java.lang.String serverID)
                throws PhidgetException
Open this Phidget remotely using a Server ID, and a specific serial number.

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:

Parameters:
serial - Serial Number
serverID - ServerID of the Phidget Webservice
Throws:
PhidgetException

open

public final void open(int serial,
                       java.lang.String serverID,
                       java.lang.String password)
                throws PhidgetException
Open this Phidget remotely and securely, using a Server ID, and a specific serial number.

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.

Throws:
PhidgetException

openAny

public final void openAny()
                   throws PhidgetException
Open a this Phidget without a serial number. This method is the same as 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().

Throws:
PhidgetException

openAny

public final void openAny(java.lang.String ipAddress,
                          int port)
                   throws PhidgetException
Open this Phidget remotely using an IP Address, without a serial number. This method is the same as 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().

Throws:
PhidgetException

openAny

public final void openAny(java.lang.String ipAddress,
                          int port,
                          java.lang.String password)
                   throws PhidgetException
Open this Phidget remotely and securely, using an IP Address, without a serial number. This method is the same as 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().

Throws:
PhidgetException

openAny

public final void openAny(java.lang.String serverID)
                   throws PhidgetException
Open this Phidget remotely using a Server ID, without a serial number. This method is the same as 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().

Throws:
PhidgetException

openAny

public final void openAny(java.lang.String serverID,
                          java.lang.String password)
                   throws PhidgetException
Open this Phidget remotely and securely, using a Server ID, without a serial number. This method is the same as 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().

Throws:
PhidgetException

openLabel

public final void openLabel(java.lang.String label)
                     throws PhidgetException
Open this Phidget with a specific label.

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.

Parameters:
label - The Label
Throws:
PhidgetException

openLabel

public final void openLabel(java.lang.String label,
                            java.lang.String ipAddress,
                            int port)
                     throws PhidgetException
Open this Phidget remotely using an IP Address, and a specific label.

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.

Parameters:
label - The Label
ipAddress - IP Address or hostname of the Phidget Webservice
port - Port of the Phidget Webservice
Throws:
PhidgetException - if the Phidget Webservice cannot be contacted

openLabel

public final void openLabel(java.lang.String label,
                            java.lang.String ipAddress,
                            int port,
                            java.lang.String password)
                     throws PhidgetException
Open this Phidget remotely and securely, using an IP Address, and a specific label.

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.

Throws:
PhidgetException

openLabel

public final void openLabel(java.lang.String label,
                            java.lang.String serverID)
                     throws PhidgetException
Open this Phidget remotely using a Server ID, and a specific label.

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:

Parameters:
label - The Label
serverID - ServerID of the Phidget Webservice
Throws:
PhidgetException

openLabel

public final void openLabel(java.lang.String label,
                            java.lang.String serverID,
                            java.lang.String password)
                     throws PhidgetException
Open this Phidget remotely and securely, using a Server ID, and a specific label.

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.

Throws:
PhidgetException

close

public final void close()
                 throws PhidgetException
Closes this Phidget. This will shut down all threads dealing with this Phidget and you won't receive any more events.

Throws:
PhidgetException - If this Phidget is not opened.

waitForAttachment

public final void waitForAttachment(int timeout)
                             throws PhidgetException
Waits for this Phidget to become available. This method can be called after open has been called to wait for thid Phidget to become available. This is usefull because open is asynchronous (and thus returns immediately), and most methods will throw a PhidgetException is they are called before a device is actually ready. This method is synonymous with polling the isAttached method until it returns True, or using the Attach event.

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.

Parameters:
timeout - Timeout in milliseconds
Throws:
PhidgetException - If this Phidget is not opened.

waitForAttachment

public final void waitForAttachment()
                             throws PhidgetException
Waits for this Phidget to become available. This method can be called after open has been called to wait for thid Phidget to become available. This is usefull because open is asynchronous (and thus returns immediately), and most methods will throw a PhidgetException is they are called before a device is actually ready. This method is synonymous with polling the isAttached method until it returns True, or using the Attach event.

This method blocks indefinitely until the Phidget becomes available. This can be quite some time (forever), if the Phidget is never plugged in.

Throws:
PhidgetException - If this Phidget is not opened.

addAttachListener

public final void addAttachListener(AttachListener l)
Adds an attach listener. The attach handler is a method that will be called when this Phidget is phisically attached to the system, and has gone through its initalization, and so is ready to be used.

There is no limit on the number of attach handlers that can be registered for a particular Phidget.

Parameters:
l - An implemetation of the AttachListener interface

removeAttachListener

public final void removeAttachListener(AttachListener l)
Removes an attach listener. This will remove a previously added attach listener.


addErrorListener

public final void addErrorListener(ErrorListener l)
Adds an error listener. The error handler is a method that will be called when an asynchronous error occurs. Error events are not currently used, but will be in the future to report any problems that happen out of context from a direct function call.

There is no limit on the number of error handlers that can be registered for a particular Phidget.

Parameters:
l - An implemetation of the ErrorListener interface

removeErrorListener

public final void removeErrorListener(ErrorListener l)
Removes an error listener. This will remove a previously added error listener.


addDetachListener

public final void addDetachListener(DetachListener l)
Adds a detach listener. The detach handler is a method that will be called when this Phidget is phisically detached from the system, and is no longer available. This is particularly usefull for applications when a phisical detach would be expected.

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.

Parameters:
l - An implemetation of the DetachListener interface

removeDetachListener

public final void removeDetachListener(DetachListener l)
Removes a detach listener. This will remove a previously added detach listener.


addServerConnectListener

public final void addServerConnectListener(ServerConnectListener l)
Adds an serverConnect listener. The serverConnect handler is a method that will be called when a connection to a server is made. This is only usefull for Phidgets opened remotely.

There is no limit on the number of serverConnect handlers that can be registered for a particular Phidget.

Parameters:
l - An implemetation of the ServerConnectListener interface

removeServerConnectListener

public final void removeServerConnectListener(ServerConnectListener l)
Removes an serverConnect listener. This will remove a previously added serverConnect listener.


addServerDisconnectListener

public final void addServerDisconnectListener(ServerDisconnectListener l)
Adds an serverDisconnect listener. The serverDisconnect handler is a method that will be called when a connection to a server is terminated. This is only usefull for Phidgets opened remotely.

There is no limit on the number of serverDisconnect handlers that can be registered for a particular Phidget.

Parameters:
l - An implemetation of the ServerDisconnectListener interface

removeServerDisconnectListener

public final void removeServerDisconnectListener(ServerDisconnectListener l)
Removes an serverDisconnect listener. This will remove a previously added serverDisconnect listener.


toString

public java.lang.String toString()
Return a Sring describing this Phidget.


equals

public boolean equals(java.lang.Object comp)
Compares two Phidgets. This method compares two Phidgets using serial number, device type and version.