Class SmartDashboard
java.lang.Object
edu.wpi.first.wpilibj.smartdashboard.SmartDashboard
The
SmartDashboard class is the bridge between robot programs and the SmartDashboard on
the laptop.
When a value is put into the SmartDashboard here, it pops up on the SmartDashboard on the laptop. Users can put values into and get values from the SmartDashboard.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidclearPersistent(String key) Stop making a key's value persistent through program restarts.static booleancontainsKey(String key) Checks the table and tells if it contains the specified key.static booleangetBoolean(String key, boolean defaultValue) Returns the boolean the key maps to.static boolean[]getBooleanArray(String key, boolean[] defaultValue) Returns the boolean array the key maps to.static Boolean[]getBooleanArray(String key, Boolean[] defaultValue) Returns the boolean array the key maps to.static SendableReturns the value at the specified key.static NetworkTableEntryGets the entry for the specified key.getKeys()Get the keys stored in the SmartDashboard table of NetworkTables.getKeys(int types) Get the keys stored in the SmartDashboard table of NetworkTables.static doubleReturns the number the key maps to.static double[]getNumberArray(String key, double[] defaultValue) Returns the number array the key maps to.static Double[]getNumberArray(String key, Double[] defaultValue) Returns the number array the key maps to.static byte[]Returns the raw value (byte array) the key maps to.static StringReturns the string the key maps to.static String[]getStringArray(String key, String[] defaultValue) Returns the string array the key maps to.static booleanisPersistent(String key) Returns whether the value is persistent through program restarts.static voidpostListenerTask(Runnable task) Posts a task from a listener to the ListenerExecutor, so that it can be run synchronously from the main loop on the next call toupdateValues().static booleanputBoolean(String key, boolean value) Put a boolean in the table.static booleanputBooleanArray(String key, boolean[] value) Put a boolean array in the table.static booleanputBooleanArray(String key, Boolean[] value) Put a boolean array in the table.static voidMaps the specified key (where the key is the name of theSendable) to the specified value in this table.static voidMaps the specified key to the specified value in this table.static booleanPut a number in the table.static booleanputNumberArray(String key, double[] value) Put a number array in the table.static booleanputNumberArray(String key, Double[] value) Put a number array in the table.static booleanPut a raw value (byte array) in the table.static booleanPut a string in the table.static booleanputStringArray(String key, String[] value) Put a string array in the table.static booleansetDefaultBoolean(String key, boolean defaultValue) Set the value in the table if key does not exist.static booleansetDefaultBooleanArray(String key, boolean[] defaultValue) Set the value in the table if key does not exist.static booleansetDefaultBooleanArray(String key, Boolean[] defaultValue) Set the value in the table if key does not exist.static booleansetDefaultNumber(String key, double defaultValue) Set the value in the table if key does not exist.static booleansetDefaultNumberArray(String key, double[] defaultValue) Set the value in the table if key does not exist.static booleansetDefaultNumberArray(String key, Double[] defaultValue) Set the value in the table if key does not exist.static booleansetDefaultRaw(String key, byte[] defaultValue) Set the value in the table if key does not exist.static booleansetDefaultString(String key, String defaultValue) Set the value in the table if key does not exist.static booleansetDefaultStringArray(String key, String[] defaultValue) Set the value in the table if key does not exist.static voidSet the NetworkTable instance used for entries.static voidsetPersistent(String key) Makes a key's value persistent through program restarts.static voidPuts all sendable data to the dashboard.
-
Method Details
-
setNetworkTableInstance
Set the NetworkTable instance used for entries. For testing purposes; use with caution.- Parameters:
inst- NetworkTable instance
-
putData
Maps the specified key to the specified value in this table. The key can not be null. The value can be retrieved by calling the get method with a key that is equal to the original key.- Parameters:
key- the keydata- the value- Throws:
IllegalArgumentException- If key is null
-
putData
Maps the specified key (where the key is the name of theSendable) to the specified value in this table. The value can be retrieved by calling the get method with a key that is equal to the original key.- Parameters:
value- the value- Throws:
IllegalArgumentException- If key is null
-
getData
Returns the value at the specified key.- Parameters:
key- the key- Returns:
- the value
- Throws:
IllegalArgumentException- if the key is null
-
getEntry
Gets the entry for the specified key.- Parameters:
key- the key name- Returns:
- Network table entry.
-
containsKey
Checks the table and tells if it contains the specified key.- Parameters:
key- the key to search for- Returns:
- true if the table as a value assigned to the given key
-
getKeys
Get the keys stored in the SmartDashboard table of NetworkTables.- Parameters:
types- bitmask of types; 0 is treated as a "don't care".- Returns:
- keys currently in the table
-
getKeys
Get the keys stored in the SmartDashboard table of NetworkTables.- Returns:
- keys currently in the table.
-
setPersistent
Makes a key's value persistent through program restarts. The key cannot be null.- Parameters:
key- the key name
-
clearPersistent
Stop making a key's value persistent through program restarts. The key cannot be null.- Parameters:
key- the key name
-
isPersistent
Returns whether the value is persistent through program restarts. The key cannot be null.- Parameters:
key- the key name- Returns:
- True if the value is persistent.
-
putBoolean
Put a boolean in the table.- Parameters:
key- the key to be assigned tovalue- the value that will be assigned- Returns:
- False if the table key already exists with a different type
-
setDefaultBoolean
Set the value in the table if key does not exist.- Parameters:
key- the keydefaultValue- the value to set if key does not exist- Returns:
- True if the key did not already exist, otherwise False
-
getBoolean
Returns the boolean the key maps to. If the key does not exist or is of different type, it will return the default value.- Parameters:
key- the key to look updefaultValue- the value to be returned if no value is found- Returns:
- the value associated with the given key or the given default value if there is no value associated with the key
-
putNumber
Put a number in the table.- Parameters:
key- the key to be assigned tovalue- the value that will be assigned- Returns:
- False if the table key already exists with a different type
-
setDefaultNumber
Set the value in the table if key does not exist.- Parameters:
key- the keydefaultValue- the value to set if key does not exist- Returns:
- True if the key did not already exist, otherwise False
-
getNumber
Returns the number the key maps to. If the key does not exist or is of different type, it will return the default value.- Parameters:
key- the key to look updefaultValue- the value to be returned if no value is found- Returns:
- the value associated with the given key or the given default value if there is no value associated with the key
-
putString
Put a string in the table.- Parameters:
key- the key to be assigned tovalue- the value that will be assigned- Returns:
- False if the table key already exists with a different type
-
setDefaultString
Set the value in the table if key does not exist.- Parameters:
key- the keydefaultValue- the value to set if key does not exist- Returns:
- True if the key did not already exist, otherwise False
-
getString
Returns the string the key maps to. If the key does not exist or is of different type, it will return the default value.- Parameters:
key- the key to look updefaultValue- the value to be returned if no value is found- Returns:
- the value associated with the given key or the given default value if there is no value associated with the key
-
putBooleanArray
Put a boolean array in the table.- Parameters:
key- the key to be assigned tovalue- the value that will be assigned- Returns:
- False if the table key already exists with a different type
-
putBooleanArray
Put a boolean array in the table.- Parameters:
key- the key to be assigned tovalue- the value that will be assigned- Returns:
- False if the table key already exists with a different type
-
setDefaultBooleanArray
Set the value in the table if key does not exist.- Parameters:
key- the keydefaultValue- the value to set if key does not exist- Returns:
- True if the key did not already exist, otherwise False
-
setDefaultBooleanArray
Set the value in the table if key does not exist.- Parameters:
key- the keydefaultValue- the value to set if key does not exist- Returns:
- True if the key did not already exist, otherwise False
-
getBooleanArray
Returns the boolean array the key maps to. If the key does not exist or is of different type, it will return the default value.- Parameters:
key- the key to look updefaultValue- the value to be returned if no value is found- Returns:
- the value associated with the given key or the given default value if there is no value associated with the key
-
getBooleanArray
Returns the boolean array the key maps to. If the key does not exist or is of different type, it will return the default value.- Parameters:
key- the key to look updefaultValue- the value to be returned if no value is found- Returns:
- the value associated with the given key or the given default value if there is no value associated with the key
-
putNumberArray
Put a number array in the table.- Parameters:
key- the key to be assigned tovalue- the value that will be assigned- Returns:
- False if the table key already exists with a different type
-
putNumberArray
Put a number array in the table.- Parameters:
key- the key to be assigned tovalue- the value that will be assigned- Returns:
- False if the table key already exists with a different type
-
setDefaultNumberArray
Set the value in the table if key does not exist.- Parameters:
key- the keydefaultValue- the value to set if key does not exist- Returns:
- True if the key did not already exist, otherwise False
-
setDefaultNumberArray
Set the value in the table if key does not exist.- Parameters:
key- the keydefaultValue- the value to set if key does not exist- Returns:
- True if the key did not already exist, otherwise False
-
getNumberArray
Returns the number array the key maps to. If the key does not exist or is of different type, it will return the default value.- Parameters:
key- the key to look updefaultValue- the value to be returned if no value is found- Returns:
- the value associated with the given key or the given default value if there is no value associated with the key
-
getNumberArray
Returns the number array the key maps to. If the key does not exist or is of different type, it will return the default value.- Parameters:
key- the key to look updefaultValue- the value to be returned if no value is found- Returns:
- the value associated with the given key or the given default value if there is no value associated with the key
-
putStringArray
Put a string array in the table.- Parameters:
key- the key to be assigned tovalue- the value that will be assigned- Returns:
- False if the table key already exists with a different type
-
setDefaultStringArray
Set the value in the table if key does not exist.- Parameters:
key- the keydefaultValue- the value to set if key does not exist- Returns:
- True if the key did not already exist, otherwise False
-
getStringArray
Returns the string array the key maps to. If the key does not exist or is of different type, it will return the default value.- Parameters:
key- the key to look updefaultValue- the value to be returned if no value is found- Returns:
- the value associated with the given key or the given default value if there is no value associated with the key
-
putRaw
Put a raw value (byte array) in the table.- Parameters:
key- the key to be assigned tovalue- the value that will be assigned- Returns:
- False if the table key already exists with a different type
-
setDefaultRaw
Set the value in the table if key does not exist.- Parameters:
key- the keydefaultValue- the value to set if key does not exist- Returns:
- True if the key did not already exist, otherwise False
-
getRaw
Returns the raw value (byte array) the key maps to. If the key does not exist or is of different type, it will return the default value.- Parameters:
key- the key to look updefaultValue- the value to be returned if no value is found- Returns:
- the value associated with the given key or the given default value if there is no value associated with the key
-
postListenerTask
Posts a task from a listener to the ListenerExecutor, so that it can be run synchronously from the main loop on the next call toupdateValues().- Parameters:
task- The task to run synchronously from the main thread.
-
updateValues
Puts all sendable data to the dashboard.
-