WPILibC++ 2023.4.3
nt::NetworkTableInstance Class Referencefinal

NetworkTables Instance. More...

#include <networktables/NetworkTableInstance.h>

Public Types

enum  NetworkMode {
  kNetModeNone = NT_NET_MODE_NONE , kNetModeServer = NT_NET_MODE_SERVER , kNetModeClient3 = NT_NET_MODE_CLIENT3 , kNetModeClient4 = NT_NET_MODE_CLIENT4 ,
  kNetModeLocal = NT_NET_MODE_LOCAL
}
 Client/server mode flag values (as returned by GetNetworkMode()). More...
 
enum  LogLevel {
  kLogCritical = NT_LOG_CRITICAL , kLogError = NT_LOG_ERROR , kLogWarning = NT_LOG_WARNING , kLogInfo = NT_LOG_INFO ,
  kLogDebug = NT_LOG_DEBUG , kLogDebug1 = NT_LOG_DEBUG1 , kLogDebug2 = NT_LOG_DEBUG2 , kLogDebug3 = NT_LOG_DEBUG3 ,
  kLogDebug4 = NT_LOG_DEBUG4
}
 Logging levels (as used by SetLogger()). More...
 

Public Member Functions

 NetworkTableInstance () noexcept
 Construct invalid instance. More...
 
 NetworkTableInstance (NT_Inst inst) noexcept
 Construct from native handle. More...
 
 operator bool () const
 Determines if the native handle is valid. More...
 
NT_Inst GetHandle () const
 Gets the native handle for the entry. More...
 
Topic GetTopic (std::string_view name) const
 Gets a "generic" (untyped) topic. More...
 
BooleanTopic GetBooleanTopic (std::string_view name) const
 Gets a boolean topic. More...
 
IntegerTopic GetIntegerTopic (std::string_view name) const
 Gets an integer topic. More...
 
FloatTopic GetFloatTopic (std::string_view name) const
 Gets a float topic. More...
 
DoubleTopic GetDoubleTopic (std::string_view name) const
 Gets a double topic. More...
 
StringTopic GetStringTopic (std::string_view name) const
 Gets a string topic. More...
 
RawTopic GetRawTopic (std::string_view name) const
 Gets a raw topic. More...
 
BooleanArrayTopic GetBooleanArrayTopic (std::string_view name) const
 Gets a boolean array topic. More...
 
IntegerArrayTopic GetIntegerArrayTopic (std::string_view name) const
 Gets an integer array topic. More...
 
FloatArrayTopic GetFloatArrayTopic (std::string_view name) const
 Gets a float array topic. More...
 
DoubleArrayTopic GetDoubleArrayTopic (std::string_view name) const
 Gets a double array topic. More...
 
StringArrayTopic GetStringArrayTopic (std::string_view name) const
 Gets a string array topic. More...
 
std::vector< TopicGetTopics ()
 Get Published Topics. More...
 
std::vector< TopicGetTopics (std::string_view prefix)
 Get Published Topics. More...
 
std::vector< TopicGetTopics (std::string_view prefix, unsigned int types)
 Get Published Topics. More...
 
std::vector< TopicGetTopics (std::string_view prefix, std::span< std::string_view > types)
 Get Published Topics. More...
 
std::vector< TopicInfoGetTopicInfo ()
 Get Topic Information about multiple topics. More...
 
std::vector< TopicInfoGetTopicInfo (std::string_view prefix)
 Get Topic Information about multiple topics. More...
 
std::vector< TopicInfoGetTopicInfo (std::string_view prefix, unsigned int types)
 Get Topic Information about multiple topics. More...
 
std::vector< TopicInfoGetTopicInfo (std::string_view prefix, std::span< std::string_view > types)
 Get Topic Information about multiple topics. More...
 
NetworkTableEntry GetEntry (std::string_view name)
 Gets the entry for a key. More...
 
std::shared_ptr< NetworkTableGetTable (std::string_view key) const
 Gets the table with the specified key. More...
 
bool operator== (const NetworkTableInstance &) const =default
 Equality operator. More...
 
Client/Server Functions
unsigned int GetNetworkMode () const
 Get the current network mode. More...
 
