Real-Time Workshop User's Guide    

Model Code Sublibrary

The Model Code sublibrary contains 10 blocks that insert custom code into the generated model files and functions. You can view the blocks either by:

The latter method opens this window.

The four blocks on the top row contain texts fields to insert custom code at the top and bottom of the following files:

The six function blocks in the second and third rows contain text fields to insert critical code sections at the top and bottom of these designated model functions:

Each block provides a dialog box that contains three fields.

Example: Using a Custom Code Block

The following example uses an MdlStart Function block to introduce code into the MdlStart function. The diagram below shows a simple model with the Model Start Function block inserted.

Double-clicking the Model Start Function block opens the Model Start Function Custom Code dialog box.

You can insert custom code into any or all of the available text fields.

The code below is the MdlStart function for this example (mymodel).

The custom code entered in the Model Start Function Custom Code dialog box is embedded directly in the generated code. Note that each block of custom code is tagged with a comment such as


 Custom Code Library Subsystem Code Sublibrary