• Keine Ergebnisse gefunden

T RANSLATIONAL S EMANTICS FOR UML CS P ROFILE

Im Dokument UML Profile for Communicating Systems (Seite 189-195)

It is assumed that a UML model is actually mapped to SDL. During the SDL-2000 compilation process, an SDL specification is successively transformed into an abstract syntax tree, namely AS1 defined in Z.100 main body. This AS1 is the result of parsing and checking by well-formedness conditions of the SDL program. AS1 abstracts away from additional but non-essential expressions like delimiters, keywords, graphical elements, blank spaces and so on only focusing on the relevant information. Furthermore, complex language constructs are decomposed into core concepts.

To validate that the mapping from UML to SDL is correct, the model defined in the UML repository and the system defined in the AS1 of SDL are compared and cross-checked if they fulfill and match specific properties. This comparison must always show that the given constraints are fulfilled.

Otherwise, the mapping is considered invalid. There are two pre-requisites for such a comparison:

First, for the comparison of values, both data types must be type-compatible. Therefore, before constraints can be applied between both models the data types have to be aligned. Second, each composite object in both the UML repository and the AS1 tree must be uniquely addressable – in other words, the repository and syntax tree must be navigable. For a specification language, the obvious choice for UML-based models is OCL as it is part of the UML standard. OCL supports navigation of the UML metamodel. Therefore, the abstract grammar is mapped to a MOF-compliant metamodel.

This profile drives the mapping from UML to SDL by means of the formal object constraint language OCL 2.0 [OMG05d]. For this purpose a mapping function Mapping is defined:

Mapping: UML Æ SDL

This mapping functions maps a UML model (e.g. given in XMI representation) to an SDL system specification. It is not described how this can be achieved within an implementation. There are OCL expressions specified that constrain the invariant variables or associations of the UML elements that apply to the stereotyped classes.

To specify the mapping performed by the function Mapping, only post-operation conditions of the mapping are given. Pre-operation conditions are already specified through the static (invariant) constraints of the profile’s stereotypes. The post-constraints validate whether both composite objects (the object in the UML repository and the object in the AS1) are equivalent after the mapping or not.

OCL is a declarative language and cannot alter the system state.

The mapping constraints relate to the abstract syntax (abstract grammar) definition of SDL on the left-hand side and to the UML stereotypes attributes and associations on the right-left-hand side. Notice, the OCL constraints only apply if a UML model element is mapped that has the correct stereotype applied. All constraints given must be preceded by an implication expression as the constraint is always defined in the context of the Mapping function. For instance, the correct OCL constraint expression for the name attribute mapping for the state class stereotyped with «state» is the following:

context Mapping(sdl: SDL-specification, uml: Classifier, co: Object, e:

Element)

post: isStereotypedBy(e,state) implies co.name=e.name

where sdl is the root object of the SDL specification, uml is the system or package class object, co is the composite object of the SDL AS1 tree that is to be validated against the Element e defined within the uml Classifier. As this applies to all following mapping rules, the context and postconstraint part has been omitted in all constraints.

Figure 81: Mapping Specification by OCL

Figure 81 pictorially represents the procedure of the translational semantic mapping to SDL. The mapping is accomplished by the rule that UML model elements with stereotyped extension of the UML CS profile are mapped to the abstract syntax of SDL-2000. How this is finally achieved in an implementation is not specified. However, the following OCL constraints validate that the mapping is done in a way that is intended by the semantic description of the profile’s modeling elements.

8.1.1 Type mapping from SDL AS1 to MOF

The abstract syntax of SDL is defined by an abstract grammar [ITU06b]. For example, the abstract UML 2

UML CS Profile

SDL Abstract Syntax AS1 MOF

OCL

Mapping: UML+UML CS Æ SDL AS1

Type Conversion:

SDL AS1 Æ MOF

Validate correct mapping by means of OCL

MOF-compliant AS1

8.1 Translational Semantics for UML CS Profile

Channel-definition :: Channel-name [NODELAY]

Channel-path-set

This defines the domain for the composite object named Channel-definition. This object consists of further three sub-components. The definition

Channel-name = Name

Name :: Token

expresses that the Channel-name resolves into a Token. This composite object can also be perceived as a tree with some root node.

To be able to compare the values of two data types, both must be of the same data type. Therefore, all elementary types of the SDL AS1, which do not resolve into other types, are converted to an appropriate OCL data type. As noted, the abstract syntax of SDL can be regarded as a named composite object (a tree) defining a set of sub components. An object might also be of some elementary (non-composite) domains. In the context of SDL, these are: Token, Nat, Quotation, and Set. These elementary objects are mapped to an OCL type.

8.1.1.1 NATURAL OBJECTS

Example:

Number-of-instances :: Nat [Nat]

Number-of-instances denotes a composite domain containing one mandatory natural (Nat) value and one optional natural ([Nat]) denoting respectively the initial number and the optional maximum number of instances. A Nat is mapped to a non-negative Integer value.

convert: Nat -> Integer

context convert(nat: Nat) : Integer post: result >=0

8.1.1.2 QUOTATION OBJECTS

