Skip to content

Commit

Permalink
Replace most usages of schedule()
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold856 committed Sep 17, 2024
1 parent 23abf75 commit 80686e6
Show file tree
Hide file tree
Showing 37 changed files with 55 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public ProxyCommand(Command command) {
@Override
public void initialize() {
m_command = m_supplier.get();
m_command.schedule();
CommandScheduler.getInstance().schedule(m_command);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public ScheduleCommand(Command... toSchedule) {
@Override
public void initialize() {
for (Command command : m_toSchedule) {
command.schedule();
CommandScheduler.getInstance().schedule(command);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void run() {
boolean pressed = m_condition.getAsBoolean();

if (m_pressedLast != pressed) {
command.schedule();
CommandScheduler.getInstance().schedule(command);
}

m_pressedLast = pressed;
Expand All @@ -92,7 +92,7 @@ public void run() {
boolean pressed = m_condition.getAsBoolean();

if (!m_pressedLast && pressed) {
command.schedule();
CommandScheduler.getInstance().schedule(command);
}

m_pressedLast = pressed;
Expand All @@ -118,7 +118,7 @@ public void run() {
boolean pressed = m_condition.getAsBoolean();

if (m_pressedLast && !pressed) {
command.schedule();
CommandScheduler.getInstance().schedule(command);
}

m_pressedLast = pressed;
Expand Down Expand Up @@ -148,7 +148,7 @@ public void run() {
boolean pressed = m_condition.getAsBoolean();

if (!m_pressedLast && pressed) {
command.schedule();
CommandScheduler.getInstance().schedule(command);
} else if (m_pressedLast && !pressed) {
command.cancel();
}
Expand Down Expand Up @@ -180,7 +180,7 @@ public void run() {
boolean pressed = m_condition.getAsBoolean();

if (m_pressedLast && !pressed) {
command.schedule();
CommandScheduler.getInstance().schedule(command);
} else if (!m_pressedLast && pressed) {
command.cancel();
}
Expand Down Expand Up @@ -211,7 +211,7 @@ public void run() {
if (command.isScheduled()) {
command.cancel();
} else {
command.schedule();
CommandScheduler.getInstance().schedule(command);
}
}

Expand Down Expand Up @@ -241,7 +241,7 @@ public void run() {
if (command.isScheduled()) {
command.cancel();
} else {
command.schedule();
CommandScheduler.getInstance().schedule(command);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ProxyCommand::ProxyCommand(std::unique_ptr<Command> command) {

void ProxyCommand::Initialize() {
m_command = m_supplier();
m_command->Schedule();
frc2::CommandScheduler::GetInstance().Schedule(m_command);
}

void ProxyCommand::End(bool interrupted) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ScheduleCommand::ScheduleCommand(Command* toSchedule) {

void ScheduleCommand::Initialize() {
for (auto command : m_toSchedule) {
command->Schedule();
frc2::CommandScheduler::GetInstance().Schedule(command);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Trigger Trigger::OnChange(Command* command) {
bool current = condition();

if (previous != current) {
command->Schedule();
frc2::CommandScheduler::GetInstance().Schedule(command);
}

previous = current;
Expand Down Expand Up @@ -47,7 +47,7 @@ Trigger Trigger::OnTrue(Command* command) {
bool current = condition();

if (!previous && current) {
command->Schedule();
frc2::CommandScheduler::GetInstance().Schedule(command);
}

previous = current;
Expand Down Expand Up @@ -75,7 +75,7 @@ Trigger Trigger::OnFalse(Command* command) {
bool current = condition();

if (previous && !current) {
command->Schedule();
frc2::CommandScheduler::GetInstance().Schedule(command);
}

previous = current;
Expand Down Expand Up @@ -103,7 +103,7 @@ Trigger Trigger::WhileTrue(Command* command) {
bool current = condition();

if (!previous && current) {
command->Schedule();
frc2::CommandScheduler::GetInstance().Schedule(command);
} else if (previous && !current) {
command->Cancel();
}
Expand Down Expand Up @@ -135,7 +135,7 @@ Trigger Trigger::WhileFalse(Command* command) {
bool current = condition();

if (previous && !current) {
command->Schedule();
frc2::CommandScheduler::GetInstance().Schedule(command);
} else if (!previous && current) {
command->Cancel();
}
Expand Down Expand Up @@ -170,7 +170,7 @@ Trigger Trigger::ToggleOnTrue(Command* command) {
if (command->IsScheduled()) {
command->Cancel();
} else {
command->Schedule();
frc2::CommandScheduler::GetInstance().Schedule(command);
}
}

Expand Down Expand Up @@ -206,7 +206,7 @@ Trigger Trigger::ToggleOnFalse(Command* command) {
if (command->IsScheduled()) {
command->Cancel();
} else {
command->Schedule();
frc2::CommandScheduler::GetInstance().Schedule(command);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void trueAndNotScheduledSchedules() {
@Test
void trueAndScheduledNoOp() {
// Scheduled and true -> no-op
m_command.schedule();
CommandScheduler.getInstance().schedule(m_command);
CommandScheduler.getInstance().run();
SmartDashboard.updateValues();
assertTrue(m_command.isScheduled());
Expand Down Expand Up @@ -90,7 +90,7 @@ void falseAndNotScheduledNoOp() {
@Test
void falseAndScheduledCancel() {
// Scheduled and false -> cancel
m_command.schedule();
CommandScheduler.getInstance().schedule(m_command);
CommandScheduler.getInstance().run();
SmartDashboard.updateValues();
assertTrue(m_command.isScheduled());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void proxyCommandScheduleTest() {

scheduler.schedule(scheduleCommand);

verify(command1).schedule();
verify(command1).initialize();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ void scheduleCommandScheduleTest() {

scheduler.schedule(scheduleCommand);

verify(command1).schedule();
verify(command2).schedule();
verify(command1).initialize();
verify(command2).initialize();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ void setNetworkButtonTest() {
pub.set(false);
button.onTrue(command);
scheduler.run();
verify(command, never()).schedule();
verify(command, never()).initialize();
pub.set(true);
scheduler.run();
scheduler.run();
verify(command).schedule();
verify(command).initialize();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void cancelWhenActiveTest() {
.until(button);

button.setPressed(false);
command1.schedule();
scheduler.schedule(command1);
scheduler.run();
assertEquals(1, startCounter.get());
assertEquals(0, endCounter.get());
Expand Down Expand Up @@ -258,13 +258,13 @@ void debounceTest() {

button.setPressed(true);
scheduler.run();
verify(command, never()).schedule();
verify(command, never()).initialize();

SimHooks.stepTiming(0.3);

button.setPressed(true);
scheduler.run();
verify(command).schedule();
verify(command).initialize();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ TEST_F(CommandSendableButtonTest, trueAndNotScheduledSchedules) {

TEST_F(CommandSendableButtonTest, trueAndScheduledNoOp) {
// Scheduled and true -> no-op
m_command->Schedule();
frc2::CommandScheduler::GetInstance().Schedule(m_command);

Check failure on line 52 in wpilibNewCommands/src/test/native/cpp/frc2/command/CommandSendableButtonTest.cpp

View workflow job for this annotation

GitHub Actions / Build - Windows

'frc2::CommandScheduler::Schedule': no overloaded function could convert all the argument types
GetScheduler().Run();
frc::SmartDashboard::UpdateValues();
EXPECT_TRUE(m_command->IsScheduled());
Expand Down Expand Up @@ -82,7 +82,7 @@ TEST_F(CommandSendableButtonTest, falseAndNotScheduledNoOp) {

TEST_F(CommandSendableButtonTest, falseAndScheduledCancel) {
// Scheduled and false -> cancel
m_command->Schedule();
frc2::CommandScheduler::GetInstance().Schedule(m_command);

Check failure on line 85 in wpilibNewCommands/src/test/native/cpp/frc2/command/CommandSendableButtonTest.cpp

View workflow job for this annotation

GitHub Actions / Build - Windows

'frc2::CommandScheduler::Schedule': no overloaded function could convert all the argument types
GetScheduler().Run();
frc::SmartDashboard::UpdateValues();
EXPECT_TRUE(m_command->IsScheduled());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void Robot::AutonomousInit() {
m_autonomousCommand = m_container.GetAutonomousCommand();

if (m_autonomousCommand) {
m_autonomousCommand->Schedule();
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void Robot::AutonomousInit() {
m_autonomousCommand = m_container.GetAutonomousCommand();

if (m_autonomousCommand != nullptr) {
m_autonomousCommand->Schedule();
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void Robot::AutonomousInit() {
m_autonomousCommand = m_container.GetAutonomousCommand();

if (m_autonomousCommand) {
m_autonomousCommand->Schedule();
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void Robot::AutonomousInit() {
m_autonomousCommand = m_robot.GetAutonomousCommand();

if (m_autonomousCommand) {
m_autonomousCommand->Schedule();
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void Robot::AutonomousInit() {
m_autonomousCommand = m_container.GetAutonomousCommand();

if (m_autonomousCommand != nullptr) {
m_autonomousCommand->Schedule();
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void Robot::AutonomousInit() {
m_autonomousCommand = m_container.GetAutonomousCommand();

if (m_autonomousCommand != nullptr) {
m_autonomousCommand->Schedule();
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void Robot::AutonomousInit() {
m_autonomousCommand = m_container.GetAutonomousCommand();

if (m_autonomousCommand) {
m_autonomousCommand->Schedule();
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand);
}
}

Expand Down
2 changes: 1 addition & 1 deletion wpilibcExamples/src/main/cpp/examples/SysId/cpp/Robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void Robot::AutonomousInit() {
m_autonomousCommand = m_container.GetAutonomousCommand();

if (m_autonomousCommand) {
m_autonomousCommand->Schedule();
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void Robot::AutonomousInit() {
m_autonomousCommand = m_container.GetAutonomousCommand();

if (m_autonomousCommand != nullptr) {
m_autonomousCommand->Schedule();
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void Robot::AutonomousInit() {
m_autonomousCommand = m_container.GetAutonomousCommand();

if (m_autonomousCommand) {
m_autonomousCommand->Schedule();
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void Robot::AutonomousInit() {
m_autonomousCommand = m_container.GetAutonomousCommand();

if (m_autonomousCommand) {
m_autonomousCommand->Schedule();
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void autonomousInit() {

// schedule the autonomous command (example)
if (m_autonomousCommand != null) {
m_autonomousCommand.schedule();
CommandScheduler.getInstance().schedule(m_autonomousCommand);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void autonomousInit() {

// schedule the autonomous command (example)
if (m_autonomousCommand != null) {
m_autonomousCommand.schedule();
CommandScheduler.getInstance().schedule(m_autonomousCommand);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void autonomousInit() {

// schedule the autonomous command (example)
if (m_autonomousCommand != null) {
m_autonomousCommand.schedule();
CommandScheduler.getInstance().schedule(m_autonomousCommand);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void autonomousInit() {

// schedule the autonomous command (example)
if (m_autonomousCommand != null) {
m_autonomousCommand.schedule();
CommandScheduler.getInstance().schedule(m_autonomousCommand);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void autonomousInit() {
m_autonomousCommand = m_robot.getAutonomousCommand();

if (m_autonomousCommand != null) {
m_autonomousCommand.schedule();
CommandScheduler.getInstance().schedule(m_autonomousCommand);
}
}

Expand Down
Loading

0 comments on commit 80686e6

Please sign in to comment.