Skip to Main Content Skip to Search
Product Documentation

Module Packaging Tool (MPT) Data Objects

The following table describes the properties and property values for all mpt.Parameter and mpt.Signal data objects that appear in the Model Explorer.

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. Another table describes the effects that example changes to property values have on the generated code.

Parameter and Signal Property Values

Class: Parameter, Signal, or BothPropertyAvailable Property Values
(* Indicates Default)
Description

Both

User object type

*auto

Prenamed and predefined property sets that are registered in the sl_customization.m file. (See Registering mpt User Object Types.) This field is unavailable if no user object type is registered.

Select auto if this field is available but you do not want to apply the properties of a user object type to a selected data object. The fields on the Model Explorer are populated with default values.

  

Any user object type name listed

Select a user object type name to apply the properties and values that you associated with this name in the sl_customization.m file. The fields on the Model Explorer are automatically populated with those values.

Parameter

Value

*0

The data type and numeric value of the data object. For example, int8(5). The numeric value is used as an initial parameter value in the generated code.

Both

Data type

 

Used to specify the data type for an mpt.Signal data object, but not for an mpt.Parameter data object. The data type for an mpt.Parameter data object is specified in the Value field above. See Working with Data Types in the Simulink documentation.

Both

Units

*null

Units of measurement of the signal or parameter. (Enter text in this field.)

Both

Dimensions

*-1

The dimension of the signal or parameter. For a parameter, the dimension is derived from its value.

Both

Complexity

*auto

real

complex

Complexity specifies whether the signal or parameter is a real or complex number. Select auto for the code generator to decide. For a parameter, the complexity is derived from its value.

Signal

Sample time

*-1

Model or block execution rate.

Signal

Sample mode

*auto

Determines how the signal propagates through the model. Select auto for the code generator to decide.

  

Sample based

The signal propagates through the model one sample at a time.

  

Frame based

The signal propagates through the model in batches of samples.

Both

Minimum

*0.0

The minimum value to which the parameter or signal is expected to be bound.

  

Any number within the minimum range of the parameter or signal. (Based on the data type and resolution of the parameter or signal.)

 

Both

Maximum

*0.0

Maximum value to which the parameter or signal is expected to be bound. (Enter information using a dialog box.)

 

Code generation options

  
 

Storage class

 

Note that an auto selection for a storage class tells the build process to decide how to declare and store the selected parameter or signal.

Both

Default (Custom)

 

Code generation decides how to declare the data object.

Both

Global (Custom)

Global (Custom) is the default storage class for mpt data objects.

Specifies the code generator to place no qualifier in the data object's declaration.

Both

Memory section

*Default

Memory section allows you to specify storage directives for the data object. Default specifies that the code generator places no type qualifier and no pragma statement with the data object's declaration.

Parameter

 

MemConst

Places the const type qualifier in the declaration.

Both

 

MemVolatile

Places the volatile type qualifier in the declaration.

Parameter

 

MemConstVolatile

Places the const volatile type qualifier in the declaration.

Both

Header file

 

Name of the file used to import or export the data object. This file contains the declaration (extern) to the data object.

Also, you can specify this header filename between the double-quotation or angle-bracket delimiter. You can specify the delimiter with or without the .h extension. For example, "object.h" or "object" has the same effect. For the selected data object, this overrides the general delimiter selection in the #include file delimiter field on the Configuration Parameters dialog box.

Both

Owner

*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 Ownership Settings and Effects of Ownership Settings.

Both

Definition file

*Blank

Name of the file that defines the data object.

  

Any valid text string

 

Both

Persistence level

 

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 Code Generation Pane: Code Placement.

Both

Bitfield (Custom)

 

Embeds Boolean data in a named bit field.

 

Struct name

 

Name of the struct into which the object's data will be packed.

Parameter

Const (Custom)

 

Places the const type qualifier in the declaration.

Parameter

Header file

 

See above.

Parameter

Owner

 

See above.

Parameter

Definition  file

 

See above.

Parameter

Persistence  level

 

See above.

Both

Volatile (Custom)

 

Places the volatile type qualifier in the declaration.

Both

Header file

 

See above.

Both

Owner

 

See above.

Both

Definition  file

 

See above.

Both

Persistence  level

 

See above.

Parameter

ConstVolatile (Custom)

 

