org.mbari.siam.core
Class SerialInstrumentPort

java.lang.Object
  extended by org.mbari.siam.core.BaseInstrumentPort
      extended by org.mbari.siam.core.SerialInstrumentPort
All Implemented Interfaces:
InstrumentPort
Direct Known Subclasses:
NVTInstrumentPort, PuckSerialInstrumentPort

public class SerialInstrumentPort
extends BaseInstrumentPort
implements InstrumentPort

Implements power control and communications to an instrument via serial port. May have a power port.

Author:
Mike Risi

Field Summary
protected  InstrumentPortInputStream _fromInstrument
           
protected  boolean _instrumentPortSuspeneded
           
protected static org.apache.log4j.Logger _log4j
          Log4j logger
protected  boolean _serialOpen
           
protected  gnu.io.SerialPort _serialPort
           
protected  java.lang.String _serialPortName
           
protected  InstrumentPortOutputStream _toInstrument
           
 
Fields inherited from class org.mbari.siam.core.BaseInstrumentPort
_powerPort
 
Fields inherited from interface org.mbari.siam.core.InstrumentPort
RTS_SENSE
 
Constructor Summary
SerialInstrumentPort(gnu.io.SerialPort serial, java.lang.String serialPortName, PowerPort power)
          create a SerialInstrumentPort.
 
Method Summary
 boolean getCarrierDetectStatus()
           
 boolean getClearToSendStatus()
           
 java.lang.String getCommPortName()
          get the commport name
 java.io.InputStream getInputStream()
          get an InputStream to the instrument
 InstrumentConsole getInstrumentConsole()
          get a console to an Instrument
 InstrumentPortOutputStream getOutputStream()
          get an OutputStream to the instrument
 gnu.io.SerialPort getSerialPort()
          Return serial port.
 SerialPortParameters getSerialPortParams()
          get the serial port parameters for the serial port associated with this instrument port
 void initialize()
          initialize the InstrumentPort
 boolean isCTS()
          get the state of the CTS line
 void resume()
          resume instrument comms from suspended state
 void sendBreak(int duration)
          set the TX line to a BREAK condition in 100 ms increments
 void setCommsMode(CommsMode commsMode)
          Set communications mode (RS422,RS485,RS232) satisfies InstrumentPort interface
 void setRTS(boolean state)
          set the state of the RTS line
 void setSerialPortParams(SerialPortParameters params)
          set the serial port parameters for the serial port associated with this instrument port
 void shutDown()
          shutdown the intrument port.
 void suspend()
          suspends comms so another application can communicate with the instrument
 
Methods inherited from class org.mbari.siam.core.BaseInstrumentPort
connectPower, disableCommunications, disconnectPower, enableCommunications, getCurrentLevel, getCurrentLimit, getStatusMessage, getStatusSummaryMessage, getTemperature, getTerseStatus, getVoltageLevel, isolatePort, isSuspended, resetStatus, setCurrentLimit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mbari.siam.core.InstrumentPort
connectPower, disableCommunications, disconnectPower, enableCommunications, getCurrentLevel, getCurrentLimit, getStatusMessage, getStatusSummaryMessage, getTerseStatus, getVoltageLevel, isolatePort, isSuspended, resetStatus, setCurrentLimit
 

Field Detail

_log4j

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


_serialPort

protected gnu.io.SerialPort _serialPort

_serialPortName

protected java.lang.String _serialPortName

_instrumentPortSuspeneded

protected boolean _instrumentPortSuspeneded

_serialOpen

protected boolean _serialOpen

_fromInstrument

protected InstrumentPortInputStream _fromInstrument

_toInstrument

protected InstrumentPortOutputStream _toInstrument
Constructor Detail

SerialInstrumentPort

public SerialInstrumentPort(gnu.io.SerialPort serial,
                            java.lang.String serialPortName,
                            PowerPort power)
create a SerialInstrumentPort. Note that we pass in the serial port name in addition to the serial port object, since SerialPort.getName() appears to be screwed up for Win32.

Method Detail

initialize

public void initialize()
                throws InitializeException
initialize the InstrumentPort

Specified by:
initialize in interface InstrumentPort
Overrides:
initialize in class BaseInstrumentPort
Throws:
InitializeException

resume

public void resume()
resume instrument comms from suspended state

Specified by:
resume in interface InstrumentPort

suspend

public void suspend()
suspends comms so another application can communicate with the instrument

Specified by:
suspend in interface InstrumentPort

shutDown

public void shutDown()
shutdown the intrument port. This port must not be used again until the initialize() method is called again.

Specified by:
shutDown in interface InstrumentPort
Overrides:
shutDown in class BaseInstrumentPort

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
get an InputStream to the instrument

Specified by:
getInputStream in interface InstrumentPort
Throws:
java.io.IOException

getCarrierDetectStatus

public boolean getCarrierDetectStatus()

getClearToSendStatus

public boolean getClearToSendStatus()

getOutputStream

public InstrumentPortOutputStream getOutputStream()
                                           throws java.io.IOException
get an OutputStream to the instrument

Specified by:
getOutputStream in interface InstrumentPort
Throws:
java.io.IOException

getInstrumentConsole

public InstrumentConsole getInstrumentConsole()
                                       throws java.io.IOException
get a console to an Instrument

Specified by:
getInstrumentConsole in interface InstrumentPort
Throws:
java.io.IOException

getCommPortName

public java.lang.String getCommPortName()
get the commport name

Specified by:
getCommPortName in interface InstrumentPort

setSerialPortParams

public void setSerialPortParams(SerialPortParameters params)
                         throws java.io.IOException,
                                gnu.io.UnsupportedCommOperationException
set the serial port parameters for the serial port associated with this instrument port

Throws:
java.io.IOException
gnu.io.UnsupportedCommOperationException

getSerialPortParams

public SerialPortParameters getSerialPortParams()
                                         throws java.io.IOException,
                                                gnu.io.UnsupportedCommOperationException
get the serial port parameters for the serial port associated with this instrument port

Throws:
java.io.IOException
gnu.io.UnsupportedCommOperationException

isCTS

public boolean isCTS()
get the state of the CTS line


setRTS

public void setRTS(boolean state)
set the state of the RTS line


sendBreak

public void sendBreak(int duration)
set the TX line to a BREAK condition in 100 ms increments

Parameters:
duration - = mS x 250 where mS is required duration to nearest 100mS

getSerialPort

public gnu.io.SerialPort getSerialPort()
Return serial port.


setCommsMode

public void setCommsMode(CommsMode commsMode)
Set communications mode (RS422,RS485,RS232) satisfies InstrumentPort interface

Specified by:
setCommsMode in interface InstrumentPort
Overrides:
setCommsMode in class BaseInstrumentPort


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.