Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | Both sides next revision | ||
| alvis:out [2016/07/11 10:53] marcin | — (current) | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Out statement ====== | ||
| - | An agent can communicate with its outside world using **ports**. Each port can be used both as an input or an output one. The current role of a port is determined by two factors: | ||
| - | - Connections to the port in the corresponding communication diagram -- e.g. if a port '' | ||
| - | - Statements used in the code layer -- e.g. if a port '' | ||
| - | |||
| - | Any communication through a port can be a **pure communication** or a **value passing combination**. | ||
| - | |||
| - | In case of a **pure communication**, | ||
| - | |||
| - | In case of a **value passing communication**, | ||
| - | |||
| - | The **out** statement as a **blocking communication** is a single-step statement. | ||
| - | |||
| - | < | ||
| - | out p; | ||
| - | out p x; | ||
| - | out p v; | ||
| - | </ | ||
| - | |||
| - | **Listing 1. ** In statement syntax: '' | ||
| - | |||
| - | |||
| - | ** Example 1 ** | ||
| - | |||
| - | {{: | ||
| - | |||
| - | **Figure 1. ** Example 1 communication diagram | ||
| - | |||
| - | < | ||
| - | agent A { | ||
| - | out a; | ||
| - | } | ||
| - | |||
| - | agent B { | ||
| - | in b; | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | **Listing 2. ** Example 1 code layer | ||
| - | |||
| - | The only task of agent '' | ||
| - | |||
| - | A communication between two active agents can be initialised by any of them. The agent that initialises it, performs the **out** statement to provide some information and waits for the second agent to take it, or performs the **in** statement to express its readiness to collect some information and waits until the second agent provides it. | ||
| - | |||
| - | **Example 2** | ||
| - | |||
| - | {{: | ||
| - | |||
| - | **Figure 2. ** Example 2 communication diagram | ||
| - | |||
| - | < | ||
| - | agent A { | ||
| - | out a; | ||
| - | } | ||
| - | |||
| - | agent B { | ||
| - | in b; | ||
| - | } | ||
| - | |||
| - | agent C { | ||
| - | in c; | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | **Listing 3. ** Example 2 code layer | ||
| - | |||
| - | In the above example the port '' | ||
| - | |||
| - | A **blocking communication** means that if an agent initialises a communication with the **out** statement then it waits until another agent finishes it. The communication cannot be aborted. | ||
| - | |||
| - | A communication with a passive agent denotes a procedure call. If an agent initialises a communication with the **out** statement and the corresponding procedure is accessible, then the passive agent starts executing it. Otherwise, the active agent waits for the procedure accessibility. | ||
| - | |||
| - | The **out** statement as an **non-blocking communication** may be a single-step or multi-step statement. | ||
| - | |||
| - | < | ||
| - | out (t) p x { | ||
| - | success { ... } | ||
| - | fail { ... } | ||
| - | } | ||
| - | |||
| - | out (t) p x { | ||
| - | fail { ... } | ||
| - | } | ||
| - | |||
| - | out (t) p x { | ||
| - | success { ... } | ||
| - | } | ||
| - | |||
| - | out (t) p x; | ||
| - | |||
| - | out (t) p { | ||
| - | success { ... } | ||
| - | fail { ... } | ||
| - | } | ||
| - | |||
| - | out (t) p { | ||
| - | fail { ... } | ||
| - | } | ||
| - | |||
| - | out (t) p { | ||
| - | success { ... } | ||
| - | } | ||
| - | |||
| - | out (t) p; | ||
| - | </ | ||
| - | |||
| - | **Listing 4. ** Out statement syntax (non-blocking version): '' | ||
| - | |||
| - | A **non-blocking communication** means that the agent aborts the communication if it cannot be realized realized within '' | ||
| - | |||
| - | **In case of non-time models**, if an agent communicates with an active agent then a **non-blocking in** succeeds if it finishes the communication. If an agent calls a procedure of a passive agent then a **non-blocking in** succeeds if the procedure is accessible and starts immediately. | ||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | **See also:** [[: | ||
| - | |||
| - | **[[: | ||