next up previous contents index
Next: 2.3.3 Importation Up: 2.3 Algorithms Previous: 2.3.1 Firing a Transition   Contents   Index


2.3.2 Alternate Algorithm for Firing a Transition

The algorithm in the previous section for firing a transition conforms to David Harel's statecharts, whose semantics is described in [5]. Alternatively, an implementation of DCharts may also support another algorithm for firing a transition. This alternate algorithm is not compatible with David Harel's statecharts. However, it sometimes better expresses the behavior of a system to be modeled.

In this algorithm, $CCS_{alt}(SRC,DES)$ is defined in a different way:

\begin{displaymath}
CCS_{alt}(SRC,DES)=
\left\{
\begin{array}{ll}
SRC, & DES...
...RC=DES \\
CCS(SRC,DES), & otherwise \\
\end{array} \right.
\end{displaymath}

The steps of the firing of a transition is described below:

  1. $CCS_{alt}(SRC,DES)$ is decided. The model exits $SRC$ and all the states in the path from $CCS_{alt}(SRC,DES)$. The exit actions of a state at a lower level are executed before the exit actions of a state at a higher level. If $CCS_{alt}(SRC,DES)$ cannot be found, all the current states are exited, and all their exit actions are executed in the correct order.

  2. Output actions in $\lambda$ of $T$ are executed.

  3. All the states in the path from $CCS_{alt}(SRC,DES)$ to $DES$ are entered. The enter actions of a state at a higher level are executed before the enter actions of a state at a lower level. The enter actions (if any) of $DES$ are executed last.

Compared to the algorithm described in the last section, this algorithm reverses the first operation and the second operation. As a result, when the $\lambda$ of a transition is executed, the model is not in $SRC$ but $CCS_{alt}(SRC,DES)$. This better reflects the fact that $\lambda$ is executed while transition $T$ is fired, not before or after that.

Suppose $DES$ is a history state, the history leaf substates $History(DES)=\{h_1,h_2,...,h_n\}$ are defined as the set of $DES$' substates recorded in its history, where $Leaf(h_1)$, $Leaf(h_2)$, ..., $Leaf(h_n)$ are all $true$. The default leaf substates $Default(DES)=\{d_1,d_2,...,d_n\}$ are defined as the set of $DES$' default substates, where $Leaf(h_1)$, $Leaf(h_2)$, ..., $Leaf(h_n)$ are all $true$. It is possible that $History(DES)$ and $Default(DES)$ contain more than one elements, considering that the $DES$ may have orthogonal components as its substates.

In the special case where $SRC=DES$, or though $SRC\neq DES$, $SRC$ is in the path from $DES$ to any state in $History(DES)$ or $Default(DES)$, the enter/exit actions of $DES$ (and its superstates) are not executed. This is because a self-loop to $DES$ is not considered as a state change. This is the reason for using $CCS_{alt}$ instead of $CCS$.

An implementation of DCharts must implement the first algorithm described in the previous section. The algorithm discussed here is highly optional.


next up previous contents index
Next: 2.3.3 Importation Up: 2.3 Algorithms Previous: 2.3.1 Firing a Transition   Contents   Index
Thomas Huining Feng 2004-04-28