Skip to content

Commit 6f3892e

Browse files
committed
Additional fixes
1 parent 988f34e commit 6f3892e

File tree

3 files changed

+34
-18
lines changed

3 files changed

+34
-18
lines changed

build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
strongback.version=1.2.0-Beta3
1+
strongback.version=1.2.0-Beta4
22
#
33
# The build will download a specific version of the WPILib given by the following URL
44
# and install it into the 'libs/wpilib' folder. To use a different version of WPILib,

strongback/src/org/strongback/Strongback.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,7 +1274,7 @@ public boolean isRunning() {
12741274
}
12751275

12761276
public synchronized void pause() {
1277-
if (running.get()) {
1277+
if (isRunning()) {
12781278
executor.stop();
12791279
}
12801280
}
@@ -1342,7 +1342,7 @@ protected boolean doStart() {
13421342
* the engine could not be started
13431343
*/
13441344
public synchronized boolean start() {
1345-
if (running.get()) {
1345+
if (isRunning()) {
13461346
// Already running, so just kill any remaining commands ...
13471347
scheduler.killAll();
13481348
executorDelayCounter.set(0);
@@ -1356,7 +1356,7 @@ public synchronized boolean start() {
13561356

13571357
public synchronized boolean submit(Command command) {
13581358
if (command != null) {
1359-
if (!running.get()) {
1359+
if (!isRunning()) {
13601360
logger.warn("Strongback is not currently running, so the command " + command
13611361
+ " will begin running when Strongback is started.");
13621362
return false;
@@ -1368,12 +1368,14 @@ public synchronized boolean submit(Command command) {
13681368
}
13691369

13701370
public synchronized void flushRecorders() {
1371-
// Finally flush the data recorder ...
1372-
dataRecorderDriver.flush();
1371+
if (isRunning()) {
1372+
// Finally flush the data recorder ...
1373+
dataRecorderDriver.flush();
1374+
}
13731375
}
13741376

13751377
public synchronized void killCommandsAndFlush() {
1376-
if (running.get()) {
1378+
if (isRunning()) {
13771379
try {
13781380
// Kill any remaining commands ...
13791381
scheduler.killAll();

strongback/src/org/strongback/hardware/Hardware.java

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,14 @@ public static enum AnalogOption {
335335
* use of this filter is to reject data points which errantly (due to averaging or sampling) appear within the
336336
* window when detecting transitions using the Rising Edge and Falling Edge functionality of the analog trigger
337337
*/
338-
FILTERED, /**
339-
* The analog output is averaged and over sampled.
340-
*/
341-
AVERAGED, /**
342-
* No filtering or averaging is to be used.
343-
*/
338+
FILTERED,
339+
/**
340+
* The analog output is averaged and over sampled.
341+
*/
342+
AVERAGED,
343+
/**
344+
* No filtering or averaging is to be used.
345+
*/
344346
NONE;
345347
}
346348

@@ -354,10 +356,11 @@ public static enum TriggerMode {
354356
* The switch is triggered only when the analog value is inside the range, and not triggered if it is outside (above
355357
* or below)
356358
*/
357-
IN_WINDOW, /**
358-
* The switch is triggered only when the value is above the upper limit, and not triggered if it is below
359-
* the lower limit and maintains the previous state if in between (hysteresis)
360-
*/
359+
IN_WINDOW,
360+
/**
361+
* The switch is triggered only when the value is above the upper limit, and not triggered if it is below the lower
362+
* limit and maintains the previous state if in between (hysteresis)
363+
*/
361364
AVERAGED;
362365
}
363366

@@ -764,6 +767,10 @@ public static Relay relay(int channel) {
764767

765768
public static final class HumanInterfaceDevices {
766769

770+
private static void verifyJoystickConnected(Joystick joystick) {
771+
joystick.getButtonCount();
772+
}
773+
767774
/**
768775
* Create an generic input device controlled by the Driver Station.
769776
*
@@ -772,6 +779,7 @@ public static final class HumanInterfaceDevices {
772779
*/
773780
public static InputDevice driverStationJoystick(int port) {
774781
Joystick joystick = new Joystick(port);
782+
verifyJoystickConnected(joystick);
775783
return InputDevice.create(joystick::getRawAxis, joystick::getRawButton, joystick::getPOV);
776784
}
777785

@@ -783,6 +791,7 @@ public static InputDevice driverStationJoystick(int port) {
783791
*/
784792
public static FlightStick logitechAttack3D(int port) {
785793
Joystick joystick = new Joystick(port);
794+
verifyJoystickConnected(joystick);
786795
return FlightStick.create(joystick::getRawAxis,
787796
joystick::getRawButton,
788797
joystick::getPOV,
@@ -802,6 +811,7 @@ public static FlightStick logitechAttack3D(int port) {
802811
*/
803812
public static FlightStick logitechExtreme3D(int port) {
804813
Joystick joystick = new Joystick(port);
814+
verifyJoystickConnected(joystick);
805815
return FlightStick.create(joystick::getRawAxis,
806816
joystick::getRawButton,
807817
joystick::getPOV,
@@ -821,6 +831,7 @@ public static FlightStick logitechExtreme3D(int port) {
821831
*/
822832
public static FlightStick microsoftSideWinder(int port) {
823833
Joystick joystick = new Joystick(port);
834+
verifyJoystickConnected(joystick);
824835
return FlightStick.create(joystick::getRawAxis,
825836
joystick::getRawButton,
826837
joystick::getPOV,
@@ -840,6 +851,7 @@ public static FlightStick microsoftSideWinder(int port) {
840851
*/
841852
public static Gamepad logitechDualAction(int port) {
842853
Joystick joystick = new Joystick(port);
854+
verifyJoystickConnected(joystick);
843855
return Gamepad.create(joystick::getRawAxis,
844856
joystick::getRawButton,
845857
joystick::getPOV,
@@ -869,6 +881,7 @@ public static Gamepad logitechDualAction(int port) {
869881
*/
870882
public static Gamepad logitechF310(int port) {
871883
Joystick joystick = new Joystick(port);
884+
verifyJoystickConnected(joystick);
872885
return Gamepad.create(joystick::getRawAxis,
873886
joystick::getRawButton,
874887
joystick::getPOV,
@@ -889,7 +902,7 @@ public static Gamepad logitechF310(int port) {
889902
() -> joystick.getRawButton(8),
890903
() -> joystick.getRawButton(9));
891904
}
892-
905+
893906
/**
894907
* Create a Microsoft Xbox360 gamepad controlled by the Driver Station.
895908
*
@@ -898,6 +911,7 @@ public static Gamepad logitechF310(int port) {
898911
*/
899912
public static Gamepad xbox360(int port) {
900913
Joystick joystick = new Joystick(port);
914+
verifyJoystickConnected(joystick);
901915
return Gamepad.create(joystick::getRawAxis,
902916
joystick::getRawButton,
903917
joystick::getPOV,

0 commit comments

Comments
 (0)