diff --git a/build.properties b/build.properties index efc24be..ff9ac07 100644 --- a/build.properties +++ b/build.properties @@ -1,4 +1,4 @@ -strongback.version=1.2.0-Beta3 +strongback.version=1.2.0-Beta4 # # The build will download a specific version of the WPILib given by the following URL # and install it into the 'libs/wpilib' folder. To use a different version of WPILib, diff --git a/strongback/src/org/strongback/Strongback.java b/strongback/src/org/strongback/Strongback.java index b64fb9f..5a9e578 100644 --- a/strongback/src/org/strongback/Strongback.java +++ b/strongback/src/org/strongback/Strongback.java @@ -1274,7 +1274,7 @@ public boolean isRunning() { } public synchronized void pause() { - if (running.get()) { + if (isRunning()) { executor.stop(); } } @@ -1342,7 +1342,7 @@ protected boolean doStart() { * the engine could not be started */ public synchronized boolean start() { - if (running.get()) { + if (isRunning()) { // Already running, so just kill any remaining commands ... scheduler.killAll(); executorDelayCounter.set(0); @@ -1356,7 +1356,7 @@ public synchronized boolean start() { public synchronized boolean submit(Command command) { if (command != null) { - if (!running.get()) { + if (!isRunning()) { logger.warn("Strongback is not currently running, so the command " + command + " will begin running when Strongback is started."); return false; @@ -1368,12 +1368,14 @@ public synchronized boolean submit(Command command) { } public synchronized void flushRecorders() { - // Finally flush the data recorder ... - dataRecorderDriver.flush(); + if (isRunning()) { + // Finally flush the data recorder ... + dataRecorderDriver.flush(); + } } public synchronized void killCommandsAndFlush() { - if (running.get()) { + if (isRunning()) { try { // Kill any remaining commands ... scheduler.killAll(); diff --git a/strongback/src/org/strongback/hardware/Hardware.java b/strongback/src/org/strongback/hardware/Hardware.java index 9a36502..e18babf 100644 --- a/strongback/src/org/strongback/hardware/Hardware.java +++ b/strongback/src/org/strongback/hardware/Hardware.java @@ -335,12 +335,14 @@ public static enum AnalogOption { * use of this filter is to reject data points which errantly (due to averaging or sampling) appear within the * window when detecting transitions using the Rising Edge and Falling Edge functionality of the analog trigger */ - FILTERED, /** - * The analog output is averaged and over sampled. - */ - AVERAGED, /** - * No filtering or averaging is to be used. - */ + FILTERED, + /** + * The analog output is averaged and over sampled. + */ + AVERAGED, + /** + * No filtering or averaging is to be used. + */ NONE; } @@ -354,10 +356,11 @@ public static enum TriggerMode { * The switch is triggered only when the analog value is inside the range, and not triggered if it is outside (above * or below) */ - IN_WINDOW, /** - * The switch is triggered only when the value is above the upper limit, and not triggered if it is below - * the lower limit and maintains the previous state if in between (hysteresis) - */ + IN_WINDOW, + /** + * The switch is triggered only when the value is above the upper limit, and not triggered if it is below the lower + * limit and maintains the previous state if in between (hysteresis) + */ AVERAGED; } @@ -764,6 +767,10 @@ public static Relay relay(int channel) { public static final class HumanInterfaceDevices { + private static void verifyJoystickConnected(Joystick joystick) { + joystick.getButtonCount(); + } + /** * Create an generic input device controlled by the Driver Station. * @@ -772,6 +779,7 @@ public static final class HumanInterfaceDevices { */ public static InputDevice driverStationJoystick(int port) { Joystick joystick = new Joystick(port); + verifyJoystickConnected(joystick); return InputDevice.create(joystick::getRawAxis, joystick::getRawButton, joystick::getPOV); } @@ -783,6 +791,7 @@ public static InputDevice driverStationJoystick(int port) { */ public static FlightStick logitechAttack3D(int port) { Joystick joystick = new Joystick(port); + verifyJoystickConnected(joystick); return FlightStick.create(joystick::getRawAxis, joystick::getRawButton, joystick::getPOV, @@ -802,6 +811,7 @@ public static FlightStick logitechAttack3D(int port) { */ public static FlightStick logitechExtreme3D(int port) { Joystick joystick = new Joystick(port); + verifyJoystickConnected(joystick); return FlightStick.create(joystick::getRawAxis, joystick::getRawButton, joystick::getPOV, @@ -821,6 +831,7 @@ public static FlightStick logitechExtreme3D(int port) { */ public static FlightStick microsoftSideWinder(int port) { Joystick joystick = new Joystick(port); + verifyJoystickConnected(joystick); return FlightStick.create(joystick::getRawAxis, joystick::getRawButton, joystick::getPOV, @@ -840,6 +851,7 @@ public static FlightStick microsoftSideWinder(int port) { */ public static Gamepad logitechDualAction(int port) { Joystick joystick = new Joystick(port); + verifyJoystickConnected(joystick); return Gamepad.create(joystick::getRawAxis, joystick::getRawButton, joystick::getPOV, @@ -869,6 +881,7 @@ public static Gamepad logitechDualAction(int port) { */ public static Gamepad logitechF310(int port) { Joystick joystick = new Joystick(port); + verifyJoystickConnected(joystick); return Gamepad.create(joystick::getRawAxis, joystick::getRawButton, joystick::getPOV, @@ -889,7 +902,7 @@ public static Gamepad logitechF310(int port) { () -> joystick.getRawButton(8), () -> joystick.getRawButton(9)); } - + /** * Create a Microsoft Xbox360 gamepad controlled by the Driver Station. * @@ -898,6 +911,7 @@ public static Gamepad logitechF310(int port) { */ public static Gamepad xbox360(int port) { Joystick joystick = new Joystick(port); + verifyJoystickConnected(joystick); return Gamepad.create(joystick::getRawAxis, joystick::getRawButton, joystick::getPOV,