ch.unizh.ini.caviar.usbaemonitor
Class USBAEMonitor

java.lang.Object
  extended by ch.unizh.ini.caviar.usbaemonitor.USBAEMonitor

public class USBAEMonitor
extends java.lang.Object

Acquires data from Anton Civit's Group's simple USB AER board that uses Silicon Labs (http://www.silabs.com) C8051F320 controller and SiLabs USBXPress device and host driver firmware and software.

The DLL's USBAEMonitor.dll and SiUSBXp.dll must be accessible for windows programs. Generally, this means they must be somewhere on the PATH, for example, in WINNT\system32, or they can be in the directory the program is started. It is generally simplest to just put the folders on the PATH variable.

Events are captured as 16 bit addresses and 32 bit timestamps with 1us tick. To use this class, construct an instance of USBAEMonitor, then open() it. Each time you want to capture available events, call acquireAvailableEventsFromDriver(), which returns the number of events grabbed. Access these events with getAddresses() and getTimestamps(), which each create new java arrays of the captured data. overrunOccured() can be used to see if there was a driver overrun.

See the main() method for an example of use.


Constructor Summary
USBAEMonitor()
          Creates a new instance of USBAEMon
 
Method Summary
 int acquireAvailableEventsFromDriver()
          Gets available events from driver.
 int close()
          Closes the device and frees the internal device handle.
 short[] getAddresses()
          Returns a newly constructed array of addresses
 int getNumEventsAcquired()
          Returns the number of events acquired by the last call to acquireAvailableEventsFromDriver()
 int[] getTimestamps()
          Returns a newly constructed array of timestamps that have a 1us tick
static void main(java.lang.String[] args)
          Tests event acquisition.
 int open()
          Opens the device driver and gets a handle to the device which is internally maintained.
 boolean overrunOccured()
          Is true if an overrun occured in the driver (>16k events) the last time acquireAvailableEventsFromDriver() was called.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

USBAEMonitor

public USBAEMonitor()
Creates a new instance of USBAEMon

Method Detail

open

public int open()
         throws USBAEMonitorException
Opens the device driver and gets a handle to the device which is internally maintained. Timestamps are reset to 0 and buffers are flushed. To reset timestamps, close() and reopen the device.

Returns:
0 if always.
Throws:
USBAEMonitorException - if there is a problem.
See Also:
close()

acquireAvailableEventsFromDriver

public int acquireAvailableEventsFromDriver()
                                     throws USBAEMonitorException
Gets available events from driver. Call this before calling getAddresses() or getTimestamps(). USBAEMonitorException is thrown if there is an error. overrunOccured() will be true if these was an overrun of the host USBXPress driver buffers (>16k events).

Returns:
number of events acquired. If this is zero there is no point in getting the events, because there are none.
Throws:
USBAEMonitorException - .

getNumEventsAcquired

public int getNumEventsAcquired()
Returns the number of events acquired by the last call to acquireAvailableEventsFromDriver()

Returns:
number of events acquired

getAddresses

public short[] getAddresses()
Returns a newly constructed array of addresses

Returns:
array of addresses

getTimestamps

public int[] getTimestamps()
Returns a newly constructed array of timestamps that have a 1us tick

Returns:
the timestamps

overrunOccured

public boolean overrunOccured()
Is true if an overrun occured in the driver (>16k events) the last time acquireAvailableEventsFromDriver() was called. This flag is cleared by the next acquireAvailableEventsFromDriver(). If there is an overrun, the events grabbed are the most ancient; events after the overrun are discarded. The timestamps continue on but will probably be lagged behind what they should be.

Returns:
true if there was an overrun.

close

public int close()
Closes the device and frees the internal device handle. Never throws an exception.

Returns:
0 if successful

main

public static void main(java.lang.String[] args)
Tests event acquisition.

Parameters:
args - the command line arguments