com.acces.aiousb
Class USBDeviceManager

java.lang.Object
  extended by com.acces.aiousb.USBDeviceManager

public class USBDeviceManager
extends java.lang.Object

Class USBDeviceManager manages all the USB devices on the bus. It scans the bus and builds a list of all the devices found. It also initializes and terminates use of the underlying AIOUSB module.


Field Summary
static int PICO_DIO16RO8
           
static int SUCCESS
          Indicates that underlying AIOUSB module operation succeeded.
static int USB_AI12_128
           
static int USB_AI12_128A
           
static int USB_AI12_128E
           
static int USB_AI12_16
           
static int USB_AI12_16A
           
static int USB_AI12_16E
           
static int USB_AI12_32
           
static int USB_AI12_32A
           
static int USB_AI12_32E
           
static int USB_AI12_64
           
static int USB_AI12_64A
           
static int USB_AI12_64E
           
static int USB_AI12_64M
           
static int USB_AI12_64MA
           
static int USB_AI12_64ME
           
static int USB_AI12_96
           
static int USB_AI12_96A
           
static int USB_AI12_96E
           
static int USB_AI16_128A
           
static int USB_AI16_128E
           
static int USB_AI16_16A
           
static int USB_AI16_16E
           
static int USB_AI16_32A
           
static int USB_AI16_32E
           
static int USB_AI16_64A
           
static int USB_AI16_64E
           
static int USB_AI16_64MA
           
static int USB_AI16_64ME
           
static int USB_AI16_96A
           
static int USB_AI16_96E
           
static int USB_AO12_12
           
static int USB_AO12_12A
           
static int USB_AO12_16
           
static int USB_AO12_16A
           
static int USB_AO12_4
           
static int USB_AO12_4A
           
static int USB_AO12_8
           
static int USB_AO12_8A
           
static int USB_AO16_12
           
static int USB_AO16_12A
           
static int USB_AO16_16
           
static int USB_AO16_16A
           
static int USB_AO16_4
           
static int USB_AO16_4A
           
static int USB_AO16_8
           
static int USB_AO16_8A
           
static int USB_CTR_15
           
static int USB_DA12_8A
           
static int USB_DA12_8A_REV_A
           
static int USB_DA12_8E
           
static int USB_DI16A
           
static int USB_DI16A_REV_A1
           
static int USB_DI16A_REV_A2
           
static int USB_DIO_16A
           
static int USB_DIO_16H
           
static int USB_DIO_32
           
static int USB_DIO_48
           
static int USB_DIO_96
           
static int USB_DIO16RO8
           
static int USB_DO16A
           
static int USB_DO16A_REV_A1
           
static int USB_IDIO_16
           
static int USB_IDIO_4
           
static int USB_IDIO_8
           
static int USB_IDO_16
           
static int USB_II_16
           
static int USB_II_16_OLD
           
static int USB_II_8
           
static int USB_II_8_OLD
           
static int USB_IIRO_16
           
static int USB_IIRO_4
           
static int USB_IIRO_8
           
static int USB_IIRO4_2SM
           
static int USB_IIRO4_COM
           
static int USB_RO_16
           
static java.lang.String VERSION_DATE
          The version date of this Java class library.
static java.lang.String VERSION_NUMBER
          The version number of this Java class library.
 
Constructor Summary
USBDeviceManager()
          Constructor for USB device manager.
 
Method Summary
 USBDeviceManager close()
          "Closes" the USB device manager for use.
 java.lang.String getAIOUSBVersion()
          Gets the version number of the underlying AIOUSB module.
 java.lang.String getAIOUSBVersionDate()
          Gets the version date of the underlying AIOUSB module.
 java.util.Vector<USBDevice> getDeviceByProductID(int productID)
          Gets a list of all the devices found on the bus matching the specified product ID.
 java.util.Vector<USBDevice> getDeviceByProductID(int minProductID, int maxProductID)
          Gets a list of all the devices found on the bus matching the specified product ID range.
 java.util.Vector<USBDevice> getDeviceBySerialNumber(long serialNumber)
          Gets a list of all the devices found on the bus matching the specified serial number.
