next up previous contents
Next: 2.5.9 An example of Up: 2.5 More Examples Previous: 2.5.7 An example of   Contents

2.5.8 An example of importation

Importation is specified in model descriptions in two steps:

  1. The designer declares all the components to be imported under the IMPORTATION descriptor. There may be multiple IMPORTATION descriptors in a single model description. Each component is located by its file name (usually ending with .des). A GUID (Globally Unique ID) is assigned to each component, which is used to referred to the component in other parts of the model description.

  2. In the specification of the state hierarchy, the GUIDs of those imported components can be used as properties for states to make them importation states. The states with such properties must be leaf states. For example, if property [b] is given to state A and b is the GUID of a component, A becomes an importation state, where the component will be dynamically loaded in it during a simulation.

The following is a model (import1_a.des) that imports a component into its two leaf states (so that the two states have exactly the same internal structure):

IMPORTATION:
    b = import1_b.des

STATECHART:
    A [DS] [b]
    B [b]

TRANSITION:
    S: A
    N: B
    E: e

The following is the component (import1_b.des) to be imported by the above model:

STATECHART:
    COMP_A [DS]
    COMP_B [FS]

TRANSITION:
    S: COMP_A
    N: COMP_B
    E: f

The submodel, import1_b.des is a model in its own right. It is possible to simulate it in SVM with command:

svm -t import1_b.des

When it is imported into import1_a.des, it is regarded as a component. All its states and transitions will be copied to the importation states at run-time. To simulate import1_a.des, run the following command instead:

svm -t import1_a.des

The simulation result is as following:

WARNING: Imported model has final states. They are automatically converted to ordinary states.
['A.COMP_A'] > f
['A.COMP_B'] > e
WARNING: Imported model has final states. They are automatically converted to ordinary states.
['B.COMP_A'] > f
['B.COMP_B'] > exit

Two warning messages are produced by SVM in this simulation, but the user can safely ignore them. When the simulation is started, the model is in its default state A. Because A has a property [b] and b is the GUID of component import1_b.des, SVM looks for import1_.des and import it into A to find the concrete current state of the model. When SVM detects a final state is defined in the imported component, it produces a warning telling the user that the final state is converted into an ordinary state. This is necessary because a component should not have the ability to terminate the simulation (for modularity).

When the user sends the f event, which is handled by the component, the current state of the model changes from A.COMP_A to A.COMP_B. After that, event e causes the model to leave state A and enter state B. (The component imported in state A is not deleted and can be reused later.) Because B is also an importation state, SVM dynamically loads the required component (import1_b,des) in it, and the second warning is produced. Event f received after this changes the model from state B.COMP_A to B.COMP_B.


next up previous contents
Next: 2.5.9 An example of Up: 2.5 More Examples Previous: 2.5.7 An example of   Contents
Thomas Huining Feng
2004-04-05