public void run() {
final ASubsystem subsystem = new ASubsystem();
TestCommand command1 = new TestCommand() {
{
requires(subsystem);
}
};
TestCommand command2 = new TestCommand() {
{
requires(subsystem);
}
};
TestCommand command3 = new TestCommand() {
{
requires(subsystem);
}
};
CommandGroup commandGroup = new CommandGroup();
commandGroup.addSequential(command1);
commandGroup.addSequential(command2);
commandGroup.addSequential(command3);
assertCommandState(command1, 0, 0, 0, 0, 0);
assertCommandState(command2, 0, 0, 0, 0, 0);
assertCommandState(command3, 0, 0, 0, 0, 0);
commandGroup.start();
assertCommandState(command1, 0, 0, 0, 0, 0);
assertCommandState(command2, 0, 0, 0, 0, 0);
assertCommandState(command3, 0, 0, 0, 0, 0);
Scheduler.getInstance().run();
assertCommandState(command1, 0, 0, 0, 0, 0);
assertCommandState(command2, 0, 0, 0, 0, 0);
assertCommandState(command3, 0, 0, 0, 0, 0);
Scheduler.getInstance().run();
assertCommandState(command1, 1, 1, 1, 0, 0);
assertCommandState(command2, 0, 0, 0, 0, 0);
assertCommandState(command3, 0, 0, 0, 0, 0);
command1.setHasFinished(true);
assertCommandState(command1, 1, 1, 1, 0, 0);
assertCommandState(command2, 0, 0, 0, 0, 0);
assertCommandState(command3, 0, 0, 0, 0, 0);
Scheduler.getInstance().run();
assertCommandState(command1, 1, 2, 2, 1, 0);
assertCommandState(command2, 1, 1, 1, 0, 0);
assertCommandState(command3, 0, 0, 0, 0, 0);
command2.setHasFinished(true);
assertCommandState(command1, 1, 2, 2, 1, 0);
assertCommandState(command2, 1, 1, 1, 0, 0);
assertCommandState(command3, 0, 0, 0, 0, 0);
Scheduler.getInstance().run();
assertCommandState(command1, 1, 2, 2, 1, 0);
assertCommandState(command2, 1, 2, 2, 1, 0);
assertCommandState(command3, 1, 1, 1, 0, 0);
command3.setHasFinished(true);
assertCommandState(command1, 1, 2, 2, 1, 0);
assertCommandState(command2, 1, 2, 2, 1, 0);
assertCommandState(command3, 1, 1, 1, 0, 0);
Scheduler.getInstance().run();
assertCommandState(command1, 1, 2, 2, 1, 0);
assertCommandState(command2, 1, 2, 2, 1, 0);
assertCommandState(command3, 1, 2, 2, 1, 0);
Scheduler.getInstance().run();
assertCommandState(command1, 1, 2, 2, 1, 0);
assertCommandState(command2, 1, 2, 2, 1, 0);
assertCommandState(command3, 1, 2, 2, 1, 0);
}
CommandSequentialGroupTest.java 文件源码
java
阅读 15
收藏 0
点赞 0
评论 0
项目:wpilib-java
作者:
评论列表
文章目录