Deploy the Generated C++ Code
In this step of the tutorial, you explore mechanisms for deploying the generated code.
Example Main Program
To facilitate deployment of the generated code, the code generator produces an example main
program that you can use to get started. The example main
program is in the file ert_main.cpp
. To use the C++ class and model entry-point functions generated for your application, you can copy the incomplete functions defined in ert_main.cpp
, and then complete the functions by inserting your custom scheduling code.
Explore the example main
program generated for model CppClassWorkflowKeyIgnition
.
If not already open, open your copy of the model
CppClassWorkflowKeyIgnition
.In the Apps gallery, click Embedded Coder.
Regenerate the code.
In the Code view, select file
ert_main.cpp
.Click in the Search field and select function
rt_OneStep
.Explore the incomplete wrapper function
rt_OneStep
. This function calls the model execution entry-point function,step0
. Your application code can callrt_OneStep
to run the model algorithm during each execution cycle.Click in the Search field and select function
main
.Explore the incomplete example
main
function. This function outlines the order and context in which your application code can callrt_OneStep
and other model entry-point functions.
Overview of Generated Code Files
The code generator creates two folders in your MATLAB® current folder for the generated code files:
slprj
CppClassWorkflowKeyIgnition_ert_rtw
The slprj/ert/_sharedutils
folder contains generated files that are shared between multiple models. This folder contains the file rtwtypes.h
, which defines standard data types that the generated code uses by default.
The CppClassWorkflowKeyIgnition_ert_rtw
folder contains the model-specific files of your generated code, including the two primary files CppClassWorkflowKeyIgnition.cpp
and CppClassWorkflowKeyIgnition.h
.
Relocate Generated Code Files
Embedded Coder® provides a packNGo utility for relocating static and generated code files for a model to another development environment. The utility packages the files in a compressed file that you can relocate and unpack by using a standard zip
utility. You can apply the packNGo utility from graphical and programming interfaces.
For more information, see Relocate or Share Generated Code.
Share and Archive a Code Generation Report
The Quick Start tool configures a model to produce an HTML code generation report. In addition to a summary of model and code information, the report includes:
A subsystem report
A code interface report
A traceability report
A static code metrics report
A code replacements report
Coder assumptions
Generated code files
Optionally, a model web view
You can use this report outside of the Simulink® environment, so it is suitable for sharing or for archival purposes. You can open the report from the tool or, on the C++ Code tab, click Open Report.
The default location for the code generation report files is in the html
subfolder of the build folder,
. model
_target
_rtw/html/
is the name of the System target file specified on the Code Generation pane. The default name for the top-level HTML report file is target
index.html
.