void StartLocal ()
 Starts local-only operation. More...
 
void StopLocal ()
 Stops local-only operation. More...
 
void StartServer (std::string_view persist_filename="networktables.json", const char *listen_address="", unsigned int port3=kDefaultPort3, unsigned int port4=kDefaultPort4)
 Starts a server using the specified filename, listening address, and port. More...
 
void StopServer ()
 Stops the server if it is running. More...
 
void StartClient3 (std::string_view identity)
 Starts a NT3 client. More...
 
void StartClient4 (std::string_view identity)
 Starts a NT4 client. More...
 
void StopClient ()
 Stops the client if it is running. More...
 
void SetServer (const char *server_name, unsigned int port=0)
 Sets server address and port for client (without restarting client). More...
 
void SetServer (std::span< const std::pair< std::string_view, unsigned int > > servers)
 Sets server addresses and ports for client (without restarting client). More...
 
void SetServer (std::span< const std::string_view > servers, unsigned int port=0)
 Sets server addresses and port for client (without restarting client). More...
 
void SetServerTeam (unsigned int team, unsigned int port=0)
 Sets server addresses and port for client (without restarting client). More...
 
void Disconnect ()
 Disconnects the client if it's running and connected. More...
 
void StartDSClient (unsigned int port=0)
 Starts requesting server address from Driver Station. More...
 
void StopDSClient ()
 Stops requesting server address from Driver Station. More...
 
void FlushLocal () const
 Flushes all updated values immediately to the local client/server. More...
 
void Flush () const
 Flushes all updated values immediately to the network. More...
 
std::vector< ConnectionInfoGetConnections () const
 Get information on the currently established network connections. More...
 
bool IsConnected () const
 Return whether or not the instance is connected to another node. More...
 
std::optional< int64_t > GetServerTimeOffset () const
 Get the time offset between server time and local time. More...
 
Logger Functions
NT_Listener AddLogger (unsigned int minLevel, unsigned int maxLevel, ListenerCallback func)
 Add logger callback function. More...
 

Static Public Member Functions

static NetworkTableInstance GetDefault ()
 Get global default instance. More...
 
static NetworkTableInstance Create ()
 Create an instance. More...
 
static void Destroy (NetworkTableInstance &inst)
 Destroys an instance (note: this has global effect). More...
 

Static Public Attributes

static constexpr unsigned int kDefaultPort3 = NT_DEFAULT_PORT3
 The default port that network tables operates on for NT3. More...
 
static constexpr unsigned int kDefaultPort4 = NT_DEFAULT_PORT4
 The default port that network tables operates on for NT4. More...
 

Listener Functions

bool WaitForListenerQueue (double timeout)
 Wait for the listener queue to be empty. More...
 
NT_Listener AddConnectionListener (bool immediate_notify, ListenerCallback callback) const
 Add a connection listener. More...
 
NT_Listener AddTimeSyncListener (bool immediate_notify, ListenerCallback callback) const
 Add a time synchronization listener. More...
 
NT_Listener AddListener (Topic topic, unsigned int eventMask, ListenerCallback listener)
 Add a listener for changes on a particular topic. More...
 
NT_Listener AddListener (Subscriber &subscriber, unsigned int eventMask, ListenerCallback listener)
 Add a listener for changes on a subscriber. More...
 
NT_Listener AddListener (MultiSubscriber &subscriber, int eventMask, ListenerCallback listener)
 Add a listener for changes on a subscriber. More...
 
NT_Listener AddListener (const NetworkTableEntry &entry, int eventMask, ListenerCallback listener)
 Add a listener for changes on an entry. More...
 
NT_Listener AddListener (std::span< const std::string_view > prefixes, int eventMask, ListenerCallback listener)
 Add a listener for changes to topics with names that start with any of the given prefixes. More...
 
static void RemoveListener (NT_Listener listener)
 Remove a listener. More...
 

Data Logger Functions

NT_DataLogger StartEntryDataLog (wpi::log::DataLog &log, std::string_view prefix, std::string_view logPrefix)
 Starts logging entry changes to a DataLog. More...
 
