2010 FRC Java API


edu.wpi.first.wpilibj
Class Timer

java.lang.Object
  extended by edu.wpi.first.wpilibj.Timer

public class Timer
extends Object

Timer objects measure accumulated time in milliseconds. The timer object functions like a stopwatch. It can be started, stopped, and cleared. When the timer is running its value counts up in milliseconds. When stopped, the timer holds the current value. The implemenation simply records the time when started and subtracts the current time whenever the value is requested.


Constructor Summary
Timer()
          Create a new timer object.
 
Method Summary
static void delay(double seconds)
          Pause the program for a specified time.
 double get()
          Get the current time from the timer.
static long getUsClock()
          Get the time in microseconds from the FPGA
 void reset()
          Reset the timer by setting the time to 0.
 void start()
          Start the timer running.
 void stop()
          Stop the timer.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Timer

public Timer()
Create a new timer object. Create a new timer object and reset the time to zero. The timer is initially not running and must be started.

Method Detail

delay

public static void delay(double seconds)
Pause the program for a specified time. Pause the execution of the program for a specified period of time given in seconds. Motors will continue to run at their last assigned values, and sensors will continue to update. Only the task containing the wait will pause until the wait time is expired.

Parameters:
seconds - Length of time to pause

getUsClock

public static long getUsClock()
Get the time in microseconds from the FPGA

Returns:
time from the fpga

get

public double get()
Get the current time from the timer. If the clock is running it is derived from the current system clock the start time stored in the timer class. If the clock is not running, then return the time when it was last stopped.

Returns:
Current time value for this timer in microseconds (uSeconds)

reset

public void reset()
Reset the timer by setting the time to 0. Make the timer startTime the current time so new requests will be relative now


start

public void start()
Start the timer running. Just set the running flag to true indicating that all time requests should be relative to the system clock.


stop

public void stop()
Stop the timer. This computes the time as of now and clears the running flag, causing all subsequent time requests to be read from the accumulated time rather than looking at the system clock.


2010 FRC Java API


Copyright © 2006-2009 Sun Microsystems, Inc. All Rights Reserved.