• Non ci sono risultati.

In order to address communications of DSTM Machines and some specific fea-tures as the termination, To address the communication mechanisms and also the machine termination a complex type system has been introduced in DSTM.

In particular three main elements are here considered: (1) Data Types, (2) Chan-nels and (3) Variables. Below mappings related to each of them are discussed.

5.3.1 Data types

With the respect to the Data Types, it has to be considered that Promela provides seven different predefined simple data types: bit, bool, pid, byte, short, int and un-signed. With the respect to the composite type, instead, Promela provides the con-cept of typedef which allows for user-defined data types. Also DSTM provides simple and multi types and the mapping process is different in the two cases. In fact, for simple types the mapping process is quite straightforward since it is a one-by-one mapping: each tInteger is mapped in a int, each tChannel, in a global channel and each tEnum, in an mtype which is a declaration for the introduction of symbolic names for constant values. Table5.2summarize mappings between Data Types.

The process to map channels and variables, and in particular the multi type ones, is very different and is treated in the following subsections.

TABLE5.2: Mapping of types

DSTM Promela equivalent

Data Types tInteger int

tEnum mtype= {literals0, literals1, ..., literalsn};

tChannel mtype= {channel_names0, ..., channel_namesm};

5.3.2 Channels

Channels represent the way with which DSTM machines can communicate. The problem in mapping channels with corresponding Promela is that DSTM intro-duces two fundamental characteristics which are not present in Promela:

1. first, DSTM distinguishes between internal and external channels; the for-mer are used for internal DSTM machine communication while the latter are used for the exchange of messages with the environment. At the con-trary, Promela, provides only one kind of channel, that is the Global Channel.

2. DSTM provides the concept of "channels of channels", which can be ex-pressed in the form Chn[T] (Section4.1.3), where T is used to trace the type of the contained channels;

3. furthermore, DSTM channels can be of simple and multi type. The first ones are simple to translate in Promela, while for the second the process is more complex.

In order to address the mapping issues discussed above, Promela channels, are generated according to the below process:

• Internal Channels of simple types, are mapped in a Promela global chan-nel which has the same bound specified within the internal chanchan-nel of the DSTM model. The type of the channel, instead, correspond to the type of messages conveyed in the channel.

• At the same way, external channels of simple types are mapped in Promela global channels, with the type corresponding to the message type, but the bound fixed to one;

• multi type channel, instead, does not have an corresponding concept in Promela. For such reason, they are modelled by creating one Promela chan-nel for each simple type contained within the multi type of the considered channel. The set of Promela channels associated with a multi-type channel are properly managed, so as to ensure that at each moment at most one of them contains a message.

• finally, the Chn[T] are translated in a Promela global channel, containing as many chan type, as the subtypes contained in T.

Thus, Table5.3reports an example of mappings related to DSTM channels.

TABLE5.3: Mapping of channels

DSTM Promela equivalent

Simple type channels

Chn external c of Int chan c = [2] of {int};

Chn internal c[bound] of Int chan c = [bound] of {int};

Chn external c of enum chan c = [2] of {mtype};

Chn internal c[bound] of enum chan c = [bound] of {mtype};

Chn external c of compound chan c = [2] of {...};

Chn internal c[bound] of compound chan c = [bound] of {...};

Multi type channels Mtype MT1 { ST1,ST2,ST3 }

Chn external c of MT1 chan c_ST 1 = [2] of {...};

chan c_ST 2 = [2] of {...};

chan c_ST 3 = [2] of {...};

Chn internal c [bound] of MT1; chan c_ST 1 = [bound] of {...};

chan c_ST 2 = [bound] of {...};

chan c_ST 3 = [bound] of {...};

Chn external c of Chn[MT1] chan c = [2] of {chan, chan, chan};

Chn external c of Chn[MT1] chan c = [2] of {chan, chan, chan};

5.3.3 Variables

DSTM global variable, are translated into the corresponding concept of Promela variable. As for the type the process is quite straightforward. In fact, type and name of a DSTM variable, are mapped in a Promela variable, in a C-like style.

The only exception is the multi type variable which does not have a correspond-ing concept in Promela. As in the case of the channels, many simple type variable as the number of subtypes contained in the considered multi type variable, are generated. Table5.4shows some examples of such mappings.

TABLE5.4: Mapping of channels

DSTM Promela equivalent

Simple type variables

Int v int v;

Enum v mtype v;

Chn v chan v;

Multi type variable Mtype MT1 { ST1,ST2,ST3 }

Chn[MT1] v chan v_ST 1;

chan v_ST 2;

chan v_ST 3;

5.3.4 Triggers, Conditions and Actions

Data types, channels and variables allow to define the decoration on the DSTM transitions. As in the HSMs, a decoration can be composed by trigger, conditions and actions and are treated as strings, whose meanings is given by the modeller with the respect to him context. In DSTM triggers, conditions and actions have a formal syntax and semantics, despite, at the modelling level, can be treated as simple strings. Treat decorations as simple strings allows to not increase the complexity of the DSTM metamodel and enables to model complex expressions (as the nested ones) by means of text. Thus, triggers, conditions and actions must be mapped in corresponding Promela concepts, according to the meaning demanded by the formal syntax and the semantics. In particular, triggers and conditions can be specified only as receptions on a channel (external and inter-nal). Thus, the mapping process must be performed according to the mapping defined for them treating separately the simple and the multi type cases. Also the actions provide send on a channel, but in addition they allow to specify vari-ables assignment. In this case the mapping is quite straightforward, since both the left and the right operands are mapped in the corresponding Promela ele-ments. Table5.5reports a summary of all possible mappings related to triggers, conditions and actions.

TABLE5.5: Translating the transitions decorations to Promela

DSTM

Simple Type Multi type

C?[,...,_], if C is internal C_T 1?[1, _, ..., _]∣∣...C_TN?[1, _, ..., _], if C is internal C? C?[1, _, ...,]if C is external C_T 1?[1, _, ...,]∣∣...C_TN?[1, _, ..., _] if C is external

C_T 1?[1, _, ..., _]∣∣...C_TN?[1, _, ..., _], if C is internal Trigger

C?T Not allowed

C_T 1?[1, _, ...,]∣∣...C_TN?[1, _, ..., _] if C is external C[? < . . . , x, ... >] if C is internal C_T 1?[1, ..., Xt, ...]∣∣...C_Tn?[1, ..., Xp, ...]1if C is internal C[? < ..., Xt, .. >] C[? < 1, . . . , x, ... >] if C is external C_T1?[1, ..., Xp, ...]∣∣...C_Tn?[1, ..., Xt, ...] if C is internal

empty(C) len(C) == 0 len(C_T1) == 0&&...&&len(C_Tn) == 0 Condition

f ull(C) len(C) = channel_bound len(C) = channel_bound&&..&&len(C) = channel_bound

V=x V p= Xp Not allowed

Action

C!< x, y, ..., z > C!x, y, ..., z C_T j!x, y, ..., z where C_T j is a channel compliant with the type T j