NT_ConnectionDataLogger StartConnectionDataLog (wpi::log::DataLog &log, std::string_view name)
 Starts logging connection changes to a DataLog. More...
 
static void StopEntryDataLog (NT_DataLogger logger)
 Stops logging entry changes to a DataLog. More...
 
static void StopConnectionDataLog (NT_ConnectionDataLogger logger)
 Stops logging connection changes to a DataLog. More...
 

Detailed Description

NetworkTables Instance.

Instances are completely independent from each other. Table operations on one instance will not be visible to other instances unless the instances are connected via the network. The main limitation on instances is that you cannot have two servers on the same network port. The main utility of instances is for unit testing, but they can also enable one program to connect to two different NetworkTables networks.

The global "default" instance (as returned by GetDefault()) is always available, and is intended for the common case when there is only a single NetworkTables instance being used in the program. The default instance cannot be destroyed.

Additional instances can be created with the Create() function. Instances are not reference counted or RAII. Instead, they must be explicitly destroyed (with Destroy()).

Member Enumeration Documentation

◆ LogLevel

Logging levels (as used by SetLogger()).

Enumerator
kLogCritical 
kLogError 
kLogWarning 
kLogInfo 
kLogDebug 
kLogDebug1 
kLogDebug2 
kLogDebug3 
kLogDebug4 

◆ NetworkMode

Client/server mode flag values (as returned by GetNetworkMode()).

This is a bitmask.

Enumerator
kNetModeNone 
kNetModeServer 
kNetModeClient3 
kNetModeClient4 
kNetModeLocal 

Constructor & Destructor Documentation

◆ NetworkTableInstance() [1/2]

nt::NetworkTableInstance::NetworkTableInstance ( )
inlinenoexcept

Construct invalid instance.

◆ NetworkTableInstance() [2/2]

nt::NetworkTableInstance::NetworkTableInstance ( NT_Inst  inst)
inlineexplicitnoexcept

Construct from native handle.

Parameters
instNative handle

Member Function Documentation

◆ AddConnectionListener()

NT_Listener nt::NetworkTableInstance::AddConnectionListener ( bool  immediate_notify,
ListenerCallback  callback 
) const
inline

Add a connection listener.

The callback function is called asynchronously on a separate thread, so it's important to use synchronization or atomics when accessing any shared state from the callback function.

Parameters
immediate_notifynotify listener of all existing connections
callbacklistener to add
Returns
Listener handle

◆ AddListener() [1/5]

NT_Listener nt::NetworkTableInstance::AddListener ( const NetworkTableEntry entry,
int  eventMask,
ListenerCallback  listener 
)

Add a listener for changes on an entry.

The callback function is called asynchronously on a separate thread, so it's important to use synchronization or atomics when accessing any shared state from the callback function.

Parameters
entryEntry
eventMaskBitmask of EventFlags values
listenerListener function
Returns
Listener handle

◆ AddListener() [2/5]

NT_Listener nt::NetworkTableInstance::AddListener ( MultiSubscriber subscriber,
int  eventMask,
ListenerCallback  listener 
)

Add a listener for changes on a subscriber.

The callback function is called asynchronously on a separate thread, so it's important to use synchronization or atomics when accessing any shared state from the callback function. This does NOT keep the subscriber active.

Parameters
subscriberSubscriber
eventMaskBitmask of EventFlags values
listenerListener function
Returns
Listener handle

◆ AddListener() [3/5]

NT_Listener nt::NetworkTableInstance::AddListener ( std::span< const std::string_view prefixes,
int  eventMask,
ListenerCallback  listener 
)
inline

Add a listener for changes to topics with names that start with any of the given prefixes.

The callback function is called asynchronously on a separate thread, so it's important to use synchronization or atomics when accessing any shared state from the callback function.

This creates a corresponding internal subscriber with the lifetime of the listener.

Parameters
prefixesTopic name string prefixes
eventMaskBitmask of EventFlags values
listenerListener function
Returns
Listener handle

◆ AddListener() [4/5]

NT_Listener nt::NetworkTableInstance::AddListener ( Subscriber subscriber,
unsigned int  eventMask,
ListenerCallback  listener 
)

Add a listener for changes on a subscriber.

