nl.knmi.orfeus.seedlink.client
Class SLState

java.lang.Object
  extended by nl.knmi.orfeus.seedlink.client.SLState

public class SLState
extends java.lang.Object

Class to manage SeedLinkConnection state.

See Also:
Blockette

Field Summary
static int BUFSIZE
          Size of receiving buffer.
 byte[] databuf
          Data buffer for received packets.
 boolean expect_info
          Flag to indicate if an INFO response is expected.
static int INFO_QUERY
          INFO query state INFO_QUERY.
static int KEEP_ALIVE_QUERY
          INFO query state KEEP_ALIVE_QUERY.
 double keepalive_time
           
 int keepalive_trig
          Send keepalive trigger.
 double netdly_time
          Network re-connect delay time stamp.
 int netdly_trig
          Network re-connect delay trigger.
 double netto_time
          Network timeout time stamp.
 int netto_trig
          Network timeout trigger.
static int NO_QUERY
          INFO query state NO_QUERY.
 double previous_time
          Time stamp of last state update.
 int query_mode
          INFO query state.
 int recptr
          Receive pointer for databuf.
 int sendptr
          Send pointer for databuf.
static int SL_DATA
          Connection state data.
static int SL_DOWN
          Connection state down.
static int SL_UP
          Connection state up.
 int state
          Connection state.
 
Constructor Summary
SLState()
          Creates a new instance of SLState
 
Method Summary
 void appendBytes(byte[] bytes)
          Appends bytes to the receive buffer after the last received data.
 int bytesRemaining()
          Return number of bytes remaining in receiving buffer.
 SLPacket getPacket()
          Returns last received packet.
 void incrementSendPointer()
          Increments the send pointer by size of one packet.
 boolean isEnd()
          Check for SeedLink END packet.
 boolean isError()
          Check for SeedLink ERROR packet.
 void packDataBuffer()
          Packs the buffer by removing all sent packets and shifting remaining bytes to beginning of buffer.
 boolean packetAvailable()
          Check for full packet available to send.
 boolean packetIsInfo()
          Check for SeedLink INFO packet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SL_DOWN

public static final int SL_DOWN
Connection state down.

See Also:
Constant Field Values

SL_UP

public static final int SL_UP
Connection state up.

See Also:
Constant Field Values

SL_DATA

public static final int SL_DATA
Connection state data.

See Also:
Constant Field Values

state

public int state
Connection state.


NO_QUERY

public static final int NO_QUERY
INFO query state NO_QUERY.

See Also:
Constant Field Values

INFO_QUERY

public static final int INFO_QUERY
INFO query state INFO_QUERY.

See Also:
Constant Field Values

KEEP_ALIVE_QUERY

public static final int KEEP_ALIVE_QUERY
INFO query state KEEP_ALIVE_QUERY.

See Also:
Constant Field Values

query_mode

public int query_mode
INFO query state.


BUFSIZE

public static final int BUFSIZE
Size of receiving buffer.

See Also:
Constant Field Values

databuf

public byte[] databuf
Data buffer for received packets.


recptr

public int recptr
Receive pointer for databuf.


sendptr

public int sendptr
Send pointer for databuf.


expect_info

public boolean expect_info
Flag to indicate if an INFO response is expected.


netto_trig

public int netto_trig
Network timeout trigger.


netdly_trig

public int netdly_trig
Network re-connect delay trigger.


keepalive_trig

public int keepalive_trig
Send keepalive trigger.


previous_time

public double previous_time
Time stamp of last state update.


netto_time

public double netto_time
Network timeout time stamp.


netdly_time

public double netdly_time
Network re-connect delay time stamp.


keepalive_time

public double keepalive_time
Constructor Detail

SLState

public SLState()
Creates a new instance of SLState

Method Detail

getPacket

public SLPacket getPacket()
                   throws SeedLinkException
Returns last received packet.

Returns:
last recieved packet if data buffer contains a full packet to send.
Throws:
SeedLinkException - if there is not a packet ready to send.
See Also:
packetAvailable()

packetAvailable

public boolean packetAvailable()
Check for full packet available to send.

Returns:
true if data buffer contains a full packet to send.
See Also:
getPacket()

bytesRemaining

public int bytesRemaining()
Return number of bytes remaining in receiving buffer.

Returns:
number of bytes remaining.

isError

public boolean isError()
                throws SeedLinkException
Check for SeedLink ERROR packet.

Returns:
true if next send packet is a SeedLink ERROR packet
Throws:
SeedLinkException - if there are not enough bytes to determine

isEnd

public boolean isEnd()
              throws SeedLinkException
Check for SeedLink END packet.

Returns:
true if next send packet is a SeedLink END packet
Throws:
SeedLinkException - if there are not enough bytes to determine

packetIsInfo

public boolean packetIsInfo()
                     throws SeedLinkException
Check for SeedLink INFO packet.

Returns:
true if next send packet is a SeedLink INFO packet
Throws:
SeedLinkException - if there are not enough bytes to determine packet type

incrementSendPointer

public void incrementSendPointer()
Increments the send pointer by size of one packet.


packDataBuffer

public void packDataBuffer()
Packs the buffer by removing all sent packets and shifting remaining bytes to beginning of buffer.


appendBytes

public void appendBytes(byte[] bytes)
                 throws SeedLinkException
Appends bytes to the receive buffer after the last received data.

Throws:
SeedLinkException