ch.elexis.rs232
Class AbstractConnection
java.lang.Object
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
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 |
AbstractConnection
public AbstractConnection(java.lang.String portName,
java.lang.String port,
java.lang.String settings,
AbstractConnection.ComPortListener l)
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 frameend
- character singalling end of framefollowing
- 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()
Copyright 2005-2011 by Gerry Weirich, Elexis