Class NtripClient
Note that all authentication is performed automatically by just
calling the standard Authenticator.setDefault(Authenticator)
method to set up an authenticator.
- Since:
- 11.0
- Author:
- Luc Maisonobe
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault maximum number of reconnect a attempts without readin any data.static final intDefault port for ntrip communication.static final doubleDefault delay before we reconnect after connection close (s).static final doubleDefault factor by which reconnection delay is multiplied after each attempt.static final intDefault timeout for connections and reads (ms). -
Constructor Summary
ConstructorsConstructorDescriptionNtripClient(String host, int port, TimeScales timeScales) Build a client for NTRIP. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddObserver(int typeCode, String mountPoint, MessageObserver observer) Add an observer for an encoded messages.voidCheck if any of the streaming thread has thrown an exception.getHost()Get the caster host.intgetPort()Get the port to use for connection.getProxy()Get proxy.Get a sourcetable.Get the known time scales.voidsetFix(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.voidsetProxy(Proxy.Type type, String proxyHost, int proxyPort) Set proxy parameters.voidsetReconnectParameters(double delay, double delayFactor, int max) Set Reconnect parameters.voidsetTimeout(int timeout) Set timeout for connections and reads.voidstartStreaming(String mountPoint, Type type, boolean requiresNMEA, boolean ignoreUnknownMessageTypes) Connect to a mount point and start streaming data from it.voidstopStreaming(int time) Stop streaming data from all connected mount points.
-
Field Details
-
DEFAULT_TIMEOUT
public static final int DEFAULT_TIMEOUTDefault timeout for connections and reads (ms).- See Also:
-
DEFAULT_PORT
public static final int DEFAULT_PORTDefault port for ntrip communication.- See Also:
-
DEFAULT_RECONNECT_DELAY
public static final double DEFAULT_RECONNECT_DELAYDefault delay before we reconnect after connection close (s).- See Also:
-
DEFAULT_RECONNECT_DELAY_FACTOR
public static final double DEFAULT_RECONNECT_DELAY_FACTORDefault factor by which reconnection delay is multiplied after each attempt.- See Also:
-
DEFAULT_MAX_RECONNECT
public static final int DEFAULT_MAX_RECONNECTDefault maximum number of reconnect a attempts without readin any data.- See Also:
-
-
Constructor Details
-
NtripClient
Build a client for NTRIP.The default configuration uses default timeout, default reconnection parameters, no GPS fix and no proxy.
- Parameters:
host- caster host providing the source tableport- port to use for connectiontimeScales- known time scales- Since:
- 13.0
see
DEFAULT_PORT
-
-
Method Details
-
getHost
Get the caster host.- Returns:
- caster host
-
getPort
public int getPort()Get the port to use for connection.- Returns:
- port to use for connection
-
getTimeScales
Get the known time scales.- Returns:
- known time scales
- Since:
- 13.0
-
setTimeout
public void setTimeout(int timeout) Set timeout for connections and reads.- Parameters:
timeout- timeout for connections and reads (ms)
-
setReconnectParameters
public void setReconnectParameters(double delay, double delayFactor, int max) Set Reconnect parameters.- Parameters:
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 data
-
setProxy
Set proxy parameters.- Parameters:
type- proxy typeproxyHost- host name of the proxy (ignored iftypeisProxy.Type.DIRECT)proxyPort- port number of the proxy (ignored iftypeisProxy.Type.DIRECT)
-
getProxy
Get proxy.- Returns:
- proxy to use
-
setFix
public 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.- Parameters:
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)
-
addObserver
Add an observer for an encoded messages.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.
- Parameters:
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 type
-
getSourceTable
Get a sourcetable.- Returns:
- source table from the caster
-
startStreaming
public void startStreaming(String mountPoint, Type type, boolean requiresNMEA, boolean ignoreUnknownMessageTypes) Connect to a mount point and start streaming data from it.This method sets up an internal dedicated thread for continuously monitoring data incoming from a mount point. When new complete
parsed messagesbecomes available, theobserversthat have been registered usingaddObserver()method will be notified about the message.This method must be called once for each stream to monitor.
- Parameters:
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 ignored
-
checkException
public void checkException()Check if any of the streaming thread has thrown an exception.If a streaming thread has thrown an exception, it will be rethrown here
-
stopStreaming
public void stopStreaming(int time) Stop streaming data from all connected mount points.If an exception was encountered during data streaming, it will be rethrown here
- Parameters:
time- timeout for waiting underlying threads termination (ms)
-