Class FrcDashboard

java.lang.Object
trclib.driverio.TrcDashboard
frclib.driverio.FrcDashboard

public class FrcDashboard extends TrcDashboard
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.
  • Method Details

    • getInstance

      public static FrcDashboard 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

      public boolean[] getBooleanArray(String key, boolean[] defaultValue)
      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 up
      defaultValue - 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

      public Boolean[] getBooleanArray(String key, Boolean[] defaultValue)
      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 up
      defaultValue - 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

      public void putBooleanArray(String key, boolean[] value)
      Put a boolean array in the table.
      Parameters:
      key - the key to be assigned to
      value - the value that will be assigned
      Throws:
      RuntimeException - if key already exists with a different type.
    • putBooleanArray

      public void putBooleanArray(String key, Boolean[] value)
      Put a boolean array in the table.
      Parameters:
      key - the key to be assigned to
      value - the value that will be assigned
      Throws:
      RuntimeException - if key already exists with a different type.
    • setDefaultBoolean

      public void setDefaultBoolean(String key, boolean defaultValue)
      Gets the current value in the table, setting it if it does not exist.
      Parameters:
      key - the key
      defaultValue - the default value to set if key does not exist.
      Throws:
      RuntimeException - if key already exists with a different type.
    • setDefaultBooleanArray

      public void setDefaultBooleanArray(String key, boolean[] defaultValue)
      Gets the current value in the table, setting it if it does not exist.
      Parameters:
      key - the key
      defaultValue - the default value to set if key does not exist.
      Throws:
      RuntimeException - if key already exists with a different type.
    • setDefaultBooleanArray

      public void setDefaultBooleanArray(String key, Boolean[] defaultValue)
      Gets the current value in the table, setting it if it does not exist.
      Parameters:
      key - the key
      defaultValue - the default value to set if key does not exist.
      Throws:
      RuntimeException - if key already exists with a different type.
    • getNumberArray

      public double[] getNumberArray(String key, double[] defaultValue)
      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 up
      defaultValue - 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

      public Double[] getNumberArray(String key, Double[] defaultValue)
      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 up
      defaultValue - 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

      public void putNumberArray(String key, double[] value)
      Put a number array in the table.
      Parameters:
      key - the key to be assigned to
      value - the value that will be assigned
      Throws:
      RuntimeException - if key already exists with a different type.
    • putNumberArray

      public void putNumberArray(String key, Double[] value)
      Put a number array in the table.
      Parameters:
      key - the key to be assigned to
      value - the value that will be assigned
      Throws:
      RuntimeException - if key already exists with a different type.
    • setDefaultNumber

      public void setDefaultNumber(String key, double defaultValue)
      Gets the current value in the table, setting it if it does not exist.
      Parameters:
      key - the key
      defaultValue - the default value to set if key does not exist.
      Throws:
      RuntimeException - if key already exists with a different type.
    • setDefaultNumberArray

      public void setDefaultNumberArray(String key, double[] defaultValue)
      Gets the current value in the table, setting it if it does not exist.
      Parameters:
      key - the key
      defaultValue - the default value to set if key does not exist.
      Throws:
      RuntimeException - if key already exists with a different type.
    • setDefaultNumberArray

      public void setDefaultNumberArray(String key, Double[] defaultValue)
      Gets the current value in the table, setting it if it does not exist.
      Parameters:
      key - the key
      defaultValue - the default value to set if key does not exist.
      Throws:
      RuntimeException - if key already exists with a different type.
    • getStringArray

      public String[] getStringArray(String key, String[] defaultValue)
      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 up
      defaultValue - 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

      public void putStringArray(String key, String[] value)
      Put a string array in the table.
      Parameters:
      key - the key to be assigned to
      value - the value that will be assigned
      Throws:
      RuntimeException - if key already exists with a different type.
    • setDefaultString

      public void setDefaultString(String key, String defaultValue)
      Gets the current value in the table, setting it if it does not exist.
      Parameters:
      key - the key
      defaultValue - the default value to set if key does not exist.
      Throws:
      RuntimeException - if key already exists with a different type.
    • setDefaultStringArray

      public void setDefaultStringArray(String key, String[] defaultValue)
      Gets the current value in the table, setting it if it does not exist.
      Parameters:
      key - the key
      defaultValue - the default value to set if key does not exist.
      Throws:
      RuntimeException - if key already exists with a different type.
    • getData

      public edu.wpi.first.util.sendable.Sendable getData(String key)
      Returns the value at the specified key.
      Parameters:
      key - the key
      Returns:
      the value
      Throws:
      IllegalArgumentException - if the key is null
    • putData

      public void putData(String key, edu.wpi.first.util.sendable.Sendable data)
      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 key
      data - 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 the Sendable 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

      public edu.wpi.first.networktables.NetworkTableEntry getEntry(String key)
      Gets the entry for the specified key.
      Parameters:
      key - the key name
      Returns:
      Network table entry.
    • getKeys

      public Set<String> getKeys(int types)
      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

      public Set<String> getKeys()
      Get the keys stored in the SmartDashboard table of NetworkTables.
      Returns:
      keys currently in the table.
    • containsKey

      public boolean containsKey(String key)
      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

      public void refreshKey(String key, Object defaultValue)
      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

      public byte[] getRaw(String key, byte[] defaultValue)
      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 up
      defaultValue - 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

      public void putRaw(String key, byte[] value)
      Put a raw value (byte array) in the table.
      Parameters:
      key - the key to be assigned to
      value - the value that will be assigned
      Throws:
      RuntimeException - if key already exists with a different type.
    • setDefaultRaw

      public void setDefaultRaw(String key, byte[] defaultValue)
      Gets the current value in the table, setting it if it does not exist.
      Parameters:
      key - the key
      defaultValue - the default value to set if key does not exist.
      Throws:
      RuntimeException - if key already exists with a different type.
    • setPersistent

      public void setPersistent(String key)
      Makes a key's value persistent through program restarts. The key cannot be null.
      Parameters:
      key - the key name
    • clearPersistent

      public void clearPersistent(String key)
      Stop making a key's value persistent through program restarts. The key cannot be null.
      Parameters:
      key - the key name
    • isPersistent

      public boolean isPersistent(String key)
      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 class TrcDashboard
    • refreshDisplay

      public void refreshDisplay()
      This method refresh the display lines to the Driver Station.
      Specified by:
      refreshDisplay in class TrcDashboard
    • displayPrintf

      public void displayPrintf(int lineNum, String msg)
      This method displays a formatted message to the display on the Driver Station.
      Specified by:
      displayPrintf in class TrcDashboard
      Parameters:
      lineNum - specifies the line number on the display.
      msg - specifies the message string.
    • displayPrintf

      public void displayPrintf(int lineNum, String format, Object... args)
      This method displays a formatted message to the display on the Driver Station.
      Specified by:
      displayPrintf in class TrcDashboard
      Parameters:
      lineNum - specifies the line number on the display.
      format - specifies the format string.
      args - specifies variable number of substitution arguments.
    • getBoolean

      public boolean getBoolean(String key, boolean defaultValue)
      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 class TrcDashboard
      Parameters:
      key - the key to look up
      defaultValue - 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

      public void putBoolean(String key, boolean value)
      Put a boolean in the table.
      Specified by:
      putBoolean in class TrcDashboard
      Parameters:
      key - the key to be assigned to
      value - the value that will be assigned
      Throws:
      RuntimeException - if key already exists with a different type.
    • getNumber

      public double getNumber(String key, double defaultValue)
      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 class TrcDashboard
      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

      public void putNumber(String key, double value)
      Put a number in the table.
      Specified by:
      putNumber in class TrcDashboard
      Parameters:
      key - the key to be assigned to
      value - the value that will be assigned
      Throws:
      RuntimeException - if key already exists with a different type.
    • getString

      public String getString(String key, String defaultValue)
      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 class TrcDashboard
      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

      public void putString(String key, String value)
      Put a string in the table.
      Specified by:
      putString in class TrcDashboard
      Parameters:
      key - the key to be assigned to
      value - the value that will be assigned
      Throws:
      RuntimeException - if key already exists with a different type.