com.phidgets
Class InterfaceKitPhidget

java.lang.Object
  extended bycom.phidgets.Phidget
      extended bycom.phidgets.InterfaceKitPhidget

public final class InterfaceKitPhidget
extends Phidget

This class represents a Phidget Interface Kit. All methods to read and write data to and from an Interface Kit are implemented in this class.

There are many types of Interface Kits, but each is simply a collection of 0 or more digital inputs, digital outpus and analog sensor inputs. The inputs can be read and outputs can be set, and event handlers can be set for each of these.

See your device's User Guide for more specific API details, technical information, and revision details. The User Guide, along with other resources, can be found on the product page for your device.

Author:
Phidgets Inc.

Field Summary
 
Fields inherited from class com.phidgets.Phidget
PHIDCLASS_ACCELEROMETER, PHIDCLASS_ADVANCEDSERVO, PHIDCLASS_ANALOG, PHIDCLASS_BRIDGE, PHIDCLASS_ENCODER, PHIDCLASS_FREQUENCYCOUNTER, PHIDCLASS_GPS, PHIDCLASS_INTERFACEKIT, PHIDCLASS_LED, PHIDCLASS_MOTORCONTROL, PHIDCLASS_NOTHING, PHIDCLASS_PHSENSOR, PHIDCLASS_RFID, PHIDCLASS_SERVO, PHIDCLASS_STEPPER, PHIDCLASS_TEMPERATURESENSOR, PHIDCLASS_TEXTLCD, PHIDCLASS_TEXTLED, PHIDCLASS_WEIGHTSENSOR, PHIDGET_LOG_CRITICAL, PHIDGET_LOG_DEBUG, PHIDGET_LOG_ERROR, PHIDGET_LOG_INFO, PHIDGET_LOG_VERBOSE, PHIDGET_LOG_WARNING, PHIDID_ACCELEROMETER_2AXIS, PHIDID_ACCELEROMETER_3AXIS, PHIDID_ADVANCEDSERVO_1MOTOR, PHIDID_ADVANCEDSERVO_8MOTOR, PHIDID_ANALOG_4OUTPUT, PHIDID_BIPOLAR_STEPPER_1MOTOR, PHIDID_BRIDGE_4INPUT, PHIDID_ENCODER_1ENCODER_1INPUT, PHIDID_ENCODER_HS_1ENCODER, PHIDID_ENCODER_HS_4ENCODER_4INPUT, PHIDID_FREQUENCYCOUNTER_2INPUT, PHIDID_GPS, PHIDID_INTERFACEKIT_0_0_4, PHIDID_INTERFACEKIT_0_0_8, PHIDID_INTERFACEKIT_0_16_16, PHIDID_INTERFACEKIT_0_8_8_w_LCD, PHIDID_INTERFACEKIT_2_2_2, PHIDID_INTERFACEKIT_4_8_8, PHIDID_INTERFACEKIT_8_8_8, PHIDID_INTERFACEKIT_8_8_8_w_LCD, PHIDID_IR, PHIDID_LED_64, PHIDID_LED_64_ADV, PHIDID_LINEAR_TOUCH, PHIDID_MOTORCONTROL_1MOTOR, PHIDID_MOTORCONTROL_HC_2MOTOR, PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT, PHIDID_NOTHING, PHIDID_PHSENSOR, PHIDID_RFID, PHIDID_RFID_2OUTPUT, PHIDID_RFID_2OUTPUT_READ_WRITE, PHIDID_ROTARY_TOUCH, PHIDID_SERVO_1MOTOR, PHIDID_SERVO_1MOTOR_OLD, PHIDID_SERVO_4MOTOR, PHIDID_SERVO_4MOTOR_OLD, PHIDID_SPATIAL_ACCEL_3AXIS, PHIDID_SPATIAL_ACCEL_GYRO_COMPASS, PHIDID_TEMPERATURESENSOR, PHIDID_TEMPERATURESENSOR_4, PHIDID_TEMPERATURESENSOR_IR, PHIDID_TEXTLCD_2x20, PHIDID_TEXTLCD_2x20_w_0_8_8, PHIDID_TEXTLCD_2x20_w_8_8_8, PHIDID_TEXTLCD_ADAPTER, PHIDID_TEXTLED_1x8, PHIDID_TEXTLED_4x8, PHIDID_UNIPOLAR_STEPPER_4MOTOR, PHIDID_WEIGHTSENSOR
 
Constructor Summary
InterfaceKitPhidget()
          Class Constructor.
 
