主要内容

FunctionPortSpecification

Query and configure C Caller block properties

Description

Query and configure theC Callerblock function definition and return argument. Configure theC Caller以编程方式阻止输入参数。

Creation

myCCallerObj = get_param(gcb, 'FunctionPortSpecification')creates aC Callerblock configuration object for the selectedC Callerblock.

Properties

expand all

Displays the mapping of the C function input to theC Callerblock in the model. You cannot edit this property using the command line. To edit the C function mapping, edit the source code of theC Callerblock.

例子:real_T add(real_T u1, real_T u2);

Data Types:char

Returns the list of function input arguments in afirctunargument对象.

Returns a scalar or an emptyfirctunargument对象.

Data Types:char

Returns a scalar or an emptyfirctunargument对象.

Data Types:char

FunctionArgumentObject

FunctionArgumentis a class that carries port specification information of aC Caller以编程方式块。这FunctionArgumentobject has these properties:

  1. Name— Name of the variable in the source code, specified as a character vector. This property is read-only.

  2. Portnumber— Port number of theinputargumentthat has been edited, specified asuint32. This property is read-only.

  3. Size— Size of the Simulink®port dimensions specified as a character vector. You can edit this property if it is allowed in the function definition.

  4. 类型— Simulink data type for the specified port specified as a character vector. You can edit this property if it is allowed in the function definition.

  5. Label— Port label on the Simulink block specified as a character vector. You can change the port label programmatically, for example:

    myCCallerObj.my_CCaller.InputArguments(1).Label ='inputport1'
    my_CCallerObj = FunctionPortSpecification with properties: CPrototype: 'real_T add(real_T u1, real_T u2);' InputArguments: [1×2 Simulink.CustomCode.FunctionArgument] ReturnArgument: [1×1 Simulink.CustomCode.FunctionArgument] GlobalArguments: [1×0 Simulink.CustomCode.FunctionArgument]

  6. 范围 - 将simulink范围映射到指定为字金宝app符向量的输入参数。如果将变量定义为恒定限定符,则该参数可以是输入或参数。如果不存在恒定的限定符,您可以将输出参数更改为input,inputoutput, or to a范围. If your scope fits any of the scenarios above, you can change it programmatically:

    my_CCallerObj.InputArguments(1).Scope ='parameter'
    my_ccallerobj = functionPortspecification with属性:cprototype:'extern real_t add(real_t u1,real_t u2);'inputArguments:[1×2 s金宝appimulink.customcode.functionargument] returnargument:[1×1 simulink.customcode.functionargument] globalarguments] globalArguments:[1×0 simulink.customcode.functionargument]

Object Functions

getGlobalArg Get an object definition of a global variable in a C Caller block

Examples

Create aC CallerConfiguration Object

This example creates aC Caller配置对象使用'slexCCallerExample'demo model.

my_ccallerobj = get_param('slexCCallerExample/C Caller','FunctionPortSpecification')
my_CCallerObj = FunctionPortSpecification with properties: CPrototype: 'real_T add(real_T u1, real_T u2);' InputArguments: [1×2 Simulink.CustomCode.FunctionArgument] ReturnArgument: [1×1 Simulink.CustomCode.FunctionArgument] GlobalArguments: [1×0 Simulink.CustomCode.FunctionArgument]
Create aFunctionArgumentobject for the 1st input port:
inargone = my_ccallerobj.inputarguments(1)
inargone = FunctionArgument with properties: Name: 'u1' PortNumber: 1 Size: '1' Type: 'double' Label: 'u1' Scope: 'Parameter'
Change the label for the first input port:
inargone.Label ='inputport1'
inargone = FunctionArgument with properties: Name: 'u1' PortNumber: 1 Size: '1' Type: 'double' Label: 'inputport1' Scope: 'Parameter'

Version History

Introduced in R2019b