232 std::string_view filename,
unsigned int line, std::string_view message)
237 int64_t rtt2,
bool valid)
263 bool Is(
unsigned int kind)
const {
return (
flags & kind) != 0; }
271 return std::get_if<ConnectionInfo>(&
data);
274 return std::get_if<ConnectionInfo>(&
data);
278 return std::get_if<TopicInfo>(&
data);
283 return std::get_if<ValueEventData>(&
data);
286 return std::get_if<ValueEventData>(&
data);
290 return std::get_if<LogMessage>(&
data);
295 return std::get_if<TimeSyncEventData>(&
data);
298 return std::get_if<TimeSyncEventData>(&
data);
585 std::span<const std::string_view> types);
618 std::span<const std::string_view> types);
745 const wpi::util::json& value);
818 const wpi::util::json& properties,
880 NT_Inst inst, std::span<const std::string_view> prefixes,
960 std::span<const std::string_view> prefixes,
996 std::span<const std::string_view> prefixes,
1065 std::string_view listen_address, std::string_view mdns_service,
1109 std::span<
const std::pair<std::string_view, unsigned int>> servers);
1267 std::string_view prefix,
1268 std::string_view logPrefix);
1288 std::string_view
name);
1331 unsigned int max_level);
1368 std::span<const uint8_t> schema);
1386 std::string_view type, std::string_view schema) {
1389 std::span<const uint8_t>{
reinterpret_cast<const uint8_t*
>(schema.data()),
1471 std::span<const uint8_t> data);
1480 std::span<const uint8_t> data);
1489 std::span<const uint8_t> data);
1498 std::span<const uint8_t> data);
@ name
Definition base.h:690
A data log for high-speed writing of data values.
Definition DataLog.hpp:69
NetworkTables event.
Definition ntcore_cpp.hpp:215
std::variant< ConnectionInfo, TopicInfo, ValueEventData, LogMessage, TimeSyncEventData > data
Event data; content depends on flags.
Definition ntcore_cpp.hpp:268
Event(NT_Listener listener, unsigned int flags, NT_Topic topic, NT_Handle subentry, Value value)
Definition ntcore_cpp.hpp:226
ConnectionInfo * GetConnectionInfo()
Definition ntcore_cpp.hpp:273
bool Is(unsigned int kind) const
Test event flags.
Definition ntcore_cpp.hpp:263
Event(NT_Listener listener, unsigned int flags, ValueEventData data)
Definition ntcore_cpp.hpp:222
TimeSyncEventData * GetTimeSyncEventData()
Definition ntcore_cpp.hpp:297
const TopicInfo * GetTopicInfo() const
Definition ntcore_cpp.hpp:277
const LogMessage * GetLogMessage() const
Definition ntcore_cpp.hpp:289
NT_Listener listener
Listener that triggered this event.
Definition ntcore_cpp.hpp:243
const TimeSyncEventData * GetTimeSyncEventData() const
Definition ntcore_cpp.hpp:294
Event(NT_Listener listener, unsigned int flags, ConnectionInfo info)
Definition ntcore_cpp.hpp:218
const ConnectionInfo * GetConnectionInfo() const
Definition ntcore_cpp.hpp:270
unsigned int flags
Event flags (NT_EventFlags).
Definition ntcore_cpp.hpp:255
Event(NT_Listener listener, unsigned int flags, LogMessage msg)
Definition ntcore_cpp.hpp:224
const ValueEventData * GetValueEventData() const
Definition ntcore_cpp.hpp:282
Event(NT_Listener listener, unsigned int flags, unsigned int level, std::string_view filename, unsigned int line, std::string_view message)
Definition ntcore_cpp.hpp:231
LogMessage * GetLogMessage()
Definition ntcore_cpp.hpp:292
ValueEventData * GetValueEventData()
Definition ntcore_cpp.hpp:285
TopicInfo * GetTopicInfo()
Definition ntcore_cpp.hpp:280
Event(NT_Listener listener, unsigned int flags, int64_t serverTimeOffset, int64_t rtt2, bool valid)
Definition ntcore_cpp.hpp:236
Event(NT_Listener listener, unsigned int flags, TopicInfo info)
Definition ntcore_cpp.hpp:220
NetworkTables log message.
Definition ntcore_cpp.hpp:171
unsigned int level
Log level of the message.
Definition ntcore_cpp.hpp:179
unsigned int line
The line number in the source file that generated the message.
Definition ntcore_cpp.hpp:185
std::string filename
The filename of the source file that generated the message.
Definition ntcore_cpp.hpp:182
LogMessage(unsigned int level, std::string_view filename, unsigned int line, std::string_view message)
Definition ntcore_cpp.hpp:174
std::string message
The message.
Definition ntcore_cpp.hpp:188
NetworkTables time sync event data.
Definition ntcore_cpp.hpp:192
int64_t rtt2
Measured round trip time divided by 2, in microseconds.
Definition ntcore_cpp.hpp:205
TimeSyncEventData()=default
int64_t serverTimeOffset
Offset between local time and server time, in microseconds.
Definition ntcore_cpp.hpp:202
bool valid
If serverTimeOffset and RTT are valid.
Definition ntcore_cpp.hpp:211
TimeSyncEventData(int64_t serverTimeOffset, int64_t rtt2, bool valid)
Definition ntcore_cpp.hpp:195
NetworkTables Value Event Data.
Definition ntcore_cpp.hpp:154
NT_Handle subentry
Subscriber/entry handle.
Definition ntcore_cpp.hpp:164
ValueEventData(NT_Topic topic, NT_Handle subentry, Value value)
Definition ntcore_cpp.hpp:157
Value value
The new value.
Definition ntcore_cpp.hpp:167
NT_Topic topic
Topic handle.
Definition ntcore_cpp.hpp:161
A network table entry value.
Definition NetworkTableValue.hpp:35
Definition BooleanTopic.hpp:24
void UnsubscribeMultiple(NT_MultiSubscriber sub)
Unsubscribes a multi-subscriber.
NT_MultiSubscriber SubscribeMultiple(NT_Inst inst, std::span< const std::string_view > prefixes, const PubSubOptions &options=kDefaultPubSubOptions)
Subscribes to multiple topics based on one or more topic name prefixes.
NT_Handle NT_Topic
Definition ntcore_c.h:42
NT_Handle NT_ConnectionDataLogger
Definition ntcore_c.h:35
NT_Handle NT_Listener
Definition ntcore_c.h:39
NT_Handle NT_Subscriber
Definition ntcore_c.h:43
unsigned int NT_Handle
Definition ntcore_c.h:34
NT_Type
NetworkTables data types.
Definition ntcore_c.h:50
NT_Handle NT_Inst
Definition ntcore_c.h:38
NT_Handle NT_Publisher
Definition ntcore_c.h:44
NT_Handle NT_ListenerPoller
Definition ntcore_c.h:40
NT_Handle NT_MultiSubscriber
Definition ntcore_c.h:41
NT_Handle NT_Entry
Definition ntcore_c.h:37
NT_Handle NT_DataLogger
Definition ntcore_c.h:36
@ NT_UNASSIGNED
Definition ntcore_c.h:51
@ NT_EVENT_LOGMESSAGE
Log message.
Definition ntcore_c.h:122
@ NT_EVENT_NONE
Definition ntcore_c.h:98
@ NT_EVENT_UNPUBLISH
Topic unpublished.
Definition ntcore_c.h:110
@ NT_EVENT_PROPERTIES
Topic properties changed.
Definition ntcore_c.h:112
@ NT_EVENT_CONNECTED
Client connected (on server, any client connected).
Definition ntcore_c.h:102
@ NT_EVENT_TIMESYNC
Time synchronized with server.
Definition ntcore_c.h:124
@ NT_EVENT_VALUE_REMOTE
Topic value updated (via network).
Definition ntcore_c.h:116
@ NT_EVENT_PUBLISH
New topic published.
Definition ntcore_c.h:108
@ NT_EVENT_DISCONNECTED
Client disconnected (on server, any client disconnected).
Definition ntcore_c.h:104
@ NT_EVENT_IMMEDIATE
Initial listener addition.
Definition ntcore_c.h:100
@ NT_EVENT_VALUE_LOCAL
Topic value updated (local).
Definition ntcore_c.h:118
constexpr PubSubOptions kDefaultPubSubOptions
Default publish/subscribe options.
Definition ntcore_cpp.hpp:388
void StopConnectionDataLog(NT_ConnectionDataLogger logger)
Stops logging connection changes to a DataLog.
void StopEntryDataLog(NT_DataLogger logger)
Stops logging entry changes to a DataLog.
NT_ConnectionDataLogger StartConnectionDataLog(NT_Inst inst, wpi::log::DataLog &log, std::string_view name)
Starts logging connection changes to a DataLog.
NT_DataLogger StartEntryDataLog(NT_Inst inst, wpi::log::DataLog &log, std::string_view prefix, std::string_view logPrefix)
Starts logging entry changes to a DataLog.
NT_Inst GetInstanceFromHandle(NT_Handle handle)
Get instance handle from another handle.
void DestroyInstance(NT_Inst inst)
Destroy an instance.
void ResetInstance(NT_Inst inst)
Reset the internals of an instance.
NT_Inst CreateInstance()
Create an instance.
NT_Inst GetDefaultInstance()
Get default instance.
void RemoveListener(NT_Listener listener)
Removes a listener.
NT_Listener AddListener(NT_Inst inst, std::span< const std::string_view > prefixes, unsigned int mask, ListenerCallback callback)
Create a listener for changes to topics with names that start with any of the given prefixes.
NT_ListenerPoller CreateListenerPoller(NT_Inst inst)
Creates a listener poller.
std::function< void(const Event &)> ListenerCallback
Definition ntcore_cpp.hpp:897
NT_Listener AddPolledListener(NT_ListenerPoller poller, std::span< const std::string_view > prefixes, unsigned int mask)
Creates a polled listener.
void DestroyListenerPoller(NT_ListenerPoller poller)
Destroys a listener poller.
bool WaitForListenerQueue(NT_Handle handle, double timeout)
Wait for the listener queue to be empty.
std::vector< Event > ReadListenerQueue(NT_ListenerPoller poller)
Read notifications.
NT_Listener AddPolledLogger(NT_ListenerPoller poller, unsigned int min_level, unsigned int max_level)
Set the log level for a log poller.
NT_Listener AddLogger(NT_Inst inst, unsigned int min_level, unsigned int max_level, ListenerCallback func)
Add logger callback function.
bool IsConnected(NT_Inst inst)
Return whether or not the instance is connected to another node.
void StartLocal(NT_Inst inst)
Starts local-only operation.
std::vector< ConnectionInfo > GetConnections(NT_Inst inst)
Get information on the currently established network connections.
void SetServer(NT_Inst inst, std::string_view server_name, unsigned int port)
Sets server address and port for client (without restarting client).
void StopLocal(NT_Inst inst)
Stops local-only operation.
void StartClient(NT_Inst inst, std::string_view identity)
Starts a client.
void StartDSClient(NT_Inst inst, unsigned int port)
Starts requesting server address from Driver Station.
void FlushLocal(NT_Inst inst)
Flush local updates.
void StopClient(NT_Inst inst)
Stops the client if it is running.
void Flush(NT_Inst inst)
Flush to network.
void SetServerTeam(NT_Inst inst, unsigned int team, unsigned int port)
Sets server addresses and port for client (without restarting client).
void StopServer(NT_Inst inst)
Stops the server if it is running.
void StartServer(NT_Inst inst, std::string_view persist_filename, std::string_view listen_address, std::string_view mdns_service, unsigned int port)
Starts a server using the specified filename, listening address, and port.
std::optional< int64_t > GetServerTimeOffset(NT_Inst inst)
Get the time offset between server time and local time.
void StopDSClient(NT_Inst inst)
Stops requesting server address from Driver Station.
unsigned int GetNetworkMode(NT_Inst inst)
Get the current network mode.
void Disconnect(NT_Inst inst)
Disconnects the client if it's running and connected.
void AddSchema(NT_Inst inst, std::string_view name, std::string_view type, std::span< const uint8_t > schema)
Registers a data schema.
bool HasSchema(NT_Inst inst, std::string_view name)
Returns whether there is a data schema already registered with the given name.
bool SetEntryValue(NT_Entry entry, const Value &value)
Set Entry Value.
unsigned int GetEntryFlags(NT_Entry entry)
Get Entry Flags.
Value GetEntryValue(NT_Handle subentry)
Get Entry Value.
void SetEntryFlags(NT_Entry entry, unsigned int flags)
Set Entry Flags.
std::vector< Value > ReadQueueValue(NT_Handle subentry)
Read Entry Queue.
int64_t GetEntryLastChange(NT_Handle subentry)
Gets the last time the entry was changed.
NT_Entry GetEntry(NT_Inst inst, std::string_view name)
Get Entry Handle.
NT_Type GetEntryType(NT_Entry entry)
Gets the type for the specified entry, or unassigned if non existent.
std::string GetEntryName(NT_Entry entry)
Gets the name of the specified entry.
bool SetDefaultEntryValue(NT_Entry entry, const Value &value)
Set Default Entry Value.
bool GetTopicCached(NT_Topic topic)
Gets the cached property of a topic.
bool GetTopicExists(NT_Handle handle)
Determine if topic exists (e.g.
NT_Topic GetTopicFromHandle(NT_Handle pubsubentry)
Gets the topic handle from an entry/subscriber/publisher handle.
std::string GetTopicName(NT_Topic topic)
Gets the name of the specified topic.
std::string GetTopicTypeString(NT_Topic topic)
Gets the type string for the specified topic, or empty string if non existent.
NT_Topic GetTopic(NT_Inst inst, std::string_view name)
Gets Topic Handle.
std::vector< TopicInfo > GetTopicInfo(NT_Inst inst, std::string_view prefix, unsigned int types)
Get Topic Information about multiple topics.
bool GetTopicRetained(NT_Topic topic)
Gets the retained property of a topic.
void SetTopicCached(NT_Topic topic, bool value)
Sets the cached property of a topic.
NT_Publisher Publish(NT_Topic topic, NT_Type type, std::string_view typeStr, const PubSubOptions &options=kDefaultPubSubOptions)
Creates a new publisher to a topic.
bool SetTopicProperties(NT_Topic topic, const wpi::util::json &update)
Updates multiple topic properties.
void Unpublish(NT_Handle pubentry)
Stops publisher.
void SetTopicRetained(NT_Topic topic, bool value)
Sets the retained property of a topic.
bool GetTopicPersistent(NT_Topic topic)
Gets the persistent property of a topic.
NT_Publisher PublishEx(NT_Topic topic, NT_Type type, std::string_view typeStr, const wpi::util::json &properties, const PubSubOptions &options=kDefaultPubSubOptions)
Creates a new publisher to a topic.
void SetTopicProperty(NT_Topic topic, std::string_view name, const wpi::util::json &value)
Sets a property value.
wpi::util::json GetTopicProperties(NT_Topic topic)
Gets all topic properties as a JSON object.
wpi::util::json GetTopicProperty(NT_Topic topic, std::string_view name)
Gets the current value of a property (as a JSON object).
void ReleaseEntry(NT_Entry entry)
Stops entry subscriber/publisher.
void SetTopicPersistent(NT_Topic topic, bool value)
Sets the persistent property of a topic.
void DeleteTopicProperty(NT_Topic topic, std::string_view name)
Deletes a property.
void Unsubscribe(NT_Subscriber sub)
Stops subscriber.
NT_Type GetTopicType(NT_Topic topic)
Gets the type for the specified topic, or unassigned if non existent.
NT_Subscriber Subscribe(NT_Topic topic, NT_Type type, std::string_view typeStr, const PubSubOptions &options=kDefaultPubSubOptions)
Creates a new subscriber to value changes on a topic.
std::vector< NT_Topic > GetTopics(NT_Inst inst, std::string_view prefix, unsigned int types)
Get Published Topics.
void Release(NT_Handle pubsubentry)
Stops entry/subscriber/publisher.
int64_t Now()
Returns monotonic current time in 1 us increments.
void SetNow(int64_t timestamp)
Sets the current timestamp used for timestamping values that do not provide a timestamp (e....
NT_Type GetTypeFromString(std::string_view typeString)
Turns a type string into a type enum value.
std::string_view GetStringFromType(NT_Type type)
Turns a type enum value into a type string.
Definition StringMap.hpp:773
void swap(wpi::util::StringMap< T > &lhs, wpi::util::StringMap< T > &rhs)
Definition StringMap.hpp:775
Definition DataLogReader.hpp:17
NetworkTables (ntcore) namespace.
Definition NTSendable.hpp:9
Definition raw_os_ostream.hpp:19
NetworkTables Connection Information.
Definition ntcore_cpp.hpp:118
std::string remote_id
The remote identifier (as set on the remote node by NetworkTableInstance::StartClient() or wpi::nt::S...
Definition ntcore_cpp.hpp:123
unsigned int remote_port
The port number of the remote node.
Definition ntcore_cpp.hpp:129
int64_t last_update
The last time any update was received from the remote node (same scale as returned by wpi::nt::Now())...
Definition ntcore_cpp.hpp:135
friend void swap(ConnectionInfo &first, ConnectionInfo &second)
Definition ntcore_cpp.hpp:143
std::string remote_ip
The IP address of the remote node.
Definition ntcore_cpp.hpp:126
unsigned int protocol_version
The protocol version being used for this connection.
Definition ntcore_cpp.hpp:141
static constexpr unsigned int kNone
Definition ntcore_cpp.hpp:54
static constexpr unsigned int kConnection
Any connection event (connect or disconnect).
Definition ntcore_cpp.hpp:66
static constexpr unsigned int kValueRemote
Topic value updated (via network).
Definition ntcore_cpp.hpp:76
static constexpr unsigned int kProperties
Topic properties changed.
Definition ntcore_cpp.hpp:72
static constexpr unsigned int kTopic
Any topic event (publish, unpublish, or properties changed).
Definition ntcore_cpp.hpp:74
static constexpr unsigned int kValueLocal
Topic value updated (local).
Definition ntcore_cpp.hpp:78
static constexpr unsigned int kPublish
New topic published.
Definition ntcore_cpp.hpp:68
static constexpr unsigned int kLogMessage
Log message.
Definition ntcore_cpp.hpp:82
static constexpr unsigned int kImmediate
Initial listener addition.
Definition ntcore_cpp.hpp:60
static constexpr unsigned int kTimeSync
Time synchronized with server.
Definition ntcore_cpp.hpp:84
static constexpr unsigned int kValueAll
Topic value updated (network or local).
Definition ntcore_cpp.hpp:80
static constexpr unsigned int kDisconnected
Client disconnected (on server, any client disconnected).
Definition ntcore_cpp.hpp:64
static constexpr unsigned int kUnpublish
Topic unpublished.
Definition ntcore_cpp.hpp:70
static constexpr unsigned int kConnected
Client connected (on server, any client connected).
Definition ntcore_cpp.hpp:62
NetworkTables publish/subscribe options.
Definition ntcore_cpp.hpp:303
bool hidden
For subscriptions, don't share the existence of the subscription with the network.
Definition ntcore_cpp.hpp:382
bool excludeSelf
For entries, don't queue (for ReadQueue) value updates for the entry's internal publisher.
Definition ntcore_cpp.hpp:374
static constexpr double kDefaultPeriodic
Default value of periodic.
Definition ntcore_cpp.hpp:307
unsigned int structSize
Structure size.
Definition ntcore_cpp.hpp:312
NT_Publisher excludePublisher
For subscriptions, if non-zero, value updates for ReadQueue() are not queued for this publisher.
Definition ntcore_cpp.hpp:334
bool prefixMatch
Perform prefix match on subscriber topic names.
Definition ntcore_cpp.hpp:356
bool topicsOnly
For subscriptions, don't ask for value changes (only topic announcements).
Definition ntcore_cpp.hpp:344
bool disableLocal
For subscriptions, if local value updates should not be queued for ReadQueue().
Definition ntcore_cpp.hpp:368
unsigned int pollStorage
Polling storage size for a subscription.
Definition ntcore_cpp.hpp:320
bool sendAll
Send all value changes over the network.
Definition ntcore_cpp.hpp:339
bool disableRemote
For subscriptions, if remote value updates should not be queued for ReadQueue().
Definition ntcore_cpp.hpp:362
bool keepDuplicates
Preserve duplicate value changes (rather than ignoring them).
Definition ntcore_cpp.hpp:349
double periodic
How frequently changes will be sent over the network, in seconds.
Definition ntcore_cpp.hpp:328
NetworkTables Topic Information.
Definition ntcore_cpp.hpp:88
wpi::util::json GetProperties() const
Get topic properties as a JSON object.
std::string name
Topic name.
Definition ntcore_cpp.hpp:93
NT_Topic topic
Topic handle.
Definition ntcore_cpp.hpp:90
std::string type_str
Topic type string.
Definition ntcore_cpp.hpp:99
NT_Type type
Topic type.
Definition ntcore_cpp.hpp:96
friend void swap(TopicInfo &first, TopicInfo &second)
Definition ntcore_cpp.hpp:107
std::string properties
Topic properties JSON string.
Definition ntcore_cpp.hpp:102