You can use the Alf editor to create an Alf body for an Opaque Action in an Activity or to edit the existing Alf body of an Opaque Action. The Alf code for an Opaque Action is stored as the body of the Opaque Action with the language Alf. Compiling this Alf code results in the creation of an executable Activity reflecting the behavior defined by the Alf code. This Activity is attached to the Opaque Behavior as a tagged value of the special CompiledRepresentation stereotype. (See also the discussion on the Alf compiler.)
To create an Alf body for an Opaque Action
Enter the Alf code for the Opaque Action and press Save to compile and save the code.
The Alf code in an Opaque Action can comprise one or more Alf statements. The names of the Input and Output Pins of the Action may be used as local names in the Alf code. The local names for Input Pins have the values that are on the Pins when the Action executes. The local names for Output Pins are assignable with the values to be placed on those pins when the Action is done executing. (But see also Using Alf expressions in Opaque Actions.) |
To edit the Alf code for an Opaque Action
When the CompiledRepresentation stereotype is applied to an Opaque Action by the Alf compiler, MagicDraw may, by default, show the Stereotype and its tagged values in the Opaque Action symbol (as shown below). If you do not want this depicted in your diagram (as in the diagram above), you can turn it off in the Opaque Action symbol properties.
|
The Alf code for an Opaque Action can also be entered or edited directly in the Body and Language property for it in the Specification window for the Opaque Action. If you open the Edit Body and Language window, then the Alf code may be edited just as in the Alf editor window. However, instead of Save and Revert buttons, this window has OK and Cancel buttons, either of which will close it. If you press OK, then the text is saved, and, if it has no errors, compiled. If you press Cancel, the Alf text is not saved.
To be recognized as Alf code, the Body of an Opaque Action must have the Language Alf. If your project was created using the Alf project template, then Alf will be the default language. Otherwise, select Alf from the Language menu (you may have to scroll upwards in the menu to find the selection for Alf). |
To make Alf the default language for Opaque Actions
|
If the Name Display Mode symbol property of an Opaque Expression is set to Body, then the Alf code for the Opaque Behavior can also be edited directly on an Activity diagram showing the Opaque Action. Since such editing does not use the Alf editor, no parsing or constraint checking happens while Alf code is being edited. The code is compiled once you finish editing it, and, if there are compilation errors, they will be recorded in an error annotation on the Opaque Action.