21.08.2013 Views

A State-Based Programming Model for Wireless Sensor Networks

A State-Based Programming Model for Wireless Sensor Networks

A State-Based Programming Model for Wireless Sensor Networks

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

116 Chapter 6. Implementation<br />

the scanner is generated by a lexical analyzer generator called JFLEX (Fast Lexical<br />

Analyzer Generator <strong>for</strong> Java). JFLEX is the Java counterpart of FLEX, a tool<br />

generating scanners in the C programming language.<br />

The second pass of the OSM compiler operates on the in-memory syntax tree<br />

(created during the first pass) of the OSM input. Concretely, it extends the inmemory<br />

representation of interfaces that are only implicitly defined in the input<br />

file (such as a complete list of variables visible <strong>for</strong> each state). It also per<strong>for</strong>ms<br />

some input verification beyond mere syntactical checks, <strong>for</strong> example, if all transition<br />

targets exist and if all variables used in actions and guards have been<br />

defined. However, error checking is mostly delegated to the Esterel compiler on<br />

the intermediate Esterel representation of the OSM program. This approach is<br />

convenient as we did not need to implement the functionality ourselves, yet can<br />

provide some error notifications. On the other hand it is very inconvenient <strong>for</strong><br />

OSM programmers as they must be able to interpret the somewhat cryptic error<br />

messages of the Esterel compiler, which in turn requires to be familiar with the<br />

Esterel language.<br />

In the third pass, the Esterel representation of the OSM input is generated<br />

according to the language mapping, as described in the previous section. This<br />

representation is then compiled to plain C code with the Esterel compiler. The<br />

final executable is produced from a C compiler by a generic makefile (see<br />

Appendix A.5.2). It compiles and links the three elements that make up an<br />

OSM program in the host-language C: (1) the C-language output of the Esterel<br />

compiler, representing the program’s control flow and structure, (2) the statevariable<br />

mappings, which are directly produced as a C header file by the OSM<br />

compiler, and (3) the definitions of actions written in C by the programmer.<br />

In the current version the OSM-compiler prototype, some features desirable<br />

<strong>for</strong> routine program development have not been implemented, mostly due to<br />

time constraints. For example, the OSM compiler does not support compilation<br />

units. Only complete OSM specifications can be processed by the compiler. Note<br />

however, that as far as compilation units are concerned, the implementation of<br />

actions is independent of the program. Actions are specified in (one or several)<br />

C files, which may be compiled separately from the OSM program (see Fig. 6.1).<br />

Also, some OSM features not supported in the current version of the compiler.<br />

These features are:<br />

• Incoming transitions with the declaration of a source state (as in<br />

onEntry: A -> e / inA();): Incoming transitions without the declaration<br />

of a source state (such as onEntry: e / inA();) work fine.<br />

This feature is currently missing, as its implementation in Esterel is rather<br />

complex.<br />

• <strong>State</strong> incarnations and thus adding and renaming actions, transitions and<br />

preemption actions to incarnations: We have shown the feasibility and<br />

usefulness of state incarnations in a previous implementation of the OSM<br />

compiler (presented in [74]). In the re-implementation, this feature was<br />

dropped due to time constraints.<br />

• Preemption actions: The realization of preemption actions in the Esterel<br />

language is straight<strong>for</strong>ward, yet, would require additional analysis in the

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

Saved successfully!

Ooh no, something went wrong!