nl.knmi.orfeus.seedlink
Class SLPacket

java.lang.Object
  extended by nl.knmi.orfeus.seedlink.SLPacket

public class SLPacket
extends java.lang.Object

Class to hold and decode a SeedLink packet.

See Also:
Blockette

Field Summary
protected  edu.iris.Fissures.seed.container.Blockette blockette
          The Blockette conained in msrecord.
static java.lang.String ENDSIGNATURE
          SeedLink END signature.
static java.lang.String ERRORSIGNATURE
          SeedLink ERROR signature.
static java.lang.String INFOSIGNATURE
          SeedLink INFO packet signature.
 byte[] msrecord
          The mini-SEED record
static java.lang.String SIGNATURE
          SeedLink header signature.
static SLPacket SLERROR
          Error flag - indicates server reported an error.
 byte[] slhead
          The SeedLink header
static int SLHEADSIZE
          SeedLink packet header size.
static SLPacket SLNOPACKET
          No packet flag - indicates no data availbale.
static int SLRECSIZE
          Mini-SEED record size.
static SLPacket SLTERMINATE
          Terminate flag - connection was closed by the server or the termination sequence completed.
static int TYPE_SLINF
          Packet type is non-terminated info packet.
static int TYPE_SLINFT
          Packet type is terminated info packet.
 
Constructor Summary
protected SLPacket()
          Empty constructor used for internal constants
  SLPacket(byte[] bytes, int offset)
          Creates a new instance of SLPacket by converting the specified subarray of bytes.
 
Method Summary
 edu.iris.Fissures.seed.container.Blockette getBlockette()
          Returns the Blockette contained in this SLPacket.
 int getSequenceNumber()
          Check for 'SL' signature and get sequence number.
 int getType()
          Determines the type of packet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_SLINFT

public static final int TYPE_SLINFT
Packet type is terminated info packet.

See Also:
Constant Field Values

TYPE_SLINF

public static final int TYPE_SLINF
Packet type is non-terminated info packet.

See Also:
Constant Field Values

SLTERMINATE

public static final SLPacket SLTERMINATE
Terminate flag - connection was closed by the server or the termination sequence completed.


SLNOPACKET

public static final SLPacket SLNOPACKET
No packet flag - indicates no data availbale.


SLERROR

public static final SLPacket SLERROR
Error flag - indicates server reported an error.


SLHEADSIZE

public static final int SLHEADSIZE
SeedLink packet header size.

See Also:
Constant Field Values

SLRECSIZE

public static final int SLRECSIZE
Mini-SEED record size.

See Also:
Constant Field Values

SIGNATURE

public static java.lang.String SIGNATURE
SeedLink header signature.


INFOSIGNATURE

public static java.lang.String INFOSIGNATURE
SeedLink INFO packet signature.


ERRORSIGNATURE

public static java.lang.String ERRORSIGNATURE
SeedLink ERROR signature.


ENDSIGNATURE

public static java.lang.String ENDSIGNATURE
SeedLink END signature.


slhead

public byte[] slhead
The SeedLink header


msrecord

public byte[] msrecord
The mini-SEED record


blockette

protected edu.iris.Fissures.seed.container.Blockette blockette
The Blockette conained in msrecord.

Constructor Detail

SLPacket

protected SLPacket()
Empty constructor used for internal constants


SLPacket

public SLPacket(byte[] bytes,
                int offset)
         throws SeedLinkException
Creates a new instance of SLPacket by converting the specified subarray of bytes.

Parameters:
bytes - The bytes to be converted.
offset - Index of the first byte to convert.
Throws:
SeedLinkException - if there are not enough bytes in the subarray
Method Detail

getSequenceNumber

public int getSequenceNumber()
Check for 'SL' signature and get sequence number.

Returns:
the packet sequence number of this SeedLink packet on success, 0 for INFO packets or -1 on error.

getType

public int getType()
            throws SeedLinkException
Determines the type of packet. First check for an INFO packet, if not, assume packet contains single blockette and return its type.

Returns:
the packet type.
Throws:
SeedLinkException

getBlockette

public edu.iris.Fissures.seed.container.Blockette getBlockette()
                                                        throws SeedLinkException
Returns the Blockette contained in this SLPacket. Creates the blockette if necessary.

Returns:
the blockette contained in this SeedLink packet.
Throws:
SeedLinkException - on error.
See Also:
Blockette, SeedObjectBuilder, SeedImportDirector