WPILibC++  2020.3.2-60-g3011ebe
frc::Notifier Class Reference
Inheritance diagram for frc::Notifier:
frc::ErrorBase

Public Member Functions

 Notifier (std::function< void()> handler)
 Create a Notifier for timer event notification. More...
 
template<typename Callable , typename Arg , typename... Args, typename = std::enable_if_t<std::is_invocable_v<Callable, Arg, Args...>>>
 Notifier (Callable &&f, Arg &&arg, Args &&... args)
 
 Notifier (int priority, std::function< void()> handler)
 Create a Notifier for timer event notification. More...
 
template<typename Callable , typename Arg , typename... Args>
 Notifier (int priority, Callable &&f, Arg &&arg, Args &&... args)
 
virtual ~Notifier ()
 Free the resources for a timer event.
 
 Notifier (Notifier &&rhs)
 
Notifieroperator= (Notifier &&rhs)
 
void SetName (const wpi::Twine &name)
 Sets the name of the notifier. More...
 
void SetHandler (std::function< void()> handler)
 Change the handler function. More...
 
void StartSingle (double delay)
 Register for single event notification. More...
 
void StartSingle (units::second_t delay)
 Register for single event notification. More...
 
void StartPeriodic (double period)
 Register for periodic event notification. More...
 
void StartPeriodic (units::second_t period)
 Register for periodic event notification. More...
 
void Stop ()
 Stop timer events from occuring. More...
 
- Public Member Functions inherited from frc::ErrorBase
 ErrorBase (const ErrorBase &)=default
 
ErrorBaseoperator= (const ErrorBase &)=default
 
 ErrorBase (ErrorBase &&)=default
 
ErrorBaseoperator= (ErrorBase &&)=default
 
virtual ErrorGetError ()
 Retrieve the current error. More...
 
virtual const ErrorGetError () const
 Retrieve the current error. More...
 
virtual void ClearError () const
 Clear the current error information associated with this sensor.
 
virtual void SetErrnoError (const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const
 Set error information associated with a C library call that set an error to the "errno" global variable. More...
 
virtual void SetImaqError (int success, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const
 Set the current error information associated from the nivision Imaq API. More...
 
virtual void SetError (Error::Code code, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void SetErrorRange (Error::Code code, int32_t minRange, int32_t maxRange, int32_t requestedValue, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void SetWPIError (const wpi::Twine &errorMessage, Error::Code code, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void CloneError (const ErrorBase &rhs) const
 
virtual bool StatusIsFatal () const
 Check if the current error code represents a fatal error. More...
 
void ClearGlobalErrors ()
 Clear global errors.
 

Additional Inherited Members

- Static Public Member Functions inherited from frc::ErrorBase
static void SetGlobalError (Error::Code code, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber)
 
static void SetGlobalWPIError (const wpi::Twine &errorMessage, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber)
 
static Error GetGlobalError ()
 Retrieve the last global error.
 
static std::vector< ErrorGetGlobalErrors ()
 Retrieve all global errors.
 
- Protected Attributes inherited from frc::ErrorBase
Error m_error
 

Constructor & Destructor Documentation

◆ Notifier() [1/2]

frc::Notifier::Notifier ( std::function< void()>  handler)
explicit

Create a Notifier for timer event notification.

Parameters
handlerThe handler is called at the notification time which is set using StartSingle or StartPeriodic.

◆ Notifier() [2/2]

frc::Notifier::Notifier ( int  priority,
std::function< void()>  handler 
)
explicit

Create a Notifier for timer event notification.

This overload makes the underlying thread run with a real-time priority. This is useful for reducing scheduling jitter on processes which are sensitive to timing variance, like model-based control.

Parameters
priorityThe FIFO real-time scheduler priority ([0..100] where a lower number represents higher priority).
handlerThe handler is called at the notification time which is set using StartSingle or StartPeriodic.

Member Function Documentation

◆ SetHandler()

void frc::Notifier::SetHandler ( std::function< void()>  handler)

Change the handler function.

Parameters
handlerHandler

◆ SetName()

void frc::Notifier::SetName ( const wpi::Twine name)

Sets the name of the notifier.

Used for debugging purposes only.

Parameters
nameName

◆ StartPeriodic() [1/2]

void frc::Notifier::StartPeriodic ( double  period)

Register for periodic event notification.

A timer event is queued for periodic event notification. Each time the interrupt occurs, the event will be immediately requeued for the same time interval.

Deprecated:
Use unit-safe StartPeriodic(units::second_t period) method instead
Parameters
periodPeriod in seconds to call the handler starting one period after the call to this method.

◆ StartPeriodic() [2/2]

void frc::Notifier::StartPeriodic ( units::second_t  period)

Register for periodic event notification.

A timer event is queued for periodic event notification. Each time the interrupt occurs, the event will be immediately requeued for the same time interval.

Parameters
periodPeriod to call the handler starting one period after the call to this method.

◆ StartSingle() [1/2]

void frc::Notifier::StartSingle ( double  delay)

Register for single event notification.

A timer event is queued for a single event after the specified delay.

Deprecated:
Use unit-safe StartSingle(units::second_t delay) method instead.
Parameters
delaySeconds to wait before the handler is called.

◆ StartSingle() [2/2]

void frc::Notifier::StartSingle ( units::second_t  delay)

Register for single event notification.

A timer event is queued for a single event after the specified delay.

Parameters
delayAmount of time to wait before the handler is called.

◆ Stop()

void frc::Notifier::Stop ( )

Stop timer events from occuring.

Stop any repeating timer events from occuring. This will also remove any single notification events from the queue.

If a timer-based call to the registered handler is in progress, this function will block until the handler call is complete.


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