mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-29 13:10:36 +08:00
Reorganized directory structure - directory 'internal' pulled up one level. No logical changes.
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include <uavcan/node/timer.hpp>
|
||||
|
||||
namespace uavcan
|
||||
{
|
||||
|
||||
void Timer::handleDeadline(MonotonicTime current_timestamp)
|
||||
{
|
||||
assert(!isRunning());
|
||||
|
||||
const MonotonicTime scheduled_time = getDeadline();
|
||||
|
||||
if (period_ < MonotonicDuration::getInfinite())
|
||||
startWithDeadline(scheduled_time + period_);
|
||||
|
||||
// Application can re-register the timer with different params, it's OK
|
||||
handleTimerEvent(TimerEvent(scheduled_time, current_timestamp));
|
||||
}
|
||||
|
||||
void Timer::startOneShotWithDeadline(MonotonicTime deadline)
|
||||
{
|
||||
stop();
|
||||
period_ = MonotonicDuration::getInfinite();
|
||||
DeadlineHandler::startWithDeadline(deadline);
|
||||
}
|
||||
|
||||
void Timer::startOneShotWithDelay(MonotonicDuration delay)
|
||||
{
|
||||
stop();
|
||||
period_ = MonotonicDuration::getInfinite();
|
||||
DeadlineHandler::startWithDelay(delay);
|
||||
}
|
||||
|
||||
void Timer::startPeriodic(MonotonicDuration period)
|
||||
{
|
||||
assert(period < MonotonicDuration::getInfinite());
|
||||
stop();
|
||||
period_ = period;
|
||||
DeadlineHandler::startWithDelay(period);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user