Class SendableBuilderImpl
java.lang.Object
edu.wpi.first.wpilibj.smartdashboard.SendableBuilderImpl
- All Implemented Interfaces:
NTSendableBuilder
,SendableBuilder
,AutoCloseable
public class SendableBuilderImpl extends Object implements NTSendableBuilder
-
Nested Class Summary
Nested classes/interfaces inherited from interface edu.wpi.first.util.sendable.SendableBuilder
SendableBuilder.BackendKind
-
Constructor Summary
Constructors Constructor Description SendableBuilderImpl()
-
Method Summary
Modifier and Type Method Description void
addBooleanArrayProperty(String key, Supplier<boolean[]> getter, Consumer<boolean[]> setter)
Add a boolean array property.void
addBooleanProperty(String key, BooleanSupplier getter, BooleanConsumer setter)
Add a boolean property.void
addCloseable(AutoCloseable closeable)
Adds a closeable.void
addDoubleArrayProperty(String key, Supplier<double[]> getter, Consumer<double[]> setter)
Add a double array property.void
addDoubleProperty(String key, DoubleSupplier getter, DoubleConsumer setter)
Add a double property.void
addFloatArrayProperty(String key, Supplier<float[]> getter, Consumer<float[]> setter)
Add a float array property.void
addFloatProperty(String key, FloatSupplier getter, FloatConsumer setter)
Add a float property.void
addIntegerArrayProperty(String key, Supplier<long[]> getter, Consumer<long[]> setter)
Add an integer array property.void
addIntegerProperty(String key, LongSupplier getter, LongConsumer setter)
Add an integer property.void
addRawProperty(String key, String typeString, Supplier<byte[]> getter, Consumer<byte[]> setter)
Add a raw property.void
addStringArrayProperty(String key, Supplier<String[]> getter, Consumer<String[]> setter)
Add a string array property.void
addStringProperty(String key, Supplier<String> getter, Consumer<String> setter)
Add a string property.void
clearProperties()
Clear properties.void
close()
NetworkTable
getTable()
Get the network table.Topic
getTopic(String key)
Add a property without getters or setters.boolean
isActuator()
Return whether this sendable should be treated as an actuator.boolean
isPublished()
Return whether this sendable has an associated table.void
setActuator(boolean value)
Set a flag indicating if this sendable should be treated as an actuator.void
setSafeState(Runnable func)
Set the function that should be called to set the Sendable into a safe state.void
setSmartDashboardType(String type)
Set the string representation of the named data type that will be used by the smart dashboard for this sendable.void
setTable(NetworkTable table)
Set the network table.void
setUpdateTable(Runnable func)
Set the function that should be called to update the network table for things other than properties.void
startListeners()
Hook setters for all properties.void
startLiveWindowMode()
Start LiveWindow mode by hooking the setters for all properties.void
stopListeners()
Unhook setters for all properties.void
stopLiveWindowMode()
Stop LiveWindow mode by unhooking the setters for all properties.void
update()
Update the network table values by calling the getters for all properties.
-
Constructor Details
-
SendableBuilderImpl
public SendableBuilderImpl()
-
-
Method Details
-
close
- Specified by:
close
in interfaceAutoCloseable
-
setTable
Set the network table. Must be called prior to any Add* functions being called.- Parameters:
table
- Network table
-
getTable
Get the network table.- Specified by:
getTable
in interfaceNTSendableBuilder
- Returns:
- The network table
-
isPublished
Return whether this sendable has an associated table.- Specified by:
isPublished
in interfaceSendableBuilder
- Returns:
- True if it has a table, false if not.
-
isActuator
Return whether this sendable should be treated as an actuator.- Returns:
- True if actuator, false if not.
-
update
Update the network table values by calling the getters for all properties.- Specified by:
update
in interfaceSendableBuilder
-
startListeners
Hook setters for all properties. -
stopListeners
Unhook setters for all properties. -
startLiveWindowMode
Start LiveWindow mode by hooking the setters for all properties. Also calls the safeState function if one was provided. -
stopLiveWindowMode
Stop LiveWindow mode by unhooking the setters for all properties. Also calls the safeState function if one was provided. -
clearProperties
Clear properties.- Specified by:
clearProperties
in interfaceSendableBuilder
-
addCloseable
Description copied from interface:SendableBuilder
Adds a closeable. The closeable.close() will be called when close() is called.- Specified by:
addCloseable
in interfaceSendableBuilder
- Parameters:
closeable
- closeable object
-
setSmartDashboardType
Set the string representation of the named data type that will be used by the smart dashboard for this sendable.- Specified by:
setSmartDashboardType
in interfaceSendableBuilder
- Parameters:
type
- data type
-
setActuator
Set a flag indicating if this sendable should be treated as an actuator. By default, this flag is false.- Specified by:
setActuator
in interfaceSendableBuilder
- Parameters:
value
- true if actuator, false if not
-
setSafeState
Set the function that should be called to set the Sendable into a safe state. This is called when entering and exiting Live Window mode.- Specified by:
setSafeState
in interfaceSendableBuilder
- Parameters:
func
- function
-
setUpdateTable
Set the function that should be called to update the network table for things other than properties. Note this function is not passed the network table object; instead it should use the topics returned by getTopic().- Specified by:
setUpdateTable
in interfaceNTSendableBuilder
- Parameters:
func
- function
-
getTopic
Add a property without getters or setters. This can be used to get entry handles for the function called by setUpdateTable().- Specified by:
getTopic
in interfaceNTSendableBuilder
- Parameters:
key
- property name- Returns:
- Network table entry
-
addBooleanProperty
Add a boolean property.- Specified by:
addBooleanProperty
in interfaceSendableBuilder
- Parameters:
key
- property namegetter
- getter function (returns current value)setter
- setter function (sets new value)
-
addIntegerProperty
Add an integer property.- Specified by:
addIntegerProperty
in interfaceSendableBuilder
- Parameters:
key
- property namegetter
- getter function (returns current value)setter
- setter function (sets new value)
-
addFloatProperty
Add a float property.- Specified by:
addFloatProperty
in interfaceSendableBuilder
- Parameters:
key
- property namegetter
- getter function (returns current value)setter
- setter function (sets new value)
-
addDoubleProperty
Add a double property.- Specified by:
addDoubleProperty
in interfaceSendableBuilder
- Parameters:
key
- property namegetter
- getter function (returns current value)setter
- setter function (sets new value)
-
addStringProperty
Add a string property.- Specified by:
addStringProperty
in interfaceSendableBuilder
- Parameters:
key
- property namegetter
- getter function (returns current value)setter
- setter function (sets new value)
-
addBooleanArrayProperty
public void addBooleanArrayProperty(String key, Supplier<boolean[]> getter, Consumer<boolean[]> setter)Add a boolean array property.- Specified by:
addBooleanArrayProperty
in interfaceSendableBuilder
- Parameters:
key
- property namegetter
- getter function (returns current value)setter
- setter function (sets new value)
-
addIntegerArrayProperty
Add an integer array property.- Specified by:
addIntegerArrayProperty
in interfaceSendableBuilder
- Parameters:
key
- property namegetter
- getter function (returns current value)setter
- setter function (sets new value)
-
addFloatArrayProperty
Add a float array property.- Specified by:
addFloatArrayProperty
in interfaceSendableBuilder
- Parameters:
key
- property namegetter
- getter function (returns current value)setter
- setter function (sets new value)
-
addDoubleArrayProperty
public void addDoubleArrayProperty(String key, Supplier<double[]> getter, Consumer<double[]> setter)Add a double array property.- Specified by:
addDoubleArrayProperty
in interfaceSendableBuilder
- Parameters:
key
- property namegetter
- getter function (returns current value)setter
- setter function (sets new value)
-
addStringArrayProperty
public void addStringArrayProperty(String key, Supplier<String[]> getter, Consumer<String[]> setter)Add a string array property.- Specified by:
addStringArrayProperty
in interfaceSendableBuilder
- Parameters:
key
- property namegetter
- getter function (returns current value)setter
- setter function (sets new value)
-
addRawProperty
public void addRawProperty(String key, String typeString, Supplier<byte[]> getter, Consumer<byte[]> setter)Add a raw property.- Specified by:
addRawProperty
in interfaceSendableBuilder
- Parameters:
key
- property nametypeString
- type stringgetter
- getter function (returns current value)setter
- setter function (sets new value)
-