WPILibC++ 2025.1.1
|
Persistent alert to be sent via NetworkTables. More...
#include <frc/Alert.h>
Public Types | |
enum class | AlertType { kError , kWarning , kInfo } |
Represents an alert's level of urgency. More... | |
Public Member Functions | |
Alert (std::string_view text, AlertType type) | |
Creates a new alert in the default group - "Alerts". | |
Alert (std::string_view group, std::string_view text, AlertType type) | |
Creates a new alert. | |
Alert (Alert &&) | |
Alert & | operator= (Alert &&) |
Alert (const Alert &)=default | |
Alert & | operator= (const Alert &)=default |
~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. | |
AlertType | GetType () const |
Get the type of this alert. | |
Persistent alert to be sent via NetworkTables.
Alerts are tagged with a type of kError, kWarning, or kInfo to denote urgency. See Alert::AlertType 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.
This API is new for 2025, but is likely to change in future seasons to facilitate deeper integration with the robot control system.
class Robot { frc::Alert alert{"Something went wrong", frc::Alert::AlertType::kWarning}; } Robot::periodic() { alert.Set(...); }
|
strong |
Represents an alert's level of urgency.
frc::Alert::Alert | ( | std::string_view | text, |
AlertType | type ) |
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. |
type | Alert urgency level. |
frc::Alert::Alert | ( | std::string_view | group, |
std::string_view | text, | ||
AlertType | type ) |
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. |
type | Alert urgency level. |
frc::Alert::Alert | ( | Alert && | ) |
|
default |
frc::Alert::~Alert | ( | ) |
|
inline |
Gets whether the alert is active.
|
inline |
Gets the current alert text.
|
inline |
Get the type of this alert.
void frc::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 frc::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. |