264 bool Is(
unsigned int kind)
const {
return (
flags & kind) != 0; }
272 return std::get_if<ConnectionInfo>(&
data);
275 return std::get_if<ConnectionInfo>(&
data);
279 return std::get_if<TopicInfo>(&
data);
284 return std::get_if<ValueEventData>(&
data);
287 return std::get_if<ValueEventData>(&
data);
291 return std::get_if<LogMessage>(&
data);
296 return std::get_if<TimeSyncEventData>(&
data);
299 return std::get_if<TimeSyncEventData>(&
data);
566 std::span<const std::string_view> types);
599 std::span<const std::string_view> types);
843 NT_Inst inst, std::span<const std::string_view> prefixes,
923 std::span<const std::string_view> prefixes,
959 std::span<const std::string_view> prefixes,
1025 const char* listen_address,
unsigned int port3,
1026 unsigned int port4);
1078 std::span<
const std::pair<std::string_view, unsigned int>> servers);
1300 unsigned int max_level);
1380 std::span<const uint8_t>
data);
1389 std::span<const uint8_t>
data);
1398 std::span<const uint8_t>
data);
1407 std::span<const uint8_t>
data);
NetworkTables event.
Definition: ntcore_cpp.h:216
Event(NT_Listener listener, unsigned int flags, ValueEventData data)
Definition: ntcore_cpp.h:223
Event(NT_Listener listener, unsigned int flags, ConnectionInfo info)
Definition: ntcore_cpp.h:219
const LogMessage * GetLogMessage() const
Definition: ntcore_cpp.h:290
const TimeSyncEventData * GetTimeSyncEventData() const
Definition: ntcore_cpp.h:295
Event(NT_Listener listener, unsigned int flags, int64_t serverTimeOffset, int64_t rtt2, bool valid)
Definition: ntcore_cpp.h:237
TopicInfo * GetTopicInfo()
Definition: ntcore_cpp.h:281
ValueEventData * GetValueEventData()
Definition: ntcore_cpp.h:286
const ValueEventData * GetValueEventData() const
Definition: ntcore_cpp.h:283
LogMessage * GetLogMessage()
Definition: ntcore_cpp.h:293
Event(NT_Listener listener, unsigned int flags, unsigned int level, std::string_view filename, unsigned int line, std::string_view message)
Definition: ntcore_cpp.h:232
std::variant< ConnectionInfo, TopicInfo, ValueEventData, LogMessage, TimeSyncEventData > data
Event data; content depends on flags.
Definition: ntcore_cpp.h:269
bool Is(unsigned int kind) const
Test event flags.
Definition: ntcore_cpp.h:264
Event(NT_Listener listener, unsigned int flags, NT_Topic topic, NT_Handle subentry, Value value)
Definition: ntcore_cpp.h:227
unsigned int flags
Event flags (NT_EventFlags).
Definition: ntcore_cpp.h:256
const ConnectionInfo * GetConnectionInfo() const
Definition: ntcore_cpp.h:271
ConnectionInfo * GetConnectionInfo()
Definition: ntcore_cpp.h:274
Event(NT_Listener listener, unsigned int flags, TopicInfo info)
Definition: ntcore_cpp.h:221
NT_Listener listener
Listener that triggered this event.
Definition: ntcore_cpp.h:244
TimeSyncEventData * GetTimeSyncEventData()
Definition: ntcore_cpp.h:298
Event(NT_Listener listener, unsigned int flags, LogMessage msg)
Definition: ntcore_cpp.h:225
const TopicInfo * GetTopicInfo() const
Definition: ntcore_cpp.h:278
NetworkTables log message.
Definition: ntcore_cpp.h:172
unsigned int line
The line number in the source file that generated the message.
Definition: ntcore_cpp.h:186
LogMessage(unsigned int level, std::string_view filename, unsigned int line, std::string_view message)
Definition: ntcore_cpp.h:175
unsigned int level
Log level of the message.
Definition: ntcore_cpp.h:180
std::string message
The message.
Definition: ntcore_cpp.h:189
std::string filename
The filename of the source file that generated the message.
Definition: ntcore_cpp.h:183
NetworkTables time sync event data.
Definition: ntcore_cpp.h:193
int64_t rtt2
Measured round trip time divided by 2, in microseconds.
Definition: ntcore_cpp.h:206
TimeSyncEventData()=default
int64_t serverTimeOffset
Offset between local time and server time, in microseconds.
Definition: ntcore_cpp.h:203
bool valid
If serverTimeOffset and RTT are valid.
Definition: ntcore_cpp.h:212
TimeSyncEventData(int64_t serverTimeOffset, int64_t rtt2, bool valid)
Definition: ntcore_cpp.h:196
NetworkTables Value Event Data.
Definition: ntcore_cpp.h:155
NT_Handle subentry
Subscriber/entry handle.
Definition: ntcore_cpp.h:165
ValueEventData(NT_Topic topic, NT_Handle subentry, Value value)
Definition: ntcore_cpp.h:158
NT_Topic topic
Topic handle.
Definition: ntcore_cpp.h:162
Value value
The new value.
Definition: ntcore_cpp.h:168
A network table entry value.
Definition: NetworkTableValue.h:27
a class to store JSON values
Definition: json.h:2655
A data log.
Definition: DataLog.h:66
basic_string_view< char > string_view
Definition: core.h:520
type
Definition: core.h:575
dimensionless::scalar_t log(const ScalarUnit x) noexcept
Compute natural logarithm.
Definition: math.h:349
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.
void UnsubscribeMultiple(NT_MultiSubscriber sub)
Unsubscribes a multi-subscriber.
NT_Handle NT_Topic
Definition: ntcore_c.h:38
NT_Handle NT_ConnectionDataLogger
Definition: ntcore_c.h:31
NT_Handle NT_Listener
Definition: ntcore_c.h:35
NT_Handle NT_Subscriber
Definition: ntcore_c.h:39
unsigned int NT_Handle
Definition: ntcore_c.h:30
NT_Type
NetworkTables data types.
Definition: ntcore_c.h:49
NT_Handle NT_Inst
Definition: ntcore_c.h:34
NT_Handle NT_Publisher
Definition: ntcore_c.h:40
NT_Handle NT_ListenerPoller
Definition: ntcore_c.h:36
NT_Handle NT_MultiSubscriber
Definition: ntcore_c.h:37
NT_Handle NT_Entry
Definition: ntcore_c.h:33
NT_Handle NT_DataLogger
Definition: ntcore_c.h:32
@ NT_UNASSIGNED
Definition: ntcore_c.h:50
@ NT_EVENT_LOGMESSAGE
Log message.
Definition: ntcore_c.h:117
@ NT_EVENT_NONE
Definition: ntcore_c.h:93
@ NT_EVENT_UNPUBLISH
Topic unpublished.
Definition: ntcore_c.h:105
@ NT_EVENT_PROPERTIES
Topic properties changed.
Definition: ntcore_c.h:107
@ NT_EVENT_CONNECTED
Client connected (on server, any client connected).
Definition: ntcore_c.h:97
@ NT_EVENT_TIMESYNC
Time synchronized with server.
Definition: ntcore_c.h:119
@ NT_EVENT_VALUE_REMOTE
Topic value updated (via network).
Definition: ntcore_c.h:111
@ NT_EVENT_PUBLISH
New topic published.
Definition: ntcore_c.h:103
@ NT_EVENT_DISCONNECTED
Client disconnected (on server, any client disconnected).
Definition: ntcore_c.h:99
@ NT_EVENT_IMMEDIATE
Initial listener addition.
Definition: ntcore_c.h:95
@ NT_EVENT_VALUE_LOCAL
Topic value updated (local).
Definition: ntcore_c.h:113
constexpr PubSubOptions kDefaultPubSubOptions
Default publish/subscribe options.
Definition: ntcore_cpp.h:381
NT_ConnectionDataLogger StartConnectionDataLog(NT_Inst inst, wpi::log::DataLog &log, std::string_view name)
Starts logging connection changes to a DataLog.
void StopConnectionDataLog(NT_ConnectionDataLogger logger)
Stops 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.
void StopEntryDataLog(NT_DataLogger logger)
Stops logging entry changes to a DataLog.
NT_Inst GetInstanceFromHandle(NT_Handle handle)
Get instance handle from another handle.
void ResetInstance(NT_Inst inst)
Reset the internals of an instance.
NT_Inst CreateInstance()
Create an instance.
NT_Inst GetDefaultInstance()
Get default instance.
void DestroyInstance(NT_Inst inst)
Destroy an instance.
std::function< void(const Event &)> ListenerCallback
Definition: ntcore_cpp.h:860
NT_Listener AddPolledListener(NT_ListenerPoller poller, std::span< const std::string_view > prefixes, unsigned int mask)
Creates a polled listener.
NT_ListenerPoller CreateListenerPoller(NT_Inst inst)
Creates a listener poller.
bool WaitForListenerQueue(NT_Handle handle, double timeout)
Wait for the listener queue to be empty.
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.
void DestroyListenerPoller(NT_ListenerPoller poller)
Destroys a listener poller.
void RemoveListener(NT_Listener listener)
Removes a listener.
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.
void StartClient4(NT_Inst inst, std::string_view identity)
Starts a NT4 client.
void Disconnect(NT_Inst inst)
Disconnects the client if it's running and connected.
std::optional< int64_t > GetServerTimeOffset(NT_Inst inst)
Get the time offset between server time and local time.
unsigned int GetNetworkMode(NT_Inst inst)
Get the current network mode.
void StopLocal(NT_Inst inst)
Stops local-only operation.
void StopDSClient(NT_Inst inst)
Stops requesting server address from Driver Station.
bool IsConnected(NT_Inst inst)
Return whether or not the instance is connected to another node.
void StopServer(NT_Inst inst)
Stops the server if it is running.
void StartLocal(NT_Inst inst)
Starts local-only operation.
void Flush(NT_Inst inst)
Flush to network.
void SetServer(NT_Inst inst, const char *server_name, unsigned int port)
Sets server address and port for client (without restarting client).
void StartClient3(NT_Inst inst, std::string_view identity)
Starts a NT3 client.
void StartDSClient(NT_Inst inst, unsigned int port)
Starts requesting server address from Driver Station.
void StopClient(NT_Inst inst)
Stops the client if it is running.
void SetServerTeam(NT_Inst inst, unsigned int team, unsigned int port)
Sets server addresses and port for client (without restarting client).
void StartServer(NT_Inst inst, std::string_view persist_filename, const char *listen_address, unsigned int port3, unsigned int port4)
Starts a server using the specified filename, listening address, and port.
std::vector< ConnectionInfo > GetConnections(NT_Inst inst)
Get information on the currently established network connections.
void FlushLocal(NT_Inst inst)
Flush local updates.
NT_Type GetEntryType(NT_Entry entry)
Gets the type for the specified entry, or unassigned if non existent.
Value GetEntryValue(NT_Handle subentry)
Get Entry Value.
void SetEntryFlags(NT_Entry entry, unsigned int flags)
Set Entry Flags.
NT_Entry GetEntry(NT_Inst inst, std::string_view name)
Get Entry Handle.
int64_t GetEntryLastChange(NT_Handle subentry)
Gets the last time the entry was changed.
unsigned int GetEntryFlags(NT_Entry entry)
Get Entry Flags.
std::vector< Value > ReadQueueValue(NT_Handle subentry)
Read Entry Queue.
std::string GetEntryName(NT_Entry entry)
Gets the name of the specified entry.
bool SetEntryValue(NT_Entry entry, const Value &value)
Set Entry Value.
bool SetDefaultEntryValue(NT_Entry entry, const Value &value)
Set Default Entry Value.
NT_Topic GetTopicFromHandle(NT_Handle pubsubentry)
Gets the topic handle from an entry/subscriber/publisher handle.
void Unsubscribe(NT_Subscriber sub)
Stops subscriber.
void Release(NT_Handle pubsubentry)
Stops entry/subscriber/publisher.
bool GetTopicRetained(NT_Topic topic)
Gets the retained property of a topic.
bool GetTopicExists(NT_Handle handle)
Determine if topic exists (e.g.
wpi::json GetTopicProperties(NT_Topic topic)
Gets all topic properties as a JSON object.
NT_Type GetTopicType(NT_Topic topic)
Gets the type for the specified topic, or unassigned if non existent.
std::string GetTopicTypeString(NT_Topic topic)
Gets the type string for the specified topic, or empty string if non existent.
std::string GetTopicName(NT_Topic topic)
Gets the name of the specified topic.
NT_Topic GetTopic(NT_Inst inst, std::string_view name)
Gets Topic Handle.
void SetTopicProperty(NT_Topic topic, std::string_view name, const wpi::json &value)
Sets a property value.
NT_Publisher PublishEx(NT_Topic topic, NT_Type type, std::string_view typeStr, const wpi::json &properties, const PubSubOptions &options=kDefaultPubSubOptions)
Creates a new publisher to a topic.
void SetTopicRetained(NT_Topic topic, bool value)
Sets the retained property of a topic.
bool SetTopicProperties(NT_Topic topic, const wpi::json &update)
Updates multiple topic properties.
NT_Publisher Publish(NT_Topic topic, NT_Type type, std::string_view typeStr, const PubSubOptions &options=kDefaultPubSubOptions)
Creates a new publisher to a topic.
std::vector< NT_Topic > GetTopics(NT_Inst inst, std::string_view prefix, unsigned int types)
Get Published Topics.
std::vector< TopicInfo > GetTopicInfo(NT_Inst inst, std::string_view prefix, unsigned int types)
Get Topic Information about multiple topics.
void SetTopicPersistent(NT_Topic topic, bool value)
Sets the persistent property of a topic.
wpi::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 Unpublish(NT_Handle pubentry)
Stops publisher.
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.
void DeleteTopicProperty(NT_Topic topic, std::string_view name)
Deletes a property.
bool GetTopicPersistent(NT_Topic topic)
Gets the persistent property of a topic.
NT_Type GetTypeFromString(std::string_view typeString)
Turns a type string into a type enum value.
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....
std::string_view GetStringFromType(NT_Type type)
Turns a type enum value into a type string.
EIGEN_CONSTEXPR Index first(const T &x) EIGEN_NOEXCEPT
Definition: IndexedViewHelper.h:81
::uint64_t uint64_t
Definition: Meta.h:58
::uint16_t uint16_t
Definition: Meta.h:54
::int64_t int64_t
Definition: Meta.h:59
NetworkTables (ntcore) namespace.
Definition: ntcore_cpp.h:35
Definition: StdDeque.h:50
void swap(wpi::SmallVectorImpl< T > &LHS, wpi::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.
Definition: SmallVector.h:1299
Definition: ntcore_cpp.h:30
/file This file defines the SmallVector class.
Definition: AprilTagFieldLayout.h:18
flags
Definition: http_parser.h:206
Definition: format.h:1544
NetworkTables Connection Information.
Definition: ntcore_cpp.h:119
unsigned int protocol_version
The protocol version being used for this connection.
Definition: ntcore_cpp.h:142
unsigned int remote_port
The port number of the remote node.
Definition: ntcore_cpp.h:130
friend void swap(ConnectionInfo &first, ConnectionInfo &second)
Definition: ntcore_cpp.h:144
int64_t last_update
The last time any update was received from the remote node (same scale as returned by nt::Now()).
Definition: ntcore_cpp.h:136
std::string remote_id
The remote identifier (as set on the remote node by NetworkTableInstance::StartClient4() or nt::Start...
Definition: ntcore_cpp.h:124
std::string remote_ip
The IP address of the remote node.
Definition: ntcore_cpp.h:127
Event notification flags.
Definition: ntcore_cpp.h:52
static constexpr unsigned int kValueRemote
Topic value updated (via network).
Definition: ntcore_cpp.h:77
static constexpr unsigned int kValueAll
Topic value updated (network or local).
Definition: ntcore_cpp.h:81
static constexpr unsigned int kTopic
Any topic event (publish, unpublish, or properties changed).
Definition: ntcore_cpp.h:75
static constexpr unsigned int kNone
Definition: ntcore_cpp.h:55
static constexpr unsigned int kLogMessage
Log message.
Definition: ntcore_cpp.h:83
static constexpr unsigned int kUnpublish
Topic unpublished.
Definition: ntcore_cpp.h:71
static constexpr unsigned int kImmediate
Initial listener addition.
Definition: ntcore_cpp.h:61
static constexpr unsigned int kConnection
Any connection event (connect or disconnect).
Definition: ntcore_cpp.h:67
static constexpr unsigned int kTimeSync
Time synchronized with server.
Definition: ntcore_cpp.h:85
static constexpr unsigned int kPublish
New topic published.
Definition: ntcore_cpp.h:69
static constexpr unsigned int kProperties
Topic properties changed.
Definition: ntcore_cpp.h:73
static constexpr unsigned int kValueLocal
Topic value updated (local).
Definition: ntcore_cpp.h:79
static constexpr unsigned int kConnected
Client connected (on server, any client connected).
Definition: ntcore_cpp.h:63
static constexpr unsigned int kDisconnected
Client disconnected (on server, any client disconnected).
Definition: ntcore_cpp.h:65
NetworkTables publish/subscribe options.
Definition: ntcore_cpp.h:304
bool topicsOnly
For subscriptions, don't ask for value changes (only topic announcements).
Definition: ntcore_cpp.h:345
NT_Publisher excludePublisher
For subscriptions, if non-zero, value updates for ReadQueue() are not queued for this publisher.
Definition: ntcore_cpp.h:335
bool excludeSelf
For entries, don't queue (for ReadQueue) value updates for the entry's internal publisher.
Definition: ntcore_cpp.h:375
bool sendAll
Send all value changes over the network.
Definition: ntcore_cpp.h:340
static constexpr double kDefaultPeriodic
Default value of periodic.
Definition: ntcore_cpp.h:308
bool keepDuplicates
Preserve duplicate value changes (rather than ignoring them).
Definition: ntcore_cpp.h:350
bool disableLocal
For subscriptions, if local value updates should not be queued for ReadQueue().
Definition: ntcore_cpp.h:369
bool disableRemote
For subscriptions, if remote value updates should not be queued for ReadQueue().
Definition: ntcore_cpp.h:363
bool prefixMatch
Perform prefix match on subscriber topic names.
Definition: ntcore_cpp.h:357
unsigned int structSize
Structure size.
Definition: ntcore_cpp.h:313
double periodic
How frequently changes will be sent over the network, in seconds.
Definition: ntcore_cpp.h:329
unsigned int pollStorage
Polling storage size for a subscription.
Definition: ntcore_cpp.h:321
NetworkTables Topic Information.
Definition: ntcore_cpp.h:89
wpi::json GetProperties() const
Get topic properties as a JSON object.
std::string name
Topic name.
Definition: ntcore_cpp.h:94
NT_Topic topic
Topic handle.
Definition: ntcore_cpp.h:91
std::string type_str
Topic type string.
Definition: ntcore_cpp.h:100
std::string properties
Topic properties JSON string.
Definition: ntcore_cpp.h:103
friend void swap(TopicInfo &first, TopicInfo &second)
Definition: ntcore_cpp.h:108
NT_Type type
Topic type.
Definition: ntcore_cpp.h:97