diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DriverStation.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DriverStation.java index 762a806be5..ea14fd1aee 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DriverStation.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DriverStation.java @@ -1042,12 +1042,12 @@ public class DriverStation { *
Checks if new control data has arrived since the last waitForData call on the current
* thread. If new data has not arrived, returns immediately.
*
- * @param timeout The maximum time in seconds to wait.
+ * @param timeoutSeconds The maximum time in seconds to wait.
* @return true if there is new data, otherwise false
*/
- public static boolean waitForData(double timeout) {
- long startTime = RobotController.getFPGATime();
- long timeoutMicros = (long) (timeout * 1000000);
+ public static boolean waitForData(double timeoutSeconds) {
+ long startTimeMicroS = RobotController.getFPGATime();
+ long timeoutMicroS = (long) (timeoutSeconds * 1e6);
m_waitForDataMutex.lock();
try {
int currentCount = m_waitForDataCount;
@@ -1056,12 +1056,13 @@ public class DriverStation {
return true;
}
while (m_waitForDataCount == currentCount) {
- if (timeout > 0) {
- long now = RobotController.getFPGATime();
- if (now < startTime + timeoutMicros) {
+ if (timeoutMicroS > 0) {
+ long nowMicroS = RobotController.getFPGATime();
+ if (nowMicroS < startTimeMicroS + timeoutMicroS) {
// We still have time to wait
boolean signaled =
- m_waitForDataCond.await(startTime + timeoutMicros - now, TimeUnit.MICROSECONDS);
+ m_waitForDataCond.await(
+ startTimeMicroS + timeoutMicroS - nowMicroS, TimeUnit.MICROSECONDS);
if (!signaled) {
// Return false if a timeout happened
return false;
diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Notifier.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Notifier.java
index e6b1790f49..40384ba80c 100644
--- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Notifier.java
+++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Notifier.java
@@ -18,9 +18,9 @@ public class Notifier implements AutoCloseable {
// The C pointer to the notifier object. We don't use it directly, it is
// just passed to the JNI bindings.
private final AtomicInteger m_notifier = new AtomicInteger();
- // The time, in microseconds, at which the corresponding handler should be
- // called. Has the same zero as Utility.getFPGATime().
- private double m_expirationTime;
+ // The time, in seconds, at which the corresponding handler should be
+ // called. Has the same zero as RobotController.getFPGATime().
+ private double m_expirationTimeSeconds;
// The handler passed in by the user which should be called at the
// appropriate interval.
private Runnable m_handler;
@@ -28,7 +28,7 @@ public class Notifier implements AutoCloseable {
private boolean m_periodic;
// If periodic, the period of the calling; if just once, stores how long it
// is until we call the handler.
- private double m_period;
+ private double m_periodSeconds;
@Override
@SuppressWarnings("NoFinalizer")
@@ -59,19 +59,19 @@ public class Notifier implements AutoCloseable {
/**
* Update the alarm hardware to reflect the next alarm.
*
- * @param triggerTime the time at which the next alarm will be triggered
+ * @param triggerTimeMicroS the time in microseconds at which the next alarm will be triggered
*/
- private void updateAlarm(long triggerTime) {
+ private void updateAlarm(long triggerTimeMicroS) {
int notifier = m_notifier.get();
if (notifier == 0) {
return;
}
- NotifierJNI.updateNotifierAlarm(notifier, triggerTime);
+ NotifierJNI.updateNotifierAlarm(notifier, triggerTimeMicroS);
}
/** Update the alarm hardware to reflect the next alarm. */
private void updateAlarm() {
- updateAlarm((long) (m_expirationTime * 1e6));
+ updateAlarm((long) (m_expirationTimeSeconds * 1e6));
}
/**
@@ -104,7 +104,7 @@ public class Notifier implements AutoCloseable {
try {
handler = m_handler;
if (m_periodic) {
- m_expirationTime += m_period;
+ m_expirationTimeSeconds += m_periodSeconds;
updateAlarm();
} else {
// need to update the alarm to cause it to wait again
@@ -165,14 +165,14 @@ public class Notifier implements AutoCloseable {
* Register for single event notification. A timer event is queued for a single event after the
* specified delay.
*
- * @param delay Seconds to wait before the handler is called.
+ * @param delaySeconds Seconds to wait before the handler is called.
*/
- public void startSingle(double delay) {
+ public void startSingle(double delaySeconds) {
m_processLock.lock();
try {
m_periodic = false;
- m_period = delay;
- m_expirationTime = RobotController.getFPGATime() * 1e-6 + delay;
+ m_periodSeconds = delaySeconds;
+ m_expirationTimeSeconds = RobotController.getFPGATime() * 1e-6 + delaySeconds;
updateAlarm();
} finally {
m_processLock.unlock();
@@ -184,15 +184,15 @@ public class Notifier implements AutoCloseable {
* notification. Each time the interrupt occurs, the event will be immediately requeued for the
* same time interval.
*
- * @param period Period in seconds to call the handler starting one period after the call to this
- * method.
+ * @param periodSeconds Period in seconds to call the handler starting one period after the call
+ * to this method.
*/
- public void startPeriodic(double period) {
+ public void startPeriodic(double periodSeconds) {
m_processLock.lock();
try {
m_periodic = true;
- m_period = period;
- m_expirationTime = RobotController.getFPGATime() * 1e-6 + period;
+ m_periodSeconds = periodSeconds;
+ m_expirationTimeSeconds = RobotController.getFPGATime() * 1e-6 + periodSeconds;
updateAlarm();
} finally {
m_processLock.unlock();
diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotController.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotController.java
index 5f8db65f48..31db69bada 100644
--- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotController.java
+++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotController.java
@@ -114,7 +114,7 @@ public final class RobotController {
/**
* Get the current output of the 3.3V rail.
*
- * @return The controller 3.3V rail output current value in Volts
+ * @return The controller 3.3V rail output current value in Amps
*/
public static double getCurrent3V3() {
return PowerJNI.getUserCurrent3V3();
diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Watchdog.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Watchdog.java
index ba11766242..044324f414 100644
--- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Watchdog.java
+++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Watchdog.java
@@ -19,13 +19,13 @@ import java.util.concurrent.locks.ReentrantLock;
*/
public class Watchdog implements Closeable, Comparable