Trace Stateflow Elements in Generated Code
To verify the generated code for your Stateflow® elements, you can trace Stateflow elements in your model to the generated code by using these types of navigation:
Code-to-model: Trace generated code back to the model by clicking hyperlinks in the comments or the hyperlinked line numbers, which highlights the corresponding model element in the Simulink Editor.
Model-to-code: Trace the model elements in the Simulink Editor to corresponding lines in generated code by right-clicking the model element and navigating to the generated code. This traceability is not supported for some Stateflow elements in Code view.
Inline Traceability for Stateflow Elements
Inline traceability refers to the line-level traceability available in the generated code. You can click the hyperlinked line numbers to trace the corresponding Stateflow elements.
This example shows how to use hyperlinks for tracing code-to-Stateflow elements:
Open the example
AirportConveyorBeltControlSystemExample
.openExample('plccoder/AirportConveyorBeltControlSystemExample')
Open the PLC Coder app. Click the PLC Code tab.
Click Settings and navigate to the Code Generation pane.
To enable report generation, select Report > Generate traceability report.
Click OK.
Click Generate PLC Code to initiate code and report generation. The code generation report for the top model opens in a MATLAB® web browser.
In the left navigation pane, select the
plcdemo_airport_conveyor.exp
file.Click the hyperlink on line 65. In the Stateflow chart, the corresponding
Stop_F1
state is highlighted.
Trace States and Transitions to Code
This example shows how to trace Stateflow states and transitions to the generated code:
Open the example
AirportConveyorBeltControlSystemExample
.openExample('plccoder/AirportConveyorBeltControlSystemExample')
Open the PLC Coder app. Click the PLC Code tab.
Click Settings and navigate to the Code Generation pane.
To enable report generation, select Report > Generate traceability report.
Click OK.
Click Generate PLC Code to initiate code and report generation. The code generation report for the top model opens in a MATLAB web browser.
In the Controller subsystem, Control block, select the
Run_F1
state. In the PLC Coder tab, click Navigate to Code. The generated code for the state is highlighted in the HTML code generation report.