Skip to content

Commit 8c8d94d

Browse files
committed
Replace most usages of schedule()
1 parent 717f82e commit 8c8d94d

File tree

38 files changed

+56
-56
lines changed

38 files changed

+56
-56
lines changed

wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/ProxyCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public ProxyCommand(Command command) {
5959
@Override
6060
public void initialize() {
6161
m_command = m_supplier.get();
62-
m_command.schedule();
62+
CommandScheduler.getInstance().schedule(m_command);
6363
}
6464

6565
@Override

wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/ScheduleCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public ScheduleCommand(Command... toSchedule) {
2828
@Override
2929
public void initialize() {
3030
for (Command command : m_toSchedule) {
31-
command.schedule();
31+
CommandScheduler.getInstance().schedule(command);
3232
}
3333
}
3434

wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/Trigger.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void run() {
6666
boolean pressed = m_condition.getAsBoolean();
6767

6868
if (m_pressedLast != pressed) {
69-
command.schedule();
69+
CommandScheduler.getInstance().schedule(command);
7070
}
7171

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

9494
if (!m_pressedLast && pressed) {
95-
command.schedule();
95+
CommandScheduler.getInstance().schedule(command);
9696
}
9797

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

120120
if (m_pressedLast && !pressed) {
121-
command.schedule();
121+
CommandScheduler.getInstance().schedule(command);
122122
}
123123

124124
m_pressedLast = pressed;
@@ -148,7 +148,7 @@ public void run() {
148148
boolean pressed = m_condition.getAsBoolean();
149149

150150
if (!m_pressedLast && pressed) {
151-
command.schedule();
151+
CommandScheduler.getInstance().schedule(command);
152152
} else if (m_pressedLast && !pressed) {
153153
command.cancel();
154154
}
@@ -180,7 +180,7 @@ public void run() {
180180
boolean pressed = m_condition.getAsBoolean();
181181

182182
if (m_pressedLast && !pressed) {
183-
command.schedule();
183+
CommandScheduler.getInstance().schedule(command);
184184
} else if (!m_pressedLast && pressed) {
185185
command.cancel();
186186
}
@@ -211,7 +211,7 @@ public void run() {
211211
if (command.isScheduled()) {
212212
command.cancel();
213213
} else {
214-
command.schedule();
214+
CommandScheduler.getInstance().schedule(command);
215215
}
216216
}
217217

@@ -241,7 +241,7 @@ public void run() {
241241
if (command.isScheduled()) {
242242
command.cancel();
243243
} else {
244-
command.schedule();
244+
CommandScheduler.getInstance().schedule(command);
245245
}
246246
}
247247

wpilibNewCommands/src/main/native/cpp/frc2/command/Command.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ void Command::InitSendable(wpi::SendableBuilder& builder) {
200200
[this](bool value) {
201201
bool isScheduled = IsScheduled();
202202
if (value && !isScheduled) {
203-
Schedule();
203+
CommandScheduler::GetInstance().Schedule(this);
204204
} else if (!value && isScheduled) {
205205
Cancel();
206206
}

wpilibNewCommands/src/main/native/cpp/frc2/command/ProxyCommand.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ ProxyCommand::ProxyCommand(std::unique_ptr<Command> command) {
3434

3535
void ProxyCommand::Initialize() {
3636
m_command = m_supplier();
37-
m_command->Schedule();
37+
frc2::CommandScheduler::GetInstance().Schedule(m_command);
3838
}
3939

4040
void ProxyCommand::End(bool interrupted) {

wpilibNewCommands/src/main/native/cpp/frc2/command/ScheduleCommand.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ScheduleCommand::ScheduleCommand(Command* toSchedule) {
1818

1919
void ScheduleCommand::Initialize() {
2020
for (auto command : m_toSchedule) {
21-
command->Schedule();
21+
frc2::CommandScheduler::GetInstance().Schedule(command);
2222
}
2323
}
2424

wpilibNewCommands/src/main/native/cpp/frc2/command/button/Trigger.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Trigger Trigger::OnChange(Command* command) {
1919
bool current = condition();
2020

2121
if (previous != current) {
22-
command->Schedule();
22+
frc2::CommandScheduler::GetInstance().Schedule(command);
2323
}
2424

2525
previous = current;
@@ -47,7 +47,7 @@ Trigger Trigger::OnTrue(Command* command) {
4747
bool current = condition();
4848

4949
if (!previous && current) {
50-
command->Schedule();
50+
frc2::CommandScheduler::GetInstance().Schedule(command);
5151
}
5252

5353
previous = current;
@@ -75,7 +75,7 @@ Trigger Trigger::OnFalse(Command* command) {
7575
bool current = condition();
7676

7777
if (previous && !current) {
78-
command->Schedule();
78+
frc2::CommandScheduler::GetInstance().Schedule(command);
7979
}
8080

8181
previous = current;
@@ -103,7 +103,7 @@ Trigger Trigger::WhileTrue(Command* command) {
103103
bool current = condition();
104104

105105
if (!previous && current) {
106-
command->Schedule();
106+
frc2::CommandScheduler::GetInstance().Schedule(command);
107107
} else if (previous && !current) {
108108
command->Cancel();
109109
}
@@ -135,7 +135,7 @@ Trigger Trigger::WhileFalse(Command* command) {
135135
bool current = condition();
136136

137137
if (previous && !current) {
138-
command->Schedule();
138+
frc2::CommandScheduler::GetInstance().Schedule(command);
139139
} else if (!previous && current) {
140140
command->Cancel();
141141
}
@@ -170,7 +170,7 @@ Trigger Trigger::ToggleOnTrue(Command* command) {
170170
if (command->IsScheduled()) {
171171
command->Cancel();
172172
} else {
173-
command->Schedule();
173+
frc2::CommandScheduler::GetInstance().Schedule(command);
174174
}
175175
}
176176

@@ -206,7 +206,7 @@ Trigger Trigger::ToggleOnFalse(Command* command) {
206206
if (command->IsScheduled()) {
207207
command->Cancel();
208208
} else {
209-
command->Schedule();
209+
frc2::CommandScheduler::GetInstance().Schedule(command);
210210
}
211211
}
212212

wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandSendableButtonTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void trueAndNotScheduledSchedules() {
5555
@Test
5656
void trueAndScheduledNoOp() {
5757
// Scheduled and true -> no-op
58-
m_command.schedule();
58+
CommandScheduler.getInstance().schedule(m_command);
5959
CommandScheduler.getInstance().run();
6060
SmartDashboard.updateValues();
6161
assertTrue(m_command.isScheduled());
@@ -90,7 +90,7 @@ void falseAndNotScheduledNoOp() {
9090
@Test
9191
void falseAndScheduledCancel() {
9292
// Scheduled and false -> cancel
93-
m_command.schedule();
93+
CommandScheduler.getInstance().schedule(m_command);
9494
CommandScheduler.getInstance().run();
9595
SmartDashboard.updateValues();
9696
assertTrue(m_command.isScheduled());

wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ProxyCommandTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void proxyCommandScheduleTest() {
2222

2323
scheduler.schedule(scheduleCommand);
2424

25-
verify(command1).schedule();
25+
verify(command1).initialize();
2626
}
2727
}
2828

wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ScheduleCommandTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ void scheduleCommandScheduleTest() {
2222

2323
scheduler.schedule(scheduleCommand);
2424

25-
verify(command1).schedule();
26-
verify(command2).schedule();
25+
verify(command1).initialize();
26+
verify(command2).initialize();
2727
}
2828
}
2929

0 commit comments

Comments
 (0)