Main Content

getFunction

Get code configuration from code mappings for model function

    Description

    example

    propertyValue = getFunction(myCPPMappingObj,function,property) returns the value of a property for the specified model function.

    Examples

    collapse all

    Open the model. To access the CodeMappingCPP object associated with the model, use the coder.mapping.api.get function.

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

    To access the method name of the initialize function for the model, use the getFunction function. If you did not specify a method name for the initialize function, the getFunction function returns an empty character vector, and the method name in the generated code uses the default method name.

    value = getFunction(cm, 'Initialize', 'MethodName')
    value =
    
      0×0 empty char array

    Specify a method name for the initialize function by using the setFunction function.

    setFunction(cm, 'Initialize', 'MethodName', 'my_$N')
    

    The getFunction function now returns the specified method name.

    value = getFunction(cm, 'Initialize', 'MethodName')
    value =
    
        'my_$N'

    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.

    Model function for which to return a code mapping property value. Specify one of the values listed in this table.

    Type of Model FunctionValue
    Exported functionExportedFunction:slIdentifier, where slIdentifier is the name of the function-call Inport block in the model
    Initialize functionInitialize
    Partition functionPartition:slIdentifier, where slIdentifier is a partition that was created explicitly from a block in the model and shown in the Simulink® Schedule Editor (for example, P1)
    Periodic multitasking functionPeriodic:slIdentifier, where slIdentifier is an annotation that corresponds to the sample time period for a periodic or continuous rate of a multi-tasking model (for example, D1)
    Periodic single-tasking functionPeriodic
    Reset functionReset:slIdentifier, where slIdentifier is the name of the reset function in the model
    Simulink functionSimulinkFunction:slIdentifier, where slIdentifier is the name of the Simulink function in the model
    Terminate functionTerminate

    For information about model partitioning, see Create Partitions.

    Example: 'Periodic:D1'

    Code mapping property value to return. Specify one of the property names listed in this table.

    Information to ReturnProperty Name
    Name to use for the method in the generated codeMethodName
    For periodic, single-tasking functions and Simulink functions, a string that shows the block names, argument names, type qualifiers, and order of arguments as they will appear in the generated code Arguments

    Example: 'MethodName'

    Output Arguments

    collapse all

    Name of the function or argument specification returned as a character vector or string scalar.

    Data Types: char | string

    Introduced in R2021a