Information Technology Reference
In-Depth Information
3.2.1.3
Component Configurations
Components are either modules or configurations . Each TinyOS “program” is a
configuration of interconnected modules; each module is an encapsulation of code
based on functionality, reminiscent of classes in object-oriented programming
languages. Each configuration and module is described in a separate .nc file. Modules
are connected through interfaces. An interface is a collection of events a given
component can signal or be notified of, and commands that a component can issue
or obey. Interfaces are also defined in their separate .nc files. A configuration is con-
nected by “software wiring” of the interfaces. This is accomplished in two steps:
1. Each module lists the desired interface in either its uses {…} block, or its pro-
vides {…} block
2. A special line in the coniguration code is added, which establishes a unidirec-
tional link between an interface provider and an interface user . This is achieved
with the following line of code:
User.UserInterfaceName -> Provider.ProvInterfaceName
or alternetively:
Provider.ProvInterfaceName <- User.UserInterfaceName
(The UserInterfaceName part may be omitted, if the interface names are the
same.)
One example of an interface is the Timer interface, through which the system
component for the onboard timer notifies the user component of regularly spaced
tick events. The description of this interface is given in Timer.nc:
interface Timer {
command result_t start(char type, unit32_t interval);
command result_t stop();
event result_t fired();
}
From the source code, it should be clear that the interface specifies one event -
fired() - through which the Timer provider notifies the user of timer ticks, and
accepts two commands - start, which accepts the type and interval parameters and
starts the timer, and stop(), which stops the timer.
The actual semantics of the words provider and user might not be immediately
clear: The events and commands which are the part of the interface are specified in
the interface's .nc file. If a module declares itself to be a provider of a given inter-
face, then it is responsible to implement all commands listed by the interface, and
acquires the right (which it may or may not use) to signal events to those users of
said interface to which it is connected through wiring. Likewise, if a module
declares itself to be a user of an interface, then it is responsible to implement event
handlers for every single event specified by the interface, and it attains the right to
issue commands to the provider of the used interface.
In other words, the provider can signal events to users, and users can issue
commands to the provider.
Search WWH ::




Custom Search