Runs DS enabled loop in process (#785)

Solves mutex issues, and other issues with the existing teststand
software. And simplifies the unit test structure.
This commit is contained in:
Thad House
2017-11-28 19:12:05 -08:00
committed by Peter Johnson
parent 26a36779a6
commit fa0b4428e9
11 changed files with 228 additions and 106 deletions

View File

@@ -17,6 +17,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.MockDS;
import edu.wpi.first.wpilibj.RobotBase;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.hal.HAL;
@@ -34,6 +35,9 @@ public abstract class AbstractComsSetup {
*/
private static boolean initialized = false;
// We have no way to stop the MockDS, so its thread is daemon.
private static MockDS ds;
/**
* This sets up the network communications library to enable the driver
* station. After starting network coms, it will loop until the driver station
@@ -45,6 +49,10 @@ public abstract class AbstractComsSetup {
// Set some implementations so that the static methods work properly
RobotBase.initializeHardwareConfiguration();
HAL.observeUserProgramStarting();
DriverStation.getInstance().getAlliance();
ds = new MockDS();
ds.start();
LiveWindow.setEnabled(false);
TestBench.out().println("Started coms");
@@ -57,8 +65,7 @@ public abstract class AbstractComsSetup {
} catch (InterruptedException ex) {
ex.printStackTrace();
}
// Prints the message on one line overwriting itself each time
TestBench.out().print("\rWaiting for enable: " + enableCounter++);
TestBench.out().println("Waiting for enable: " + enableCounter++);
}
TestBench.out().println();