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 |
---|---|---|---|
Both | * | Prenamed and predefined property sets that are registered
in the Select | |
Listed user object type name | Select a user object type name to apply the properties
and values that you associated with this name in the | ||
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 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 Override Data Object Naming Rules, 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 Generate Preprocessor Conditionals for Variant Systems. | 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 Generate Preprocessor Conditionals for Variant Systems. | 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 |
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.
Embedded Coder® allows you to create custom mpt
object
types and specify properties and property values to be associated
with them. Once created, a user object type can be applied to data
objects displayed in Model Explorer. When you apply a user object
type to a data object, by selecting a type name in the User
object type pull-down list in Model Explorer, the data
object is automatically populated with the properties and property
values that you specified for the user object type.
To register mpt
user object type customizations,
use the Simulink customization file sl_customization.m
.
This file is a mechanism that allows you to use MATLAB code to
perform customizations of the standard Simulink user interface.
The Simulink software reads the sl_customization.m
file,
if present on the MATLAB path, when it starts and the customizations
specified in the file are applied to the Simulink session. For
more information on the sl_customization.m
customization
file, see Registering Customizations.
To register mpt
user object type customizations,
you create an instance of sl_customization.m
and
include it on the MATLAB path of the Simulink installation
that you want to customize. The sl_customization
function
accepts one argument: a handle to a customization manager object.
For example,
function sl_customization(cm)
As a starting point for your customizations, the sl_customization
function
must first get the default (factory) customizations, using the following
assignment statement:
hObj = cm.slDataObjectCustomizer;
You then invoke methods to register your customizations. The
customization manager object includes the following methods for registering mpt
user
object type customizations:
addMPTObjectType(hObj, objectTypeName, classtype,
propName1, propValue1, propName2, propValue2, ...)
addMPTObjectType(hObj, objectTypeName, classtype, {propName1,
propName2, ...}, {propValue1, propValue2, ...})
Registers the specified user object type, along with specified values for object properties, and adds the object type to the top of the user object type list, as displayed in the User object type pull-down list in the Model Explorer.
objectTypeName
— Name of
the user object type
classType
— Class to which
the user object type applies: 'Signal'
, 'Parameter'
,
or 'Both'
propName
— Name of a property
of an mpt
or mpt
-derived data
object to be populated with a corresponding propValue
when
the registered user object type is selected
propValue
— Specifies the
value for a corresponding propName
moveMPTObjectTypeToTop(hObj, objectTypeName)
Moves the specified user object type to the top of the user object type list, as displayed in the User object type pull-down list in the Model Explorer.
moveMPTObjectTypeToEnd(hObj, objectTypeName)
Moves the specified user object type to the end of the user object type list, as displayed in the User object type pull-down list in the Model Explorer.
removeMPTObjectType(hObj, objectTypeName)
Removes the specified user object type from the user object type list.
Your instance of the sl_customization
function
should use these methods to register mpt
object
type customizations for your Simulink installation.
The Simulink software reads the sl_customization.m
file
when it starts. If you subsequently change the file, to use the changes,
you must restart your MATLAB session.
The sl_customization.m
file shown in mpt User Object Type Customization Using sl_customization.m
uses the addMPTObjectType
method to register the user signal
types EngineType
and FuelType
for
mpt
objects.
function sl_customization(cm) % Register user customizations % Get default (factory) customizations hObj = cm.slDataObjectCustomizer; % Add commonly used signal types hObj.addMPTObjectType(... 'EngineType','Signal',... 'DataType', 'uint8',... 'Min', 0,... 'Max', 255,... 'Unit','m/s'); hObj.addMPTObjectType(... 'FuelType','Signal',... 'DataType', 'int16',... 'Min', -12,... 'Max', 3000,... 'Unit','mg/hr'); end
If you include the above file on the MATLAB path of the Simulink installation that you want to customize, the specified customizations will appear in Model Explorer. For example, you could view the customizations as follows:
Start a MATLAB session.
Open Model Explorer, for example, by entering the MATLAB command daexplr
.
Select Base Workspace.
Add an mpt
signal, for example, by selecting Add > Add Custom.
In the right-hand pane display for the added mpt
signal, examine the User object type drop-down
list, noting the impact of the changes specified in mpt User Object Type Customization Using sl_customization.m.
From the User object type drop-down list, select
one of the registered user signal types, for example,
FuelType
, and verify that the displayed settings
are consistent with the arguments specified to the
addMPTObjectType
method in
sl_customization.m
.