The callback function is called asynchronously on a separate thread, so it's important to use synchronization or atomics when accessing any shared state from the callback function. This does NOT keep the subscriber active.

Parameters
subscriberSubscriber
eventMaskBitmask of EventFlags values
listenerListener function
Returns
Listener handle

◆ AddListener() [5/5]

NT_Listener nt::NetworkTableInstance::AddListener ( Topic  topic,
unsigned int  eventMask,
ListenerCallback  listener 
)

Add a listener for changes on a particular topic.

The callback function is called asynchronously on a separate thread, so it's important to use synchronization or atomics when accessing any shared state from the callback function.

This creates a corresponding internal subscriber with the lifetime of the listener.

Parameters
topicTopic
eventMaskBitmask of EventFlags values
listenerListener function
Returns
Listener handle

◆ AddLogger()

NT_Listener nt::NetworkTableInstance::AddLogger ( unsigned int  minLevel,
unsigned int  maxLevel,
ListenerCallback  func 
)
inline

Add logger callback function.

By default, log messages are sent to stderr; this function sends log messages with the specified levels to the provided callback function instead. The callback function will only be called for log messages with level greater than or equal to minLevel and less than or equal to maxLevel; messages outside this range will be silently ignored.

Parameters
minLevelminimum log level
maxLevelmaximum log level
funccallback function
Returns
Listener handle

◆ AddTimeSyncListener()

NT_Listener nt::NetworkTableInstance::AddTimeSyncListener ( bool  immediate_notify,
ListenerCallback  callback 
) const
inline

Add a time synchronization listener.

The callback function is called asynchronously on a separate thread, so it's important to use synchronization or atomics when accessing any shared state from the callback function.

Parameters
immediate_notifynotify listener of current time synchronization value
callbacklistener to add
Returns
Listener handle

◆ Create()

NetworkTableInstance nt::NetworkTableInstance::Create ( )
inlinestatic

Create an instance.

Returns
Newly created instance

◆ Destroy()

void nt::NetworkTableInstance::Destroy ( NetworkTableInstance inst)
inlinestatic

Destroys an instance (note: this has global effect).

Parameters
instInstance

◆ Disconnect()

void nt::NetworkTableInstance::Disconnect ( )
inline

Disconnects the client if it's running and connected.

This will automatically start reconnection attempts to the current server list.

◆ Flush()

void nt::NetworkTableInstance::Flush ( ) const
inline

Flushes all updated values immediately to the network.

Note
This is rate-limited to protect the network from flooding. This is primarily useful for synchronizing network updates with user code.

◆ FlushLocal()

void nt::NetworkTableInstance::FlushLocal ( ) const
inline

Flushes all updated values immediately to the local client/server.

This does not flush to the network.

◆ GetBooleanArrayTopic()

BooleanArrayTopic nt::NetworkTableInstance::GetBooleanArrayTopic ( std::string_view  name) const

Gets a boolean array topic.

Parameters
nametopic name
Returns
Topic

◆ GetBooleanTopic()

BooleanTopic nt::NetworkTableInstance::GetBooleanTopic ( std::string_view  name) const

Gets a boolean topic.

Parameters
nametopic name
Returns
Topic

◆ GetConnections()

std::vector< ConnectionInfo > nt::NetworkTableInstance::GetConnections ( ) const
inline

Get information on the currently established network connections.

If operating as a client, this will return either zero or one values.

Returns
array of connection information

◆ GetDefault()

NetworkTableInstance nt::NetworkTableInstance::GetDefault ( )
inlinestatic

Get global default instance.

Returns
Global default instance

◆ GetDoubleArrayTopic()

DoubleArrayTopic nt::NetworkTableInstance::GetDoubleArrayTopic ( std::string_view  name) const

Gets a double array topic.

Parameters
nametopic name
Returns
Topic

◆ GetDoubleTopic()

DoubleTopic nt::NetworkTableInstance::GetDoubleTopic ( std::string_view  name) const

Gets a double topic.

Parameters
nametopic name
Returns
Topic

◆ GetEntry()

NetworkTableEntry nt::NetworkTableInstance::GetEntry ( std::string_view  name)
inline

