com.LabJack
Class LabJackWrapper

java.lang.Object
  extended bycom.LabJack.LabJackWrapper

public class LabJackWrapper
extends java.lang.Object

This is a helper class providing a simpler, alternate interface for the LabJack analog/digital USB I/O box.

Use the LabJack JNI class for access to all LabJack features.


Field Summary
static int AO0
          Constant for specifying D/A output channel
static int AO1
          Constant for specifying D/A output channel
protected  int demo
           
protected  int[] idnum
           
 
Constructor Summary
LabJackWrapper(int idnum)
          Class constructor.
LabJackWrapper(int idnum, int demo)
           
 
Method Summary
 void addSPI(SPI device)
          Used to add an SPI device to the list of SPI devices attached to the LabJack.
 float analogInDI(int channel, int gain)
          Reads differental analog input value.
 float analogInSE(int channel)
          Reads single-ended analog input value.
 void analogOut(int channel, float voltage)
          Outputs analog value.
 void configSPI(int spiMode)
          Used to specify basic SPI configuration, using default values for most items.
 void configSPI(int spiMode, int spiMsDelay, int spiHusDelay, int spiControlCS, int spiCsLine, int spiCsState, int spiConfigD)
          Used to fully specify SPI configuration.
 double counterRead(int reset)
          Reads digital counter.
 double counterRead(int reset, double[] ms)
          Reads digital counter.
 boolean digitalIn(int channel)
          Reads value on 'digital' pin (DB-25 connector).
 void digitalOut(int channel, int state)
          Sets value on 'digital' pin (DB-25).
 boolean ioIn(int channel)
          Reads value on IO pin.
 void ioOut(int channel, int state)
          Sets value on IO pin.
 void updateSPI()
          This method performs SPI communication, transfering data in from and/or out to SPI peripherals attached to the LabJack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AO0

public static final int AO0
Constant for specifying D/A output channel

See Also:
Constant Field Values

AO1

public static final int AO1
Constant for specifying D/A output channel

See Also:
Constant Field Values

idnum

protected int[] idnum

demo

protected int demo
Constructor Detail

LabJackWrapper

public LabJackWrapper(int idnum)
Class constructor.

Parameters:
idnum - Local identifier of LabJack to communicate with.

LabJackWrapper

public LabJackWrapper(int idnum,
                      int demo)
Method Detail

analogInSE

public float analogInSE(int channel)
                 throws LabJackException
Reads single-ended analog input value. This method invokes the native EAnalogIn method that reads a single value from specified channel.

Parameters:
channel - Which channel to read from (0-7).
Throws:
LabJackException

analogInDI

public float analogInDI(int channel,
                        int gain)
                 throws LabJackException
Reads differental analog input value. This method invokes the native EAnalogIn method that reads a single value from specified channel.

Parameters:
channel - Which channel to read from (0-3).
gain - Programmable gain value (G_1 - G_20)
Throws:
LabJackException

analogOut

public void analogOut(int channel,
                      float voltage)
               throws LabJackException
Outputs analog value. This method invokes the native EAnalogOut method that sets the output voltage on analog outputs 0/1.

Parameters:
channel - Which channel to output to (0/1)
Throws:
LabJackException

counterRead

public double counterRead(int reset,
                          double[] ms)
                   throws LabJackException
Reads digital counter. This method invokes the ECount method.

Parameters:
reset - Reset counter after reading if > 0.
ms - Receives time (Windows ms timer) counter was actually read.
Throws:
LabJackException

counterRead

public double counterRead(int reset)
                   throws LabJackException
Reads digital counter. This method invokes the ECount method.

Parameters:
reset - Reset counter after reading if > 0.
Throws:
LabJackException

ioIn

public boolean ioIn(int channel)
             throws LabJackException
Reads value on IO pin. This method invokes the EDigitalIn method.

Parameters:
channel - Which input to read (0-3).
Returns:
Signal state.
Throws:
LabJackException

ioOut

public void ioOut(int channel,
                  int state)
           throws LabJackException
Sets value on IO pin. This method invokes the EDigitalOut method.

Parameters:
channel - Which output to set (0-3).
state - Value to set output to (0/1).
Throws:
LabJackException

digitalIn

public boolean digitalIn(int channel)
                  throws LabJackException
Reads value on 'digital' pin (DB-25 connector). This method invokes the EDigitalIn method.

Parameters:
channel - Which input to read (0-15).
Returns:
Signal state.
Throws:
LabJackException

digitalOut

public void digitalOut(int channel,
                       int state)
                throws LabJackException
Sets value on 'digital' pin (DB-25). This method invokes the EDigitalOut method.

Parameters:
channel - Which output to set (0-15).
state - Value to set output to (0/1).
Throws:
LabJackException

addSPI

public void addSPI(SPI device)
Used to add an SPI device to the list of SPI devices attached to the LabJack.

SPI devices are added to the list starting with the first device in the SPI chain, working towards the last device in the chain. If you sub-divide a device into multiple groups of bits, add the groups starting with the LSB's working towards the MSB's.

All devices must be added before invoking updateSPI()

Parameters:
device - A single SPI device.

configSPI

public void configSPI(int spiMode)
Used to specify basic SPI configuration, using default values for most items. Use this method if you don't need (or want) the LabJack to automatically generate a chip select signal and you don't want to insert delays inbetween data bits (i.e. slow down the SPI, which at 'full-speed' only runs less than 200kHz).

Refer to the Synch() API method for information on configuring SPI.

Parameters:
spiMode - Specifies SPI mode (0: Mode A, 1: Mode B, etc.)

configSPI

public void configSPI(int spiMode,
                      int spiMsDelay,
                      int spiHusDelay,
                      int spiControlCS,
                      int spiCsLine,
                      int spiCsState,
                      int spiConfigD)
Used to fully specify SPI configuration.

Refer to the Synch() API method for information on configuring SPI.

Parameters:
spiMode - Specify SPI mode as: 0=A,1=B,2=C,3=D (0-3).
spiMsDelay - If >0, a 1 ms delay is added between each bit.
spiHusDelay - If >0, a hundred us delay is added between each bit.
spiControlCS - If >0, D0-D7 is automatically controlled as CS. The state and direction of CS is only tested if control is enabled.
spiCsLine - D line to use as CS if enabled (0-7).
spiCsState - Active state for CS line. This would be 0 for the normal !CS, or >0 for the less common CS.
spiConfigD - If >0, state and tris are configured for D13, D14, D15, and !CS.

updateSPI

public void updateSPI()
               throws LabJackException
This method performs SPI communication, transfering data in from and/or out to SPI peripherals attached to the LabJack.

The SPI hardware configuration must be specified using configSPI() and SPI devices added using addSPI() before using this method.

Throws:
LabJackException