IBM
Contents Index Previous Next



Referencing Components of Complex Types


TTCN allows the use of individual components of complex types as operands in expressions or as the l.h.s. of an assignment. Such components include:

In the context of ASN.1 it is possible to access:

These references may be made either:

References in the Context of SEND and RECEIVE

These are references to ASP parameters, PDU fields or structure elements made from a statement line that contains a SEND or RECEIVE and, most importantly, an associated constraint. In their simplest form these references are denoted by:

Suppose that a substructured PDU is chained to an ASP. To reference the kth element in the structure from a statement line we could write:

However, because the ASP, PDU and structure identifiers are unique within the test suite, it is allowed to simply use:

For example, if we wish to preserve the value of the user_data field of the incoming DT_PDU, embedded in an N_DATAindication. This could be done by writing:

This is rather verbose and because the PDU identifier is unique it is enough to write:

In other words the `dotted path' need only contain the identifiers that are enough to give a complete and unique reference.

Referencing ASN.1 Elements

The same mechanism can be used to reference elements in ASN.1 constraints that use SEQUENCE, SEQUENCE OF etc.

Suppose that we have defined the following PDU:

Figure 48 : A TTCN PDU Type

A constraint on that PDU may be:

Figure 49 : A TTCN PDU Constraint

Then writing:

Figure 50 : A Send Statement

means that the third field in the constraint is overridden and that the send object a_pdu is transmitted with field3 having the value FALSE.

Note:

Where possible values should be set using parameters, rather than by this mechanism.

In cases where the elements are not named, such as the elements in the SEQUENCE OF INTEGER that compose field2 in our previous examples, it is possible to reference the element by position. For example, if we wish to override the value 22 in field2 we simply write:

Figure 51 : A Send statement

Individual bits in a BIT STRING can also be accessed in a similar manner. If we wish to change the third bit in the value of field1 from 0 to 1 we write:

Figure 52 : A Send statement

This mechanism cannot be used with other string types.

Capturing Incoming ASPs and PDUs

An incoming ASP or PDU (i.e. received object) is only preserved for the duration of a RECEIVE statement, i.e. components of the received object cannot be accessed on statement lines subsequent to the RECEIVE event. It is possible, however, to declare variables of ASP, PDU or structure type. These variables are then bound to the received object. Suppose the variable temp_pdu is of type A_PDU:

Figure 53 : A Receive statement

We can now access components of a_pdu on subsequent statement lines and not just on the statement line that contains the RECEIVE statement:

Figure 54 : A Qualifier statement


http://www.ibm.com/rational
Contents Index Previous Next