myWRIO
C++ framework for NationalInstruments myRIO
myRIO::Time Class Reference

Stopwatch or countdown. More...

#include <Time.h>

Public Member Functions

 Time (unsigned long sec=0, unsigned long nsec=0)
 Constructor Create a time object referencing the given time. More...
 
void reset ()
 Reset timer to the current time. More...
 
long elapsed_ns ()
 Elapsed time nanoseconds If you get elapsed_ns() = 1000, 1000ns are elapsed, or 1000e-9 seconds WARNING : cannot measure more than 2 seconds (long limit = 2e9; 1 seconds in ns = 1e9) More...
 
 ~Time ()
 

Static Public Member Functions

static Time stopwatch ()
 Get the current time. More...
 
static void wait_s (long int s)
 Wait function in seconds. More...
 
static void wait_ms (long int ms)
 Wait function in milliseconds. More...
 
static void wait_us (long int us)
 Wait function in microseconds. More...
 

Private Attributes

unsigned long startTimeSec
 The start time in seconds. More...
 
unsigned long startTimeNsec
 The start time in nanosecond. More...
 

Detailed Description

Stopwatch or countdown.

Examples
example_aio.cpp, example_log.cpp, and example_motor_pid_encoder.cpp.

Definition at line 14 of file Time.h.

Constructor & Destructor Documentation

◆ Time()

Time::Time ( unsigned long  sec = 0,
unsigned long  nsec = 0 
)

Constructor Create a time object referencing the given time.

Definition at line 7 of file Time.cpp.

◆ ~Time()

Time::~Time ( )

Definition at line 105 of file Time.cpp.

Member Function Documentation

◆ elapsed_ns()

long Time::elapsed_ns ( )

Elapsed time nanoseconds If you get elapsed_ns() = 1000, 1000ns are elapsed, or 1000e-9 seconds WARNING : cannot measure more than 2 seconds (long limit = 2e9; 1 seconds in ns = 1e9)

Returns
the elapsed time in nanoseconds
Examples
example_aio.cpp, and example_motor_pid_encoder.cpp.

Definition at line 34 of file Time.cpp.

◆ reset()

void Time::reset ( )

Reset timer to the current time.

Examples
example_aio.cpp, and example_motor_pid_encoder.cpp.

Definition at line 21 of file Time.cpp.

◆ stopwatch()

Time Time::stopwatch ( )
static

Get the current time.

Returns
creates a time object with the current time
Examples
example_aio.cpp, example_log.cpp, and example_motor_pid_encoder.cpp.

Definition at line 12 of file Time.cpp.

◆ wait_ms()

void Time::wait_ms ( long int  ms)
static

Wait function in milliseconds.

Parameters
msthe milliseconds to wait
Examples
example_acc.cpp, example_blink.cpp, and example_log.cpp.

Definition at line 61 of file Time.cpp.

◆ wait_s()

void Time::wait_s ( long int  s)
static

Wait function in seconds.

Parameters
sthe seconds to wait
Examples
example_motor_pid_encoder.cpp, and example_pwm.cpp.

Definition at line 48 of file Time.cpp.

◆ wait_us()

void Time::wait_us ( long int  us)
static

Wait function in microseconds.

Parameters
usthe microseconds to wait
Examples
example_aio.cpp, and project_car.cpp.

Definition at line 85 of file Time.cpp.

Member Data Documentation

◆ startTimeNsec

unsigned long myRIO::Time::startTimeNsec
private

The start time in nanosecond.

Definition at line 28 of file Time.h.

◆ startTimeSec

unsigned long myRIO::Time::startTimeSec
private

The start time in seconds.

Definition at line 27 of file Time.h.


The documentation for this class was generated from the following files: