• Keine Ergebnisse gefunden

Agents and Agent Types

Im Dokument Formal Semantics for SDL (Seite 65-68)

Part 3: RSDL Language Definition

3.7 Agents and Agent Types

This clause introduces a number of language mechanisms to support the modelling of application specific phenomena by instances and application specific concepts by types.

The language mechanisms introduced provide:

a) (pure) type definitions that may be defined anywhere in a system; and

b) typebased instance definitions that define instances or instance sets according to types.

3.7.1 Block Types

There is a distinction between definition of instances (or sets of instances) and definition of types in RSDL descriptions. This clause introduces type definitions for agents, and corresponding instance specifications. An agent type definition is not connected (by channels) to any instances; instead, agent type definitions introduce gates (Section 3.8). These are connection points on the typebased instances for channels.

A type defines a set of properties, which are used by instances of the type.

An instance (or instance set) always has a type, which is implied if the instance is not explicitly based on a type, i.e. a block definition has an implied equivalent anonymous block type.

Abstract grammar

Agent-type-definition :: Agent-type-name

Signal-definition-set

Timer-definition-set Variable-definition-set

Agent-type-definition-set

Agent-definition-set

Gate-definition-set

Channel-definition-set

[ State-transition-graph ] State-transition-graph :: Start-node

State-node-set

Free-action-set

Agent-type-identifier = Identifier

If Agent-definition-set is not empty, Variable-definition-set must be empty and State-transition-graph must not be present. If State-transition-graph is present, Agent-definition-set and Channel-definition-set must be empty.

Concrete grammar

<agent type definition> ::= <block type definition>

<agent type structure> ::= { <entity in agent>

| <channel definition>

| <channel to channel connection>

| <gate in definition>

| <agent definition>

| <agent reference>

| <textual typebased agent definition> }*

[ <agent type body> ]

<agent type body> ::= <state machine graph>

<state machine graph>::= <start> { <state> | <free action> } *

<entity in agent> ::= <signal definition>

| <variable definition>

| <remote variable definition>

| <timer definition>

| <agent type definition>

| <agent type reference>

<block type definition> ::= <block type heading> <end> <agent type structure>

endblock type [ <block type name> ] <end>

<block type heading> ::= block type <block type name>

Semantics

An Agent-type-definition defines an agent type. All agents of an agent type have the same properties as defined for that agent type.

Signals mentioned in <output>s of the state machine of an agent type must be in the <signal list> of a gate in the direction from the agent type.

The properties defined in an Agent-type-definition such as the Agent-definition-set, and Gate-definition-set determine the properties of any Agent-definition based on the type.

A <block type definition> defines a block type.

3.7.2 Typebased Block Definition

Abstract grammar

Agent-definition :: Agent-name

Number-of-instances

Agent-type-identifier

Number-of-instances :: Initial-number [Maximum-number]

Initial-number = Int

Maximum-number = Int

Agent-identifier = Identifier

Concrete grammar

<textual typebased agent definition> ::=

<textual typebased block definition>

<textual typebased block definition> ::=

block <typebased block heading> <end>

<typebased block heading> ::=

<block name> [<number of instances>] <colon> <block type expression>

<type expression> ::= <base type>

<base type> ::= <identifier>

<number of instances> ::= ( [<initial number>] [ , [<maximum number>] ] )

<initial number> ::= <Integer name>

<maximum number> ::= <Integer name>

The initial number of instances and maximum number of instances contained in Number-of-instances are derived from <number of instances>. If <initial number> is omitted, then <initial number> is 1. If <maximum number>

is omitted, then <maximum number> is unbounded.

The <initial number> of instances must be less than or equal to <maximum number> and <maximum number>

must be greater than zero.

Semantics

A typebased block definition defines an Agent-definition based on a block type.

Blocks are always defined based on types. Types, on the other hand, may be arbitrarily nested in scopes.

An agent definition defines an (arbitrarily large) set of agents (blocks). An agent is characterised by having variables, a state machine or sets of contained agents.

