Main Content

getData

Get code mapping configuration for model data

Description

example

value = getData(myCPPMappingObj, category, property) returns the code mapping information for the property specified by property and the model data category specified by category.

Examples

collapse all

Configure the data visibility of model parameters to be public.

Open the model. Use the coder.mapping.api.get function to access the CodeMappingCPP object associated with the model.

open_system('rtwdemo_cppclass');
cm = coder.mapping.api.get('rtwdemo_cppclass');

To view the data visibility of the model parameters, use the getData function.

value = getData(cm, 'ModelParameters', 'DataVisibility')
value =

    'private'

To configure the data visibility, specify the 'DataVisibility' parameter using the setData function.

setData(cm, 'ModelParameters', 'DataVisibility', 'public');

Input Arguments

collapse all

C++ code mapping object, returned by a call to either the coder.mapping.utils.create function or the coder.mapping.api.get function.

Category of model data to access, specified as one of these categories.

CategoryDescription
'Inports'Root-level input ports of a model, such as Inport and In Bus Element blocks.
'Outports'Root-level output ports of a model, such as Outport and Out Bus Element blocks.
'ModelParameters'Parameters that are defined within a model, such as parameters in the model workspace. Excludes model arguments.
'ModelParameterArguments'Parameters in the model workspace configured as model arguments. These parameters are exposed at the model block to enable each model instance to provide its own value.
'InternalData'Data elements that are internal to a model, such as block output signals, discrete block states, data stores, and zero-crossing signals.

Data Types: char | string

Property of model data to access, specified as either 'MemberAccessMethod', 'DataVisibility', or 'DataAccess'.

The MemberAccessMethod property specifies how the methods, if any, are generated for the data elements.

The DataVisibility property specifies the visibility (private, public, or protected) of the data category in the generated code.

The DataAccess property specifies if model parameter arguments are stored by value or pointer in the generated code.

Data Types: char | string

Output Arguments

collapse all

The code mapping property value of the specified category, returned as a character vector.

Introduced in R2021a