de.bsvrz.kex.tls.osi2osi3.osi2.tc57primary
Class SerialPortControl

java.lang.Object
  extended by de.bsvrz.kex.tls.osi2osi3.osi2.tc57primary.SerialPortControl
All Implemented Interfaces:
gnu.io.SerialPortEventListener, EventListener

public class SerialPortControl
extends Object
implements gnu.io.SerialPortEventListener

Klasse zum Senden und Empfangen von TC57-Telegrammen via serieller Schnittstelle.

Author:
Kappich Systemberatung

Field Summary
private  long _byteTransmitDurationMicros
           
private  boolean _checkDsr
           
private static Debug _debug
           
private  boolean _flushAfterSend
           
private  InputStream _in
           
private  boolean _initialized
           
private  int _interCharacterTimeout
           
private  long _lastReadTime
           
private  long _lastSendTime
           
private  OutputStream _out
           
private  boolean _overrunError
           
private  boolean _parityError
           
private  int _pendingInput
           
private  boolean _pendingOutput
           
private  gnu.io.SerialPort _port
           
private  String _portName
           
private  PropertyConsultant _propertyConsultant
           
private  byte[] _receiveBuffer
           
private  int _receivedCount
           
private  boolean _receiving
           
private  boolean _rtsOnSend
           
private  int _rtsPostSendDelay
           
private  int _rtsPreSendDelay
           
private  int _tap
           
private  boolean _waitForCts
           
private  boolean _waitForDcdDown
           
private  boolean _waitWhilePendingOutput
           
private static Object OPEN_ACCESS_LOCK
           
 
Constructor Summary
SerialPortControl()
           
 
Method Summary
(package private) static String getEventTypeName(int eventType)
           
private  void prepareReceive()
           
 byte[] query(int waitTimeSinceLastReceive, byte[] sendBytes, int receiveTimeout)
           
 byte[] readBytes(long timeout)
           
private  byte[] readPacket(int timeout)
           
private  byte[] receivePacket(ByteBuffer buffer, int timeout)
           
private  void sendPacket(int waitTimeSinceLastReceive, byte[] packet)
           
 void serialEvent(gnu.io.SerialPortEvent serialPortEvent)
           
 void shutdown()
           
 void start(PropertyQueryInterface propertyQueryInterface, String applicationName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_debug

private static final Debug _debug

OPEN_ACCESS_LOCK

private static final Object OPEN_ACCESS_LOCK

_propertyConsultant

private PropertyConsultant _propertyConsultant

_port

private gnu.io.SerialPort _port

_out

private OutputStream _out

_in

private InputStream _in

_rtsOnSend

private boolean _rtsOnSend

_rtsPreSendDelay

private int _rtsPreSendDelay

_rtsPostSendDelay

private int _rtsPostSendDelay

_tap

private int _tap

_interCharacterTimeout

private int _interCharacterTimeout

_waitForCts

private boolean _waitForCts

_waitForDcdDown

private boolean _waitForDcdDown

_pendingOutput

private boolean _pendingOutput

_checkDsr

private boolean _checkDsr

_lastSendTime

private long _lastSendTime

_pendingInput

private int _pendingInput

_receiving

private boolean _receiving

_lastReadTime

private long _lastReadTime

_parityError

private boolean _parityError

_overrunError

private boolean _overrunError

_receivedCount

private int _receivedCount

_receiveBuffer

private byte[] _receiveBuffer

_flushAfterSend

private boolean _flushAfterSend

_byteTransmitDurationMicros

private long _byteTransmitDurationMicros

_portName

private String _portName

_initialized

private boolean _initialized

_waitWhilePendingOutput

private boolean _waitWhilePendingOutput
Constructor Detail

SerialPortControl

public SerialPortControl()
Method Detail

start

public void start(PropertyQueryInterface propertyQueryInterface,
                  String applicationName)
           throws Exception
Throws:
Exception

shutdown

public void shutdown()

getEventTypeName

static String getEventTypeName(int eventType)

sendPacket

private void sendPacket(int waitTimeSinceLastReceive,
                        byte[] packet)
                 throws InterruptedException,
                        IOException
Throws:
InterruptedException
IOException

prepareReceive

private void prepareReceive()
                     throws IOException
Throws:
IOException

receivePacket

private byte[] receivePacket(ByteBuffer buffer,
                             int timeout)
                      throws InterruptedException
Throws:
InterruptedException

serialEvent

public void serialEvent(gnu.io.SerialPortEvent serialPortEvent)
Specified by:
serialEvent in interface gnu.io.SerialPortEventListener

query

public byte[] query(int waitTimeSinceLastReceive,
                    byte[] sendBytes,
                    int receiveTimeout)
             throws InterruptedException,
                    IOException
Throws:
InterruptedException
IOException

readPacket

private byte[] readPacket(int timeout)
                   throws InterruptedException,
                          IOException
Throws:
InterruptedException
IOException

readBytes

public byte[] readBytes(long timeout)
                 throws InterruptedException
Throws:
InterruptedException