Class Alert
java.lang.Object
org.wpilib.driverstation.Alert
- All Implemented Interfaces:
AutoCloseable
Persistent alert to be sent via NetworkTables. Alerts are tagged with a type of
ERROR,
WARNING, or INFO to denote urgency. See Level for suggested usage of each type. Alerts can be
displayed on supported dashboards, and are shown in a priority order based on type and recency of
activation, with newly activated alerts first.
Alerts should be created once and stored persistently, then updated to "active" or "inactive"
as necessary. set(boolean) can be safely called periodically.
class Robot {
Alert alert = new Alert("Something went wrong", Alert.Level.WARNING);
periodic() {
alert.set(...);
}
}
Alternatively, alerts which are only used once at startup can be created and activated inline.
public Robot() {
new Alert("Failed to load auto paths", Alert.Level.ERROR).set(true);
}
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionAlert(String group, String text, Alert.Level type) Creates a new alert.Alert(String text, Alert.Level type) Creates a new alert in the default group - "Alerts". -
Method Summary
-
Constructor Details
-
Alert
Creates a new alert in the default group - "Alerts". If this is the first to be instantiated, the appropriate entries will be added to NetworkTables.- Parameters:
text- Text to be displayed when the alert is active.type- Alert urgency level.
-
Alert
Creates a new alert. If this is the first to be instantiated in its group, the appropriate entries will be added to NetworkTables.- Parameters:
group- Group identifier, used as the entry name in NetworkTables.text- Text to be displayed when the alert is active.type- Alert urgency level.
-
-
Method Details
-
set
Sets whether the alert should currently be displayed. This method can be safely called periodically.- Parameters:
active- Whether to display the alert.
-
get
-
setText
-
getText
-
getType
-
close
- Specified by:
closein interfaceAutoCloseable
-