[wpilib] Add EventLoop (#4104)

This is a generic expansion of the command-based Trigger framework.
This commit is contained in:
Starlight220
2022-06-09 08:16:51 +03:00
committed by GitHub
parent 16a4888c52
commit 45b7fc445b
27 changed files with 1265 additions and 428 deletions

View File

@@ -20,7 +20,7 @@ public class CommandTestBase {
void commandSetup() {
CommandScheduler.getInstance().cancelAll();
CommandScheduler.getInstance().enable();
CommandScheduler.getInstance().clearButtons();
CommandScheduler.getInstance().getActiveButtonLoop().clear();
CommandGroupBase.clearGroupedCommands();
setDSEnabled(true);

View File

@@ -170,10 +170,10 @@ class ButtonTest extends CommandTestBase {
button1.setPressed(true);
button2.setPressed(false);
assertFalse(button1.and(button2).get());
assertTrue(button1.or(button2).get());
assertFalse(button1.negate().get());
assertTrue(button1.and(button2.negate()).get());
assertFalse(button1.and(button2).getAsBoolean());
assertTrue(button1.or(button2).getAsBoolean());
assertFalse(button1.negate().getAsBoolean());
assertTrue(button1.and(button2.negate()).getAsBoolean());
}
@Test
@@ -183,8 +183,8 @@ class ButtonTest extends CommandTestBase {
button1.setPressed(true);
assertFalse(button1.and(booleanSupplier).get());
assertTrue(button1.or(booleanSupplier).get());
assertFalse(button1.and(booleanSupplier).getAsBoolean());
assertTrue(button1.or(booleanSupplier).getAsBoolean());
}
@Test

View File

@@ -10,7 +10,7 @@ CommandTestBase::CommandTestBase() {
auto& scheduler = CommandScheduler::GetInstance();
scheduler.CancelAll();
scheduler.Enable();
scheduler.ClearButtons();
scheduler.GetActiveButtonLoop()->Clear();
}
CommandScheduler CommandTestBase::GetScheduler() {
@@ -22,7 +22,7 @@ void CommandTestBase::SetUp() {
}
void CommandTestBase::TearDown() {
CommandScheduler::GetInstance().ClearButtons();
CommandScheduler::GetInstance().GetActiveButtonLoop()->Clear();
}
void CommandTestBase::SetDSEnabled(bool enabled) {