Method Summary
 void addInputChangeListener(InputChangeListener l)
          Adds an input change listener.
 void addOutputChangeListener(OutputChangeListener l)
          Adds an output change listener.
 void addSensorChangeListener(SensorChangeListener l)
          Adds a sensor change listener.
 int getDataRate(int index)
          Returns the data rate for a sensor, in milliseconds.
 int getDataRateMax(int index)
          Returns the maximum data rate for a sensor, in milliseconds.
 int getDataRateMin(int index)
          Returns the minimum data rate for a sensor, in milliseconds.
 int getInputCount()
          Returns the number of ditigal inputs on this Interface Kit.
 boolean getInputState(int index)
          Returns the state of a digital input.
 int getOutputCount()
          Returns the number of digital outputs on this Interface Kit.
 boolean getOutputState(int index)
          Returns the state of a digital output.
 boolean getRatiometric()
          Gets the ratiometric state for the analog sensors
 int getSensorChangeTrigger(int index)
          Returns the change trigger for an analog input.
 int getSensorCount()
          Returns the number of analog inputs on the Interface Kit.
 int getSensorRawValue(int index)
          Returns the raw value of a analog input.
 int getSensorValue(int index)
          Returns the value of a analog input.
 void removeInputChangeListener(InputChangeListener l)
          Removes an input change listener.
 void removeOutputChangeListener(OutputChangeListener l)
          Removes an output change listener.
 void removeSensorChangeListener(SensorChangeListener l)
          Removes a sensor change listener.
 void setDataRate(int index, int newVal)
          Sets the data rate of a sensor, in milliseconds.
 void setOutputState(int index, boolean newVal)
          Sets the state of a digital output.
 void setRatiometric(boolean state)
          Sets the ratiometric state for the analog inputs.
 void setSensorChangeTrigger(int index, int newVal)
          Sets the change trigger for an analog input.
 
Methods inherited from class com.phidgets.Phidget
addAttachListener, addDetachListener, addErrorListener, addServerConnectListener, addServerDisconnectListener, close, disableLogging, enableLogging, equals, getDeviceClass, getDeviceID, getDeviceLabel, getDeviceName, getDeviceType, getDeviceVersion, getLibraryVersion, getSerialNumber, getServerAddress, getServerID, getServerPort, isAttached, isAttachedToServer, log, open, open, open, open, open, openAny, openAny, openAny, openAny, openAny, openLabel, openLabel, openLabel, openLabel, openLabel, removeAttachListener, removeDetachListener, removeErrorListener, removeServerConnectListener, removeServerDisconnectListener, setDeviceLabel, toString, waitForAttachment, waitForAttachment
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InterfaceKitPhidget

public InterfaceKitPhidget()
                    throws PhidgetException
Class Constructor. Calling this opens a connection to the phidget21 C library creates an internal handle for this Phidget, ready to call open on.

Throws:
PhidgetException - If there was a problem connecting to phidget21 or creating the internal handle.
Method Detail

getOutputCount

public int getOutputCount()
                   throws PhidgetException
Returns the number of digital outputs on this Interface Kit. Not all interface kits have the same number of digital outputs, and some don't have any digital outputs at all.

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

getInputCount

public int getInputCount()
                  throws PhidgetException
Returns the number of ditigal inputs on this Interface Kit. Not all interface kits have the same number of digital inputs, and some don't have any digital inputs at all.

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

getSensorCount

public int getSensorCount()
                   throws PhidgetException
Returns the number of analog inputs on the Interface Kit. Not all interface kits have the same number of analog inputs, and some don't have any analog inputs at all.

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

getDataRateMin

public int getDataRateMin(int index)
                   throws PhidgetException
Returns the minimum data rate for a sensor, in milliseconds.

Parameters:
index - Index of the input
Returns:
minimum data rate
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

getDataRateMax

public int getDataRateMax(int index)
                   throws PhidgetException
Returns the maximum data rate for a sensor, in milliseconds.

Parameters:
index - Index of the input
Returns:
maximum data rate
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

getInputState

public boolean getInputState(int index)
                      throws PhidgetException
Returns the state of a digital input. Digital inputs read True where they are activated and false when they are in their default state.

Be sure to check getInputCount first if you are unsure as to the number of inputs, so as not to set an Index that is out of range.

Parameters:
index - Index of the input
Returns:
State of the input
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

getOutputState

public boolean getOutputState(int index)
                       throws PhidgetException
Returns the state of a digital output. Depending on the Phidget, this value may be either the value that you last wrote out to the Phidget, or the value that the Phidget last returned. This is because some Phidgets return their output state and others do not. This means that with some devices, reading the output state of a pin directly after setting it, may not return the value that you just set.

