com.acces.aiousb
Class Counter

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

public class Counter
extends java.lang.Object

Class Counter represents a single counter/timer. One accesses a counter through its CounterSubsystem parent object (see getCounter()).


Field Summary
static int MODE_HW_TRIGGERED
          Mode 5: hardware triggered strobe (retriggerable) (see setMode()).
static int MODE_ONE_SHOT
          Mode 1: hardware retriggerable one-shot (see setMode()).
static int MODE_RATE_GENERATOR
          Mode 2: rate generator (see setMode()).
static int MODE_SQUARE_WAVE
          Mode 3: square wave mode (see setMode()).
static int MODE_SW_TRIGGERED
          Mode 4: software triggered mode (see setMode()).
static int MODE_TERMINAL_COUNT
          Mode 0: interrupt on terminal count (see setMode()).
 
Method Summary
 int getDeviceIndex()
          Gets the index of the parent device on the USB bus.
 char readCount()
          Reads a counter's current count value.
 char readCountAndSetModeAndCount(int mode, char count)
          Reads a counter's current count value, then sets a new mode and loads a new count value into the counter.
 char[] readCountAndStatus()
          Reads a counter's current count value and status.
 Counter setCount(char count)
          Loads a count value into the counter.
 Counter setMode(int mode)
          Sets the counter's mode.
 Counter setModeAndCount(int mode, char count)
          Sets a counter mode and loads a count value into the counter.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODE_TERMINAL_COUNT

public static final int MODE_TERMINAL_COUNT
Mode 0: interrupt on terminal count (see setMode()).

See Also:
Constant Field Values

MODE_ONE_SHOT

public static final int MODE_ONE_SHOT
Mode 1: hardware retriggerable one-shot (see setMode()).

See Also:
Constant Field Values

MODE_RATE_GENERATOR

public static final int MODE_RATE_GENERATOR
Mode 2: rate generator (see setMode()).

See Also:
Constant Field Values

MODE_SQUARE_WAVE

public static final int MODE_SQUARE_WAVE
Mode 3: square wave mode (see setMode()).

See Also:
Constant Field Values

MODE_SW_TRIGGERED

public static final int MODE_SW_TRIGGERED
Mode 4: software triggered mode (see setMode()).

See Also:
Constant Field Values

MODE_HW_TRIGGERED

public static final int MODE_HW_TRIGGERED
Mode 5: hardware triggered strobe (retriggerable) (see setMode()).

See Also:
Constant Field Values
Method Detail

getDeviceIndex

public int getDeviceIndex()
Gets the index of the parent device on the USB bus. Used internally in calls to the underlying API.

Returns:
The index of the parent device on the USB bus.

setMode

public Counter setMode(int mode)
Sets the counter's mode.

Parameters:
mode - the counter mode. May be one of:
MODE_TERMINAL_COUNT
MODE_ONE_SHOT
MODE_RATE_GENERATOR
MODE_SQUARE_WAVE
MODE_SW_TRIGGERED
MODE_HW_TRIGGERED
Returns:
This counter, useful for chaining together multiple operations.
Throws:
java.lang.IllegalArgumentException
OperationFailedException

setCount

public Counter setCount(char count)
Loads a count value into the counter.

Parameters:
count - the count value (0-65,535) to load into the counter.
Returns:
This counter, useful for chaining together multiple operations.
Throws:
OperationFailedException

setModeAndCount

public Counter setModeAndCount(int mode,
                               char count)
Sets a counter mode and loads a count value into the counter.

Parameters:
mode - the counter mode (see setMode()).
count - the count value (0-65,535) to load into the counter.
Returns:
This counter, useful for chaining together multiple operations.
Throws:
java.lang.IllegalArgumentException
OperationFailedException

readCount

public char readCount()
Reads a counter's current count value.

Returns:
The current count value (0-65,535).
Throws:
OperationFailedException

readCountAndStatus

public char[] readCountAndStatus()
Reads a counter's current count value and status.

Returns:
An array of 2 16-bit integers:
char[ 0 ] contains the current count value (0-65,535)
char[ 1 ] contains the current counter status (0-255)
Throws:
OperationFailedException

readCountAndSetModeAndCount

public char readCountAndSetModeAndCount(int mode,
                                        char count)
Reads a counter's current count value, then sets a new mode and loads a new count value into the counter.

Parameters:
mode - the counter mode (see setMode()).
count - the count value (0-65,535) to load into the counter.
Returns:
The 16-bit count value (0-65,535) prior to setting the new mode and count.
Throws:
java.lang.IllegalArgumentException
OperationFailedException