Class NtripClient
- java.lang.Object
-
- org.orekit.gnss.metric.ntrip.NtripClient
-
public class NtripClient extends Object
Source table for ntrip streams retrieval.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
Fields Modifier and Type Field 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 Summary
Constructors Constructor Description NtripClient(String host, int port)
Build a client for NTRIP.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Field Detail
-
DEFAULT_TIMEOUT
public static final int DEFAULT_TIMEOUT
Default timeout for connections and reads (ms).- See Also:
- Constant Field Values
-
DEFAULT_PORT
public static final int DEFAULT_PORT
Default port for ntrip communication.- See Also:
- Constant Field Values
-
DEFAULT_RECONNECT_DELAY
public static final double DEFAULT_RECONNECT_DELAY
Default delay before we reconnect after connection close (s).- See Also:
- Constant Field Values
-
DEFAULT_RECONNECT_DELAY_FACTOR
public static final double DEFAULT_RECONNECT_DELAY_FACTOR
Default factor by which reconnection delay is multiplied after each attempt.- See Also:
- Constant Field Values
-
DEFAULT_MAX_RECONNECT
public static final int DEFAULT_MAX_RECONNECT
Default maximum number of reconnect a attempts without readin any data.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NtripClient
public NtripClient(String host, int port)
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 connection seeDEFAULT_PORT
-
-
Method Detail
-
getHost
public String 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
-
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
public void setProxy(Proxy.Type type, String proxyHost, int proxyPort)
Set proxy parameters.- Parameters:
type
- proxy typeproxyHost
- host name of the proxy (ignored iftype
isProxy.Type.DIRECT
)proxyPort
- port number of the proxy (ignored iftype
isProxy.Type.DIRECT
)
-
getProxy
public Proxy 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
public void addObserver(int typeCode, String mountPoint, MessageObserver observer)
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
public SourceTable 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 messages
becomes available, theobservers
that 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)
-
-