RobotCore 1.0
WPILib port to raspberry Pi
Loading...
Searching...
No Matches
org.wpilib.tunable.TunableRegistry Class Reference

Classes

interface  TypeHandler

Static Public Member Functions

static void setReportWarning (Consumer< String > func)
static Consumer< String > getReportWarning ()
static void reportWarning (String msg)
static< T > void registerTypeHandler (Class< T > cls, TypeHandler< T > handler)
static void registerBackend (String prefix, TunableBackend backend)
static< T > TypeHandler< T > getTypeHandler (T value)
static TunableBackend getBackend (String path)
static long getTuneRevision (TunableBase tunable)
static long getTuneRevision (ComplexTunable tunable)
static void recordTuneApplied (TunableBase tunable)
static void resetChangedAfterUpdate (TunableBase tunable)
static void runAfterUpdate (Runnable callback)
static void updateComplexIfNeeded (ComplexTunable tunable)
static TunableTable getTable (String path)
static void publishComplexChildren (String path, ComplexTunable tunable)
static boolean publish (String path, TunableBase tunable)
static boolean publish (String path, ComplexTunable tunable)
static void remove (String path)
static void remove (ComplexTunable tunable)
static void update ()
static void withUpdateMutex (Runnable func)
static void reset ()

Detailed Description

Global registry for tunable handlers and tunable backends.

Definition at line 26 of file TunableRegistry.java.

Member Function Documentation

◆ getBackend()

TunableBackend org.wpilib.tunable.TunableRegistry.getBackend ( String path)
static

Gets the backend for creating a tunable. Should generally only be used internally or by custom backends.

Parameters
pathfull name
Returns
tunable backend, or a no-op backend if no match

Definition at line 429 of file TunableRegistry.java.

◆ getReportWarning()

Consumer< String > org.wpilib.tunable.TunableRegistry.getReportWarning ( )
static

Get function used for reporting warning messages.

Returns
reporting function

Definition at line 239 of file TunableRegistry.java.

◆ getTable()

TunableTable org.wpilib.tunable.TunableRegistry.getTable ( String path)
static

Get a tunable table for a particular name.

Parameters
pathfull name
Returns
tunable table

Definition at line 616 of file TunableRegistry.java.

◆ getTuneRevision() [1/2]

long org.wpilib.tunable.TunableRegistry.getTuneRevision ( ComplexTunable tunable)
static

Returns a complex tunable's current tuning revision token.

This is the same token returned for the underlying registry record, and it also advances when a backend successfully applies tuning input to a descendant child tunable.

Parameters
tunablecomplex tunable
Returns
current tuning revision token

Definition at line 509 of file TunableRegistry.java.

◆ getTuneRevision() [2/2]

long org.wpilib.tunable.TunableRegistry.getTuneRevision ( TunableBase tunable)
static

Returns a tunable's current tuning revision token.

The token starts at zero and changes once for each tuning input that a backend successfully applies to this tunable or one of its descendant tunables. Direct local set() calls, in-place mutations, and getter refreshes do not change it. Reading the token does not consume or reset it, so independent observers can each store a previous token and compare it to the current value with !=.

Treat this as a 64-bit equality token. Do not rely on ordering or sign. This getter follows the same threading model as the rest of the tunable API and does not make tunable access thread-safe.

Parameters
tunabletunable
Returns
current tuning revision token

Definition at line 494 of file TunableRegistry.java.

◆ getTypeHandler()

static< T > TypeHandler< T > org.wpilib.tunable.TunableRegistry.getTypeHandler ( T value)
static

Gets the handler for logging an object. Should generally only be used by Tunable.

Parameters
<T>class
valuevalue
Returns
handler or null if no match

Definition at line 409 of file TunableRegistry.java.

◆ publish() [1/2]

boolean org.wpilib.tunable.TunableRegistry.publish ( String path,
ComplexTunable tunable )
static

Publishes a complex tunable.

Parameters
pathnormalized path
tunablethe tunable
Returns
true if the backend accepted the tunable

Definition at line 672 of file TunableRegistry.java.

◆ publish() [2/2]

boolean org.wpilib.tunable.TunableRegistry.publish ( String path,
TunableBase tunable )
static

Publishes a tunable.

Parameters
pathnormalized path
tunablethe tunable
Returns
true if the backend accepted the tunable

Definition at line 640 of file TunableRegistry.java.

◆ publishComplexChildren()

void org.wpilib.tunable.TunableRegistry.publishComplexChildren ( String path,
ComplexTunable tunable )
static

Publishes a complex tunable's children.

This should generally only be used by TunableBackend implementations after they publish the complex parent entry.