Gets the entry for a key.

Parameters
nameKey
Returns
Network table entry.

◆ GetFloatArrayTopic()

FloatArrayTopic nt::NetworkTableInstance::GetFloatArrayTopic ( std::string_view  name) const

Gets a float array topic.

Parameters
nametopic name
Returns
Topic

◆ GetFloatTopic()

FloatTopic nt::NetworkTableInstance::GetFloatTopic ( std::string_view  name) const

Gets a float topic.

Parameters
nametopic name
Returns
Topic

◆ GetHandle()

NT_Inst nt::NetworkTableInstance::GetHandle ( ) const
inline

Gets the native handle for the entry.

Returns
Native handle

◆ GetIntegerArrayTopic()

IntegerArrayTopic nt::NetworkTableInstance::GetIntegerArrayTopic ( std::string_view  name) const

Gets an integer array topic.

Parameters
nametopic name
Returns
Topic

◆ GetIntegerTopic()

IntegerTopic nt::NetworkTableInstance::GetIntegerTopic ( std::string_view  name) const

Gets an integer topic.

Parameters
nametopic name
Returns
Topic

◆ GetNetworkMode()

unsigned int nt::NetworkTableInstance::GetNetworkMode ( ) const
inline

Get the current network mode.

Returns
Bitmask of NetworkMode.

◆ GetRawTopic()

RawTopic nt::NetworkTableInstance::GetRawTopic ( std::string_view  name) const

Gets a raw topic.

Parameters
nametopic name
Returns
Topic

◆ GetServerTimeOffset()

std::optional< int64_t > nt::NetworkTableInstance::GetServerTimeOffset ( ) const
inline

Get the time offset between server time and local time.

Add this value to local time to get the estimated equivalent server time. In server mode, this always returns 0. In client mode, this returns the time offset only if the client and server are connected and have exchanged synchronization messages. Note the time offset may change over time as it is periodically updated; to receive updates as events, add a listener to the "time sync" event.

Returns
Time offset in microseconds (optional)

◆ GetStringArrayTopic()

StringArrayTopic nt::NetworkTableInstance::GetStringArrayTopic ( std::string_view  name) const

Gets a string array topic.

Parameters
nametopic name
Returns
Topic

◆ GetStringTopic()

StringTopic nt::NetworkTableInstance::GetStringTopic ( std::string_view  name) const

Gets a string topic.

Parameters
nametopic name
Returns
Topic

◆ GetTable()

std::shared_ptr< NetworkTable > nt::NetworkTableInstance::GetTable ( std::string_view  key) const

Gets the table with the specified key.

Parameters
keythe key name
Returns
The network table

◆ GetTopic()

Topic nt::NetworkTableInstance::GetTopic ( std::string_view  name) const

Gets a "generic" (untyped) topic.

Parameters
nametopic name
Returns
Topic

◆ GetTopicInfo() [1/4]

std::vector< TopicInfo > nt::NetworkTableInstance::GetTopicInfo ( )
inline

Get Topic Information about multiple topics.

Returns an array of topic information (handle, name, type, and properties).

Returns
Array of topic information.

◆ GetTopicInfo() [2/4]

std::vector< TopicInfo > nt::NetworkTableInstance::GetTopicInfo ( std::string_view  prefix)
inline

Get Topic Information about multiple topics.

Returns an array of topic information (handle, name, type, and properties). The results are filtered by string prefix to only return a subset of all topics.

Parameters
prefixname required prefix; only topics whose name starts with this string are returned
Returns
Array of topic information.

◆ GetTopicInfo() [3/4]

std::vector< TopicInfo > nt::NetworkTableInstance::GetTopicInfo ( std::string_view  prefix,
std::span< std::string_view types 
)
inline

Get Topic Information about multiple topics.

Returns an array of topic information (handle, name, type, and properties). The results are filtered by string prefix and type to only return a subset of all topics.

Parameters
prefixname required prefix; only topics whose name starts with this string are returned
typesarray of type strings
Returns
Array of topic information.

◆ GetTopicInfo() [4/4]

std::vector< TopicInfo > nt::NetworkTableInstance::GetTopicInfo ( std::string_view  prefix,
unsigned int  types 
)
inline

