Initializer, finalizer and interactor are SVM extensions to DCharts 1.0. In most models, they are highly simulation-oriented.
Initializer is the Python code to be executed before a model starts running. It is executed even before the model is placed in its default states (so that it may be illegal to test the current state within the initializer). This code usually initializes the environment where the model is simulated or executed. For example, this code can be used to initialize all the variables that the model uses.
An initializer is written under the INITIALIZER descriptor. Arbitrary Python code can be written, including function definitions, if-else or switch-case conditional structures and loops.
Finalizer is used to finalize the model. It is executed after the model changes to a final state. If the final state has enter actions, those enter actions are executed before the finalizer. A finalizer is written under the FINALIZER descriptor. Similar to initializer, arbitrary Python code can be written.
Interactor is used to define a model-specific interface. As discussed in later chapters, SVM provides a default textual interface, a default curses interface (for Unix or Linux systems) and a default graphical interface. However, in many cases designers may want to redesign the interface for specific models. They can write Python code under the INTERACTOR descriptor for this purpose. The difference between the interactor and the initializer is that the initializer is executed before the model starts running, while the interactor is executed while the model is running. In the SVM implementation, an extra thread is allocated for the interactor, so that it is allowed to use an infinite loop in the interactor to handle user events received from the interface, and pass those events to the running model.
The default definition of these parts is shown in Table 4.16. The default actions of initializer and finalizer are empty. The default action of interactor, if the default graphical interface is used, is to setup the interface, which includes creating all the widgets, building a tree view of the state hierarchy, and handling GUI events afterward.