/** * This file is part of license combination gpl version 3 license and eCos. * The corresponding license terms are below. * * gpl version 3 Licence: * * The file were developed during the student thesis "Datensammlung in Wireless * Sensor Networks fuer Autonomic Home NetworkingÒ of Thomas Kothmayr and is * included in the dissertation "Secure Data Transmission in Wireless * Sensor Networks" by Corinna Schmitt during employment at the Technische * UniversitŠt MŸnchen, Department Computer Science, Chair Network * Architectures and Services (Germany). * Copyright (C) 2013 * Authors: Thomas Kothmayr and Corinna Schmitt (schmitt[at]net.in.tum.de) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3 of the License * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * * eCos Licence: (http://ecos.sourceware.org) * * This file is part of eCos, the Embedded Configurable Operating System. * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, * 2007, 2008, 2009 Free Software Foundation, Inc. * * eCos is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free * Software Foundation; either version 3 any later version. * * eCos is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along * with eCos; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * As a special exception, if other files instantiate templates or use * macros or inline functions from this file, or you compile this file and * link it with other works to produce a work based on this file, this file * does not by itself cause the resulting work to be covered by the GNU * General Public License. However the source code for this file must still * be made available in accordance with section (3) of the GNU General * Public License v2. * * This exception does not invalidate any other reasons why a work based on * this file might be covered by the GNU General Public License. * */ Interface: tos.lib.timer.Alarm

Interface: tos.lib.timer.Alarm

interface Alarm<typedef precision_tag, typedef size_type>

An Alarm is a low-level interface intended for precise timing.

An Alarm is parameterised by its "precision" (milliseconds, microseconds, etc), identified by a type. This prevents, e.g., unintentionally mixing components expecting milliseconds with those expecting microseconds as those interfaces have a different type.

An Alarm's second parameter is its "width", i.e., the number of bits used to represent time values. Width is indicated by including the appropriate size integer type as an Alarm parameter.

See TEP102 for more details.

Parameters:
precision_tag - A type indicating the precision of this Alarm.
size_type - An integer type representing time values for this Alarm.
Author:
Cory Sharp <cssharp@eecs.berkeley.edu>

Commands
command size_type getAlarm() Return the time the currently running alarm will fire or the time that the previously running alarm was set to fire.
command size_type getNow() Return the current time.
command bool isRunning() Check if alarm is running.
command void start(size_type dt) Set a single-short alarm to some time units in the future.
command void startAt(size_type t0, size_type dt) Set a single-short alarm to time t0+dt.
command void stop() Cancel an alarm.

Events
event void fired() Signaled when the alarm expires.

Commands - Details

getAlarm

command size_type getAlarm()

Return the time the currently running alarm will fire or the time that the previously running alarm was set to fire.

Returns:
Alarm time.

getNow

command size_type getNow()

Return the current time.

Returns:
Current time.

isRunning

command bool isRunning()

Check if alarm is running. Note that a FALSE return does not indicate that the fired event will not be signaled (it may have already started executing, but not reached your code yet).

Returns:
TRUE if the alarm is still running.

start

command void start(size_type dt)

Set a single-short alarm to some time units in the future. Replaces any current alarm time. Equivalent to start(getNow(), dt). The fired will be signaled when the alarm expires.

Parameters:
dt - Time until the alarm fires.

startAt

command void startAt(size_type t0, size_type dt)

Set a single-short alarm to time t0+dt. Replaces any current alarm time. The fired will be signaled when the alarm expires. Alarms set in the past will fire "soon".

Because the current time may wrap around, it is possible to use values of t0 greater than the getNow's result. These values represent times in the past, i.e., the time at which getNow() would last of returned that value.

Parameters:
t0 - Base time for alarm.
dt - Alarm time as offset from t0.

stop

command void stop()

Cancel an alarm. Note that the fired event may have already been signaled (even if your code has not yet started executing).

Events - Details

fired

event void fired()

Signaled when the alarm expires.