WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
frc::Alert Class Reference

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 &&)
 
Alertoperator= (Alert &&)
 
 Alert (const Alert &)=default
 
Alertoperator= (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.
 

Detailed Description

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(...);
}

Member Enumeration Documentation

◆ AlertType

enum class frc::Alert::AlertType
strong

Represents an alert's level of urgency.

Enumerator
kError 

High priority alert - displayed first on the dashboard with a red "X" symbol.

Use this type for problems which will seriously affect the robot's functionality and thus require immediate attention.

kWarning 

Medium priority alert - displayed second on the dashboard with a yellow "!" symbol.

Use this type for problems which could affect the robot's functionality but do not necessarily require immediate attention.

kInfo 

Low priority alert - displayed last on the dashboard with a green "i" symbol.

Use this type for problems which are unlikely to affect the robot's functionality, or any other alerts which do not fall under the other categories.

Constructor & Destructor Documentation

◆ Alert() [1/4]

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.

Parameters
textText to be displayed when the alert is active.
typeAlert urgency level.

◆ Alert() [2/4]

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.

Parameters
groupGroup identifier, used as the entry name in NetworkTables.
textText to be displayed when the alert is active.
typeAlert urgency level.

◆ Alert() [3/4]

frc::Alert::Alert ( Alert && )

◆ Alert() [4/4]

frc::Alert::Alert ( const Alert & )
default

◆ ~Alert()

frc::Alert::~Alert ( )

Member Function Documentation

◆ Get()

bool frc::Alert::Get ( ) const
inline

Gets whether the alert is active.

Returns
whether the alert is active.

◆ GetText()

std::string frc::Alert::GetText ( ) const
inline

Gets the current alert text.

Returns
the current text.

◆ GetType()

AlertType frc::Alert::GetType ( ) const
inline

Get the type of this alert.

Returns
the type

◆ operator=() [1/2]

Alert & frc::Alert::operator= ( Alert && )

◆ operator=() [2/2]

Alert & frc::Alert::operator= ( const Alert & )
default

◆ Set()

void frc::Alert::Set ( bool active)

Sets whether the alert should currently be displayed.

This method can be safely called periodically.

Parameters
activeWhether to display the alert.

◆ SetText()

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.

Parameters
textText to be displayed when the alert is active.

The documentation for this class was generated from the following file: