Main Content

model_reset

Generated C/C++ entry-point function that contains reset code for a Simulink model

Description

example

void model_reset(void) is a generated C or C++ entry-point function that executes reset code for a Simulink® model. If a model includes a Reset Function block, reset code is generated. To reset conditions or state, call the function from the application code.

The generated calling interface of the reset entry-point function for a model differs depending on the Language and Code interface packaging parameters. For more information, see Code interface packaging.

To preview and customize the name of the generated reset entry-point function an Embedded Coder® license is required. To preview the reset entry-point function, open the Code Mappings editor and click the Functions tab. To customize the function name, in the Function Name column click and edit the spreadsheet directly. To customize the function name and arguments, in the Function Preview column click the function hyperlink and configure the reset function from the opened dialogue box. To customize a function using a template (not supported for C++), in the Function Customization Template column select a template to apply to the function. For more information, see Configure Name and Arguments for Individual Step Functions (Embedded Coder), Interactively Configure C++ Interface (Embedded Coder), and Configure Default Code Generation for Functions (Embedded Coder).

To view the generated reset entry-point function, open the Code view or Code Generation Report and view the source code for your model. For more information see, Analyze Generated Data Code Interface (Embedded Coder).

Examples

collapse all

This example shows how to generate a nonreusable C reset entry-point function with Simulink Coder.

Open the model and examine the subsystem Counter Subsystem. The counter is driven by a Discrete-Time Integrator block.

counterModel = "CounterSimCoderModel";
open_system(counterModel);

Simulate the model and observe how the subsystem increments the output. The simulation is set to run in paced mode to slow down the counting in this example.

sim(counterModel);

Generate C code from the model.

evalc("slbuild(bdroot,GenerateCodeOnly=true);");

Open the generated .c file and inspect the generated reset function CounterSimCoderModel_reset.

generatedCFile = fullfile(counterModel + "_grt_rtw",counterModel + ".c")
generatedCFile = 
"CounterSimCoderModel_grt_rtw/CounterSimCoderModel.c"

The reset function sets the value of the Discrete-Time Integrator block to 0 by using a constant.

coder.example.extractLines(generatedCFile,"CounterSimCoderModel_reset",...
      "/* End of Outputs for SubSystem: '<S1>/Reset Function' */",true,true);
void CounterSimCoderModel_reset(void)
{
  /* Outputs for Atomic SubSystem: '<S1>/Reset Function' */
  /* StateWriter: '<S2>/State Writer' incorporates:
   *  Constant: '<S2>/Constant'
   */
  C_DiscreteTimeIntegrator_DSTATE = CounterSimCoderModel_P.Constant_Value;

Input Arguments

collapse all

The reset entry-point C or C++ function provides an interface to the model reset code. By default, the generated function provides a void-void interface that does not have arguments.

Output Arguments

collapse all

The reset entry-point C or C++ function provides an interface to model reset code. By default, the generated function provides a void-void interface that does not have a return value.

Version History

Introduced before R2006a