Get Topic Information about multiple topics.

Returns an array of topic information (handle, name, type, and properties). The results are filtered by string prefix and type to only return a subset of all topics.

Parameters
prefixname required prefix; only topics whose name starts with this string are returned
typesbitmask of NT_Type values; 0 is treated specially as a "don't care"
Returns
Array of topic information.

◆ GetTopics() [1/4]

std::vector< Topic > nt::NetworkTableInstance::GetTopics ( )
inline

Get Published Topics.

Returns an array of topics.

Returns
Array of topics.

◆ GetTopics() [2/4]

std::vector< Topic > nt::NetworkTableInstance::GetTopics ( std::string_view  prefix)
inline

Get Published Topics.

Returns an array of topics. The results are filtered by string prefix to only return a subset of all topics.

Parameters
prefixname required prefix; only topics whose name starts with this string are returned
Returns
Array of topics.

◆ GetTopics() [3/4]

std::vector< Topic > nt::NetworkTableInstance::GetTopics ( std::string_view  prefix,
std::span< std::string_view types 
)
inline

Get Published Topics.

Returns an array of topics. The results are filtered by string prefix and type to only return a subset of all topics.

Parameters
prefixname required prefix; only topics whose name starts with this string are returned
typesarray of type strings
Returns
Array of topic handles.

◆ GetTopics() [4/4]

std::vector< Topic > nt::NetworkTableInstance::GetTopics ( std::string_view  prefix,
unsigned int  types 
)
inline

Get Published Topics.

Returns an array of topics. The results are filtered by string prefix and type to only return a subset of all topics.

Parameters
prefixname required prefix; only topics whose name starts with this string are returned
typesbitmask of NT_Type values; 0 is treated specially as a "don't care"
Returns
Array of topics.

◆ IsConnected()

bool nt::NetworkTableInstance::IsConnected ( ) const
inline

Return whether or not the instance is connected to another node.

Returns
True if connected.

◆ operator bool()

nt::NetworkTableInstance::operator bool ( ) const
inlineexplicit

Determines if the native handle is valid.

Returns
True if the native handle is valid, false otherwise.

◆ operator==()

bool nt::NetworkTableInstance::operator== ( const NetworkTableInstance ) const
default

Equality operator.

Returns true if both instances refer to the same native handle.

◆ RemoveListener()

void nt::NetworkTableInstance::RemoveListener ( NT_Listener  listener)
inlinestatic

Remove a listener.

Parameters
listenerListener handle to remove

◆ SetServer() [1/3]

void nt::NetworkTableInstance::SetServer ( const char *  server_name,
unsigned int  port = 0 
)
inline

Sets server address and port for client (without restarting client).

Parameters
server_nameserver name (UTF-8 string, null terminated)
portport to communicate over (0 = default)

◆ SetServer() [2/3]

void nt::NetworkTableInstance::SetServer ( std::span< const std::pair< std::string_view, unsigned int > >  servers)
inline

Sets server addresses and ports for client (without restarting client).

The client will attempt to connect to each server in round robin fashion.

Parameters
serversarray of server address and port pairs

◆ SetServer() [3/3]

void nt::NetworkTableInstance::SetServer ( std::span< const std::string_view servers,
unsigned int  port = 0 
)

Sets server addresses and port for client (without restarting client).

The client will attempt to connect to each server in round robin fashion.

Parameters
serversarray of server names
portport to communicate over (0 = default)

◆ SetServerTeam()

void nt::NetworkTableInstance::SetServerTeam ( unsigned int  team,
unsigned int  port = 0 
)
inline

Sets server addresses and port for client (without restarting client).

Connects using commonly known robot addresses for the specified team.

Parameters
teamteam number
portport to communicate over (0 = default)

◆ StartClient3()

void nt::NetworkTableInstance::StartClient3 ( std::string_view  identity)
inline

Starts a NT3 client.

Use SetServer or SetServerTeam to set the server name and port.

Parameters
identitynetwork identity to advertise (cannot be empty string)

◆ StartClient4()

void nt::NetworkTableInstance::StartClient4 ( std::string_view  identity)
inline

