Main Content

Schedule Component Initialization in Software Architectures

In a software architecture model, use initialize functions to schedule and customize component initialization of each reference component for simulation and code generation. When you simulate your software architecture, all components are initialized during the model initialization phase of simulation. By default, each reference component of your software architecture has an initialize function. To visualize and schedule the order of component initialization, open the Initialize tab of the Functions Editor. To implement behavior of the initialize function of a component, add an Initialize Function block to the referenced model. For more information on defining initialization routines, see Common Uses of the Initialize Function Block.

An initialize function is a specialization of a function that executes during model initialization. The code generated from Initialize Function blocks is part of the model_initialize function that is called once at the beginning of model execution. This topic describes how to:

  • Schedule component initialization using the Functions Editor.

  • Visualize initialize functions using class diagrams.

  • Generate component code for initialize functions.

For more information about authoring, adding properties using stereotypes, and importing and exporting functions, see Author and Extend Functions for Software Architectures.

Schedule Component Initialization Using Functions Editor

By default, each reference component in your software architecture has an initialize function. You can observe the initialize functions in the Initialize tab of the Functions Editor. To open the Functions Editor, in the toolstrip on the Modeling tab, select Functions Editor.

Functions Editor with the Initialize tab open.

Use the Initialize tab of the Functions Editor to schedule the order of initialization of each reference component.

  1. When you open the Functions Editor, the model will automatically update, and the table will display all functions populated from your model. Initialize functions are listed in the Initialize tab.

  2. If there are changes in the software architecture model, the Update Model button becomes yellow to signal that an update is required to refresh your functions tables.

  3. To change the order of initialize functions, use the up and down arrows or drag and drop functions to sort them.

Visualize Initialize Functions Using Class Diagram Views

Class diagrams display a graphical representation of the structure of a software architecture model. Each component is represented as a class box with methods and properties listed. The root architecture is also represented as a class box which lists all methods, stereotypes, and properties. Each reference component has an initialize function listed in the Methods section of the corresponding class box. An initialize function is listed in the Methods section of the root architecture class box.

To open the Architecture Views Gallery, navigate to Modeling > Architecture Views. To open the class diagram view, click Diagram > Class Diagram.

Class diagram view with initialize functions listed in class boxes of reference components.

For more information, see Class Diagram View of Software Architectures.

Generate Code for Initialize Functions

You can generate code from your software architecture for the initialize functions. To generate code, from the Apps tab, select Embedded Coder, then select Build.

Observe that each component has an initialize function call in the model_initialize function. The order of the function calls follows the order specified in the Functions Editor.

Model initialize function from the generated code of the throttle example.

Programmatically Configure Initialize Functions

To programmatically configure and customize initialize functions:

  • Use the decreaseOrder and increaseOrder functions to decrease or increase the order of component initialization, respectively. You can use this command to view initialize functions by order:

    initializeFunctions = {model.Architecture.Initialization.Name}'

  • Use the systemcomposer.exportModel function to output an initializeFunctions field that contains a table with information such as the order and component of a function.

  • Use the systemcomposer.importModel function to import a model with functions where the importStruct argument can have a initializeFunctions field that contains function information.

  • Use the slbuild function to generate code for software architecture components.

See Also

Tools

Objects

Functions

Related Topics