CommandGroup Class Reference
#include <CommandGroup.h>


Public Member Functions | |
| CommandGroup () | |
| CommandGroup (const char *name) | |
| void | AddSequential (Command *command) |
| void | AddSequential (Command *command, double timeout) |
| void | AddParallel (Command *command) |
| void | AddParallel (Command *command, double timeout) |
| bool | IsInterruptible () |
| int | GetSize () |
Protected Member Functions | |
| virtual void | Initialize () |
| virtual void | Execute () |
| virtual bool | IsFinished () |
| virtual void | End () |
| virtual void | Interrupted () |
| virtual void | _Initialize () |
| virtual void | _Interrupted () |
| virtual void | _Execute () |
| virtual void | _End () |
Detailed Description
A CommandGroup is a list of commands which are executed in sequence.
Commands in a CommandGroup are added using the AddSequential(...) method and are called sequentially. CommandGroups are themselves Commands and can be given to other CommandGroups.
CommandGroups will carry all of the requirements of their subcommands. Additional requirements can be specified by calling Requires(...) normally in the constructor.
CommandGroups can also execute commands in parallel, simply by adding them using AddParallel(...).
Definition at line 33 of file CommandGroup.h.
Constructor & Destructor Documentation
| CommandGroup::CommandGroup | ( | ) |
Creates a new CommandGroup.
Definition at line 13 of file CommandGroup.cpp.
| CommandGroup::CommandGroup | ( | const char * | name | ) |
Creates a new CommandGroup with the given name.
- Parameters:
-
name the name for this command group
Definition at line 22 of file CommandGroup.cpp.
Member Function Documentation
| void CommandGroup::AddParallel | ( | Command * | command, | |
| double | timeout | |||
| ) |
Adds a new child Command to the group with the given timeout. The Command will be started after all the previously added Commands.
Once the Command is started, it will run until it finishes, is interrupted, or the time expires, whichever is sooner. Note that the given Command will have no knowledge that it is on a timer.
Instead of waiting for the child to finish, a CommandGroup will have it run at the same time as the subsequent Commands. The child will run until either it finishes, the timeout expires, a new child with conflicting requirements is started, or the main sequence runs a Command with conflicting requirements. In the latter two cases, the child will be canceled even if it says it can't be interrupted.
Note that any requirements the given Command has will be added to the group. For this reason, a Command's requirements can not be changed after being added to a group.
It is recommended that this method be called in the constructor.
- Parameters:
-
command The command to be added timeout The timeout (in seconds)
Definition at line 169 of file CommandGroup.cpp.
| void CommandGroup::AddParallel | ( | Command * | command | ) |
Adds a new child Command to the group. The Command will be started after all the previously added Commands.
Instead of waiting for the child to finish, a CommandGroup will have it run at the same time as the subsequent Commands. The child will run until either it finishes, a new child with conflicting requirements is started, or the main sequence runs a Command with conflicting requirements. In the latter two cases, the child will be canceled even if it says it can't be interrupted.
Note that any requirements the given Command has will be added to the group. For this reason, a Command's requirements can not be changed after being added to a group.
It is recommended that this method be called in the constructor.
- Parameters:
-
command The command to be added
Definition at line 125 of file CommandGroup.cpp.
| void CommandGroup::AddSequential | ( | Command * | command, | |
| double | timeout | |||
| ) |
Adds a new Command to the group with a given timeout. The Command will be started after all the previously added commands.
Once the Command is started, it will be run until it finishes or the time expires, whichever is sooner. Note that the given Command will have no knowledge that it is on a timer.
Note that any requirements the given Command has will be added to the group. For this reason, a Command's requirements can not be changed after being added to a group.
It is recommended that this method be called in the constructor.
- Parameters:
-
command The Command to be added timeout The timeout (in seconds)
Definition at line 81 of file CommandGroup.cpp.
| void CommandGroup::AddSequential | ( | Command * | command | ) |
Adds a new Command to the group. The Command will be started after all the previously added Commands.
Note that any requirements the given Command has will be added to the group. For this reason, a Command's requirements can not be changed after being added to a group.
It is recommended that this method be called in the constructor.
- Parameters:
-
command The Command to be added
Definition at line 44 of file CommandGroup.cpp.
| void CommandGroup::End | ( | ) | [protected, virtual] |
Called when the command ended peacefully. This is where you may want to wrap up loose ends, like shutting off a motor that was being used in the command.
Implements Command.
Definition at line 318 of file CommandGroup.cpp.
| void CommandGroup::Execute | ( | ) | [protected, virtual] |
The execute method is called repeatedly until this Command either finishes or is canceled.
Implements Command.
Definition at line 313 of file CommandGroup.cpp.
| void CommandGroup::Initialize | ( | ) | [protected, virtual] |
The initialize method is called the first time this Command is run after being started.
Implements Command.
Definition at line 308 of file CommandGroup.cpp.
| void CommandGroup::Interrupted | ( | ) | [protected, virtual] |
Called when the command ends because somebody called cancel() or another command shared the same requirements as this one, and booted it out.
This is where you may want to wrap up loose ends, like shutting off a motor that was being used in the command.
Generally, it is useful to simply call the end() method within this method
Implements Command.
Definition at line 323 of file CommandGroup.cpp.
| bool CommandGroup::IsFinished | ( | ) | [protected, virtual] |
Returns whether this command is finished. If it is, then the command will be removed and end() will be called.
It may be useful for a team to reference the isTimedOut() method for time-sensitive commands.
- Returns:
- whether this command is finished.
- See also:
- Command::isTimedOut() isTimedOut()
Implements Command.
Definition at line 327 of file CommandGroup.cpp.
| bool CommandGroup::IsInterruptible | ( | ) |
Returns whether or not this command can be interrupted.
- Returns:
- whether or not this command can be interrupted
Reimplemented from Command.
Definition at line 332 of file CommandGroup.cpp.
The documentation for this class was generated from the following files:
Generated on Thu Jan 12 2012 22:35:29 for WPILibC++ by
1.7.1