static java.lang.String getResultCodeAsString(int result)
          Gets the string representation of an AIOUSB result code, useful mainly for debugging purposes.
 boolean isOpen()
          Tells if the USB device manager has been "opened" for use (see open()).
 void listDevices()
          Prints the properties of all the devices found on the bus to the standard output device.
 USBDeviceManager open()
          "Opens" the USB device manager for use.
 java.io.PrintStream print(java.io.PrintStream stream)
          Prints the properties of this device manager and all of the devices found on the bus to the specified print stream.
 USBDeviceManager printDevices()
          Prints the properties of this device manager and all of the devices found on the bus to the standard output device.
 USBDeviceManager scanForDevices()
          Re-scans the bus for devices.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION_NUMBER

public static final java.lang.String VERSION_NUMBER
The version number of this Java class library.

See Also:
Constant Field Values

VERSION_DATE

public static final java.lang.String VERSION_DATE
The version date of this Java class library.

See Also:
Constant Field Values

SUCCESS

public static final int SUCCESS
Indicates that underlying AIOUSB module operation succeeded.

See Also:
Constant Field Values

USB_DA12_8A_REV_A

public static final int USB_DA12_8A_REV_A
See Also:
Constant Field Values

USB_DA12_8A

public static final int USB_DA12_8A
See Also:
Constant Field Values

USB_DA12_8E

public static final int USB_DA12_8E
See Also:
Constant Field Values

USB_DIO_32

public static final int USB_DIO_32
See Also:
Constant Field Values

USB_DIO_48

public static final int USB_DIO_48
See Also:
Constant Field Values

USB_DIO_96

public static final int USB_DIO_96
See Also:
Constant Field Values

USB_DI16A_REV_A1

public static final int USB_DI16A_REV_A1
See Also:
Constant Field Values

USB_DO16A_REV_A1

public static final int USB_DO16A_REV_A1
See Also:
Constant Field Values

USB_DI16A_REV_A2

public static final int USB_DI16A_REV_A2
See Also:
Constant Field Values

USB_DIO_16H

public static final int USB_DIO_16H
See Also:
Constant Field Values

USB_DI16A

public static final int USB_DI16A
See Also:
Constant Field Values

USB_DO16A

public static final int USB_DO16A
See Also:
Constant Field Values

USB_DIO_16A

public static final int USB_DIO_16A
See Also:
Constant Field Values

USB_IIRO_16

public static final int USB_IIRO_16
See Also:
Constant Field Values

USB_II_16

public static final int USB_II_16
See Also:
Constant Field Values

USB_RO_16

public static final int USB_RO_16
See Also:
Constant Field Values

USB_IIRO_8

public static final int USB_IIRO_8
See Also:
Constant Field Values

USB_II_8

public static final int USB_II_8
See Also:
Constant Field Values

USB_IIRO_4

public static final int USB_IIRO_4
See Also:
Constant Field Values

USB_IDIO_16

public static final int USB_IDIO_16
See Also:
Constant Field Values

USB_II_16_OLD

public static final int USB_II_16_OLD
See Also:
Constant Field Values

USB_IDO_16

public static final int USB_IDO_16
See Also:
Constant Field Values

USB_IDIO_8

public static final int USB_IDIO_8
See Also:
Constant Field Values

USB_II_8_OLD

public static final int USB_II_8_OLD
See Also:
Constant Field Values

USB_IDIO_4

public static final int USB_IDIO_4
See Also:
Constant Field Values

USB_CTR_15

public static final int USB_CTR_15
See Also:
Constant Field Values

USB_IIRO4_2SM

public static final int USB_IIRO4_2SM
See Also:
Constant Field Values

USB_IIRO4_COM

public static final int USB_IIRO4_COM
See Also:
Constant Field Values

USB_DIO16RO8

public static final int USB_DIO16RO8
See Also:
Constant Field Values

PICO_DIO16RO8

public static final int PICO_DIO16RO8
See Also:
Constant Field Values

USB_AI16_16A

public static final int USB_AI16_16A
See Also:
Constant Field Values

USB_AI16_16E

public static final int USB_AI16_16E
See Also:
Constant Field Values

USB_AI12_16A

public static final int USB_AI12_16A
See Also:
Constant Field Values

USB_AI12_16

public static final int USB_AI12_16
See Also:
Constant Field Values

USB_AI12_16E