These are represented as any bold face sequence of uppercase letters and digits.

Example:

Channel-definition :: Channel-name

[NODELAY]

Channel-path-set

A channel may be delaying or not. This is denoted by an optional quotation NODELAY. This quotation is mapped to a String that is associated with the respective compound object. If no composite object is defined in the AS, the name of the String is constructed with the first name of its containing composite object name with suffix -kind. For example, the name of the String containing the Quotation object NODELAY for a Channel-definition would be Channel-kind.

convert: Quotation -> String

8.1.1.3 UNSPECIFIED OBJECTS AND REPETITIONS

The abstract syntax appends the postfix operator -set denoting a set (un-ordered collection of distinct objects).

Example:

Agent-graph :: Agent-start-node State-node-set

An Agent-graph consists of an Agent-start-node and a set of State-nodes. A –set of the abstract syntax is mapped to a Set. A Set is an un-ordered collection of distinct object types.

convert: -set -> Set

The same mapping also applies to repetitions of composite object.

8.1.1.4 TOKEN OBJECTS

Token denotes the domain of tokens. This domain can be considered to consist of a potentially infinite set of distinct atomic objects for which no representation is required.

Example:

Name :: Token

A name consists of an atomic object so that any Name can be distinguished from any other name. A Token is mapped to a String.

convert: Token -> String

Each Token being an SDL name shall follow the EBNF grammar given in Z.100. An Identifier that addresses each distinct object within an SDL specification is also mapped to a String which is compatible to the UML notation for qualified names.

Identifier :: Qualifier Name Qualifier = Path-item +

Path-item = Package-qualifier | … Package-qualifier :: Package-name Package-name = Name

Name :: Token

convert: Qualifier, Name -> String

context convert(Qualifier: q[1..*], Name: n): String

post: let s:String=”” in result = q->forAll(s->concat(convert(q))->concat(“::”))->concat(convert(n))

8.1.1.5 UMLCONSTRAINTS

UML Constraints are specified by means of a ValueSpecification. The ValueSpecification of a constraint is mapped to a String.

convert: Constraint -> String context convert(c: Constraint): String post: result = c.specification.stringValue()

8.1 Translational Semantics for UML CS Profile

8.1.2 OCL Constraints for AS1

The Figure 82 shows the conceptual outline of the type mapping and constrained tree. Dotted lines imply a type conversion. Underlined expressions denote OCL constraints applied to the object tree.

The given constraints are only exemplary.

Figure 82: OCL Constraints on AS1 Composite Object Tree

During translation from the concrete SDL syntax to an executable system, there are several transformation steps applied (the concrete steps are not described here; it is referred to the appendices of Z.100 [ITU02a]). The abstract syntax AS1 is a composite object tree and defines an SDL-specification as root. From this, the tree is traversed by means of the defined objects within the system description. It is assumed that each object within this tree can be constrained by means of OCL. For this, type conformance has to be assured first. As described in Section 8.1.1, some type mappings are defined for a mapping to OCL compliant types. For example, a Nat within the tree is mapped to a non-negative Integer. However, a concrete mapping is not provided; instead, it is assumed that such a mapping is already available, so that all constraint qualifiers are valid (however, if the type compliance would fail, none of the constraint qualifiers is correct and the mapping is considered invalid).

The type mapping must not only be provided on leaf objects. Objects defining a set are implicitly mapped to an OCL set that is shown at the Package-definition-set object. The Bag itself contains the set of Package-definitions which itself decomposes into several objects. If the resolution path down to the tree leaf is unambiguous, it is assumed that derived attributes are available. For instance, although the Agent-name is resolved into a Token it is assumed that this is also done implicitly at parent objects.

Therefore, the correct navigation through such a composite tree would be Agent-name.Name.Token = ”Agent1”. However, the shorthand notation Agent-name = ”Agent1” is allowed.

8.1.3 Example - Mapping the SDL AS1 for Channel Definition to MOF

Nevertheless, OCL constraints require some navigation on the composite objects. This is briefly illustrated in the following. For example, the abstract grammar of a channel definition in Z.100 main body is

Abstract grammar

Channel-definition :: Channel-name [NODELAY]

Channel-path-set

Channel-path :: Originating-gate

Destination-gate

Signal-identifier-set

Originating-gate = Gate-identifier Destination-gate = Gate-identifier Gate-identifier = Identifier Agent-identifier = Identifier Channel-name = Name

The mapping should map the following excerpt of the composite object tree of the AS1 to a metamodel that is type-conformant and navigable. The result is shown in Figure 83;

Figure 83: Abstract Grammar mapped to Metamodel

Note, this metamodel defines only an excerpt, as the associations of the metaclass Qualifier are omitted. In this example, -set are mapped to multiplicities 0..*. Optional components are mapped to multiplicities 0..1. However, quotation objects like NODELAY are currently mapped to a String with 0..1 multiplicity with the first name of its containing composite object and a -kind suffix. If the quotation does not apply (e.g. a channel that does not have the quotation NODELAY), the String property is empty.

Im Dokument UML Profile for Communicating Systems (Seite 189-195)