Topic
- class ntcore.Topic
Bases:
pybind11_object
NetworkTables Topic.
- deleteProperty(name: str) None
Deletes a property. Has no effect if the property does not exist.
- Parameters:
name – property name
- exists() bool
Determines if the topic is currently being published.
- Returns:
True if the topic exists, false otherwise.
- genericPublish(typeString: str, options: ntcore._ntcore.PubSubOptions = <ntcore._ntcore.PubSubOptions object at 0x7f7830b5b830>) ntcore._ntcore.GenericPublisher
Create a new publisher to the topic.
The publisher is only active as long as the returned object is not destroyed.
@note It is not possible to publish two different data types to the same topic. Conflicts between publishers are typically resolved by the server on a first-come, first-served basis. Any published values that do not match the topic’s data type are dropped (ignored). To determine if the data type matches, use the appropriate Topic functions.
- Parameters:
typeString – type string
options – publish options
- Returns:
publisher
- genericPublishEx(typeString: str, properties: json, options: ntcore._ntcore.PubSubOptions = <ntcore._ntcore.PubSubOptions object at 0x7f7830b801b0>) ntcore._ntcore.GenericPublisher
Create a new publisher to the topic, with type string and initial properties.
The publisher is only active as long as the returned object is not destroyed.
@note It is not possible to publish two different data types to the same topic. Conflicts between publishers are typically resolved by the server on a first-come, first-served basis. Any published values that do not match the topic’s data type are dropped (ignored). To determine if the data type matches, use the appropriate Topic functions.
- Parameters:
typeString – type string
properties – JSON properties
options – publish options
- Returns:
publisher
- genericSubscribe(*args, **kwargs)
Overloaded function.
genericSubscribe(self: ntcore._ntcore.Topic, options: ntcore._ntcore.PubSubOptions = <ntcore._ntcore.PubSubOptions object at 0x7f7830b69ab0>) -> ntcore._ntcore.GenericSubscriber
Create a new subscriber to the topic.
The subscriber is only active as long as the returned object is not destroyed.
- Parameters:
options – subscribe options
- Returns:
subscriber
genericSubscribe(self: ntcore._ntcore.Topic, typeString: str, options: ntcore._ntcore.PubSubOptions = <ntcore._ntcore.PubSubOptions object at 0x7f7830b65370>) -> ntcore._ntcore.GenericSubscriber
Create a new subscriber to the topic.
The subscriber is only active as long as the returned object is not destroyed.
@note Subscribers that do not match the published data type do not return any values. To determine if the data type matches, use the appropriate Topic functions.
- Parameters:
typeString – type string
options – subscribe options
- Returns:
subscriber
- getGenericEntry(*args, **kwargs)
Overloaded function.
getGenericEntry(self: ntcore._ntcore.Topic, options: ntcore._ntcore.PubSubOptions = <ntcore._ntcore.PubSubOptions object at 0x7f7830b71070>) -> ntcore._ntcore.GenericEntry
Create a new generic entry for the topic.
Entries act as a combination of a subscriber and a weak publisher. The subscriber is active as long as the entry is not destroyed. The publisher is created when the entry is first written to, and remains active until either Unpublish() is called or the entry is destroyed.
@note It is not possible to use two different data types with the same topic. Conflicts between publishers are typically resolved by the server on a first-come, first-served basis. Any published values that do not match the topic’s data type are dropped (ignored), and the entry will show no new values if the data type does not match. To determine if the data type matches, use the appropriate Topic functions.
- Parameters:
options – publish and/or subscribe options
- Returns:
entry
getGenericEntry(self: ntcore._ntcore.Topic, typeString: str, options: ntcore._ntcore.PubSubOptions = <ntcore._ntcore.PubSubOptions object at 0x7f7830b721f0>) -> ntcore._ntcore.GenericEntry
Create a new generic entry for the topic.
Entries act as a combination of a subscriber and a weak publisher. The subscriber is active as long as the entry is not destroyed. The publisher is created when the entry is first written to, and remains active until either Unpublish() is called or the entry is destroyed.
@note It is not possible to use two different data types with the same topic. Conflicts between publishers are typically resolved by the server on a first-come, first-served basis. Any published values that do not match the topic’s data type are dropped (ignored), and the entry will show no new values if the data type does not match. To determine if the data type matches, use the appropriate Topic functions.
- Parameters:
typeString – type string
options – publish and/or subscribe options
- Returns:
entry
- getInfo() ntcore._ntcore.TopicInfo
Gets combined information about the topic.
- Returns:
Topic information
- getInstance() ntcore._ntcore.NetworkTableInstance
Gets the instance for the topic.
- Returns:
Instance
- getName() str
Gets the name of the topic.
- Returns:
the topic’s name
- getProperties() json
Gets all topic properties as a JSON object. Each key in the object is the property name, and the corresponding value is the property value.
- Returns:
JSON object
- getProperty(name: str) json
Gets the current value of a property (as a JSON object).
- Parameters:
name – property name
- Returns:
JSON object; null object if the property does not exist.
- getType() ntcore._ntcore.NetworkTableType
Gets the type of the topic.
- Returns:
the topic’s type
- getTypeString() str
Gets the type string of the topic. This may have more information than the numeric type (especially for raw values).
- Returns:
the topic’s type
- isPersistent() bool
Returns whether the value is persistent through server restarts.
- Returns:
True if the value is persistent.
- isRetained() bool
Returns whether the topic is retained by server when there are no publishers.
- Returns:
True if the topic is retained.
- setPersistent(persistent: bool) None
Make value persistent through server restarts.
- Parameters:
persistent – True for persistent, false for not persistent.
- setProperties(properties: json) bool
Updates multiple topic properties. Each key in the passed-in object is the name of the property to add/update, and the corresponding value is the property value to set for that property. Null values result in deletion of the corresponding property.
- Parameters:
properties – JSON object with keys to add/update/delete
- Returns:
False if properties is not an object
- setProperty(name: str, value: json) None
Sets a property value.
- Parameters:
name – property name
value – property value
- setRetained(retained: bool) None
Make the server retain the topic even when there are no publishers.
- Parameters:
retained – True for retained, false for not retained.