# Alert
declaration: package: swervelib.telemetry, class: Alert

Package swervelib.telemetry

# Class Alert

java.lang.Object
swervelib.telemetry.Alert

public class Alert extends Object
Class for managing persistent alerts to be sent over NetworkTables.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static enum`
`Alert.AlertType`
Represents an alert's level of urgency.
`private static class`
`Alert.SendableAlerts`
Sendable alert for advantage scope.

## Field Summary

Fields
Modifier and Type
Field
Description
`private boolean`
`active`
Activation state of alert.
`private double`
`activeStartTime`
When the alert was raised.
`private static Map<String,Alert.SendableAlerts>`
`groups`
Group of the alert.
`private String`
`text`
Text of the alert.
`private final Alert.AlertType`
`type`
Type of the Alert to raise.

## Constructor Summary

Constructors
Constructor
Description
`Alert(String group, String text, Alert.AlertType type)`
Creates a new Alert.
`Alert(String text, Alert.AlertType type)`
Creates a new Alert in the default group - "Alerts".

## Method Summary

Modifier and Type
Method
Description
`private void`
`printAlert(String text)`
Print the alert message.
`void`
`set(boolean active)`
Sets whether the alert should currently be displayed.
`void`
`setText(String text)`
Updates current alert text.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### groups

private static Map<String,Alert.SendableAlerts> groups
Group of the alert.

### type

private final Alert.AlertType type
Type of the Alert to raise.

### active

private boolean active
Activation state of alert.

### activeStartTime

private double activeStartTime
When the alert was raised.

### text

private String text
Text of the alert.

## Constructor Details

### Alert

public Alert(String text, Alert.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:
  `text` - Text to be displayed when the alert is active.
  `type` - Alert level specifying urgency.

### Alert

public Alert(String group, String text, Alert.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:
  `group` - Group identifier, also used as NetworkTables title
  `text` - Text to be displayed when the alert is active.
  `type` - Alert level specifying urgency.

## Method Details

### set

public void set(boolean active)
Sets whether the alert should currently be displayed. When activated, the alert text will also be sent to the console.

Parameters:
  `active` - Set the alert as active and report it to the driver station.

### setText

public void setText(String text)
Updates current alert text.

Parameters:
  `text` - The text for the alert.

### printAlert

private void printAlert(String text)
Print the alert message.

Parameters:
  `text` - Text to print.