Elexis API documentation
Version 2.1.6 as of December 11 2011

ch.elexis.rs232
Class AbstractConnection

java.lang.Object
  extended by ch.elexis.rs232.AbstractConnection
All Implemented Interfaces:
PortEventListener
Direct Known Subclasses:
AfinionConnection, CobasMiraConnection, ReflotronConnection, SysmexConnection

public abstract class AbstractConnection
extends java.lang.Object
implements PortEventListener


Nested Class Summary
static interface AbstractConnection.ComPortListener
           
 
Field Summary
 
Fields inherited from interface ch.elexis.rs232.PortEventListener
CR, ETX, LF, NAK, STX, XOFF, XON
 
Constructor Summary
AbstractConnection(java.lang.String portName, java.lang.String port, java.lang.String settings, AbstractConnection.ComPortListener l)
           
 
Method Summary
 void awaitFrame(Shell shell, java.lang.String text, int start, int end, int following, int timeout, boolean background, boolean adjustEndTime)
          Wait for a frame of the device to be sent.
 void breakInterrupt(int state)
           
 void close()
           
 java.lang.String connect()
           
static java.lang.String[] getComPorts()
           
 byte getLineSeparator()
           
 int getState()
           
 boolean isOpen()
          Reports the open status of the port.
 boolean send(byte[] bytes)
           
 boolean send(java.lang.String data)
           
 void sendBreak()
          Send a one second break signal.
abstract  void serialEvent(int state, java.io.InputStream inputStream, SerialPortEvent e)
           
 void serialEvent(SerialPortEvent e)
          Handles SerialPortEvents.
 void setConnectionParameters(SerialParameters parameters)
          Sets the connection parameters to the setting in the parameters object.
 void setState(int state)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractConnection

public AbstractConnection(java.lang.String portName,
                          java.lang.String port,
                          java.lang.String settings,
                          AbstractConnection.ComPortListener l)
Method Detail

connect

public java.lang.String connect()

setConnectionParameters

public void setConnectionParameters(SerialParameters parameters)
                             throws SerialConnectionException
Sets the connection parameters to the setting in the parameters object. If set fails return the parameters object to origional settings and throw exception.

Throws:
SerialConnectionException

awaitFrame

public void awaitFrame(Shell shell,
                       java.lang.String text,
                       int start,
                       int end,
                       int following,
                       int timeout,
                       boolean background,
                       boolean adjustEndTime)
Wait for a frame of the device to be sent. Ignores all input until a start byte is found. collects all bytes from that point until an end byte was received or the timeout happened.

Parameters:
start - character defining the start of a frame
end - character singalling end of frame
following - number of bytes after end to wait for (e.g. checksum)
timeout - number of seconds to wait for a frame to complete before givng up

serialEvent

public void serialEvent(SerialPortEvent e)
Handles SerialPortEvents. The two types of SerialPortEvents that this program is registered to listen for are DATA_AVAILABLE and BI. During DATA_AVAILABLE the port buffer is read until it is drained, when no more data is available and 30ms has passed the method returns. When a BI event occurs the words BREAK RECEIVED are written to the messageAreaIn.


serialEvent

public abstract void serialEvent(int state,
                                 java.io.InputStream inputStream,
                                 SerialPortEvent e)
                          throws java.io.IOException
Throws:
java.io.IOException

breakInterrupt

public void breakInterrupt(int state)

close

public void close()

isOpen

public boolean isOpen()
Reports the open status of the port.

Returns:
true if port is open, false if port is closed.

sendBreak

public void sendBreak()
Send a one second break signal.


send

public boolean send(java.lang.String data)

send

public boolean send(byte[] bytes)

getComPorts

public static java.lang.String[] getComPorts()

getLineSeparator

public byte getLineSeparator()

setState

public void setState(int state)

getState

public int getState()

Elexis API documentation
Version 2.1.6 as of December 11 2011

Copyright 2005-2011 by Gerry Weirich, Elexis