mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
Fixed a few simple SmartDashboard FIXMEs and TODOs
SmartDashboard does usage reporting now (or will when it's implemented in the HAL). Global errors are raised in C++ when problems happen, since there is no SmartDashboard instance. Previously, no error reporting was done at all. GetData was uncommented. Change-Id: I3331eb9f09924d1d0028e3fa041f0cf68caa5cf5
This commit is contained in:
@@ -2,7 +2,7 @@ package edu.wpi.first.wpilibj;
|
||||
|
||||
/**
|
||||
* Support for high level usage reporting.
|
||||
*
|
||||
*
|
||||
* @author alex
|
||||
*/
|
||||
public class HLUsageReporting {
|
||||
@@ -11,21 +11,28 @@ public class HLUsageReporting {
|
||||
public static void SetImplementation(Interface i) {
|
||||
impl = i;
|
||||
}
|
||||
|
||||
|
||||
public static void reportScheduler() {
|
||||
if (impl != null) {
|
||||
if (impl != null) {
|
||||
impl.reportScheduler();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void reportPIDController(int num) {
|
||||
if (impl != null) {
|
||||
if (impl != null) {
|
||||
impl.reportPIDController(num);
|
||||
}
|
||||
}
|
||||
|
||||
public static void reportSmartDashboard() {
|
||||
if(impl != null) {
|
||||
impl.reportSmartDashboard();
|
||||
}
|
||||
}
|
||||
|
||||
public interface Interface {
|
||||
void reportScheduler();
|
||||
void reportPIDController(int num);
|
||||
void reportSmartDashboard();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import edu.wpi.first.wpilibj.networktables.NetworkTable;
|
||||
import edu.wpi.first.wpilibj.networktables.NetworkTableKeyNotDefined;
|
||||
import edu.wpi.first.wpilibj.tables.ITable;
|
||||
import edu.wpi.first.wpilibj.tables.TableKeyNotDefinedException;
|
||||
import edu.wpi.first.wpilibj.HLUsageReporting;
|
||||
import java.util.Hashtable;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
@@ -26,7 +27,6 @@ import java.util.NoSuchElementException;
|
||||
* @author Joe Grinstead
|
||||
*/
|
||||
public class SmartDashboard {
|
||||
//TODO usage reporting
|
||||
/** The {@link NetworkTable} used by {@link SmartDashboard} */
|
||||
private static final NetworkTable table = NetworkTable.getTable("SmartDashboard");
|
||||
/**
|
||||
@@ -35,6 +35,10 @@ public class SmartDashboard {
|
||||
*/
|
||||
private static final Hashtable tablesToData = new Hashtable();
|
||||
|
||||
static {
|
||||
HLUsageReporting.reportSmartDashboard();
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps the specified key to the specified value in this table.
|
||||
* The key can not be null.
|
||||
@@ -71,15 +75,15 @@ public class SmartDashboard {
|
||||
* @throws IllegalArgumentException if the value mapped to by the key is not a {@link SmartDashboardData}
|
||||
* @throws IllegalArgumentException if the key is null
|
||||
*/
|
||||
//TODO public static SmartDashboardData getData(String key) {
|
||||
// NetworkTable subtable = table.getSubTable(key);
|
||||
// Object data = tablesToData.get(subtable);
|
||||
// if (data == null) {
|
||||
// throw new IllegalArgumentException("Value at \"" + key + "\" is not a boolean");
|
||||
// } else {
|
||||
// return (SmartDashboardData) data;
|
||||
// }
|
||||
// }
|
||||
public static Sendable getData(String key) {
|
||||
ITable subtable = table.getSubTable(key);
|
||||
Object data = tablesToData.get(subtable);
|
||||
if (data == null) {
|
||||
throw new IllegalArgumentException("SmartDashboard data does not exist: " + key);
|
||||
} else {
|
||||
return (Sendable) data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps the specified key to the specified value in this table.
|
||||
|
||||
Reference in New Issue
Block a user