![]() |
![]() |
![]() |
![]() |
![]() |
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:
- an individual BIT in a BITSTRING;
- an element in a SEQUENCE or SEQUENCE OF;
- an element in a SET or SET OF;
- an element in a CHOICE.
These references may be made either:
- in the context of a SEND or RECEIVE statement; or
- by capturing an incoming ASP or PDU for later reference.
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:
- ASP_Identifier . ParameterIdentifier
- PDU_Identifer . FieldIdentifier
- CM_Identifer . FieldIdentifier
- StructuredTypeIdentifier . ElementIdentifier
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:
A constraint on that PDU may be:
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.
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:
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:
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:
We can now access components of a_pdu on subsequent statement lines and not just on the statement line that contains the RECEIVE statement:
http://www.ibm.com/rational |
![]() |
![]() |
![]() |
![]() |