MPT Data Object Properties
Note
While mpt.Signal
and mpt.Parameter
objects
continue to be supported for legacy applications, for model data configuration for
code generation, use the Code Mappings editor. For more information, see Code Mappings
Editor – C and C Data Code Interface Configuration for Model Interface Elements.
The following table describes the properties and property values
for mpt.Parameter
and mpt.Signal
data
objects that appear in the Model Explorer.
Note
You can create mpt.Signal
and mpt.Parameter
objects in the base MATLAB® or model workspace. However, if you create a signal object in a model
workspace, the object's storage class must be set to
Auto
.
The figure below shows an example of the Model Explorer. When
you select an mpt.Parameter
or mpt.Signal
data
object in the middle pane, its properties and property values display
in the rightmost pane.
In the Properties column, the table lists the properties in the order in which they appear on the Model Explorer.
Parameter and Signal Property Values
Class: Parameter, Signal, or Both | Property | Available Property Values (* Indicates Default) | Description |
---|---|---|---|
Parameter |
| The data type and numeric value of the data object. For
example, | |
Both | Used to specify the data type for an | ||
Both | * | Units of measurement of the signal or parameter. (Enter text in this field.) | |
Both |
| The dimension of the signal or parameter. For a parameter, the dimension is derived from its value. | |
Both |
| Complexity specifies whether the signal or parameter
is a real or complex number. Select | |
Signal |
| Model or block execution rate. | |
Signal |
| Determines how the signal propagates through the model.
Select | |
The signal propagates through the model one sample at a time. | |||
The signal propagates through the model in batches of samples. | |||
Both | * | The minimum value to which the parameter or signal is expected to be bound. | |
Number within the minimum range of the parameter or signal. (Based on the data type and resolution of the parameter or signal.) | |||
Both | * | Maximum value to which the parameter or signal is expected to be bound. (Enter information using a dialog box.) | |
Note that an | |||
Both |
| Specifies that a code generator not place a qualifier in the data object's declaration. | |
Both |
| Memory section allows you to specify
storage directives for the data object. | |
Parameter | Places the | ||
Both | Places the | ||
Parameter | Places the | ||
Both | Name of the file used to import or export the data object.
This file contains the declaration ( Also, you can specify this header filename
between the double-quotation or angle-bracket delimiter. You can specify
the delimiter with or without the | ||
Both | *Blank | The name of the module that owns this signal or parameter. This is used to help determine the ownership of a definition. For details, see Control Placement of Global Data Definitions and Declarations in Generated Files. | |
Both | *Blank | Name of the file that defines the data object. | |
Valid character vector | |||
Both | The number you specify is relative to Signal display level or Parameter tune level on the Code Placement pane of the Configuration Parameters dialog box. For a signal, allows you to specify whether or not the code generator declares the data object as global data. For a parameter, allows you to specify whether or not the code generator declares the data object as tunable global data. See Signal display level and Parameter tune level in Model Configuration Parameters: Code Generation Code Placement. | ||
Both | Embeds Boolean, fixed-point, or integer data in a named bit field. | ||
Name of the | |||
Parameter | Places the | ||
Parameter | Header file | See above. | |
Parameter | Owner | See above. | |
Parameter | Definition file | See above. | |
Parameter | Persistence level | See above. | |
Both | Places the | ||
Both | Header file | See above. | |
Both | Owner | See above. | |
Both | Definition file | See above. | |
Both | Persistence level | See above. | |
Parameter | Places the | ||
Parameter | Header file | See above. | |
Parameter | Owner | See above. | |
Parameter | Definition file | See above. | |
Parameter | Persistence level | See above. | |
Parameter | Represents parameters with a | ||
Parameter | Header file | See above. | |
Both | Generates global variable definition, and generates a
user-specified header ( | ||
Both | Memory section | See above. | |
Both | Header file | See above. | |
Both | Definition file | See above. | |
Both | Includes predefined header files containing global variable
declarations, and places the | ||
Both | Allows you to specify whether the identifier that corresponds
to the selected data object stores data of a data type ( | ||
Both | If you select | ||
Header file | See above. | ||
Both | Embeds data in a named | ||
Both | Struct name | See above. | |
Signal | Reads (gets) and writes (sets) data using functions. | ||
Signal | Header file | See above. | |
Signal | Specify the Get function. | ||
Signal | Specify the Set function. | ||
Both | * | As explained in detail in Apply Custom Naming Conventions to Identifiers, for a Simulink® or | |
Valid ANSI®a C/C++ variable name | |||
Both | * | Text description of the parameter or signal. Appears as a comment beside the signal or parameter's identifier in the generated code. | |
Character vector | |||
Signal | Reusable | Allows the code generator to reuse a pair of root I/O signals when you specify the same
name and the same storage class for both. The storage class is
either | |
Signal | Data Scope | *Auto | You can specify the scope of symbols code generation
generates for a data object of this class by selecting a value for DataScope.
When you take the default of |
| Code generation defines the scope of each symbol as the file that defines it. File scope requires each symbol to be used in a single file. If the same symbol is referenced in multiple files, code generation reports an error. | ||
| Code generation exports symbols to external code in the
header file specified by the HeaderFile field.
If a HeaderFile is not specified, symbols are
exported to external code in | ||
| Code generation imports symbols from external code in
the header file specified by the HeaderFile field.
If you do not specify a header file, code generation generates an | ||
Signal | Header file | See above. | |
Signal | Owner | See above. | |
Signal | Definition file | See above. | |
a ANSI is a registered trademark of the American National Standards Institute, Inc. |
mpt
Package Storage Classes
CSC Name | Purpose | Signals? | Parameters? |
---|---|---|---|
| Generate a | Y | Y |
CompilerFlag | Supports preprocessor conditionals defined via compiler flag. See Compile Code Conditionally for Variations of Component Represented Using Variant Block. | N | Y |
| Generate a constant declaration with the | N | Y |
| Generate declaration of volatile constant with the | N | Y |
| Generate | Y | Y |
| Generate header ( | Y | Y |
FileScope | Generate a static qualifier suffix for a variable declaration so that the scope of the variable is limited to the current file. | Y | Y |
GetSet | Supports specialized function calls to read and write the memory associated with a Data Store Memory block. See Access Data Through Functions with Storage Class GetSet. | Y | Y |
| The default storage class for the | Y | Y |
ImportedDefine | Supports preprocessor conditionals defined via legacy header file. See Compile Code Conditionally for Variations of Component Represented Using Variant Block. | N | Y |
| Generate directives to include predefined header files containing global variable declarations. | Y | Y |
| Allows the code generator to reuse a pair of root I/O signals when you specify the same
name and the same storage class for both. The storage class is
either | Y | N |
| Generate a | Y | Y |
| Generate a | N | Y |
| Generate a | Y | Y |
| Use | Y | Y |
Examples of Property Value Changes on Generated Code
What I noticed when inspecting the .c/.cpp file | Change I made to property value settings | What I noticed after regenerating and reinspecting the file |
---|---|---|
Example 1: | In the Model Explorer, I clicked the data object | I notice two differences. One is that now |
Example 2: | I changed the Storage class selection to
|
|
Example 3: | On the Model Explorer, I notice that the property value
for the Header file property is blank. I changed
this to |
|
Example 4: | In the Model Explorer, I selected the data object | The identifier |
Specify Persistence Level for Signals and Parameters
With this procedure, you can control the persistence level of
signal and parameter objects associated with a model. Persistence
level allows you to make intermediate variables or parameters global
during initial development. At the later stages of development, you
can use this procedure to remove these signals and parameters for
efficiency. Use the Persistence Level property
of mpt.Signal
and mpt.Parameter
data
objects. For descriptions of the properties on the Model Explorer,
see MPT Data Object Properties.
Notice also the Signal display level and Parameter tune level fields on the Code Placement pane of the Configuration Parameters dialog box, as illustrated in the next figure.
The Signal display level field allows you
to specify whether or not the code generator defines a signal data
object as global data in the generated code. The number you specify
in this field is relative to the number you specify in the Persistence
level field. The Signal display level number
is for mpt
(module packaging tool) signal data
objects in the model. The Persistence level number
is for a particular mpt
signal
data object. If the data object's Persistence level is
equal to or less than the Signal display level,
the signal appears in the generated code as global data with the custom
attributes that you specified. For example, this would occur if Persistence
level is 2
and Signal display
level is 5
.
Otherwise, the code generator automatically determines how the particular signal data object appears in the generated code. Depending on the settings on the Optimization pane of the Configuration Parameters dialog box, the signal data object could appear in the code as local data without the custom attributes you specified for that data object. Or, based on expression folding, the code generator could remove the data object so that it does not appear in the code.
The Parameter tune level field allows you to specify whether or not the code generator declares a parameter data object as tunable global data in the generated code.
The number you specify in this field is relative to the number
you specify in the Persistence level field. The Parameter
tune level number is for mpt
parameter
data objects in the model. The Persistence level number
is for a particular mpt
parameter
data object. If the data object's Persistence level is
equal to or less than the Parameter tune level,
the parameter appears tunable in the generated code with the custom
attributes that you specified. For example, this would occur if Persistence
level is 2
and Parameter tune
level is 5
.
Otherwise, the parameter is inlined in the generated code, and the code generation settings determine its exact form.
Note that, in the initial stages of development, you might be
more concerned about debugging than code size. Or, you might want
one or more particular data objects to appear in the code so that
you can analyze intermediate calculations of an equation. In this
case, you might want to specify the Parameter tune level (Signal
display level for signals) to be higher than Persistence
level for some mpt
parameter (or signal)
data objects. This results in larger code size, because the code generator
defines the parameter (or signal) data objects as global data, which
have the custom properties you specified. As you approach production
code generation, however, you might have more concern about reducing
the size of the code and less need for debugging or intermediate analyses.
In this stage of the tradeoff, you could make the Parameter
tune level (Signal display level for
signals) greater than Persistence level for one
or more data objects, generate code and observe the results. Repeat
until satisfied.
With the model open, in the Configuration Parameters dialog box, select Code Generation > Code Placement.
Type the desired number in the Signal display level or Parameter tune level field, and click Apply.
In the Model Explorer, type the desired number in the Persistence field for the selected signal or parameter, and click Apply.
Save the model and generate code.