Places the const volatile type qualifier in declaration.

Parameter

Header file

 

See above.

Parameter

Owner

 

See above.

Parameter

Definition  file

 

See above.

Parameter

Persistence  level

 

See above.

Parameter

Define (Custom)

 

Represents parameters with a #define macro.

Parameter

Header file

 

See above.

Both

ExportToFile (Custom)

 

Generates global variable definition, and generates a user-specified header (.h) file that contains the declaration (extern) to that variable.

Both

Memory  section

 

See above.

Both

Header file

 

See above.

Both

Definition  file

 

See above.

Both

ImportFromFile (Custom)

 

Includes predefined header files containing global variable declarations, and places the #include in a corresponding file. Assumes external code defines (allocates memory) for the global variable.

Both

Data access

*Direct

Allows you to specify whether the identifier that corresponds to the selected data object stores data of a data type (Direct) or stores the address of the data (a pointer).

Both

 

Pointer

If you select Pointer, the code generator places * before the identifier in the generated code.

 

Header file

 

See above.

Both

Struct (Custom)

 

Embeds data in a named struct to encapsulate sets of data.

Both

Struct name

 

See above.

Signal

GetSet (Custom)

 

Reads (gets) and writes (sets) data using functions.

Signal

Header file

 

See above.

Signal

Get function

 

Specify the Get function.

Signal

Set function

 

Specify the Set function.

Both

Alias

*null

As explained in detail in Applying Naming Rules to Identifiers Globally, for a Simulink or mpt data object (identifier), specifying a name in the Alias field overrides the global naming rule selection you make on the Configuration Parameters dialog box.

  

Any valid ANSI[a] C/C++ variable name

 

Both

Description

*null

Text description of the parameter or signal. Appears as a comment beside the signal or parameter's identifier in the generated code.

  

Any text string

 

[a] ANSI is a registered trademark of the American National Standards Institute, Inc.

Some Examples of the Effect of Property Value Changes on Generated Code

What I noticed when inspecting the .c/.cpp fileChange I made to property value settingsWhat I noticed after regenerating and reinspecting the file

Example 1:
Parameter data objects can be declared or defined as constants. I know that the data object GAIN is a parameter. I want this to be declared or defined in the .c file as a variable. But I notice that GAIN is declared as a constant by the statement const real_T GAIN = 5.0;. Also, this statement is in the constant section of the file.

In the Model Explorer, I clicked the data object GAIN. I noticed that the property value for its Memory section property is set at MemConst. I changed this to Default.

I notice two differences. One is that now GAIN is declared as a variable with the statement real_T GAIN = 5.0;. The second difference is that the declaration now is located in the MemConst memory section in the .c or .cpp file.

Example 2:
I notice again the declaration of GAIN in the .c file mentioned in Example 1. It appears as real_T GAIN = 5.0;. But I have changed my mind. I want data object GAIN to be #define.

I changed the Storage class selection to Define (Custom).

GAIN is no longer declared in the .c file as a MemConst parameter. Rather, it now is defined as a #define macro by the code #define GAIN 5.0, and this is located near the top of the .c file with the other preprocessor directives.

Example 3:
I changed my mind again after doing Example 2. I do want GAIN defined using the #define preprocessor directive. But I do not want to include the #define in this file. I know it exists in another file and I want to reference that file.

On the Model Explorer, I notice that the property value for the Header file property is blank. I changed this to filename.h. (I chose the ANSI C/C++ double quote mechanism for the #include, but could have chosen the angle bracket mechanism.) Also, it is necessary that I make the user-defined filename.h available to the compiler, placing it either in the system path or local directory.

The #define GAIN 5.0 is no longer in this .c file. Instead, the #include filename.h code appears as a preprocessor directive at the top of the file.

Example 4:
I have one more change I want to make. Let us say that we have declared the data object data_in, and that its declaration statement in the .c file reads
real_T data_in = 0.0;. I want to replace this in all locations in the .c file with an alias.

In the Model Explorer, I selected the data object data_in. I noticed that the Alias field is blank. I changed this to data_in_alias, which I know is a valid ANSI C/C++ variable name.

The identifier
data_in_alias now appears in the .c file everywhere data_in appeared.


[a] ANSI is a registered trademark of the American National Standards Institute, Inc.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS