Package org.hyperonline.hyperlib
Class PeriodicScheduler
- java.lang.Object
-
- org.hyperonline.hyperlib.PeriodicScheduler
-
public class PeriodicScheduler extends java.lang.Object
ThePeriodicScheduler
class allows one to easily add tasks to run periodically in every mode except test mode. For example, one can add methods to report information to the driver station, or to check if preferences have been changed. This class should be thread-safe, provided it is OK to run all events from the main thread.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEvent(java.lang.Runnable event)
Add an event to the list of events.void
clear()
Remove all scheduled tasks.static PeriodicScheduler
getInstance()
Return the single instance ofPeriodicScheduler
.void
run()
Run all of the events which have been added to the scheduler.
-
-
-
Method Detail
-
getInstance
public static PeriodicScheduler getInstance()
Return the single instance ofPeriodicScheduler
. It is safe to call this method from any thread.- Returns:
- The single instance of
PeriodicScheduler
-
addEvent
public void addEvent(java.lang.Runnable event)
Add an event to the list of events. This event will run once every timerun()
is called. If usingHYPERRobot
, this happens once every autonomousPeriodic, teleopPeriodic, and disabledPeriodic. As of hyperLib 0.3.1, it is safe to call this from within an event, and to call it from any thread.- Parameters:
event
- ARunnable
object representing the task to run
-
clear
public void clear()
Remove all scheduled tasks. This is mainly useful for testing.
-
run
public void run()
Run all of the events which have been added to the scheduler. If you are usingHYPERRobot
, you do not need to call this manually.
-
-