mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-04 03:11:43 +00:00
Updates SmartDashboard with new NetworkTables3 functions (#162)
This commit is contained in:
committed by
Peter Johnson
parent
8b2345a706
commit
64ebe7f5e5
@@ -7,8 +7,10 @@
|
||||
|
||||
package edu.wpi.first.wpilibj.smartdashboard;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Hashtable;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
|
||||
import edu.wpi.first.wpilibj.HLUsageReporting;
|
||||
import edu.wpi.first.wpilibj.NamedSendable;
|
||||
@@ -89,123 +91,499 @@ public class SmartDashboard {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Checks the table and tells if it contains the specified key.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
* @throws IllegalArgumentException if key is null
|
||||
* @param key the key to search for
|
||||
* @return true if the table as a value assigned to the given key
|
||||
*/
|
||||
public static void putBoolean(String key, boolean value) {
|
||||
table.putBoolean(key, value);
|
||||
public static boolean containsKey(String key) {
|
||||
return table.containsKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value at the specified key.
|
||||
*
|
||||
* @param key the key
|
||||
* @return the value
|
||||
* @throws NetworkTableKeyNotDefined if there is no value mapped to by the key
|
||||
* @throws IllegalArgumentException if the value mapped to by the key is not a boolean
|
||||
* @throws IllegalArgumentException if the key is null
|
||||
* @param types bitmask of types; 0 is treated as a "don't care".
|
||||
* @return keys currently in the table
|
||||
*/
|
||||
public Set<String> getKeys(int types) {
|
||||
return table.getKeys(types);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return keys currently in the table.
|
||||
*/
|
||||
public Set<String> getKeys() {
|
||||
return table.getKeys();
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a key's value persistent through program restarts.
|
||||
* The key cannot be null.
|
||||
*
|
||||
* @param key the key name
|
||||
*/
|
||||
public void setPersistent(String key) {
|
||||
table.setPersistent(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop making a key's value persistent through program restarts.
|
||||
* The key cannot be null.
|
||||
*
|
||||
* @param key the key name
|
||||
*/
|
||||
public void clearPersistent(String key) {
|
||||
table.clearPersistent(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the value is persistent through program restarts.
|
||||
* The key cannot be null.
|
||||
*
|
||||
* @param key the key name
|
||||
* @return True if the value is persistent.
|
||||
*/
|
||||
public boolean isPersistent(String key) {
|
||||
return table.isPersistent(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets flags on the specified key in this table. The key can
|
||||
* not be null.
|
||||
*
|
||||
* @param key the key name
|
||||
* @param flags the flags to set (bitmask)
|
||||
*/
|
||||
public void setFlags(String key, int flags) {
|
||||
table.setFlags(key, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears flags on the specified key in this table. The key can
|
||||
* not be null.
|
||||
*
|
||||
* @param key the key name
|
||||
* @param flags the flags to clear (bitmask)
|
||||
*/
|
||||
public void clearFlags(String key, int flags) {
|
||||
table.clearFlags(key, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the flags for the specified key.
|
||||
*
|
||||
* @param key the key name
|
||||
* @return the flags, or 0 if the key is not defined
|
||||
*/
|
||||
public int getFlags(String key) {
|
||||
return table.getFlags(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the specified key in this table. The key can
|
||||
* not be null.
|
||||
*
|
||||
* @param key the key name
|
||||
*/
|
||||
public void delete(String key) {
|
||||
table.delete(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a boolean in the table.
|
||||
* @param key the key to be assigned to
|
||||
* @param value the value that will be assigned
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
public static boolean putBoolean(String key, boolean value) {
|
||||
return table.putBoolean(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
* @param key the key
|
||||
* @param defaultValue the default value to set if key doens't exist.
|
||||
* @return False if the table key exists with a different type
|
||||
*/
|
||||
public boolean setDefaultBoolean(String key, boolean defaultValue) {
|
||||
return table.setDefaultBoolean(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the boolean the key maps to.
|
||||
* @param key the key to look up
|
||||
* @return the value associated with the given key
|
||||
* @throws TableKeyNotDefinedException if there is no value associated with
|
||||
* the given key
|
||||
* @deprecated This exception-raising method has been replaced by the
|
||||
* default-taking method {@link #getBoolean(String, boolean)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean getBoolean(String key) throws TableKeyNotDefinedException {
|
||||
return table.getBoolean(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value at the specified key.
|
||||
*
|
||||
* @param key the key
|
||||
* @param defaultValue returned if the key doesn't exist
|
||||
* @return the value
|
||||
* @throws IllegalArgumentException if the value mapped to by the key is not a boolean
|
||||
* @throws IllegalArgumentException if the key is null
|
||||
* Returns the boolean the key maps to. If the key does not exist or is of
|
||||
* different type, it will return the default value.
|
||||
* @param key the key to look up
|
||||
* @param defaultValue the value to be returned if no value is found
|
||||
* @return the value associated with the given key or the given default value
|
||||
* if there is no value associated with the key
|
||||
*/
|
||||
public static boolean getBoolean(String key, boolean defaultValue) {
|
||||
return table.getBoolean(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
* @throws IllegalArgumentException if key is null
|
||||
* Put a number in the table.
|
||||
* @param key the key to be assigned to
|
||||
* @param value the value that will be assigned
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
public static void putNumber(String key, double value) {
|
||||
table.putNumber(key, value);
|
||||
public static boolean putNumber(String key, double value) {
|
||||
return table.putNumber(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value at the specified key.
|
||||
*
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
* @param key the key
|
||||
* @return the value
|
||||
* @throws TableKeyNotDefinedException if there is no value mapped to by the key
|
||||
* @throws IllegalArgumentException if the value mapped to by the key is not a double
|
||||
* @throws IllegalArgumentException if the key is null
|
||||
* @param defaultValue the default value to set if key doens't exist.
|
||||
* @return False if the table key exists with a different type
|
||||
*/
|
||||
public boolean setDefaultNumber(String key, double defaultValue) {
|
||||
return table.setDefaultNumber(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number the key maps to.
|
||||
* @param key the key to look up
|
||||
* @return the value associated with the given key
|
||||
* @throws TableKeyNotDefinedException if there is no value associated with
|
||||
* the given key
|
||||
* @deprecated This exception-raising method has been replaced by the
|
||||
* default-taking method {@link #getNumber(String, double)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public static double getNumber(String key) throws TableKeyNotDefinedException {
|
||||
return table.getNumber(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value at the specified key.
|
||||
*
|
||||
* @param key the key
|
||||
* @param defaultValue the value returned if the key is undefined
|
||||
* @return the value
|
||||
* @throws NetworkTableKeyNotDefined if there is no value mapped to by the key
|
||||
* @throws IllegalArgumentException if the value mapped to by the key is not a double
|
||||
* @throws IllegalArgumentException if the key is null
|
||||
* Returns the number the key maps to. If the key does not exist or is of
|
||||
* different type, it will return the default value.
|
||||
* @param key the key to look up
|
||||
* @param defaultValue the value to be returned if no value is found
|
||||
* @return the value associated with the given key or the given default value
|
||||
* if there is no value associated with the key
|
||||
*/
|
||||
public static double getNumber(String key, double defaultValue) {
|
||||
return table.getNumber(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps the specified key to the specified value in this table. Neither the key nor the value can
|
||||
* be null. The value can be retrieved by calling the get method with a key that is equal to the
|
||||
* original key.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
* @throws IllegalArgumentException if key or value is null
|
||||
* Put a string in the table.
|
||||
* @param key the key to be assigned to
|
||||
* @param value the value that will be assigned
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
public static void putString(String key, String value) {
|
||||
table.putString(key, value);
|
||||
public static boolean putString(String key, String value) {
|
||||
return table.putString(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value at the specified key.
|
||||
*
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
* @param key the key
|
||||
* @return the value
|
||||
* @throws NetworkTableKeyNotDefined if there is no value mapped to by the key
|
||||
* @throws IllegalArgumentException if the value mapped to by the key is not a string
|
||||
* @throws IllegalArgumentException if the key is null
|
||||
* @param defaultValue the default value to set if key doens't exist.
|
||||
* @return False if the table key exists with a different type
|
||||
*/
|
||||
public boolean setDefaultString(String key, String defaultValue) {
|
||||
return table.setDefaultString(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string the key maps to.
|
||||
* @param key the key to look up
|
||||
* @return the value associated with the given key
|
||||
* @throws TableKeyNotDefinedException if there is no value associated with
|
||||
* the given key
|
||||
* @deprecated This exception-raising method has been replaced by the
|
||||
* default-taking method {@link #getString(String, String)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public static String getString(String key) throws TableKeyNotDefinedException {
|
||||
return table.getString(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value at the specified key.
|
||||
*
|
||||
* @param key the key
|
||||
* @param defaultValue The value returned if the key is undefined
|
||||
* @return the value
|
||||
* @throws NetworkTableKeyNotDefined if there is no value mapped to by the key
|
||||
* @throws IllegalArgumentException if the value mapped to by the key is not a string
|
||||
* @throws IllegalArgumentException if the key is null
|
||||
* Returns the string the key maps to. If the key does not exist or is of
|
||||
* different type, it will return the default value.
|
||||
* @param key the key to look up
|
||||
* @param defaultValue the value to be returned if no value is found
|
||||
* @return the value associated with the given key or the given default value
|
||||
* if there is no value associated with the key
|
||||
*/
|
||||
public static String getString(String key, String defaultValue) {
|
||||
return table.getString(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a boolean array in the table.
|
||||
* @param key the key to be assigned to
|
||||
* @param value the value that will be assigned
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
public boolean putBooleanArray(String key, boolean[] value) {
|
||||
return table.putBooleanArray(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a boolean array in the table.
|
||||
* @param key the key to be assigned to
|
||||
* @param value the value that will be assigned
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
public boolean putBooleanArray(String key, Boolean[] value) {
|
||||
return table.putBooleanArray(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
* @param key the key
|
||||
* @param defaultValue the default value to set if key doens't exist.
|
||||
* @return False if the table key exists with a different type
|
||||
*/
|
||||
public boolean setDefaultBooleanArray(String key, boolean[] defaultValue) {
|
||||
return table.setDefaultBooleanArray(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
* @param key the key
|
||||
* @param defaultValue the default value to set if key doens't exist.
|
||||
* @return False if the table key exists with a different type
|
||||
*/
|
||||
public boolean setDefaultBooleanArray(String key, Boolean[] defaultValue) {
|
||||
return table.setDefaultBooleanArray(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the boolean array the key maps to.
|
||||
* @param key the key to look up
|
||||
* @return the value associated with the given key
|
||||
* @throws TableKeyNotDefinedException if there is no value associated with
|
||||
* the given key
|
||||
* @deprecated This exception-raising method has been replaced by the
|
||||
* default-taking method {@link #getBooleanArray(String, boolean[])}.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean[] getBooleanArray(String key) throws TableKeyNotDefinedException {
|
||||
return table.getBooleanArray(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param key the key to look up
|
||||
* @param defaultValue the value to be returned if no value is found
|
||||
* @return the value associated with the given key or the given default value
|
||||
* if there is no value associated with the key
|
||||
*/
|
||||
public boolean[] getBooleanArray(String key, boolean[] defaultValue) {
|
||||
return table.getBooleanArray(key, 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.
|
||||
* @param key the key to look up
|
||||
* @param defaultValue the value to be returned if no value is found
|
||||
* @return the value associated with the given key or the given default value
|
||||
* if there is no value associated with the key
|
||||
*/
|
||||
public Boolean[] getBooleanArray(String key, Boolean[] defaultValue) {
|
||||
return table.getBooleanArray(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a number array in the table.
|
||||
* @param key the key to be assigned to
|
||||
* @param value the value that will be assigned
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
public boolean putNumberArray(String key, double[] value) {
|
||||
return table.putNumberArray(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a number array in the table.
|
||||
* @param key the key to be assigned to
|
||||
* @param value the value that will be assigned
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
public boolean putNumberArray(String key, Double[] value) {
|
||||
return table.putNumberArray(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
* @param key the key
|
||||
* @param defaultValue the default value to set if key doens't exist.
|
||||
* @return False if the table key exists with a different type
|
||||
*/
|
||||
public boolean setDefaultNumberArray(String key, double[] defaultValue) {
|
||||
return table.setDefaultNumberArray(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
* @param key the key
|
||||
* @param defaultValue the default value to set if key doens't exist.
|
||||
* @return False if the table key exists with a different type
|
||||
*/
|
||||
public boolean setDefaultNumberArray(String key, Double[] defaultValue) {
|
||||
return table.setDefaultNumberArray(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number array the key maps to.
|
||||
* @param key the key to look up
|
||||
* @return the value associated with the given key
|
||||
* @throws TableKeyNotDefinedException if there is no value associated with
|
||||
* the given key
|
||||
* @deprecated This exception-raising method has been replaced by the
|
||||
* default-taking method {@link #getNumberArray(String, double[])}.
|
||||
*/
|
||||
@Deprecated
|
||||
public double[] getNumberArray(String key) throws TableKeyNotDefinedException {
|
||||
return table.getNumberArray(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param key the key to look up
|
||||
* @param defaultValue the value to be returned if no value is found
|
||||
* @return the value associated with the given key or the given default value
|
||||
* if there is no value associated with the key
|
||||
*/
|
||||
public double[] getNumberArray(String key, double[] defaultValue) {
|
||||
return table.getNumberArray(key, 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.
|
||||
* @param key the key to look up
|
||||
* @param defaultValue the value to be returned if no value is found
|
||||
* @return the value associated with the given key or the given default value
|
||||
* if there is no value associated with the key
|
||||
*/
|
||||
public Double[] getNumberArray(String key, Double[] defaultValue) {
|
||||
return table.getNumberArray(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a string array in the table.
|
||||
* @param key the key to be assigned to
|
||||
* @param value the value that will be assigned
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
public boolean putStringArray(String key, String[] value) {
|
||||
return table.putStringArray(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
* @param key the key
|
||||
* @param defaultValue the default value to set if key doens't exist.
|
||||
* @return False if the table key exists with a different type
|
||||
*/
|
||||
public boolean setDefaultStringArray(String key, String[] defaultValue) {
|
||||
return table.setDefaultStringArray(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string array the key maps to.
|
||||
* @param key the key to look up
|
||||
* @return the value associated with the given key
|
||||
* @throws TableKeyNotDefinedException if there is no value associated with
|
||||
* the given key
|
||||
* @deprecated This exception-raising method has been replaced by the
|
||||
* default-taking method {@link #getStringArray(String, String[])}.
|
||||
*/
|
||||
@Deprecated
|
||||
public String[] getStringArray(String key) throws TableKeyNotDefinedException {
|
||||
return table.getStringArray(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param key the key to look up
|
||||
* @param defaultValue the value to be returned if no value is found
|
||||
* @return the value associated with the given key or the given default value
|
||||
* if there is no value associated with the key
|
||||
*/
|
||||
public String[] getStringArray(String key, String[] defaultValue) {
|
||||
return table.getStringArray(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a raw value (byte array) in the table.
|
||||
* @param key the key to be assigned to
|
||||
* @param value the value that will be assigned
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
public boolean putRaw(String key, byte[] value) {
|
||||
return table.putRaw(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a raw value (bytes from a byte buffer) in the table.
|
||||
* @param key the key to be assigned to
|
||||
* @param value the value that will be assigned
|
||||
* @param len the length of the value
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
public boolean putRaw(String key, ByteBuffer value, int len) {
|
||||
return table.putRaw(key, value, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
* @param key the key
|
||||
* @param defaultValue the default value to set if key doens't exist.
|
||||
* @return False if the table key exists with a different type
|
||||
*/
|
||||
public boolean setDefaultRaw(String key, byte[] defaultValue) {
|
||||
return table.setDefaultRaw(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw value (byte array) the key maps to.
|
||||
* @param key the key to look up
|
||||
* @return the value associated with the given key
|
||||
* @throws TableKeyNotDefinedException if there is no value associated with
|
||||
* the given key
|
||||
* @deprecated This exception-raising method has been replaced by the
|
||||
* default-taking method {@link #getRaw(String, byte[])}.
|
||||
*/
|
||||
@Deprecated
|
||||
public byte[] getRaw(String key) throws TableKeyNotDefinedException {
|
||||
return table.getRaw(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param key the key to look up
|
||||
* @param defaultValue the value to be returned if no value is found
|
||||
* @return the value associated with the given key or the given default value
|
||||
* if there is no value associated with the key
|
||||
*/
|
||||
public byte[] getRaw(String key, byte[] defaultValue) {
|
||||
return table.getRaw(key, defaultValue);
|
||||
}
|
||||
|
||||
/*
|
||||
* Deprecated Methods
|
||||
|
||||
Reference in New Issue
Block a user