mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Add ability to end startCompetition() main loop (#2032)
This is useful for both cleanly exiting from simulation and for unit testing at a framework level. This change required removing move constructor/assignment from IterativeRobot.
This commit is contained in:
@@ -33,6 +33,8 @@ public class Robot extends RobotBase {
|
||||
public void test() {
|
||||
}
|
||||
|
||||
private volatile boolean m_exit;
|
||||
|
||||
@SuppressWarnings("PMD.CyclomaticComplexity")
|
||||
@Override
|
||||
public void startCompetition() {
|
||||
@@ -41,7 +43,7 @@ public class Robot extends RobotBase {
|
||||
// Tell the DS that the robot is ready to be enabled
|
||||
HAL.observeUserProgramStarting();
|
||||
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
while (!Thread.currentThread().isInterrupted() && !m_exit) {
|
||||
if (isDisabled()) {
|
||||
m_ds.InDisabled(true);
|
||||
disabled();
|
||||
@@ -77,4 +79,9 @@ public class Robot extends RobotBase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endCompetition() {
|
||||
m_exit = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user