![]() |
WPILibC++ 2027.0.0-alpha-4
|
Persistent alert to be sent to the driver station. More...
#include <wpi/driverstation/Alert.hpp>
Public Types | |
| enum class | Level { HIGH = HAL_ALERT_HIGH , ERROR = HIGH , MEDIUM = HAL_ALERT_MEDIUM , WARNING = MEDIUM , LOW = HAL_ALERT_LOW , INFO = LOW } |
| Represents an alert's level of urgency. More... | |
Public Member Functions | |
| Alert (std::string_view text, Level level) | |
| Creates a new alert in the default group - "Alerts". | |
| Alert (std::string_view group, std::string_view text, Level level) | |
| Creates a new alert. | |
| void | Set (bool active) |
| Sets whether the alert should currently be displayed. | |
| bool | Get () const |
| Gets whether the alert is active. | |
| void | SetText (std::string_view text) |
| Updates current alert text. | |
| std::string | GetText () const |
| Gets the current alert text. | |
| Level | GetType () const |
| Get the type of this alert. | |
Persistent alert to be sent to the driver station.
Alerts are tagged with a type of HIGH/ERROR, MEDIUM/WARNING, or LOW/INFO to denote urgency. See Alert::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(bool) can be safely called periodically.
class Robot {
wpi::Alert alert{"Something went wrong", wpi::Alert::Level::WARNING};
}
Robot::periodic() {
alert.Set(...);
}
|
strong |
Represents an alert's level of urgency.
| wpi::Alert::Alert | ( | std::string_view | text, |
| Level | level ) |
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.
| text | Text to be displayed when the alert is active. |
| level | Alert urgency level. |
| wpi::Alert::Alert | ( | std::string_view | group, |
| std::string_view | text, | ||
| Level | level ) |
Creates a new alert.
If this is the first to be instantiated in its group, the appropriate entries will be added to NetworkTables.
| group | Group identifier, used as the entry name in NetworkTables. |
| text | Text to be displayed when the alert is active. |
| level | Alert urgency level. |
| bool wpi::Alert::Get | ( | ) | const |
Gets whether the alert is active.
| std::string wpi::Alert::GetText | ( | ) | const |
Gets the current alert text.
|
inline |
Get the type of this alert.
| void wpi::Alert::Set | ( | bool | active | ) |
Sets whether the alert should currently be displayed.
This method can be safely called periodically.
| active | Whether to display the alert. |
| void wpi::Alert::SetText | ( | std::string_view | text | ) |
Updates current alert text.
Use this method to dynamically change the displayed alert, such as including more details about the detected problem.
| text | Text to be displayed when the alert is active. |