Class NotifierJNI

java.lang.Object
org.wpilib.hardware.hal.JNIWrapper
org.wpilib.hardware.hal.NotifierJNI

public class NotifierJNI extends JNIWrapper
The NotifierJNI class directly wraps the C++ HAL Notifier.

This class is not meant for direct use by teams. Instead, the org.wpilib.system.Notifier class, which corresponds to the C++ Notifier class, should be used.

See Also:
  • "wpi/hal/Notifier.h"
  • Method Details

    • createNotifier

      public static int createNotifier()
      Creates a notifier.

      A notifier is an timer that alarms at an initial and (optionally) repeated intervals. This can be used to make precise control loops.

      Returns:
      the created notifier
      See Also:
      • "HAL_CreateNotifier"
    • setHALThreadPriority

      public static boolean setHALThreadPriority(boolean realTime, int priority)
      Sets the HAL notifier thread priority.

      The HAL notifier thread is responsible for managing the system's notifier interrupt and waking up user's Notifiers when it's their time to run. Giving the HAL notifier thread real-time priority helps ensure the user's real-time Notifiers, if any, are notified to run in a timely manner.

      Parameters:
      realTime - Set to true to set a real-time priority, false for standard priority.
      priority - Priority to set the thread to. For real-time, this is 1-99 with 99 being highest. For non-real-time, this is forced to 0. See "man 7 sched" for more details.
      Returns:
      True on success.
      See Also:
      • "HAL_SetNotifierThreadPriority"
    • setNotifierName

      public static void setNotifierName(int notifierHandle, String name)
      Sets the name of the notifier.
      Parameters:
      notifierHandle - Notifier handle.
      name - Notifier name.
      See Also:
      • "HAL_SetNotifierName"
    • destroyNotifier

      public static void destroyNotifier(int notifierHandle)
      Destroys a notifier.

      Destruction wakes up any waiters.

      Parameters:
      notifierHandle - the notifier handle
      See Also:
      • "HAL_DestroyNotifier"
    • setNotifierAlarm

      public static void setNotifierAlarm(int notifierHandle, long alarmTime, long intervalTime, boolean absolute, boolean ack)
      Updates the initial and interval alarm times for a notifier.

      The alarmTime is an absolute time (using the WPI now() time base) if absolute is true, or relative to the current time if absolute is false.

      If intervalTime is non-zero, the notifier will alarm periodically following alarmTime at the given interval.

      If an absolute alarmTime is in the past, the notifier will alarm immediately.

      Parameters:
      notifierHandle - the notifier handle
      alarmTime - the first alarm time (in microseconds)
      intervalTime - the periodic interval time (in microseconds)
      absolute - true if the alarm time is absolute
      ack - true to acknowledge any prior alarm
      See Also:
      • "HAL_SetNotifierAlarm"
    • cancelNotifierAlarm

      public static void cancelNotifierAlarm(int notifierHandle, boolean ack)
      Cancels all future notifier alarms for a notifier.
      Parameters:
      notifierHandle - the notifier handle
      ack - true to acknowledge any prior alarm
      See Also:
      • "HAL_CancelNotifierAlarm"
    • acknowledgeNotifierAlarm

      public static void acknowledgeNotifierAlarm(int notifierHandle)
      Indicates the notifier alarm has been serviced. Makes no change to future alarms.

      One of setNotifierAlarm (with ack=true), cancelNotifierAlarm (with ack=true), or this function must be called before waiting for the next alarm.

      Parameters:
      notifierHandle - the notifier handle
      See Also:
      • "HAL_AcknowledgeNotifierAlarm"
    • getNotifierOverrun

      public static int getNotifierOverrun(int notifierHandle)
      Gets the overrun count for a notifier.

      An overrun occurs when a notifier's alarm is not serviced before the next scheduled alarm time.

      Parameters:
      notifierHandle - the notifier handle
      Returns:
      overrun count