001// Copyright (c) FIRST and other WPILib contributors. 002// Open Source Software; you can modify and/or share it under the terms of 003// the WPILib BSD license file in the root directory of this project. 004 005package org.wpilib.hardware.hal; 006 007/** 008 * The AlertJNI class directly wraps the C++ HAL Alert. 009 * 010 * <p>This class is not meant for direct use by teams. Instead, the org.wpilib.driverstation.Alert 011 * class, which corresponds to the C++ Alert class, should be used. 012 * 013 * @see "wpi/hal/Alert.h" 014 */ 015public class AlertJNI extends JNIWrapper { 016 /** 017 * High priority alert - displayed first with a red "X" symbol. Use this type for problems which 018 * will seriously affect the robot's functionality and thus require immediate attention. 019 */ 020 public static final int LEVEL_HIGH = 0; 021 022 /** 023 * Medium priority alert - displayed second with a yellow "!" symbol. Use this type for problems 024 * which could affect the robot's functionality but do not necessarily require immediate 025 * attention. 026 */ 027 public static final int LEVEL_MEDIUM = 1; 028 029 /** 030 * Low priority alert - displayed last with a green "i" symbol. Use this type for problems which 031 * are unlikely to affect the robot's functionality, or any other alerts which do not fall under 032 * the other categories. 033 */ 034 public static final int LEVEL_LOW = 2; 035 036 /** 037 * Creates an alert. 038 * 039 * @param group Group identifier 040 * @param text Text to be displayed when the alert is active 041 * @param level Alert urgency level (LEVEL_HIGH, LEVEL_MEDIUM, LEVEL_LOW) 042 * @return the created alert handle 043 * @see "HAL_CreateAlert" 044 */ 045 public static native int createAlert(String group, String text, int level); 046 047 /** 048 * Destroys an alert. 049 * 050 * @param alertHandle the alert handle 051 * @see "HAL_DestroyAlert" 052 */ 053 public static native void destroyAlert(int alertHandle); 054 055 /** 056 * Sets whether the alert should be displayed. This method can be safely be called periodically. 057 * 058 * @param alertHandle the alert handle 059 * @param active true to display the alert, false to hide it 060 * @see "HAL_SetAlertActive" 061 */ 062 public static native void setAlertActive(int alertHandle, boolean active); 063 064 /** 065 * Checks if an alert is active. 066 * 067 * @param alertHandle the alert handle 068 * @return true if the alert is active 069 * @see "HAL_IsAlertActive" 070 */ 071 public static native boolean isAlertActive(int alertHandle); 072 073 /** 074 * Sets the text of the alert. Use this method to dynamically change the displayed alert, such as 075 * including more details about the detected problem. 076 * 077 * @param alertHandle Alert handle. 078 * @param text new text to be displayed when the alert is active 079 * @see "HAL_SetAlertText" 080 */ 081 public static native void setAlertText(int alertHandle, String text); 082 083 /** 084 * Gets the text of the alert. 085 * 086 * @param alertHandle Alert handle. 087 * @return the text displayed when the alert is active 088 * @see "HAL_GetAlertText" 089 */ 090 public static native String getAlertText(int alertHandle); 091 092 /** Utility class. */ 093 private AlertJNI() {} 094}