GenericSubscriber

class ntcore.GenericSubscriber

Bases: Subscriber

NetworkTables generic subscriber.

get() ntcore._ntcore.Value

Get the last published value. If no value has been published, returns a value with unassigned type.

Returns:

value

get_boolean(default_value: bool) bool

Gets the entry’s value as a boolean. If the entry does not exist or is of different type, it will return the default value.

Parameters:

default_value – the value to be returned if no value is found

Returns:

the entry’s value or the given default value

get_boolean_array(default_value: List[SupportsInt | SupportsIndex]) list[int]

Gets the entry’s value as a boolean array. If the entry does not exist or is of different type, it will return the default value.

Parameters:

default_value – the value to be returned if no value is found

Returns:

the entry’s value or the given default value

Note

This makes a copy of the array. If the overhead of this is a concern, use GetValue() instead.

Note

The returned array is std::vector<int> instead of std::vector<bool> because std::vector<bool> is special-cased in C++. 0 is false, any non-zero value is true.

get_double(default_value: SupportsFloat | SupportsIndex) float

Gets the entry’s value as a double. If the entry does not exist or is of different type, it will return the default value.

Parameters:

default_value – the value to be returned if no value is found

Returns:

the entry’s value or the given default value

get_double_array(default_value: List[SupportsFloat | SupportsIndex]) list[float]

Gets the entry’s value as a double array. If the entry does not exist or is of different type, it will return the default value.

Parameters:

default_value – the value to be returned if no value is found

Returns:

the entry’s value or the given default value

Note

This makes a copy of the array. If the overhead of this is a concern, use GetValue() instead.

get_float(default_value: SupportsFloat | SupportsIndex) float

Gets the entry’s value as a float. If the entry does not exist or is of different type, it will return the default value.

Parameters:

default_value – the value to be returned if no value is found

Returns:

the entry’s value or the given default value

get_float_array(default_value: List[SupportsFloat | SupportsIndex]) list[float]

Gets the entry’s value as a float array. If the entry does not exist or is of different type, it will return the default value.

Parameters:

default_value – the value to be returned if no value is found

Returns:

the entry’s value or the given default value

Note

This makes a copy of the array. If the overhead of this is a concern, use GetValue() instead.

get_integer(default_value: SupportsInt | SupportsIndex) int

Gets the entry’s value as a integer. If the entry does not exist or is of different type, it will return the default value.

Parameters:

default_value – the value to be returned if no value is found

Returns:

the entry’s value or the given default value

get_integer_array(default_value: List[SupportsInt | SupportsIndex]) list[int]

Gets the entry’s value as a integer array. If the entry does not exist or is of different type, it will return the default value.

Parameters:

default_value – the value to be returned if no value is found

Returns:

the entry’s value or the given default value

Note

This makes a copy of the array. If the overhead of this is a concern, use GetValue() instead.

get_raw(default_value: Buffer) bytes

Gets the entry’s value as a raw. If the entry does not exist or is of different type, it will return the default value.

Parameters:

default_value – the value to be returned if no value is found

Returns:

the entry’s value or the given default value

get_string(default_value: str) str

Gets the entry’s value as a string. If the entry does not exist or is of different type, it will return the default value.

Parameters:

default_value – the value to be returned if no value is found

Returns:

the entry’s value or the given default value

get_string_array(default_value: List[str]) list[str]

Gets the entry’s value as a string array. If the entry does not exist or is of different type, it will return the default value.

Parameters:

default_value – the value to be returned if no value is found

Returns:

the entry’s value or the given default value

Note

This makes a copy of the array. If the overhead of this is a concern, use GetValue() instead.

get_topic() ntcore._ntcore.Topic

Get the corresponding topic.

Returns:

Topic

read_queue() list[ntcore._ntcore.Value]

Get an array of all value changes since the last call to ReadQueue. Also provides a timestamp for each value.

Note

The “poll storage” subscribe option can be used to set the queue depth.

Returns:

Array of timestamped values; empty array if no new changes have been published since the previous call.