edu.sc.seis.seisFile.seedlink
Class SeedlinkReader

java.lang.Object
  extended by edu.sc.seis.seisFile.seedlink.SeedlinkReader

public class SeedlinkReader
extends java.lang.Object


Field Summary
static java.lang.String DEFAULT_HOST
           
static int DEFAULT_PORT
           
static int DEFAULT_TIMEOUT_SECOND
           
static java.lang.String INFO_ALL
           
static java.lang.String INFO_CAPABILITIES
           
static java.lang.String INFO_CONNECTIONS
           
static java.lang.String INFO_GAPS
           
static java.lang.String INFO_ID
           
static java.lang.String INFO_STATIONS
           
static java.lang.String INFO_STREAMS
           
 
Constructor Summary
SeedlinkReader()
          default of IRIS DMC
SeedlinkReader(java.lang.String host)
          uses the default port of 18000
SeedlinkReader(java.lang.String host, int port)
           
SeedlinkReader(java.lang.String host, int port, int timeoutSeconds)
           
SeedlinkReader(java.lang.String host, int port, int timeoutSeconds, boolean verbose)
           
 
Method Summary
 boolean available()
          true if there is enough data in the instream to possibly read a data record.
 void close()
           
 void endHandshake()
           
 java.lang.String getHost()
           
 int getPort()
           
 java.io.PrintWriter getVerboseWriter()
           
 boolean hasNext()
           
 void info(java.lang.String level)
          send an INFO command.
protected  void internalSendCmd(java.lang.String cmd)
           
 boolean isConnected()
           
 boolean isVerbose()
           
 SeedlinkPacket next()
           
 void reconnect()
           
 void sendCmd(java.lang.String cmd)
          sends a seedlink modifier command, generally should be limited to STATION, SELECT FETCH and DATA.
 void setVerbose(boolean verbose)
           
 void setVerboseWriter(java.io.PrintWriter verboseWriter)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_HOST

public static final java.lang.String DEFAULT_HOST
See Also:
Constant Field Values

DEFAULT_PORT

public static final int DEFAULT_PORT
See Also:
Constant Field Values

DEFAULT_TIMEOUT_SECOND

public static final int DEFAULT_TIMEOUT_SECOND
See Also:
Constant Field Values

INFO_ID

public static final java.lang.String INFO_ID
See Also:
Constant Field Values

INFO_CAPABILITIES

public static final java.lang.String INFO_CAPABILITIES
See Also:
Constant Field Values

INFO_STATIONS

public static final java.lang.String INFO_STATIONS
See Also:
Constant Field Values

INFO_STREAMS

public static final java.lang.String INFO_STREAMS
See Also:
Constant Field Values

INFO_GAPS

public static final java.lang.String INFO_GAPS
See Also:
Constant Field Values

INFO_CONNECTIONS

public static final java.lang.String INFO_CONNECTIONS
See Also:
Constant Field Values

INFO_ALL

public static final java.lang.String INFO_ALL
See Also:
Constant Field Values
Constructor Detail

SeedlinkReader

public SeedlinkReader()
               throws java.net.UnknownHostException,
                      java.io.IOException
default of IRIS DMC

Throws:
java.net.UnknownHostException
java.io.IOException

SeedlinkReader

public SeedlinkReader(java.lang.String host)
               throws java.net.UnknownHostException,
                      java.io.IOException
uses the default port of 18000

Throws:
java.net.UnknownHostException
java.io.IOException

SeedlinkReader

public SeedlinkReader(java.lang.String host,
                      int port)
               throws java.net.UnknownHostException,
                      java.io.IOException
Throws:
java.net.UnknownHostException
java.io.IOException

SeedlinkReader

public SeedlinkReader(java.lang.String host,
                      int port,
                      int timeoutSeconds)
               throws java.net.UnknownHostException,
                      java.io.IOException
Throws:
java.net.UnknownHostException
java.io.IOException

SeedlinkReader

public SeedlinkReader(java.lang.String host,
                      int port,
                      int timeoutSeconds,
                      boolean verbose)
               throws java.net.UnknownHostException,
                      java.io.IOException
Throws:
java.net.UnknownHostException
java.io.IOException
Method Detail

hasNext

public boolean hasNext()
                throws java.io.IOException
Throws:
java.io.IOException

available

public boolean available()
                  throws java.io.IOException
true if there is enough data in the instream to possibly read a data record. This should not block, unlike hasNext() and next().

Throws:
java.io.IOException

next

public SeedlinkPacket next()
                    throws java.io.IOException,
                           SeedlinkException
Throws:
java.io.IOException
SeedlinkException

info

public void info(java.lang.String level)
          throws java.io.IOException
send an INFO command. The resulting packets can be retrieved with calls to next(), although it seems there is no good way to determine how many packets will be returned or when they have all arrived without parsing the xml. This appears to be a shortcoming of the seedlink protocol. INFO requests should probably not be sent after the end of the handshake as real data packets may arrive causing confusion.

Throws:
java.io.IOException

endHandshake

public void endHandshake()
                  throws java.io.IOException
Throws:
java.io.IOException

close

public void close()

isConnected

public boolean isConnected()

reconnect

public void reconnect()
               throws java.io.IOException,
                      SeedlinkException
Throws:
java.io.IOException
SeedlinkException

sendCmd

public void sendCmd(java.lang.String cmd)
             throws java.io.IOException,
                    SeedlinkException
sends a seedlink modifier command, generally should be limited to STATION, SELECT FETCH and DATA. TIME may work but has not been tested.

Throws:
java.io.IOException
SeedlinkException

internalSendCmd

protected void internalSendCmd(java.lang.String cmd)
                        throws java.io.IOException,
                               SeedlinkException
Throws:
java.io.IOException
SeedlinkException

isVerbose

public boolean isVerbose()

setVerbose

public void setVerbose(boolean verbose)

getVerboseWriter

public java.io.PrintWriter getVerboseWriter()

setVerboseWriter

public void setVerboseWriter(java.io.PrintWriter verboseWriter)

getHost

public java.lang.String getHost()

getPort

public int getPort()