Skip to content

Commit

Permalink
Additional fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rhauch committed Dec 22, 2016
1 parent 988f34e commit 6f3892e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
2 changes: 1 addition & 1 deletion build.properties
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
14 changes: 8 additions & 6 deletions strongback/src/org/strongback/Strongback.java
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ public boolean isRunning() {
}

public synchronized void pause() {
if (running.get()) {
if (isRunning()) {
executor.stop();
}
}
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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();
Expand Down
36 changes: 25 additions & 11 deletions strongback/src/org/strongback/hardware/Hardware.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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.
*
Expand All @@ -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);
}

Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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.
*
Expand All @@ -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,
Expand Down

0 comments on commit 6f3892e

Please sign in to comment.