The design and simulation of a HelloWorld example is discussed in this section. This model has two states A (default state) and B (final state). When simulation is started, only event e is accepted, which changes the model from state A to state B, and prints a ``Hello World!'' message.
To design a textual model manually, the designer writes the description according to the DCharts textual syntax (see my master's thesis) and saves it in a .des file. For this example, the textual description is listed below:
DESCRIPTION: # description of the model Hello World Example STATECHART: # definition of the state hierarchy A [DS] B [FS] TRANSITION: # one single transition S: A N: B E: e O: [DUMP("Hello World!")]
This description is saved as HelloWorld.des. Several important points about this description are explained below:
Property [DS] is assigned to state A, which means it is a default state. Similarly, property [FS] of state B means it is a final state.
To run the model, first make sure that HelloWorld.des is in the current directory and the SVM directory is added to the PATH environment variable. Execute the following command:
svm HelloWorld.desThe default graphical interface (Figure 2.1) will be shown, and the simulation is started.
First-time users may not be familiar with this default graphical interface, and brief explanation may be required. There are two separate windows: the right one is the main window, and the left one is the state hierarchy window.
An unaccepted command entered by the user is simply ignored.
If no state is selected in the state list (as in Figure 2.1), this box is empty.
To send event e to the HelloWorld model, the user should either use the left mouse button to double click the event name in the enabled event list, or type in e in the command box and then enter. This event triggers the only transition defined in the model, and message ``Hello World!'' is printed in the output box (Figure 2.2).
Now, because state B (the current state) is a final state, there is no enabled event any more, and the enabled event list becomes empty. To close SVM, the user should either enter command exit in the command box, or click the ``exit'' button with the left mouse button, or close the main window.