Model Initialization Order

It may be helpful to understand the model initialization order in terms of ordering of various operations.

  1. The top-level agent of the model (Main) is constructed, its parameters are set up, and its function create() is called. Dynamic variables are initialized, animation is created. The function create() does the same steps for all its embedded objects. At this point creation of the model and the animation is completed.
  2. The function start() for each object is called. Each object creates and initializes its statecharts (each statechart enters its initial state) and events. Finally On startup code is executed, first on the innermost objects and then up along the model tree.
  3. The model execution is started.

So, On startup code is executed at the final stage of model initialization, after all objects throughout the entire model have been constructed, connected, and initialized, and before anything else is done. This is a place for some additional initialization and starting object’s activities such as events.