Class Alert
java.lang.Object
org.wpilib.util.Alert
- All Implemented Interfaces:
AutoCloseable
Persistent alert. Alerts are tagged with a type of
HIGH, MEDIUM, or LOW
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("somethingWrong", "Something went wrong", Alert.Level.MEDIUM);
periodic() {
alert.set(...);
}
}
Alternatively, alerts which are only used once at startup can be created and activated inline.
public Robot() {
new Alert("autoPathsFailed", "Failed to load auto paths", Alert.Level.HIGH).set(true);
}
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionAlert(String group, String id, String text, Alert.Level level) Creates a new alert.Alert(String id, String text, Alert.Level level) Creates a new alert in the default group - "Alerts". -
Method Summary
-
Constructor Details
-
Alert
Creates a new alert in the default group - "Alerts".- Parameters:
id- Alert identifier. This should be unique within the group.text- Text to be displayed when the alert is active.level- Alert urgency level.
-
Alert
Creates a new alert.- Parameters:
group- Group identifier.id- Alert identifier. This should be unique within the group.text- Text to be displayed when the alert is active.level- Alert urgency level.
-
-
Method Details
-
set
public void set(boolean active) Sets whether the alert should currently be displayed. This method can be safely called periodically.- Parameters:
active- Whether to display the alert.
-
get
public boolean get()Gets whether the alert is active.- Returns:
- whether the alert is active.
-
setText
Updates current alert text. Use this method to dynamically change the displayed alert, such as including more details about the detected problem.- Parameters:
text- Text to be displayed when the alert is active.
-
getText
-
getLevel
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-