Package edu.wpi.first.networktables
Class NetworkTableListenerPoller
java.lang.Object
edu.wpi.first.networktables.NetworkTableListenerPoller
- All Implemented Interfaces:
AutoCloseable
Event listener poller. This queues events matching the specified mask. Code using the listener
must periodically call readQueue() to read the events.
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a topic listener poller. -
Method Summary
Modifier and TypeMethodDescriptionintaddConnectionListener(boolean immediateNotify) Add a connection listener.intaddListener(MultiSubscriber subscriber, EnumSet<NetworkTableEvent.Kind> eventKinds) Start listening to topic changes on a subscriber.intaddListener(NetworkTableEntry entry, EnumSet<NetworkTableEvent.Kind> eventKinds) Start listening to topic changes on an entry.intaddListener(Subscriber subscriber, EnumSet<NetworkTableEvent.Kind> eventKinds) Start listening to topic changes on a subscriber.intaddListener(Topic topic, EnumSet<NetworkTableEvent.Kind> eventKinds) Start listening to changes to a particular topic.intaddListener(String[] prefixes, EnumSet<NetworkTableEvent.Kind> eventKinds) Start listening to topic changes for topics with names that start with any of the given prefixes.intaddLogger(int minLevel, int maxLevel) Add logger callback function.intaddTimeSyncListener(boolean immediateNotify) Add a time synchronization listener.voidclose()intGets the native handle.booleanisValid()Determines if the native handle is valid.Read topic notifications.voidremoveListener(int listener) Remove a listener.
-
Constructor Details
-
NetworkTableListenerPoller
Construct a topic listener poller.- Parameters:
inst- Instance
-
-
Method Details
-
addListener
Start listening to topic changes for topics with names that start with any of the given prefixes. This creates a corresponding internal subscriber with the lifetime of the listener.- Parameters:
prefixes- Topic name string prefixeseventKinds- set of event kinds to listen to- Returns:
- Listener handle
-
addListener
Start listening to changes to a particular topic. This creates a corresponding internal subscriber with the lifetime of the listener.- Parameters:
topic- TopiceventKinds- set of event kinds to listen to- Returns:
- Listener handle
-
addListener
Start listening to topic changes on a subscriber. This does NOT keep the subscriber active.- Parameters:
subscriber- SubscribereventKinds- set of event kinds to listen to- Returns:
- Listener handle
-
addListener
Start listening to topic changes on a subscriber. This does NOT keep the subscriber active.- Parameters:
subscriber- SubscribereventKinds- set of event kinds to listen to- Returns:
- Listener handle
-
addListener
Start listening to topic changes on an entry.- Parameters:
entry- EntryeventKinds- set of event kinds to listen to- Returns:
- Listener handle
-
addConnectionListener
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:
immediateNotify- notify listener of all existing connections- Returns:
- Listener handle
-
addTimeSyncListener
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:
immediateNotify- notify listener of current time synchronization value- Returns:
- Listener handle
-
addLogger
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:
minLevel- minimum log levelmaxLevel- maximum log level- Returns:
- Listener handle
-
removeListener
Remove a listener.- Parameters:
listener- Listener handle
-
readQueue
Read topic notifications.- Returns:
- Topic notifications since the previous call to readQueue()
-
close
- Specified by:
closein interfaceAutoCloseable
-
isValid
Determines if the native handle is valid.- Returns:
- True if the native handle is valid, false otherwise.
-
getHandle
Gets the native handle.- Returns:
- Handle
-