next up previous contents index
Next: 8.2.5 Importation Up: 8.2 Transformation Strategies Previous: 8.2.3 History   Contents   Index

8.2.4 Event Handling

Method handleEvent handles events by comparing their IDs with accepted event IDs. It uses a switch-case structure to test those events, and invokes the changeState method to change the current state.

Method changeState usually makes the following three calls:

  1. recordHistory($com$) records the necessary history in the path from $com=Common(SRC,DES)$ to the bottom of the state hierarchy. $Common(SRC,DES)$ is computed statically and stored in a 2-dimensional array. If $Common(SRC,DES)$ does not exist (because $SRC$ and $DES$ are or belong to two different top-level states), recordHistory(-1) is called.

  2. removeOutStates($com$) causes the model to leave state $com=Common(SRC,DES)$ by removing that state and all its substates from the current state list. If $Common(SRC,DES)$ does not exist, the code generator simply writes statement state=null; to clean up the current state list.

  3. generateStates($com$, $DES$) generates new states in the path from $com=Common(SRC,DES)$ to $DES$, and adds them to the current state list.


next up previous contents index
Next: 8.2.5 Importation Up: 8.2 Transformation Strategies Previous: 8.2.3 History   Contents   Index
Thomas Huining Feng 2004-04-28