Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionBoth sides next revision | ||
alvis:codestructure [2013/11/27 05:46] marcin created | — (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Code layer structure ====== | ||
- | The code layer is used to describe the behaviour of individual agents in Alvis models. The layer uses Alvis behaviour description statements and some elements of the Haskell functional programming language. The code layer is used to: | ||
- | * define data types used in the model under consideration, | ||
- | * define functions for data manipulation, | ||
- | * specify the considered embedded system environment, | ||
- | * define behaviour of individual agents. | ||
- | |||
- | < | ||
- | -- Preamble: | ||
- | -- types | ||
- | -- | ||
- | -- | ||
- | -- | ||
- | |||
- | -- Implementation: | ||
- | -- | ||
- | </ | ||
- | |||
- | **Listing 1. ** Structure of the code layer | ||
- | |||
- | The general structure of the code layer is presented in Listing 1. | ||
- | The **preamble** contains definitions of types, constants and functions used to manipulate data in a model. This part of the preamble is encoded in pure Haskell. Moreover, the preamble may contain specification of some environment activities that may be useful e.g. for an Alvis model simulation. | ||
- | |||
- | |||
- | The **implementation** contains definitions of the agents' | ||
- | |||
- | < | ||
- | agent AgentName | ||
- | { | ||
- | -- declaration of parameters | ||
- | -- agent body | ||
- | } | ||
- | </ | ||
- | |||
- | **Listing 2. ** Structure of an agent block | ||
- | |||
- | Both Haskell and Alvis are case sensitive languages. Haskell requires type names to start with an upper-case letter, and variable names to start with a lower-case letter. We follow Haskell footsteps. Moreover, Alvis requires agent names to start with an upper-case letter, and port names to start with a lower-case letter. | ||
- | |||
- | |||
- | **[[: |