WPILibC++  2020.3.2-60-g3011ebe
frc::Watchdog Class Reference

A class that's a wrapper around a watchdog timer. More...

#include <Watchdog.h>

Public Member Functions

 Watchdog (double timeout, std::function< void()> callback)
 Watchdog constructor. More...
 
 Watchdog (units::second_t timeout, std::function< void()> callback)
 Watchdog constructor. More...
 
template<typename Callable , typename Arg , typename... Args>
 Watchdog (double timeout, Callable &&f, Arg &&arg, Args &&... args)
 
template<typename Callable , typename Arg , typename... Args>
 Watchdog (units::second_t timeout, Callable &&f, Arg &&arg, Args &&... args)
 
 Watchdog (Watchdog &&)=default
 
Watchdogoperator= (Watchdog &&)=default
 
double GetTime () const
 Returns the time in seconds since the watchdog was last fed.
 
void SetTimeout (double timeout)
 Sets the watchdog's timeout. More...
 
void SetTimeout (units::second_t timeout)
 Sets the watchdog's timeout. More...
 
double GetTimeout () const
 Returns the watchdog's timeout in seconds.
 
bool IsExpired () const
 Returns true if the watchdog timer has expired.
 
void AddEpoch (wpi::StringRef epochName)
 Adds time since last epoch to the list printed by PrintEpochs(). More...
 
void PrintEpochs ()
 Prints list of epochs added so far and their times.
 
void Reset ()
 Resets the watchdog timer. More...
 
void Enable ()
 Enables the watchdog timer.
 
void Disable ()
 Disables the watchdog timer.
 
void SuppressTimeoutMessage (bool suppress)
 Enable or disable suppression of the generic timeout message. More...
 

Detailed Description

A class that's a wrapper around a watchdog timer.

When the timer expires, a message is printed to the console and an optional user-provided callback is invoked.

The watchdog is initialized disabled, so the user needs to call Enable() before use.

Constructor & Destructor Documentation

◆ Watchdog() [1/2]

frc::Watchdog::Watchdog ( double  timeout,
std::function< void()>  callback 
)

Watchdog constructor.

Deprecated:
use unit-safe version instead. Watchdog(units::second_t timeout, std::function<void()> callback)
Parameters
timeoutThe watchdog's timeout in seconds with microsecond resolution.
callbackThis function is called when the timeout expires.

◆ Watchdog() [2/2]

frc::Watchdog::Watchdog ( units::second_t  timeout,
std::function< void()>  callback 
)

Watchdog constructor.

Parameters
timeoutThe watchdog's timeout in seconds with microsecond resolution.
callbackThis function is called when the timeout expires.

Member Function Documentation

◆ AddEpoch()

void frc::Watchdog::AddEpoch ( wpi::StringRef  epochName)

Adds time since last epoch to the list printed by PrintEpochs().

Epochs are a way to partition the time elapsed so that when overruns occur, one can determine which parts of an operation consumed the most time.

Parameters
epochNameThe name to associate with the epoch.

◆ Reset()

void frc::Watchdog::Reset ( )

Resets the watchdog timer.

This also enables the timer if it was previously disabled.

◆ SetTimeout() [1/2]

void frc::Watchdog::SetTimeout ( double  timeout)

Sets the watchdog's timeout.

Deprecated:
use the unit safe version instead. SetTimeout(units::second_t timeout)
Parameters
timeoutThe watchdog's timeout in seconds with microsecond resolution.

◆ SetTimeout() [2/2]

void frc::Watchdog::SetTimeout ( units::second_t  timeout)

Sets the watchdog's timeout.

Parameters
timeoutThe watchdog's timeout in seconds with microsecond resolution.

◆ SuppressTimeoutMessage()

void frc::Watchdog::SuppressTimeoutMessage ( bool  suppress)

Enable or disable suppression of the generic timeout message.

This may be desirable if the user-provided callback already prints a more specific message.

Parameters
suppressWhether to suppress generic timeout message.

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