Class SendableBuilderImpl
- java.lang.Object
-
- edu.wpi.first.wpilibj.smartdashboard.SendableBuilderImpl
-
- All Implemented Interfaces:
SendableBuilder
public class SendableBuilderImpl extends Object implements SendableBuilder
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface edu.wpi.first.wpilibj.smartdashboard.SendableBuilder
SendableBuilder.BooleanConsumer
-
-
Constructor Summary
Constructors Constructor Description SendableBuilderImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBooleanArrayProperty(String key, Supplier<boolean[]> getter, Consumer<boolean[]> setter)Add a boolean array property.voidaddBooleanProperty(String key, BooleanSupplier getter, SendableBuilder.BooleanConsumer setter)Add a boolean property.voidaddDoubleArrayProperty(String key, Supplier<double[]> getter, Consumer<double[]> setter)Add a double array property.voidaddDoubleProperty(String key, DoubleSupplier getter, DoubleConsumer setter)Add a double property.voidaddRawProperty(String key, Supplier<byte[]> getter, Consumer<byte[]> setter)Add a raw property.voidaddStringArrayProperty(String key, Supplier<String[]> getter, Consumer<String[]> setter)Add a string array property.voidaddStringProperty(String key, Supplier<String> getter, Consumer<String> setter)Add a string property.voidaddValueProperty(String key, Supplier<NetworkTableValue> getter, Consumer<NetworkTableValue> setter)Add a NetworkTableValue property.voidclearProperties()Clear properties.NetworkTableEntrygetEntry(String key)Add a property without getters or setters.NetworkTablegetTable()Get the network table.booleanhasTable()Return whether this sendable has an associated table.booleanisActuator()Return whether this sendable should be treated as an actuator.voidsetActuator(boolean value)Set a flag indicating if this sendable should be treated as an actuator.voidsetSafeState(Runnable func)Set the function that should be called to set the Sendable into a safe state.voidsetSmartDashboardType(String type)Set the string representation of the named data type that will be used by the smart dashboard for this sendable.voidsetTable(NetworkTable table)Set the network table.voidsetUpdateTable(Runnable func)Set the function that should be called to update the network table for things other than properties.voidstartListeners()Hook setters for all properties.voidstartLiveWindowMode()Start LiveWindow mode by hooking the setters for all properties.voidstopListeners()Unhook setters for all properties.voidstopLiveWindowMode()Stop LiveWindow mode by unhooking the setters for all properties.voidupdateTable()Update the network table values by calling the getters for all properties.
-
-
-
Method Detail
-
setTable
public void setTable(NetworkTable table)
Set the network table. Must be called prior to any Add* functions being called.- Parameters:
table- Network table
-
getTable
public NetworkTable getTable()
Get the network table.- Returns:
- The network table
-
hasTable
public boolean hasTable()
Return whether this sendable has an associated table.- Returns:
- True if it has a table, false if not.
-
isActuator
public boolean isActuator()
Return whether this sendable should be treated as an actuator.- Returns:
- True if actuator, false if not.
-
updateTable
public void updateTable()
Update the network table values by calling the getters for all properties.
-
startListeners
public void startListeners()
Hook setters for all properties.
-
stopListeners
public void stopListeners()
Unhook setters for all properties.
-
startLiveWindowMode
public void startLiveWindowMode()
Start LiveWindow mode by hooking the setters for all properties. Also calls the safeState function if one was provided.
-
stopLiveWindowMode
public void stopLiveWindowMode()
Stop LiveWindow mode by unhooking the setters for all properties. Also calls the safeState function if one was provided.
-
clearProperties
public void clearProperties()
Clear properties.
-
setSmartDashboardType
public void setSmartDashboardType(String type)
Set the string representation of the named data type that will be used by the smart dashboard for this sendable.- Specified by:
setSmartDashboardTypein interfaceSendableBuilder- Parameters:
type- data type
-
setActuator
public void setActuator(boolean value)
Set a flag indicating if this sendable should be treated as an actuator. By default this flag is false.- Specified by:
setActuatorin interfaceSendableBuilder- Parameters:
value- true if actuator, false if not
-
setSafeState
public void setSafeState(Runnable func)
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:
setSafeStatein interfaceSendableBuilder- Parameters:
func- function
-
setUpdateTable
public void setUpdateTable(Runnable func)
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 entry handles returned by getEntry().- Specified by:
setUpdateTablein interfaceSendableBuilder- Parameters:
func- function
-
getEntry
public NetworkTableEntry getEntry(String key)
Add a property without getters or setters. This can be used to get entry handles for the function called by setUpdateTable().- Specified by:
getEntryin interfaceSendableBuilder- Parameters:
key- property name- Returns:
- Network table entry
-
addBooleanProperty
public void addBooleanProperty(String key, BooleanSupplier getter, SendableBuilder.BooleanConsumer setter)
Add a boolean property.- Specified by:
addBooleanPropertyin interfaceSendableBuilder- Parameters:
key- property namegetter- getter function (returns current value)setter- setter function (sets new value)
-
addDoubleProperty
public void addDoubleProperty(String key, DoubleSupplier getter, DoubleConsumer setter)
Add a double property.- Specified by:
addDoublePropertyin interfaceSendableBuilder- Parameters:
key- property namegetter- getter function (returns current value)setter- setter function (sets new value)
-
addStringProperty
public void addStringProperty(String key, Supplier<String> getter, Consumer<String> setter)
Add a string property.- Specified by:
addStringPropertyin 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:
addBooleanArrayPropertyin 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:
addDoubleArrayPropertyin 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:
addStringArrayPropertyin interfaceSendableBuilder- Parameters:
key- property namegetter- getter function (returns current value)setter- setter function (sets new value)
-
addRawProperty
public void addRawProperty(String key, Supplier<byte[]> getter, Consumer<byte[]> setter)
Add a raw property.- Specified by:
addRawPropertyin interfaceSendableBuilder- Parameters:
key- property namegetter- getter function (returns current value)setter- setter function (sets new value)
-
addValueProperty
public void addValueProperty(String key, Supplier<NetworkTableValue> getter, Consumer<NetworkTableValue> setter)
Add a NetworkTableValue property.- Specified by:
addValuePropertyin interfaceSendableBuilder- Parameters:
key- property namegetter- getter function (returns current value)setter- setter function (sets new value)
-
-