Starts a NT4 client.

Use SetServer or SetServerTeam to set the server name and port.

Parameters
identitynetwork identity to advertise (cannot be empty string)

◆ StartConnectionDataLog()

NT_ConnectionDataLogger nt::NetworkTableInstance::StartConnectionDataLog ( wpi::log::DataLog log,
std::string_view  name 
)
inline

Starts logging connection changes to a DataLog.

Parameters
logdata log object; lifetime must extend until StopConnectionDataLog is called or the instance is destroyed
namedata log entry name
Returns
Data logger handle

◆ StartDSClient()

void nt::NetworkTableInstance::StartDSClient ( unsigned int  port = 0)
inline

Starts requesting server address from Driver Station.

This connects to the Driver Station running on localhost to obtain the server IP address.

Parameters
portserver port to use in combination with IP from DS (0 = default)

◆ StartEntryDataLog()

NT_DataLogger nt::NetworkTableInstance::StartEntryDataLog ( wpi::log::DataLog log,
std::string_view  prefix,
std::string_view  logPrefix 
)
inline

Starts logging entry changes to a DataLog.

Parameters
logdata log object; lifetime must extend until StopEntryDataLog is called or the instance is destroyed
prefixonly store entries with names that start with this prefix; the prefix is not included in the data log entry name
logPrefixprefix to add to data log entry names
Returns
Data logger handle

◆ StartLocal()

void nt::NetworkTableInstance::StartLocal ( )
inline

Starts local-only operation.

Prevents calls to StartServer or StartClient from taking effect. Has no effect if StartServer or StartClient has already been called.

◆ StartServer()

void nt::NetworkTableInstance::StartServer ( std::string_view  persist_filename = "networktables.json",
const char *  listen_address = "",
unsigned int  port3 = kDefaultPort3,
unsigned int  port4 = kDefaultPort4 
)
inline

Starts a server using the specified filename, listening address, and port.

Parameters
persist_filenamethe name of the persist file to use (UTF-8 string, null terminated)
listen_addressthe address to listen on, or null to listen on any address (UTF-8 string, null terminated)
port3port to communicate over (NT3)
port4port to communicate over (NT4)

◆ StopClient()

void nt::NetworkTableInstance::StopClient ( )
inline

Stops the client if it is running.

◆ StopConnectionDataLog()

void nt::NetworkTableInstance::StopConnectionDataLog ( NT_ConnectionDataLogger  logger)
inlinestatic

Stops logging connection changes to a DataLog.

Parameters
loggerdata logger handle

◆ StopDSClient()

void nt::NetworkTableInstance::StopDSClient ( )
inline

Stops requesting server address from Driver Station.

◆ StopEntryDataLog()

void nt::NetworkTableInstance::StopEntryDataLog ( NT_DataLogger  logger)
inlinestatic

Stops logging entry changes to a DataLog.

Parameters
loggerdata logger handle

◆ StopLocal()

void nt::NetworkTableInstance::StopLocal ( )
inline

Stops local-only operation.

StartServer or StartClient can be called after this call to start a server or client.

◆ StopServer()

void nt::NetworkTableInstance::StopServer ( )
inline

Stops the server if it is running.

◆ WaitForListenerQueue()

bool nt::NetworkTableInstance::WaitForListenerQueue ( double  timeout)
inline

Wait for the listener queue to be empty.

This is primarily useful for deterministic testing. This blocks until either the listener queue is empty (e.g. there are no more events that need to be passed along to callbacks or poll queues) or the timeout expires.

Parameters
timeouttimeout, in seconds. Set to 0 for non-blocking behavior, or a negative value to block indefinitely
Returns
False if timed out, otherwise true.

Member Data Documentation

◆ kDefaultPort3

constexpr unsigned int nt::NetworkTableInstance::kDefaultPort3 = NT_DEFAULT_PORT3
staticconstexpr

The default port that network tables operates on for NT3.

◆ kDefaultPort4

constexpr unsigned int nt::NetworkTableInstance::kDefaultPort4 = NT_DEFAULT_PORT4
staticconstexpr

The default port that network tables operates on for NT4.


The documentation for this class was generated from the following files: