NetworkTableListenerPoller
- class ntcore.NetworkTableListenerPoller(*args, **kwargs)
Bases:
pybind11_object
Event polled listener. This queues events matching the specified mask. Code using the listener must periodically call ReadQueue() to read the events.
Overloaded function.
__init__(self: ntcore._ntcore.NetworkTableListenerPoller) -> None
__init__(self: ntcore._ntcore.NetworkTableListenerPoller, inst: ntcore._ntcore.NetworkTableInstance) -> None
Construct a listener poller.
- Parameters:
inst – Instance
- addConnectionListener(immediate_notify: bool) int
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_notify – notify listener of all existing connections
- Returns:
Listener handle
- addListener(*args, **kwargs)
Overloaded function.
addListener(self: ntcore._ntcore.NetworkTableListenerPoller, prefixes: List[str], mask: typing.SupportsInt) -> int
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 prefixes
mask – Bitmask of EventFlags values
- Returns:
Listener handle
addListener(self: ntcore._ntcore.NetworkTableListenerPoller, topic: ntcore._ntcore.Topic, mask: typing.SupportsInt) -> int
Start listening to changes to a particular topic. This creates a corresponding internal subscriber with the lifetime of the listener.
- Parameters:
topic – Topic
mask – Bitmask of EventFlags values
- Returns:
Listener handle
addListener(self: ntcore._ntcore.NetworkTableListenerPoller, subscriber: ntcore._ntcore.Subscriber, mask: typing.SupportsInt) -> int
Start listening to topic changes on a subscriber. This does NOT keep the subscriber active.
- Parameters:
subscriber – Subscriber
mask – Bitmask of EventFlags values
- Returns:
Listener handle
addListener(self: ntcore._ntcore.NetworkTableListenerPoller, subscriber: ntcore._ntcore.MultiSubscriber, mask: typing.SupportsInt) -> int
Start listening to topic changes on a subscriber. This does NOT keep the subscriber active.
- Parameters:
subscriber – Subscriber
mask – Bitmask of EventFlags values
- Returns:
Listener handle
addListener(self: ntcore._ntcore.NetworkTableListenerPoller, entry: ntcore._ntcore.NetworkTableEntry, mask: typing.SupportsInt) -> int
Start listening to topic changes on an entry.
- Parameters:
entry – Entry
mask – Bitmask of EventFlags values
- Returns:
Listener handle
- addLogger(minLevel: SupportsInt, maxLevel: SupportsInt) int
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 level
maxLevel – maximum log level
- Returns:
Listener handle
- addTimeSyncListener(immediate_notify: bool) int
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_notify – notify listener of current time synchronization value
- Returns:
Listener handle
- close() None
Destroys the poller
- getHandle() int
Gets the native handle.
- Returns:
Handle
- readQueue() list[ntcore._ntcore.Event]
Read events.
- Returns:
Events since the previous call to ReadQueue()
- removeListener(listener: SupportsInt) None
Remove a listener.
- Parameters:
listener – Listener handle