I have a couple of questions regarding how command groups are processed.
As an example, lets assume that I want to:
- Run CommandA first and wait for it to complete.
- Then run CommandB and CommandC at the same time.
- After CommandB and CommandC complete I then want to run CommandD.
I'm assuming the following would generate this sequence:
Code:
public static Command buildMyCommand() {
CommandGroup bc = new CommandGroup();
bc.addParallel(new CommandB());
bc.addParallel(new CommandC());
CommandGroup cmd = new CommandGroup();
cmd.addSequential(new CommandA());
cmd.addSequential(bc);
cmd.addSequential(new CommandD());
return cmd;
}
From my understanding of how addParallel() and addSequential() work, the above could also be written as:
Code:
public static Command buildMyCommand() {
CommandGroup cmd = new CommandGroup();
cmd.addSequential(new CommandA());
// Start of first command to run in parallel
cmd.addParallel(new CommandB());
// End of commands to run in parallel (runs in parallel with CommandB)
cmd.addSequential(new CommandC());
cmd.addSequential(new CommandD());
return cmd;
}
So, my first question is: Would the two versions of buildMyCommand() shown above produce the same results when run?
My next questions have to do with what happens to a command group when things don't complete nicely:
- If CommandA from the example command group above was interrupted, would the entire command group be interrupted? For example, let's assume CommandA was waiting for something to move into position and CommandB performed a firing action. If CommandA was interrupted, would CommandB still run, or would the interruption stop CommandB from ever being run?
- Secondly, Assume CommandA has used the setTimeout() method or was added to the group with a timeout option to indicate that it has 2 seconds to complete. If the timeout is reached, will the rest of the commands complete in the sequence?
Thanks,
Paul