Main Content

cgsl_0404: Model startup and shutdown events by using Initialize Function and Terminate Function blocks for component deployment

ID: Titlecgsl_0404: Model startup and shutdown events by using Initialize Function and Terminate Function blocks for component deployment
Description

To model startup and shutdown behavior, use Initialize Function and Terminate Function blocks.

Notes

By following this guideline, the code generator produces one initialize function and one terminate function.

When a Terminate Function block is not needed in the model, clear model configuration parameter Terminate function required (IncludeMdlTerminateFcn).

Rationale

Decouples the execution order of component initialize and terminate functions from the execution order across components.

Separates component startup and shutdown functionality from periodic and aperiodic algorithm function code.

Model Advisor CheckVerify this guideline by using Model Advisor check Check Startup and Shutdown Event (Embedded Coder).
Examples

Initialize and terminate events in the model and generated code

void CD_initialize(void)
{
  .  
  .
  .
}

void CD_terminate(void)
{
  .
  .
  .
}

Version History

expand all

Introduced in R2022b