Be sure to check getOutputCount first if you are unsure as to the number of outputs, so as not to attempt to get an Index that is out of range.

Parameters:
index - Index of the output
Returns:
State of the output
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

getSensorValue

public int getSensorValue(int index)
                   throws PhidgetException
Returns the value of a analog input. The analog inputs are where analog sensors are attached on the InterfaceKit 8/8/8. On the Linear and Circular touch sensor Phidgets, analog input 0 represents position on the slider.

The valid range is 0-1000. In the case of a sensor, this value can be converted to an actual sensor value using the formulas provided here: http://www.phidgets.com/documentation/Sensors.pdf

Parameters:
index - Index of the sensor
Returns:
Sensor value
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

getSensorRawValue

public int getSensorRawValue(int index)
                      throws PhidgetException
Returns the raw value of a analog input. This is a more accurate version of getSensorValue. The valid range is 0-4095. Note however that the analog outputs on the Interface Kit 8/8/8 are only 10-bit values and this value represents an oversampling to 12-bit.

Parameters:
index - Index of the sensor
Returns:
Sensor value
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

getSensorChangeTrigger

public int getSensorChangeTrigger(int index)
                           throws PhidgetException
Returns the change trigger for an analog input. This is the ammount that an inputs must change between successive SensorChangeEvents. This is based on the 0-1000 range provided by getSensorValue. This value is by default set to 10 for most Interface Kits with analog inputs.

Parameters:
index - Index of the sensor
Returns:
Trigger value
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

getDataRate

public int getDataRate(int index)
                throws PhidgetException
Returns the data rate for a sensor, in milliseconds.

Parameters:
index - Index of the sensor
Returns:
data rate
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

getRatiometric

public boolean getRatiometric()
                       throws PhidgetException
Gets the ratiometric state for the analog sensors

Returns:
state State
Throws:
PhidgetException - If this Phidget is not opened and attached, or if this phidget does not support ratiometric. See open for information on determining if a device is attached.

setOutputState

public void setOutputState(int index,
                           boolean newVal)
                    throws PhidgetException
Sets the state of a digital output. Setting this to true will activate the output, False is the default state.

Parameters:
index - Index of the output
newVal - State to set the output to
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

setSensorChangeTrigger

public void setSensorChangeTrigger(int index,
                                   int newVal)
                            throws PhidgetException
Sets the change trigger for an analog input. This is the ammount that an inputs must change between successive SensorChangeEvents. This is based on the 0-1000 range provided by getSensorValue. This value is by default set to 10 for most Interface Kits with analog inputs.

Parameters:
index - Input
newVal - Value
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

setDataRate

public void setDataRate(int index,
                        int newVal)
                 throws PhidgetException
Sets the data rate of a sensor, in milliseconds.

Parameters:
index - Input
newVal - data rate
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

setRatiometric

public void setRatiometric(boolean state)
                    throws PhidgetException
Sets the ratiometric state for the analog inputs. The default is for ratiometric to be set on and this is appropriate for most sensors.

Parameters:
state - State
Throws:
PhidgetException - If this Phidget is not opened and attached, or if this Phidget does not support ratiometric See open for information on determining if a device is attached.

addInputChangeListener

public final void addInputChangeListener(InputChangeListener l)
Adds an input change listener. The input change handler is a method that will be called when an input on this Interface Kit has changed.

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

Parameters:
l - An implemetation of the InputChangeListener interface

removeInputChangeListener

public final void removeInputChangeListener(InputChangeListener l)
Removes an input change listener. This will remove a previously added input change listener.


addOutputChangeListener

public final void addOutputChangeListener(OutputChangeListener l)
Adds an output change listener. The output change handler is a method that will be called when an output on this Interface Kit has changed.

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

Parameters:
l - An implemetation of the OutputChangeListener interface

removeOutputChangeListener

public final void removeOutputChangeListener(OutputChangeListener l)
Removes an output change listener. This will remove a previously added output change listener.


addSensorChangeListener

public final void addSensorChangeListener(SensorChangeListener l)
Adds a sensor change listener. The sensor change handler is a method that will be called when a sensor on this Interface Kit has changed by at least the Trigger that has been set for this sensor.

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

Parameters:
l - An implemetation of the SensorChangeListener interface

removeSensorChangeListener

public final void removeSensorChangeListener(SensorChangeListener l)
Removes a sensor change listener. This will remove a previously added sensor change listener.