Class Notifier
java.lang.Object
org.wpilib.system.Notifier
- All Implemented Interfaces:
AutoCloseable
Notifiers run a user-provided callback function on a separate thread.
If startSingle() is used, the callback will run once. If startPeriodic() is used, the callback will run repeatedly with the given period until stop() is called.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidsetCallback(Runnable callback) Change the callback function.voidSets the name of the notifier.voidstartPeriodic(double period) Run the callback periodically with the given period.voidstartPeriodic(Frequency frequency) Run the callback periodically with the given frequency.voidstartPeriodic(Time period) Run the callback periodically with the given period.voidstartSingle(double delay) Run the callback once after the given delay.voidstartSingle(Time delay) Run the callback once after the given delay.voidstop()Stop further callback invocations.
-
Constructor Details
-
Notifier
Create a Notifier with the given callback.Configure when the callback runs with startSingle() or startPeriodic().
- Parameters:
callback- The callback to run.
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
setName
Sets the name of the notifier. Used for debugging purposes only.- Parameters:
name- Name
-
setCallback
Change the callback function.- Parameters:
callback- The callback function.
-
startSingle
public void startSingle(double delay) Run the callback once after the given delay.- Parameters:
delay- Time in seconds to wait before the callback is called.
-
startSingle
Run the callback once after the given delay.- Parameters:
delay- Time to wait before the callback is called.
-
startPeriodic
public void startPeriodic(double period) Run the callback periodically with the given period.The user-provided callback should be written so that it completes before the next time it's scheduled to run.
- Parameters:
period- Period in seconds after which to call the callback starting one period after the call to this method.
-
startPeriodic
Run the callback periodically with the given period.The user-provided callback should be written so that it completes before the next time it's scheduled to run.
- Parameters:
period- Period after which to call the callback starting one period after the call to this method.
-
startPeriodic
Run the callback periodically with the given frequency.The user-provided callback should be written so that it completes before the next time it's scheduled to run.
- Parameters:
frequency- Frequency at which to call the callback, starting one period after the call to this method.
-
stop
public void stop()Stop further callback invocations.No further periodic callbacks will occur. Single invocations will also be cancelled if they haven't yet occurred.
-