next up previous contents
Next: 2.5.10 An example of Up: 2.5 More Examples Previous: 2.5.8 An example of   Contents

2.5.9 An example of recursive importation

Since there is no essential difference between a model and a component, a model may import itself as a component directly or indirectly. This creates an infinite state hierarchy that cannot be flattened into a state hierarchy without importation. The following is an example of direct recursive importation (import2.des):

IMPORTATION:
    self = import2.des

STATECHART:
    A [DS]
    B [self]

TRANSITION:
    S: A
    N: B
    E: e

The simulation result is as following:

['A'] > e
['B.A'] > e
['B.B.A'] > e
['B.B.B.A'] > e
['B.B.B.B.A'] > e
['B.B.B.B.B.A'] > e
['B.B.B.B.B.B.A'] > e
['B.B.B.B.B.B.B.A'] > exit

In this example, the model imports itself into its importation state B by giving self (could be any other identifier) as the ID of its textual description and using this ID as a property of state B. As a result, when event e is received, import2.des itself is imported into state B and the current state becomes B.B.A. At this time, event e is again acceptable and is handled by the component that is just imported. This importation continues infinitely.

As an importance notice, it is the designer's responsibility to ensure there is no dead-lock in the model. If we slightly modify the above example, dead-lock is created: give the [self] property to state A or remove the [DS] of state A but add it to state B. In both cases, the default state of the model imports itself, and the default state of the just imported component again requires an importation. This operation never stops and the simulation hangs until all the memory is exhausted. SVM would never be able to provide the current state string to the user, because its length grows to infinity.

If model A imports model B and model B imports model A, an indirect recursive importation is created, which is not demonstrated here.


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