Parameters
pathnormalized path
tunablethe tunable

Definition at line 629 of file TunableRegistry.java.

◆ recordTuneApplied()

void org.wpilib.tunable.TunableRegistry.recordTuneApplied ( TunableBase tunable)
static

Records that a backend successfully applied one tuning input to a tunable.

TunableBackend implementations should call this exactly once after each accepted remote tuning input has been applied to the tunable value, before scheduling any corresponding onTune callback. Rejected inputs and writes ignored due to immutability should not call this method.

Parameters
tunabletuned tunable

Definition at line 525 of file TunableRegistry.java.

◆ registerBackend()

void org.wpilib.tunable.TunableRegistry.registerBackend ( String prefix,
TunableBackend backend )
static

Registers a backend for creating tunables. When calling getBackend(), the longest prefix match is used.

Parameters
prefixprefix for tunables covered by this backend
backendbackend

Definition at line 299 of file TunableRegistry.java.

◆ registerTypeHandler()

static< T > void org.wpilib.tunable.TunableRegistry.registerTypeHandler ( Class< T > cls,
TypeHandler< T > handler )
static

Registers a handler for tuning objects of a particular type. The handler should populate the provided TunableTable name as appropriate for the object's data.

Parameters
<T>class
clsclass object
handlerhandler (accepts TunableTable, entry name, and object)

Definition at line 264 of file TunableRegistry.java.

◆ remove() [1/2]

void org.wpilib.tunable.TunableRegistry.remove ( ComplexTunable tunable)
static

Removes every tracked publication for a complex tunable.

Parameters
tunablecomplex tunable to remove

Definition at line 781 of file TunableRegistry.java.

◆ remove() [2/2]

void org.wpilib.tunable.TunableRegistry.remove ( String path)
static

Removes a tunable.

Parameters
pathnormalized path

Definition at line 763 of file TunableRegistry.java.

◆ reportWarning()

void org.wpilib.tunable.TunableRegistry.reportWarning ( String msg)
static

Report a warning message (e.g. type mismatch).

Parameters
msgwarning message

Definition at line 250 of file TunableRegistry.java.

◆ reset()

void org.wpilib.tunable.TunableRegistry.reset ( )
static

Clear all registered types and backends and closes all entries. Should typically only be used by unit test code.

Definition at line 821 of file TunableRegistry.java.

◆ resetChangedAfterUpdate()

void org.wpilib.tunable.TunableRegistry.resetChangedAfterUpdate ( TunableBase tunable)
static

Resets a tunable's changed flag after the current update cycle finishes.

Backends should call this after publishing a changed tunable so every alias in every backend can observe the shared changed flag before it is cleared.

Parameters
tunabletunable to reset

Definition at line 539 of file TunableRegistry.java.

◆ runAfterUpdate()

void org.wpilib.tunable.TunableRegistry.runAfterUpdate ( Runnable callback)
static

Runs a callback after the current update cycle finishes resetting changed flags.

Backends should use this for callbacks that react to tuned values so callback mutations are observed as new changes in the next update cycle.

Parameters
callbackcallback to run; must not throw

Definition at line 557 of file TunableRegistry.java.

◆ setReportWarning()

void org.wpilib.tunable.TunableRegistry.setReportWarning ( Consumer< String > func)
static

Set function used for reporting warning messages (e.g. type mismatches).

The reporting function must not throw.

Parameters
funcreporting function; pass null to use default

Definition at line 224 of file TunableRegistry.java.

◆ update()

void org.wpilib.tunable.TunableRegistry.update ( )
static

Updates all tunable values from backends.

Definition at line 788 of file TunableRegistry.java.

◆ updateComplexIfNeeded()

void org.wpilib.tunable.TunableRegistry.updateComplexIfNeeded ( ComplexTunable tunable)
static

Updates a complex tunable if it has not already been updated during the current registry update.

This should generally only be used by TunableBackend implementations.

Parameters
tunabletunable to update

Definition at line 575 of file TunableRegistry.java.

◆ withUpdateMutex()

void org.wpilib.tunable.TunableRegistry.withUpdateMutex ( Runnable func)
static

Execute a function while holding the same mutex used for update(). As tunables are not thread-safe, this is designed to allow external synchronization for tunables used in secondary threads outside of the robot main loop.

Every competing access, including main-loop access, must use this method or another safe handoff. The update mutex is held while backends and user callbacks run, so the function should be short and must not allow a mutable tunable value to escape and be accessed after the function completes.

Parameters
funcfunction to execute

Definition at line 810 of file TunableRegistry.java.


The documentation for this class was generated from the following file: