org.mbari.siam.foce.devices.co2subsys
Class BB232SPDA

java.lang.Object
  extended by org.mbari.siam.foce.devices.co2subsys.BB232SPDA

public class BB232SPDA
extends java.lang.Object

The 232SPDA module is used to interface various analog and digital signals from within the CO2 electronics housing. It has seven 12-bit A/D inputs, four 8-bit D/A outputs, two digital inputs and one digital output. It is powered by +12Vdc and is communicated to via an RS-232 connection.


Field Summary
protected static org.apache.log4j.Logger _log4j
          Log4j logger
protected  int _serialMode
          Serial port mode.
protected  byte[] _terminator
          Response terminator (as byte array)
protected  java.lang.String _terminatorString
          Response terminator (as String)
static int ANALOG_INPUTS
           
static int ANALOG_OUTPUTS
           
static int BUF32
          Buffer size (32)
static int DI_0_BIT
           
static byte DI_0_MASK
           
static int DI_1_BIT
           
static byte DI_1_MASK
           
static int DIGITAL_INPUTS
           
static int DIGITAL_OUTPUTS
           
static int DO_0_BIT
           
static byte DO_0_MASK
           
static byte[] LINE_END_BYTES
          line end for terminating command
static int MAX_ANALOG_INPUT
           
static int MODE_SERIAL_LOCAL
          Driver serial mode - use local serial port If this mode is selected command pacing is not used during cmdWriteRead (not an Elmo mode)
static int MODE_SERIAL_RFC1722
          Driver RFC1722 mode - use ethernet/serial converter e.g.
static int RA_AI_0
           
static int RA_AI_1
           
static int RA_AI_2
           
static int RA_AI_3
           
static int RA_AI_4
           
static int RA_AI_5
           
static int RA_AI_6
           
static int RA_DI_0
           
static int RA_DI_1
           
static int RA_DO_0
           
static int RAI_AI_0
           
static int RAI_AI_1
           
static int RAI_AI_2
           
static int RAI_AI_3
           
static int RAI_AI_4
           
static int RAI_AI_5
           
static int RAI_AI_6
           
static int RDIO_DI_0
           
static int RDIO_DI_1
           
static int RDIO_DO_0
           
static java.lang.String READ_ALL_ANALOG
           
static java.lang.String READ_ANALOG_IN
           
static java.lang.String READ_DIGITAL_IO
           
static long TM_CMD_DELAY_MSEC
          time between writing and reading command (see cmdWriteRead)
static long TM_CMD_MSEC
          Command timeout (milliseconds)
static long TM_EMPTY_INPUT_MSEC
          default timeout during input stream flush
static long TM_MOTION_WAIT_MSEC
          default motion wait polling interval
static long TM_POLL_DELAY_MSEC
          polling delay during motor start/stop (milliseconds)
static long TM_START_MSEC
          motor startup timeout (milliseconds)
static long TM_STOP_MSEC
          motor stop timeout (milliseconds)
static long TM_WRITE_DELAY_MSEC
          time following digitial output write
static long TM_WRITEREAD_MSEC
          default write/read cycle timeout
static java.lang.String WRITE_DIGITAL_OUT
           
static byte[] WRITE_DIGITAL_OUT_BYTES
           
 
Constructor Summary
BB232SPDA()
           
BB232SPDA(gnu.io.SerialPort port, int serialMode)
           
 
Method Summary
protected  int cmdWriteRead(java.lang.String cmd, byte[] buf, int startIndex, int len, long timeoutMsec)
          Perform one I/O transaction, (write then read).
protected  byte[] cmdWriteReadBytes(java.lang.String cmd, int len, long timeoutMsec)
          Write one command and parse the resulting return value as a String.
 void configure()
           
protected  void delay(long delayMsec)
          Sleep for specified time
protected  void emptyInput(java.io.InputStream instream, long timeoutMsec)
          Flush the serial input stream.
 void emptyInput(long timeoutMsec)
          Flush the serial input stream.
 java.io.InputStream getInputStream()
          Return serial port input stream used by this controller.
 java.io.OutputStream getOutputStream()
          Return serial port output stream used by this controller.
 int getSerialMode()
          set serial mode
 gnu.io.SerialPort getSerialPort()
          Return SerialPort used by this controller.
static java.lang.String mkCmd(java.lang.String cmd, int value)
           
 short[] readADChannels(int maxChannel)
          max channel 0:MAX_ANALOG_INPUT
 short[] readAll()
           
 short[] readDigitalIO()
           
 void setSerialMode(int mode)
          set serial mode
 void setSerialPort(gnu.io.SerialPort port)
          Set the SerialPort for this controller to use.
 void writeAnalogOutput(int channel, short data)
           
protected  void writeCommand(java.lang.String cmd)
          Write a command to the serial port.
 void writeDigitalOut(boolean state)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_log4j

protected static org.apache.log4j.Logger _log4j
Log4j logger


MODE_SERIAL_LOCAL

