next up previous contents index
Next: 4.3.1.2 Parameters Up: 4.3.1 Macros Previous: 4.3.1 Macros   Contents   Index

4.3.1.1 An Example

Figure 4.16: An example of the graphical representation of macros
Image macrosample


Table 4.13: An example of the textual representation of macros
\begin{table}\begin{center}
\begin{minipage}{4cm}
\begin{verbatim}
STATECHART:...
...: B.C
N: B.D
E: [EXIT]\end{verbatim}
\end{minipage} \end{center}
\end{table}


In the graphical form, macros are defined as a UML comment at the top level, as shown in Figure 4.16. The textual description of the same model is in Table 4.13. In this example, macros E(n)=ev[n] and EXIT=ex are defined. To use those macros in the model description, put the name of a macro in a pair of square brackets, and replace all the necessary parameters with values. In the figure, macro EXIT is used as an event name ([EXIT]). It is equivalent to ex in this case.

Macros can be used wherever text is written. For example, they can be used in event names, in guards, in actions, in importations, and so on. In the textual form of a model, they can even be used in the specification of state hierarchy, ports, connections and so on. In particular, the values of macros can also be used as descriptors, with the exception of the MACRO descriptor.

On the right-hand side of a macro definition, other macros that are defined before it can be used without ambiguity. However, it may be a fatal error to use this macro itself or the macros defined after it.


next up previous contents index
Next: 4.3.1.2 Parameters Up: 4.3.1 Macros Previous: 4.3.1 Macros   Contents   Index
Thomas Huining Feng 2004-04-28