03.08.2013 Views

Design and Implementation of TinyGALS: A Programming Model for ...

Design and Implementation of TinyGALS: A Programming Model for ...

Design and Implementation of TinyGALS: A Programming Model for ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2.2.1 <strong>TinyGALS</strong> Components<br />

Components are the most basic elements <strong>of</strong> a <strong>TinyGALS</strong> program. A <strong>TinyGALS</strong> compo-<br />

nent C is a 3-tuple:<br />

C = (VC,XC,IC), (1)<br />

where VC is a set <strong>of</strong> internal variables, XC is a set <strong>of</strong> external variables, <strong>and</strong> IC is a set<br />

<strong>of</strong> methods that constitute the interface <strong>of</strong> C. The internal variables carry the state <strong>of</strong> C<br />

from one invocation <strong>of</strong> an interface method <strong>of</strong> C to another. The external variables can<br />

be accessed by C through read <strong>and</strong> write operations. 2 The set <strong>of</strong> methods IC is further<br />

divided into two disjoint sets: ACCEPT SC <strong>and</strong> USESC. The methods in ACCEPT SC can<br />

be called by other components (these are the inputs <strong>of</strong> component C), while the methods<br />

in USESC are those needed by C <strong>and</strong> may possibly belong to other components (these are<br />

the outputs <strong>of</strong> component C). 3 Thus, a component is like an object in most object-oriented<br />

programming languages, but with explicit definition <strong>of</strong> the external variables <strong>and</strong> methods<br />

it uses. Syntactically, a component is defined in two parts – an interface definition <strong>and</strong> an<br />

implementation.<br />

Figure 2 shows a fragment <strong>of</strong> the code <strong>for</strong> the interface definition <strong>of</strong> the COUNTER<br />

component shown in Figure 1, while Figure 3 shows a fragment <strong>of</strong> the code <strong>for</strong> its imple-<br />

mentation. 4 In Figure 2, we see that the component has two ACCEPT S methods <strong>and</strong> one<br />

USES method. In Figure 3, we see that the component accesses an internal variable <strong>of</strong> type<br />

short named _counter. Using the tuple notation given in Equation 1, the COUNTER<br />

component can be defined as C = (VC = { counter},XC = /0,IC = {init, f ire, f ireOut}).<br />

2 External variables are implemented as TinyGUYS. See Section 2.4 <strong>for</strong> more in<strong>for</strong>mation.<br />

3 Using TinyOS conventions, ACCEPT SC is the set <strong>for</strong>med by the union <strong>of</strong> the TinyOS ACCEPTS <strong>and</strong><br />

HANDLES methods, <strong>and</strong> USESC is the set <strong>for</strong>med by the union <strong>of</strong> the TinyOS USES <strong>and</strong> SIGNALS methods.<br />

4 The syntax is similar to that <strong>of</strong> TinyOS.<br />

8

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!