mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Moved C++ comments from source files to headers (#1111)
Also sorted functions in C++ sources to match order in related headers.
This commit is contained in:
committed by
Peter Johnson
parent
d9971a705a
commit
8c680a26f8
@@ -15,12 +15,6 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
/**
|
||||
* Create a Notifier for timer event notification.
|
||||
*
|
||||
* @param handler The handler is called at the notification time which is set
|
||||
* using StartSingle or StartPeriodic.
|
||||
*/
|
||||
Notifier::Notifier(TimerEventHandler handler) {
|
||||
if (handler == nullptr)
|
||||
wpi_setWPIErrorWithContext(NullParameter, "handler must not be nullptr");
|
||||
@@ -53,9 +47,6 @@ Notifier::Notifier(TimerEventHandler handler) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Free the resources for a timer event.
|
||||
*/
|
||||
Notifier::~Notifier() {
|
||||
int32_t status = 0;
|
||||
// atomically set handle to 0, then clean
|
||||
@@ -69,9 +60,33 @@ Notifier::~Notifier() {
|
||||
HAL_CleanNotifier(handle, &status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the HAL alarm time.
|
||||
*/
|
||||
void Notifier::SetHandler(TimerEventHandler handler) {
|
||||
std::lock_guard<wpi::mutex> lock(m_processMutex);
|
||||
m_handler = handler;
|
||||
}
|
||||
|
||||
void Notifier::StartSingle(double delay) {
|
||||
std::lock_guard<wpi::mutex> lock(m_processMutex);
|
||||
m_periodic = false;
|
||||
m_period = delay;
|
||||
m_expirationTime = Timer::GetFPGATimestamp() + m_period;
|
||||
UpdateAlarm();
|
||||
}
|
||||
|
||||
void Notifier::StartPeriodic(double period) {
|
||||
std::lock_guard<wpi::mutex> lock(m_processMutex);
|
||||
m_periodic = true;
|
||||
m_period = period;
|
||||
m_expirationTime = Timer::GetFPGATimestamp() + m_period;
|
||||
UpdateAlarm();
|
||||
}
|
||||
|
||||
void Notifier::Stop() {
|
||||
int32_t status = 0;
|
||||
HAL_CancelNotifierAlarm(m_notifier, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
void Notifier::UpdateAlarm() {
|
||||
int32_t status = 0;
|
||||
// Return if we are being destructed, or were not created successfully
|
||||
@@ -81,61 +96,3 @@ void Notifier::UpdateAlarm() {
|
||||
notifier, static_cast<uint64_t>(m_expirationTime * 1e6), &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the handler function.
|
||||
*
|
||||
* @param handler Handler
|
||||
*/
|
||||
void Notifier::SetHandler(TimerEventHandler handler) {
|
||||
std::lock_guard<wpi::mutex> lock(m_processMutex);
|
||||
m_handler = handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void Notifier::StartSingle(double delay) {
|
||||
std::lock_guard<wpi::mutex> lock(m_processMutex);
|
||||
m_periodic = false;
|
||||
m_period = delay;
|
||||
m_expirationTime = Timer::GetFPGATimestamp() + m_period;
|
||||
UpdateAlarm();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param period Period in seconds to call the handler starting one period
|
||||
* after the call to this method.
|
||||
*/
|
||||
void Notifier::StartPeriodic(double period) {
|
||||
std::lock_guard<wpi::mutex> lock(m_processMutex);
|
||||
m_periodic = true;
|
||||
m_period = period;
|
||||
m_expirationTime = Timer::GetFPGATimestamp() + m_period;
|
||||
UpdateAlarm();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void Notifier::Stop() {
|
||||
int32_t status = 0;
|
||||
HAL_CancelNotifierAlarm(m_notifier, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user