Main Content

模型_step

生成的C/C ++入口点函数包含每个步骤的执行代码金宝app模型

Description

例子

void模型_step(voidis an execution function that contains the output and update code for the blocks in a Simulink®模型。

voidmodel_step_n(void是具有任务标识符的执行函数,该函数包含Simulink模型中块的输出代码和更新代码。金宝app

步骤入口点函数计算块的当前值。如果启用了记录,则步骤功能会更新记录变量。根据设计,从中断级别调用步骤函数rt_OneStep((invoked as a timer ISR). Thert_OneStepfunction calls the模型_stepfunction to execute processing for one clock period of the model. For a more information, seeRT_ONESTEP和调度注意事项(嵌入式编码器)

如果模型具有有限的停止时间,则步骤函数在当前时间等于停止时间时表示执行结束。否则,如果这些条件中的一个或多个是正确的,则步骤函数不会检查当前时间,并且程序无限期运行:

  • The model stop time is set toinf

  • 日志记录是禁用的。

  • 范围需要终止功能is not selected.

模型的步骤入口点函数的生成的调用接口取决于以下参数:

  1. To generate a step entry-point function, select theSingle output/update function范围。If you clear this parameter,model_outputand模型_update入口点功能是生成步骤函数的。

  2. 要生成具有可配置参数的单个步骤函数,请清除将每个离散率视为单独的任务范围。要根据时序要求生成单独的步骤函数,请选择此参数。有关更多信息,请参阅将每个离散率视为单独的任务

    • 参数值:Off(单率或多级单任务模型)

      Function Prototype:void model_step(void);

    • 参数值:On((multirate multi-tasking model)

      Function Prototype:void model_step_n(void);((n是任务标识符)

  3. 要更改生成的调用接口,请设置and代码接口包装参数。有关更多信息,请参阅代码接口包装

To preview and customize the name and arguments of the generated C or C++ step entry-point function an Embedded Coder®license is required. To preview a step entry-point function, open the Code Mappings editor and click the功能标签。自定义函数名称,在Function Name列单击并直接编辑电子表格。自定义函数名称和参数,在功能预览列单击功能超链接,然后从打开的对话框中配置步骤函数。使用模板自定义函数,功能自定义模板column select a template to apply to the function. For more information, seeConfigure Name and Arguments for Individual Step Functions(嵌入式编码器),,,,交互式配置C ++接口(嵌入式编码器),,,,and为函数配置默认代码生成(嵌入式编码器)

To view the generated step entry-point function, open the代码查看或代码生成报告并查看模型的源代码。有关更多信息,请参见分析生成的代码接口(嵌入式编码器)

Examples

全部折叠

此示例显示了如何配置,自定义,生成和检查步骤入口点功能的基本工作流程。该特定示例为模型生成了不可撤销的C终止函数rtwdemo_irt_base

  1. 打开模型。对于此示例,请使用rtwdemo_irt_base模型。

  2. 选择一个编码器。在应用程序画廊中,单击金宝appSimulink编码器orEmbedded Coder

  3. 配置参数。在“配置参数”对话框中,设置Single output/update function,,,,将每个离散率视为单独的任务,,,,,,,,and代码接口包装参数。在此示例中,为您设置了参数。

  4. ((Embedded Coder only) Customize the function. Using Embedded Coder, you can customize the name and arguments of the step entry-point function.

    • 打开代码映射编辑器。

    • Click on the功能标签。

    • 自定义名称和参数。在里面功能预览column, click the function hyperlink to open the配置C步骤功能接口对话框。配置名称和参数。

  5. 生成代码。

  6. 检查生成的代码。在里面代码查看,验证生成的终止函数带有预期名称和参数。

输入参数

全部折叠

步骤入口点C或C ++函数提供了模型执行代码的接口。默认情况下,生成的函数提供了void-voidinterface that does not have arguments. To configure the input arguments for a C step function, use the代码映射编辑器 - C。To configure the input arguments for a C++ step function, use the代码映射 - C ++编辑器(嵌入式编码器)

输出参数

全部折叠

步骤入口点C或C ++函数提供了模型执行代码的接口。默认情况下,生成的函数提供了void-voidinterface that does not have arguments. To configure the output arguments for a C step function, use the代码映射编辑器 - C。To configure the output arguments for a C++ step function, use the代码映射 - C ++编辑器(嵌入式编码器)

版本历史记录

Introduced before R2006a