public static final int MODE_SERIAL_LOCAL
Driver serial mode - use local serial port If this mode is selected command pacing is not used during cmdWriteRead (not an Elmo mode)

See Also:
Constant Field Values

MODE_SERIAL_RFC1722

public static final int MODE_SERIAL_RFC1722
Driver RFC1722 mode - use ethernet/serial converter e.g. Digi. If this mode is selected, command pacing is used during cmdWriteRead (not an Elmo mode)

See Also:
Constant Field Values

TM_CMD_MSEC

public static final long TM_CMD_MSEC
Command timeout (milliseconds)

See Also:
Constant Field Values

TM_START_MSEC

public static final long TM_START_MSEC
motor startup timeout (milliseconds)

See Also:
Constant Field Values

TM_STOP_MSEC

public static final long TM_STOP_MSEC
motor stop timeout (milliseconds)

See Also:
Constant Field Values

TM_POLL_DELAY_MSEC

public static final long TM_POLL_DELAY_MSEC
polling delay during motor start/stop (milliseconds)

See Also:
Constant Field Values

TM_EMPTY_INPUT_MSEC

public static final long TM_EMPTY_INPUT_MSEC
default timeout during input stream flush

See Also:
Constant Field Values

TM_WRITEREAD_MSEC

public static final long TM_WRITEREAD_MSEC
default write/read cycle timeout

See Also:
Constant Field Values

TM_MOTION_WAIT_MSEC

public static final long TM_MOTION_WAIT_MSEC
default motion wait polling interval

See Also:
Constant Field Values

TM_CMD_DELAY_MSEC

public static final long TM_CMD_DELAY_MSEC
time between writing and reading command (see cmdWriteRead)

See Also:
Constant Field Values

TM_WRITE_DELAY_MSEC

public static final long TM_WRITE_DELAY_MSEC
time following digitial output write

See Also:
Constant Field Values

BUF32

public static final int BUF32
Buffer size (32)

See Also:
Constant Field Values

ANALOG_INPUTS

public static final int ANALOG_INPUTS
See Also:
Constant Field Values

ANALOG_OUTPUTS

public static final int ANALOG_OUTPUTS
See Also:
Constant Field Values

DIGITAL_INPUTS

public static final int DIGITAL_INPUTS
See Also:
Constant Field Values

DIGITAL_OUTPUTS

public static final int DIGITAL_OUTPUTS
See Also:
Constant Field Values

MAX_ANALOG_INPUT

public static final int MAX_ANALOG_INPUT
See Also:
Constant Field Values

RAI_AI_0

public static final int RAI_AI_0
See Also:
Constant Field Values

RAI_AI_1

public static final int RAI_AI_1
See Also:
Constant Field Values

RAI_AI_2

public static final int RAI_AI_2
See Also:
Constant Field Values

RAI_AI_3

public static final int RAI_AI_3
See Also:
Constant Field Values

RAI_AI_4

public static final int RAI_AI_4
See Also:
Constant Field Values

RAI_AI_5

public static final int RAI_AI_5
See Also:
Constant Field Values

RAI_AI_6

public static final int RAI_AI_6
See Also:
Constant Field Values

RDIO_DO_0

public static final int RDIO_DO_0
See Also:
Constant Field Values

RDIO_DI_0

public static final int RDIO_DI_0
See Also:
Constant Field Values

RDIO_DI_1

public static final int RDIO_DI_1
See Also:
Constant Field Values

RA_AI_0

public static final int RA_AI_0
See Also:
Constant Field Values

RA_AI_1

public static final int RA_AI_1
See Also:
Constant Field Values

RA_AI_2

public static final int RA_AI_2
See Also:
Constant Field Values

RA_AI_3

public static final int RA_AI_3
See Also:
Constant Field Values

RA_AI_4

public static final int RA_AI_4
See Also:
Constant Field Values

RA_AI_5

public static final int RA_AI_5
See Also:
Constant Field Values

RA_AI_6

public static final int RA_AI_6
See Also:
Constant Field Values

RA_DO_0

public static final int RA_DO_0
See Also:
Constant Field Values

RA_DI_0

public static final int RA_DI_0
See Also:
Constant Field Values

RA_DI_1

public static final int RA_DI_1
See Also:
Constant Field Values

DO_0_MASK

public static final byte DO_0_MASK
See Also:
Constant Field Values

DI_0_MASK

public static final byte DI_0_MASK
See Also:
Constant Field Values

DI_1_MASK

public static final byte DI_1_MASK
See Also:
Constant Field Values

DO_0_BIT

public static final int DO_0_BIT
See Also:
Constant Field Values

DI_0_BIT

public static final int DI_0_BIT
See Also:
Constant Field Values

DI_1_BIT

public static final int DI_1_BIT
See Also:
Constant Field Values

READ_ANALOG_IN

public static final java.lang.String READ_ANALOG_IN
See Also:
Constant Field Values

READ_DIGITAL_IO

public static final java.lang.String READ_DIGITAL_IO
See Also:
Constant Field Values

