Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Both 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. 
- 
-<code> 
--- Preamble: 
---   types 
---   constants 
---   functions  
---   environment specification 
- 
--- Implementation: 
---   agents 
-</code> 
- 
-**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' behaviour. This part is encoded using native Alvis  statements, but the preamble contents is used to represent parameters values and to manipulate them. It contains at least one **agent block** as shown in Listing 2. It is possible to share one definition among a few agents. In such a case, a few agents' names are placed after the keyword **agent** separated by commas. 
- 
-<code> 
-agent AgentName  
-{ 
-  -- declaration of parameters 
-  -- agent body 
- 
-</code> 
- 
-**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. 
- 
- 
-**[[:alvis:manual|Go back]]**