com.phidgets
Class InterfaceKitPhidget

java.lang.Object
  extended by com.phidgets.Phidget
      extended by com.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 sensors. Inputs can be read and outputs can be set, and event handlers can be set for each of these.

See your hardware documentation for more information on the I/O specific to your Phidget.


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 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.
 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 setOutputState(int index, boolean newVal)
          Sets the state of a digital output.
 void setSensorChangeTrigger(int index, int newVal)
          Sets the change trigger for an analog input.
 
Methods inherited from class com.phidgets.Phidget
addAttachListener, addDetachListener, addErrorListener, close, equals, getDeviceName, getDeviceType, getDeviceVersion, getLibraryVersion, getSerialNumber, getTag, isAttached, open, openAny, removeAttachListener, removeDetachListener, removeErrorListener, setTag, toString, 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.

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.

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.

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.