Main Content

Schedule Component Initialization in Software Architectures

You use initialize functions in a software architecture model to schedule and customize component initialization of each reference component for simulation and code generation. An initialize function is a specialization of a function that executes during model initialization. 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. You can visualize and schedule the order of component initialization, on 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. The code generated from Initialize Function blocks is part of the model_initialize function that is called once at the beginning of model execution. For more information on defining initialization routines, see Common Uses of the Initialize Function Block.

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

To open the Functions Editor, in the toolstrip on the Modeling tab, click Functions Editor.

On the Initialize tab of the Functions Editor, you can view the initialize functions and schedule the order of initialization of each reference component.

  • When you open the Functions Editor, the model automatically updates, and the table displays all functions populated from your model.

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

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

Functions Editor with the Initialize tab open.

Visualize Initialize Functions Using Class Diagram Views

Class diagrams are graphical representations of software architecture model structures. Each architecture component is represented as a class box with methods and properties listed. The root architecture is also represented as a class box that lists all methods, stereotypes, and properties. For both the root architecture and each reference component, an initialize function listed in the Methods section of the corresponding 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.

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. To view initialize functions by order, use this command.

    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

Topics