Execute subsystem on model or subsystem reinitialize event
Simulink / User-Defined Functions
The Reinitialize Function block is a preconfigured subsystem block that executes on a model or subsystem reinitialize event. By default, the Reinitialize Function block includes:
Customize the Reinitalize Function block by, for example, replacing the Constant block with source blocks that generate the state value for the State Writer block and specifying a State owner block for the State Writer block.
To generate a model reinitialize event, send a function-call signal to a reinitialize port of a Model block that references a model containing a Reinitialize Function block. To generate a subsystem reinitialize event, send a function-call signal to a reinitialize port of a subsystem block containing a Reinitialize Function block. The reinitialize event has these effects:
The state of each block in the model or subsystem reverts back to its initial condition, including blocks within subsystems or referenced models inside the model or subsystem receiving the reinitialize event.
The contents of the Reinitialize Function block corresponding to the reinitialize port are executed.
If any subsystems or referenced models inside the model or subsystem receiving the reinitialize event contain a Reinitialize Function block, and the Event name of that block matches the Event name of the Reinitialize Function block corresponding to the reinitialize port, then the contents of those Reinitialize Function blocks are executed.
If a Simulink® based state in a Stateflow® chart contains a Reinitialize Function block, to generate a subsystem reinitialize event for the state, use a transition event with this syntax:
Conditionally executed subsystem blocks with output ports are fully supported within Reinitialize Function blocks.
A model or subsystem can have multiple Reinitialize Function blocks with each block having a different Event name. Each of these reinitialize events appears in the generated code as a different function. Set the Event name in the block dialog of the Event Listener block. The Event Name appears on the Reinitialize Function block icon, and as the port label for the reinitialize port corresponding to the reinitialize event.
You can select an Initialize Function, Reinitialize Function, Reset Function, or Terminate Function block or a corresponding state owner block to highlight blocks related to it. To show a related block in an open diagram or new tab, pause on the ellipsis that appears after selection. Then, select Related Blocks from the action bar. When multiple blocks correspond to the selected block, a list of related blocks opens. You can filter the list of related blocks by entering a search term in the text box. After you select a related block from the list, window focus goes to the open diagram or new tab that shows the related block.
If a referenced model or subsystem contains more than one Reinitialize Function block, the function-call signals driving all reinitialize ports of the Model or subsystem block must have a common source.
Only these blocks can have reinitialize ports:
Enabled and Triggered Subsystem
Message Triggered Subsystem
Message Polling Subsystem
If Action Subsystem
Switch Case Action Subsystem
For Iterator Subsystem
While Iterator Subsystem
For a list of unsupported blocks and features, see Initialize, Reinitialize, Reset, and Terminate Function Limitations.
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Actual code generation support depends on block implementation.
Design and simulate fixed-point systems using Fixed-Point Designer™.
Actual data type support depends on block implementation.