Alert
- class wpiutil.Alert(*args, **kwargs)
Bases:
pybind11_objectPersistent alert. Alerts are tagged with a type of HIGH, MEDIUM, or LOW 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::util::Alert alert{"Something went wrong", wpi::util::Alert::Level::MEDIUM}; } Robot::periodic() { alert.Set(...); }
Overloaded function.
__init__(self: wpiutil._wpiutil.Alert, id: str, text: str, level: wpiutil._wpiutil.Alert.Level) -> None
Creates a new alert in the default group - “Alerts”.
- Parameters:
text – Text to be displayed when the alert is active.
id – Alert identifier. This should be unique within the group.
level – Alert urgency level.
__init__(self: wpiutil._wpiutil.Alert, group: str, id: str, text: str, level: wpiutil._wpiutil.Alert.Level) -> None
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.
- class Level(value: SupportsInt | SupportsIndex)
Bases:
pybind11_objectRepresents an alert’s level of urgency.
Members:
HIGH : High priority alert - displayed first with a red “X”
symbol. Use this type for problems which will seriously affect the robot’s functionality and thus require immediate attention.
MEDIUM : Medium priority alert - displayed second with a yellow “!” symbol.
Use this type for problems which could affect the robot’s functionality but do not necessarily require immediate attention.
LOW : Low priority alert - displayed last 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.
- HIGH = <Level.HIGH: 0>
- LOW = <Level.LOW: 2>
- MEDIUM = <Level.MEDIUM: 1>
- Alert.Level.name -> str
- property value
- close() None
Destroys the alert
- get() bool
Gets whether the alert is active.
- Returns:
whether the alert is active.
- get_level() wpiutil._wpiutil.Alert.Level
Get the level of this alert.
- Returns:
the level
- get_text() str
Gets the current alert text.
- Returns:
the current text.
- set(active: bool) None
Sets whether the alert should currently be displayed. This method can be safely called periodically.
- Parameters:
active – Whether to display the alert.
- set_text(text: str) None
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.