public class Scheduler extends java.lang.Object implements NamedSendable
Scheduler
is a singleton which holds the top-level running commands. It is in charge
of both calling the command's run()
method and to make sure that there are
no two commands with conflicting requirements running.
It is fine if teams wish to take control of the Scheduler
themselves, all that needs
to be done is to call Scheduler.getInstance()
.run()
often to have Commands
function correctly. However, this
is already done for you if you use the CommandBased Robot template.
Command
Modifier and Type | Method and Description |
---|---|
void |
add(Command command)
Adds the command to the
Scheduler . |
void |
addButton(Trigger.ButtonScheduler button)
Adds a button to the
Scheduler . |
void |
disable()
Disable the command scheduler.
|
void |
enable()
Enable the command scheduler.
|
static Scheduler |
getInstance()
Returns the
Scheduler , creating it if one does not exist. |
java.lang.String |
getName()
The name of the subtable.
|
java.lang.String |
getSmartDashboardType()
The string representation of the named data type that will be used by the smart dashboard for
this
Sendable . |
ITable |
getTable()
The table that is associated with this
Sendable . |
java.lang.String |
getType() |
void |
initTable(ITable subtable)
Initializes a table for this
Sendable object. |
void |
removeAll()
Removes all commands.
|
void |
run()
Runs a single iteration of the loop.
|
public static Scheduler getInstance()
Scheduler
, creating it if one does not exist.Scheduler
public void add(Command command)
Scheduler
. This will not add the Command
immediately,
but will instead wait for the proper time in the run()
loop before doing so.
The command returns immediately and does nothing if given null.
Adding a Command
to the Scheduler
involves the Scheduler
removing
any Command
which has shared requirements.
command
- the command to addpublic void addButton(Trigger.ButtonScheduler button)
button
- the button to addpublic void run()
Command
system. The loop has five stages:
public void removeAll()
public void disable()
public void enable()
public java.lang.String getName()
NamedSendable
getName
in interface NamedSendable
public java.lang.String getType()
public void initTable(ITable subtable)
Sendable
Sendable
object.public ITable getTable()
Sendable
Sendable
.public java.lang.String getSmartDashboardType()
Sendable
Sendable
.getSmartDashboardType
in interface Sendable
Sendable
.