WRITE_DIGITAL_OUT

public static final java.lang.String WRITE_DIGITAL_OUT
See Also:
Constant Field Values

WRITE_DIGITAL_OUT_BYTES

public static final byte[] WRITE_DIGITAL_OUT_BYTES

READ_ALL_ANALOG

public static final java.lang.String READ_ALL_ANALOG
See Also:
Constant Field Values

_serialMode

protected int _serialMode
Serial port mode. Use MODE_SERIAL_LOCAL if using a standard hardware serial port User MODE_SERIAL_RFC_1722 if using a serial/ethernet converter (e.g. Digi)


_terminatorString

protected java.lang.String _terminatorString
Response terminator (as String)


_terminator

protected byte[] _terminator
Response terminator (as byte array)


LINE_END_BYTES

public static final byte[] LINE_END_BYTES
line end for terminating command

Constructor Detail

BB232SPDA

public BB232SPDA()

BB232SPDA

public BB232SPDA(gnu.io.SerialPort port,
                 int serialMode)
          throws java.io.IOException,
                 java.lang.IllegalArgumentException
Throws:
java.io.IOException
java.lang.IllegalArgumentException
Method Detail

setSerialPort

public void setSerialPort(gnu.io.SerialPort port)
                   throws java.io.IOException
Set the SerialPort for this controller to use.

Parameters:
port - SerialPort to use
Throws:
java.io.IOException

getSerialPort

public gnu.io.SerialPort getSerialPort()
Return SerialPort used by this controller.

Returns:
serial port or null if not set.

getInputStream

public java.io.InputStream getInputStream()
Return serial port input stream used by this controller.

Returns:
input stream or null if not set.

getOutputStream

public java.io.OutputStream getOutputStream()
Return serial port output stream used by this controller.

Returns:
output stream or null if not set.

configure

public void configure()

readADChannels

public short[] readADChannels(int maxChannel)
                       throws java.lang.Exception
max channel 0:MAX_ANALOG_INPUT

Throws:
java.lang.Exception

writeAnalogOutput

public void writeAnalogOutput(int channel,
                              short data)
                       throws java.lang.Exception
Throws:
java.lang.Exception

readDigitalIO

public short[] readDigitalIO()
                      throws java.lang.Exception
Throws:
java.lang.Exception

writeDigitalOut

public void writeDigitalOut(boolean state)
                     throws java.lang.Exception
Throws:
java.lang.Exception

readAll

public short[] readAll()
                throws java.lang.Exception
Throws:
java.lang.Exception

setSerialMode

public void setSerialMode(int mode)
                   throws java.lang.IllegalArgumentException
set serial mode

Throws:
java.lang.IllegalArgumentException

getSerialMode

public int getSerialMode()
set serial mode


delay

protected void delay(long delayMsec)
Sleep for specified time

Parameters:
delayMsec - Time to sleep (milliseconds)

mkCmd

public static java.lang.String mkCmd(java.lang.String cmd,
                                     int value)

emptyInput

public void emptyInput(long timeoutMsec)
                throws java.io.IOException
Flush the serial input stream. (using default (this) input stream)

Parameters:
timeoutMsec - (milliseconds)
Throws:
java.io.IOException

emptyInput

protected void emptyInput(java.io.InputStream instream,
                          long timeoutMsec)
                   throws java.io.IOException
Flush the serial input stream. (using default (this) input stream)

Parameters:
instream - an InputStream to flush
timeoutMsec - (milliseconds)
Throws:
java.io.IOException

writeCommand

protected void writeCommand(java.lang.String cmd)
                     throws java.io.IOException
Write a command to the serial port. terminates the command with a newline and flush the serial port.

Parameters:
cmd - command string to write
Throws:
java.io.IOException

cmdWriteRead

protected int cmdWriteRead(java.lang.String cmd,
                           byte[] buf,
                           int startIndex,
                           int len,
                           long timeoutMsec)
                    throws TimeoutException,
                           java.io.IOException,
                           java.lang.NullPointerException,
                           java.lang.Exception
Perform one I/O transaction, (write then read).

Parameters:
cmd - Command to send
buf - Destination buffer
startIndex - Buffer start position
len - Buffer length
timeoutMsec - Timeout (milliseconds)
Returns:
number of bytes in response.
Throws:
TimeoutException
java.io.IOException
java.lang.NullPointerException
java.lang.Exception

cmdWriteReadBytes

protected byte[] cmdWriteReadBytes(java.lang.String cmd,
                                   int len,
                                   long timeoutMsec)
                            throws TimeoutException,
                                   java.io.IOException,
                                   java.lang.NullPointerException,
                                   java.lang.Exception
Write one command and parse the resulting return value as a String.

Parameters:
cmd - command to send
len - maximum expected return length (bytes)
timeoutMsec - timeout for return value (milliseconds)
Returns:
command return value (String)
Throws:
TimeoutException
java.io.IOException
java.lang.NullPointerException
java.lang.Exception


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.