Package frclib.driverio
Class FrcDashboard
java.lang.Object
trclib.driverio.TrcDashboard
frclib.driverio.FrcDashboard
This class extends the SmartDashboard class and provides a way to send named
data to the Driver Station to be displayed, it also simulates an LCD display
similar to the NXT Mindstorms. The Mindstorms has only 8 lines but this
dashboard can support as many lines as the Driver Station can support. By
default, we set the number of lines to 16. By changing a constant here, you
can have as many lines as you want. This dashboard display is very useful for
displaying debug information.
-
Field Summary
Fields inherited from class trclib.driverio.TrcDashboard
displayKeyFormat, instance, MAX_NUM_TEXTLINES, numLines
-
Method Summary
Modifier and TypeMethodDescriptionvoid
This method clears all the display lines.void
clearPersistent
(String key) Stop making a key's value persistent through program restarts.boolean
containsKey
(String key) Checks the table and tells if it contains the specified key.void
displayPrintf
(int lineNum, String msg) This method displays a formatted message to the display on the Driver Station.void
displayPrintf
(int lineNum, String format, Object... args) This method displays a formatted message to the display on the Driver Station.boolean
getBoolean
(String key, boolean defaultValue) Returns the boolean the key maps to.boolean[]
getBooleanArray
(String key, boolean[] defaultValue) Returns the boolean array the key maps to.Boolean[]
getBooleanArray
(String key, Boolean[] defaultValue) Returns the boolean array the key maps to.edu.wpi.first.util.sendable.Sendable
Returns the value at the specified key.edu.wpi.first.networktables.NetworkTableEntry
Gets the entry for the specified key.static FrcDashboard
This method returns the instance of this object if one already exist, creates one if none existed.getKeys()
Get the keys stored in the SmartDashboard table of NetworkTables.getKeys
(int types) Get the keys stored in the SmartDashboard table of NetworkTables.double
This method returns the value associated with the given key.double[]
getNumberArray
(String key, double[] defaultValue) Returns the number array the key maps to.Double[]
getNumberArray
(String key, Double[] defaultValue) Returns the number array the key maps to.byte[]
Returns the raw value (byte array) the key maps to.This method returns the value associated with the given key.String[]
getStringArray
(String key, String[] defaultValue) Returns the string array the key maps to.boolean
isPersistent
(String key) Returns whether the value is persistent through program restarts.void
putBoolean
(String key, boolean value) Put a boolean in the table.void
putBooleanArray
(String key, boolean[] value) Put a boolean array in the table.void
putBooleanArray
(String key, Boolean[] value) Put a boolean array in the table.void
putData
(edu.wpi.first.util.sendable.Sendable value) Maps the specified key (where the key is the name of theSendable
to the specified value in this table.void
Maps the specified key to the specified value in this table.void
Put a number in the table.void
putNumberArray
(String key, double[] value) Put a number array in the table.void
putNumberArray
(String key, Double[] value) Put a number array in the table.void
Put a raw value (byte array) in the table.void
Put a string in the table.void
putStringArray
(String key, String[] value) Put a string array in the table.void
This method refresh the display lines to the Driver Station.void
refreshKey
(String key, Object defaultValue) Refreshes the entry value.void
setDefaultBoolean
(String key, boolean defaultValue) Gets the current value in the table, setting it if it does not exist.void
setDefaultBooleanArray
(String key, boolean[] defaultValue) Gets the current value in the table, setting it if it does not exist.void
setDefaultBooleanArray
(String key, Boolean[] defaultValue) Gets the current value in the table, setting it if it does not exist.void
setDefaultNumber
(String key, double defaultValue) Gets the current value in the table, setting it if it does not exist.void
setDefaultNumberArray
(String key, double[] defaultValue) Gets the current value in the table, setting it if it does not exist.void
setDefaultNumberArray
(String key, Double[] defaultValue) Gets the current value in the table, setting it if it does not exist.void
setDefaultRaw
(String key, byte[] defaultValue) Gets the current value in the table, setting it if it does not exist.void
setDefaultString
(String key, String defaultValue) Gets the current value in the table, setting it if it does not exist.void
setDefaultStringArray
(String key, String[] defaultValue) Gets the current value in the table, setting it if it does not exist.void
setPersistent
(String key) Makes a key's value persistent through program restarts.void
Puts all sendable data to the dashboard.Methods inherited from class trclib.driverio.TrcDashboard
getNumTextLines
-
Method Details
-
getInstance
This method returns the instance of this object if one already exist, creates one if none existed.- Returns:
- instance of the object, null if none existed.
-
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
-
putBooleanArray
Put a boolean array in the table.- Parameters:
key
- the key to be assigned tovalue
- the value that will be assigned- Throws:
RuntimeException
- if 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- Throws:
RuntimeException
- if key already exists with a different type.
-
setDefaultBoolean
Gets the current value in the table, setting it if it does not exist.- Parameters:
key
- the keydefaultValue
- the default value to set if key does not exist.- Throws:
RuntimeException
- if key already exists with a different type.
-
setDefaultBooleanArray
Gets the current value in the table, setting it if it does not exist.- Parameters:
key
- the keydefaultValue
- the default value to set if key does not exist.- Throws:
RuntimeException
- if key already exists with a different type.
-
setDefaultBooleanArray
Gets the current value in the table, setting it if it does not exist.- Parameters:
key
- the keydefaultValue
- the default value to set if key does not exist.- Throws:
RuntimeException
- if key already exists with a different type.
-
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
-
putNumberArray
Put a number array in the table.- Parameters:
key
- the key to be assigned tovalue
- the value that will be assigned- Throws:
RuntimeException
- if 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- Throws:
RuntimeException
- if key already exists with a different type.
-
setDefaultNumber
Gets the current value in the table, setting it if it does not exist.- Parameters:
key
- the keydefaultValue
- the default value to set if key does not exist.- Throws:
RuntimeException
- if key already exists with a different type.
-
setDefaultNumberArray
Gets the current value in the table, setting it if it does not exist.- Parameters:
key
- the keydefaultValue
- the default value to set if key does not exist.- Throws:
RuntimeException
- if key already exists with a different type.
-
setDefaultNumberArray
Gets the current value in the table, setting it if it does not exist.- Parameters:
key
- the keydefaultValue
- the default value to set if key does not exist.- Throws:
RuntimeException
- if key already exists with a different type.
-
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
-
putStringArray
Put a string array in the table.- Parameters:
key
- the key to be assigned tovalue
- the value that will be assigned- Throws:
RuntimeException
- if key already exists with a different type.
-
setDefaultString
Gets the current value in the table, setting it if it does not exist.- Parameters:
key
- the keydefaultValue
- the default value to set if key does not exist.- Throws:
RuntimeException
- if key already exists with a different type.
-
setDefaultStringArray
Gets the current value in the table, setting it if it does not exist.- Parameters:
key
- the keydefaultValue
- the default value to set if key does not exist.- Throws:
RuntimeException
- if key already exists with a different type.
-
getData
Returns the value at the specified key.- Parameters:
key
- the key- Returns:
- the value
- Throws:
IllegalArgumentException
- if the key is null
-
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
public void putData(edu.wpi.first.util.sendable.Sendable value) 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
-
getEntry
Gets the entry for the specified key.- Parameters:
key
- the key name- Returns:
- Network table entry.
-
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.
-
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
-
refreshKey
Refreshes the entry value. If the entry doesn't exist, create it with the corresponding value.- Parameters:
key
- The name of the entry.defaultValue
- The value to create the entry with if it doesn't exist.
-
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
-
putRaw
Put a raw value (byte array) in the table.- Parameters:
key
- the key to be assigned tovalue
- the value that will be assigned- Throws:
RuntimeException
- if key already exists with a different type.
-
setDefaultRaw
Gets the current value in the table, setting it if it does not exist.- Parameters:
key
- the keydefaultValue
- the default value to set if key does not exist.- Throws:
RuntimeException
- if key already exists with a different type.
-
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.
-
updateValues
public void updateValues()Puts all sendable data to the dashboard. -
clearDisplay
public void clearDisplay()This method clears all the display lines.- Specified by:
clearDisplay
in classTrcDashboard
-
refreshDisplay
public void refreshDisplay()This method refresh the display lines to the Driver Station.- Specified by:
refreshDisplay
in classTrcDashboard
-
displayPrintf
This method displays a formatted message to the display on the Driver Station.- Specified by:
displayPrintf
in classTrcDashboard
- Parameters:
lineNum
- specifies the line number on the display.msg
- specifies the message string.
-
displayPrintf
This method displays a formatted message to the display on the Driver Station.- Specified by:
displayPrintf
in classTrcDashboard
- Parameters:
lineNum
- specifies the line number on the display.format
- specifies the format string.args
- specifies variable number of substitution arguments.
-
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.- Specified by:
getBoolean
in classTrcDashboard
- 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
-
putBoolean
Put a boolean in the table.- Specified by:
putBoolean
in classTrcDashboard
- Parameters:
key
- the key to be assigned tovalue
- the value that will be assigned- Throws:
RuntimeException
- if key already exists with a different type.
-
getNumber
This method returns the value associated with the given key. If the key does not already exist, it will create the key and put the default value in it and also return the default value.- Specified by:
getNumber
in classTrcDashboard
- Parameters:
key
- specifies the key.defaultValue
- specifies the default value if the key does not already exist.- Returns:
- value associated with the key or the default value if key does not exist.
-
putNumber
Put a number in the table.- Specified by:
putNumber
in classTrcDashboard
- Parameters:
key
- the key to be assigned tovalue
- the value that will be assigned- Throws:
RuntimeException
- if key already exists with a different type.
-
getString
This method returns the value associated with the given key. If the key does not already exist, it will create the key and put the default value in it and also return the default value.- Specified by:
getString
in classTrcDashboard
- Parameters:
key
- specifies the key.defaultValue
- specifies the default value if the key does not already exist.- Returns:
- value associated with the key or the default value if key does not exist.
-
putString
Put a string in the table.- Specified by:
putString
in classTrcDashboard
- Parameters:
key
- the key to be assigned tovalue
- the value that will be assigned- Throws:
RuntimeException
- if key already exists with a different type.
-