public static final int USB_AI12_16E
See Also:
Constant Field Values

USB_AI16_64MA

public static final int USB_AI16_64MA
See Also:
Constant Field Values

USB_AI16_64ME

public static final int USB_AI16_64ME
See Also:
Constant Field Values

USB_AI12_64MA

public static final int USB_AI12_64MA
See Also:
Constant Field Values

USB_AI12_64M

public static final int USB_AI12_64M
See Also:
Constant Field Values

USB_AI12_64ME

public static final int USB_AI12_64ME
See Also:
Constant Field Values

USB_AI16_32A

public static final int USB_AI16_32A
See Also:
Constant Field Values

USB_AI16_32E

public static final int USB_AI16_32E
See Also:
Constant Field Values

USB_AI12_32A

public static final int USB_AI12_32A
See Also:
Constant Field Values

USB_AI12_32

public static final int USB_AI12_32
See Also:
Constant Field Values

USB_AI12_32E

public static final int USB_AI12_32E
See Also:
Constant Field Values

USB_AI16_64A

public static final int USB_AI16_64A
See Also:
Constant Field Values

USB_AI16_64E

public static final int USB_AI16_64E
See Also:
Constant Field Values

USB_AI12_64A

public static final int USB_AI12_64A
See Also:
Constant Field Values

USB_AI12_64

public static final int USB_AI12_64
See Also:
Constant Field Values

USB_AI12_64E

public static final int USB_AI12_64E
See Also:
Constant Field Values

USB_AI16_96A

public static final int USB_AI16_96A
See Also:
Constant Field Values

USB_AI16_96E

public static final int USB_AI16_96E
See Also:
Constant Field Values

USB_AI12_96A

public static final int USB_AI12_96A
See Also:
Constant Field Values

USB_AI12_96

public static final int USB_AI12_96
See Also:
Constant Field Values

USB_AI12_96E

public static final int USB_AI12_96E
See Also:
Constant Field Values

USB_AI16_128A

public static final int USB_AI16_128A
See Also:
Constant Field Values

USB_AI16_128E

public static final int USB_AI16_128E
See Also:
Constant Field Values

USB_AI12_128A

public static final int USB_AI12_128A
See Also:
Constant Field Values

USB_AI12_128

public static final int USB_AI12_128
See Also:
Constant Field Values

USB_AI12_128E

public static final int USB_AI12_128E
See Also:
Constant Field Values

USB_AO16_16A

public static final int USB_AO16_16A
See Also:
Constant Field Values

USB_AO16_16

public static final int USB_AO16_16
See Also:
Constant Field Values

USB_AO16_12A

public static final int USB_AO16_12A
See Also:
Constant Field Values

USB_AO16_12

public static final int USB_AO16_12
See Also:
Constant Field Values

USB_AO16_8A

public static final int USB_AO16_8A
See Also:
Constant Field Values

USB_AO16_8

public static final int USB_AO16_8
See Also:
Constant Field Values

USB_AO16_4A

public static final int USB_AO16_4A
See Also:
Constant Field Values

USB_AO16_4

public static final int USB_AO16_4
See Also:
Constant Field Values

USB_AO12_16A

public static final int USB_AO12_16A
See Also:
Constant Field Values

USB_AO12_16

public static final int USB_AO12_16
See Also:
Constant Field Values

USB_AO12_12A

public static final int USB_AO12_12A
See Also:
Constant Field Values

USB_AO12_12

public static final int USB_AO12_12
See Also:
Constant Field Values

USB_AO12_8A

public static final int USB_AO12_8A
See Also:
Constant Field Values

USB_AO12_8

public static final int USB_AO12_8
See Also:
Constant Field Values

USB_AO12_4A

public static final int USB_AO12_4A
See Also:
Constant Field Values

USB_AO12_4

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

USBDeviceManager

public USBDeviceManager()
Constructor for USB device manager. You must call open() before using the device manager.

Method Detail

print

public java.io.PrintStream print(java.io.PrintStream stream)
Prints the properties of this device manager and all of the devices found on the bus to the specified print stream. Mainly useful for diagnostic purposes.

Parameters:
stream - the print stream where properties will be printed.
Returns:
The print stream.

printDevices