A system is the outermost block.

3.7.3 Direct Agent Definitions

A block is defined by a <block definition>.

The instances contained within a block instance are interpreted concurrently and asynchronously with each other.

All communication between different contained instances within a block is performed asynchronously using signal exchange, either explicitly or implicitly.

Concrete grammar

<agent definition> ::= <block definition>

<agent structure> ::= <agent type structure>

<block definition> ::= <block heading> <end> <agent structure>

endblock [ <block name> ] <end>

<block heading> ::= block <block name> <agent instantiation>

<agent instantiation> ::= [<number of instances>]

Semantics

An Agent-definition has a name which can be used in qualifiers in conjunction with block.

An agent definition defines a set of agents. Several instances of the same agent set may exist at the same time and be interpreted asynchronously and in parallel with each other and with instances of other agent sets in the system.

The first value in the Number-of-instances represents the number of instances of the agent set which exist when the system or containing entity is created (initial instances), the second value represents the maximum number of simultaneous instances of the agent set.

An agent instance may have a communicating extended finite state machine defined by its state machine definition. Whenever the state machine is in a state, on input of a given signal it will perform a certain sequence of actions, denoted as a transition. The completion of the transition results in the state machine of the agent instance waiting in another state, which is not necessarily different from the first one.

When an agent is interpreted, the initial agents it contains are created. The signal communication between the finite state machines of these initial agents, the finite state machine of the agent and their environment commences only when all the initial agents have been created. The time taken to create an agent may or may not be significant.

Agent instances exist from the time that the containing agent is created or they can be created by create request actions of agents being interpreted; their interpretations start when their start action is interpreted; they may cease to exist by performing stop actions.

When the state machine of an agent interprets a stop, the agent ceases to exist.

Signals received by agent instances are denoted as input signals, and signals sent from agent instances are denoted as output signals.

Accessing remote variables also corresponds to exchange of signals, see Section 3.8.5.

Signals may be consumed by the state machine of an agent instance only when it is in a state.

Exactly one input port is associated with the finite state machine of each agent instance. Signals sent to a container agent will be delivered to a contained agent according to the channel structure.

The finite state machine of an agent is either waiting in a state or active, performing a transition. For each state, there is a save signal set. When waiting in a state, the first input signal whose identifier is not in the save signal set is taken from the queue and consumed by the agent.

The input port may retain any number of input signals, so that several input signals can be queued for the finite state machine of the agent instance. The set of retained signals are ordered in the queue according to their arrival time. If two or more signals arrive on different paths "simultaneously", they are arbitrarily ordered.

When the agent is created, its finite state machine is given an empty input port, and local variables of the agent are created.

When a container agent instance is created, the initial agents of the contained agent sets are created. If the container is created by a <create request>, parent of the contained agents (see Model below) receives the pid of the container.

A block definition is an agent definition that defines containers for one or more block definitions.

A block instance is an instantiation of a block type defined by an Agent-definition. To interpret a block instance is to:

a) interpret the contained agents and their connected channels, or b) interpret the state machine of the block (if present).

In a block with a finite state machine, the finite state machine is interpreted.

Variables of a block cannot be accessed from other blocks.

Model

An Agent-definition has an implied anonymous agent type that defines the properties of the agent.

In all agent instances, four anonymous variables of the pid sort are declared and are, in the following, referred to by self, parent, offspring and sender. They give a result for:

a) the agent instance (self);

b) the creating agent instance (parent);

c) the most recent agent instance created by the agent instance (offspring);

d) the agent instance from which the last input signal has been consumed (sender).

These anonymous variables are accessed using pid expressions as further explained in Section 3.12.4.

For all initial agent instances parent is initialised to the container agent. For the system agent, parent is initialised to null.

For all newly created agent instances, sender and offspring are initialised to null.

3.8 Communication

Im Dokument Formal Semantics for SDL (Seite 65-68)