public class NtripClient extends Object
Note that all authentication is performed automatically by just
calling the standard Authenticator.setDefault(Authenticator)
method to set up an authenticator.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAX_RECONNECT
Default maximum number of reconnect a attempts without readin any data.
|
static int |
DEFAULT_PORT
Default port for ntrip communication.
|
static double |
DEFAULT_RECONNECT_DELAY
Default delay before we reconnect after connection close (s).
|
static double |
DEFAULT_RECONNECT_DELAY_FACTOR
Default factor by which reconnection delay is multiplied after each attempt.
|
static int |
DEFAULT_TIMEOUT
Default timeout for connections and reads (ms).
|
Constructor and Description |
---|
NtripClient(String host,
int port)
Build a client for NTRIP.
|
Modifier and Type | Method and Description |
---|---|
void |
addObserver(int typeCode,
String mountPoint,
MessageObserver observer)
Add an observer for an encoded messages.
|
void |
checkException()
Check if any of the streaming thread has thrown an exception.
|
String |
getHost()
Get the caster host.
|
int |
getPort()
Get the port to use for connection.
|
Proxy |
getProxy()
Get proxy.
|
SourceTable |
getSourceTable()
Get a sourcetable.
|
void |
setFix(int hour,
int minute,
double second,
double latitude,
double longitude,
double ellAltitude,
double undulation)
Set GPS fix data to send as NMEA sentence to Ntrip caster if required.
|
void |
setProxy(Proxy.Type type,
String proxyHost,
int proxyPort)
Set proxy parameters.
|
void |
setReconnectParameters(double delay,
double delayFactor,
int max)
Set Reconnect parameters.
|
void |
setTimeout(int timeout)
Set timeout for connections and reads.
|
void |
startStreaming(String mountPoint,
Type type,
boolean requiresNMEA,
boolean ignoreUnknownMessageTypes)
Connect to a mount point and start streaming data from it.
|
void |
stopStreaming(int time)
Stop streaming data from all connected mount points.
|
public static final int DEFAULT_TIMEOUT
public static final int DEFAULT_PORT
public static final double DEFAULT_RECONNECT_DELAY
public static final double DEFAULT_RECONNECT_DELAY_FACTOR
public static final int DEFAULT_MAX_RECONNECT
public NtripClient(String host, int port)
The default configuration uses default timeout, default reconnection parameters, no GPS fix and no proxy.
host
- caster host providing the source tableport
- port to use for connection
see DEFAULT_PORT
public String getHost()
public int getPort()
public void setTimeout(int timeout)
timeout
- timeout for connections and reads (ms)public void setReconnectParameters(double delay, double delayFactor, int max)
delay
- delay before we reconnect after connection closedelayFactor
- factor by which reconnection delay is multiplied after each attemptmax
- max number of reconnect a attempts without reading any datapublic void setProxy(Proxy.Type type, String proxyHost, int proxyPort)
type
- proxy typeproxyHost
- host name of the proxy (ignored if type
is Proxy.Type.DIRECT
)proxyPort
- port number of the proxy (ignored if type
is Proxy.Type.DIRECT
)public Proxy getProxy()
public void setFix(int hour, int minute, double second, double latitude, double longitude, double ellAltitude, double undulation)
hour
- hour of the fix (UTC time)minute
- minute of the fix (UTC time)second
- second of the fix (UTC time)latitude
- latitude (radians)longitude
- longitude (radians)ellAltitude
- altitude above ellipsoid (m)undulation
- height of the geoid above ellipsoid (m)public void addObserver(int typeCode, String mountPoint, MessageObserver observer)
If messages of the specified type have already been retrieved from a stream, the observer will be immediately notified with the last message from each mount point (in unspecified order) as a side effect of being added.
typeCode
- code for the message type (if set to 0, notification
will be triggered regardless of message type)mountPoint
- mountPoint from which data must come (if null, notification
will be triggered regardless of mount point)observer
- observer for this message typepublic SourceTable getSourceTable()
public void startStreaming(String mountPoint, Type type, boolean requiresNMEA, boolean ignoreUnknownMessageTypes)
This method sets up an internal dedicated thread for continuously
monitoring data incoming from a mount point. When new complete
parsed messages
becomes available, the
observers
that have been registered
using addObserver()
method will be notified about the message.
This method must be called once for each stream to monitor.
mountPoint
- mount point providing the streamtype
- messages type of the mount pointrequiresNMEA
- if true, the mount point requires a NMEA GGA sentence in the requestignoreUnknownMessageTypes
- if true, unknown messages types are silently ignoredpublic void checkException()
If a streaming thread has thrown an exception, it will be rethrown here
public void stopStreaming(int time)
If an exception was encountered during data streaming, it will be rethrown here
time
- timeout for waiting underlying threads termination (ms)Copyright © 2002-2022 CS GROUP. All rights reserved.