public USBDeviceManager printDevices()
Prints the properties of this device manager and all of the devices found on the bus to the standard output device. Mainly useful for diagnostic purposes.

Returns:
This device manager, useful for chaining together multiple operations.
Throws:
OperationFailedException

getAIOUSBVersion

public java.lang.String getAIOUSBVersion()
Gets the version number of the underlying AIOUSB module.

Returns:
The AIOUSB module version number as a string with the form, "1.78".

getAIOUSBVersionDate

public java.lang.String getAIOUSBVersionDate()
Gets the version date of the underlying AIOUSB module.

Returns:
The AIOUSB module version date as a string with the form, "15 November 2009".

listDevices

public void listDevices()
Prints the properties of all the devices found on the bus to the standard output device. This function is similar to printDevices() but is implemented by the underlying AIOUSB module and produces different output than printDevices(). Mainly useful for diagnostic purposes.


getResultCodeAsString

public static java.lang.String getResultCodeAsString(int result)
Gets the string representation of an AIOUSB result code, useful mainly for debugging purposes. This method is also used to convert an AIOUSB result code to a string when a OperationFailedException is thrown in response to an AIOUSB failure.

Parameters:
result - an AIOUSB result code.
Returns:
The string representation of result.

isOpen

public boolean isOpen()
Tells if the USB device manager has been "opened" for use (see open()).

Returns:
True indicates that the device manager is open and ready to be used; false indicates that it is not open.

open

public USBDeviceManager open()
"Opens" the USB device manager for use. Before the USB device manager may be used, open() must be called. Open() initializes the underlying AIOUSB module and scans the bus for devices, building a list of the devices found. When finished using the USB device manager, close() must be called. It is possible to call close() and then call open() again, which effectively reinitializes everything.

Returns:
This device manager, useful for chaining together multiple operations.
Throws:
OperationFailedException

close

public USBDeviceManager close()
"Closes" the USB device manager for use. When finished using the USB device manager, and assuming open() was properly called, close() must be called. Close() terminates use of the underlying AIOUSB module and discards the list of devices found. You must terminate use of all USB devices before calling close()! You can call open() again to reinitialize things and reestablish connections to USB devices.

Returns:
This device manager, useful for chaining together multiple operations.
Throws:
OperationFailedException

scanForDevices

public USBDeviceManager scanForDevices()
Re-scans the bus for devices. ScanForDevices() is called automatically by open(). You must terminate use of all USB devices before calling scanForDevices()! After calling scanForDevices() you can reestablish connections to USB devices.

Returns:
This device manager, useful for chaining together multiple operations.
Throws:
OperationFailedException

getDeviceByProductID

public java.util.Vector<USBDevice> getDeviceByProductID(int productID)
Gets a list of all the devices found on the bus matching the specified product ID. Only devices exactly matching the specified product ID will be returned.

Parameters:
productID - the product ID to search for.
Returns:
A vector of all the devices found. If no devices were found matching the specified product ID, the vector will be empty (i.e. contain zero items).

getDeviceByProductID

public java.util.Vector<USBDevice> getDeviceByProductID(int minProductID,
                                                        int maxProductID)
Gets a list of all the devices found on the bus matching the specified product ID range. Any device with a product ID greater than or equal to minProductID and less than or equal to maxProductID will be returned. You can obtain the entire list of devices detected by passing a value of 0 for minProductID and a value of 0xffff for maxProductID. Then you can search the list obtained using your own search criteria.

Parameters:
minProductID - the minimum product ID to search for.
maxProductID - the maximum product ID to search for.
Returns:
A vector of all the devices found. If no devices were found matching the specified product ID range, the vector will be empty (i.e. contain zero items).
Throws:
java.lang.IllegalArgumentException

getDeviceBySerialNumber

public java.util.Vector<USBDevice> getDeviceBySerialNumber(long serialNumber)
Gets a list of all the devices found on the bus matching the specified serial number. Only devices exactly matching the specified serial number will be returned. In theory, there ought to be only one device matching a given serial number, but this method returns a vector in order to be consistent with the other search methods, and in unlikely event that multiple devices do share the same serial number.

Parameters:
serialNumber - the serial number to search for.
Returns:
A vector of all the devices found. If no devices were found matching the specified serial number, the vector will be empty (i.e. contain zero items).