Main Content

Simulink.CodeImporter.Function class

Package:Simulink.CodeImporter

Access and configure detailed information about parsed custom code functions

Since R2021a

Description

Access detailed information about parsed custom code functions obtained fromSimulink.CodeImporterorsltest.CodeImporter类实例。配置自定义信息code functions for importing into Simulink®.

TheSimulink.CodeImporter.Functionclass is a处理class.

Creation

One or more objects of this class are automatically created when you invoke thegetFunctionsmethod of an object of classSimuink.CodeImporter.ParseInfo. ASimulink.CodeImporter.Functionobject is created for each function in the parsed custom code for whichgetFunctionsis invoked. Do not create an object of classSimulink.CodeImporter.Functiondirectly.

Properties

expand all

Function name, returned as a string scalar.

Example:"Controller"

Data Types:string scalar

C prototype for function, returned as a string scalar.

Example:"pump_control_bus Controller(real_T Tset, real_T Troom_in);"

Data Types:string scalar

Port specification of function, specified as an object of classSimulink.CodeImporter.SimulinkPortSpecification.

Whether function is an entry-point function, returned as a logical scalar. An entry-point function is not called by other functions in the custom code.

Whether function is defined, returned as a logical scalar. This scalar indicates whether custom code contains a function body defining the function in addition to a function prototype defined in a header.

Whether function is deterministic, specified as a logical scalar. A deterministic function always produces the same outputs for the same input values. Specifying a function as deterministic enables the correspondingC Callerblock to be used in a For Each subsystem and with continuous sample time, and optimizes the use of the block in conditional input branch execution. SeeDeterministic functions.

Whether function is stubbed, returned as a logical scalar. This scalar indicates whether, for a unit test, a stub for undefined symbols was generated for the function (Simulink Test™license required).

Array layout for function, returned asNotSpecified,ColumnMajor,RowMajor, orAny. IfNotSpecified, then the default setting for the custom code as specified in theFunctionArrayLayoutproperty of the relevantSimulinkCode.CustomCodeobject is used. Otherwise, the value specified for the function overrides the default.

Data Types:枚举

Methods

expand all

Examples

collapse all

Specify and parse custom code, then query information regarding custom code functions.

obj = Simulink.CodeImporter;%% Set library file name and output folderobj.LibraryFileName ="pumpController"; obj.OutputFolder =".";%% Set the custom code to importobj.CustomCode.InterfaceHeaders = ["pumpController.h"]; obj.CustomCode.IncludePaths = ["./include"]; obj.CustomCode.SourceFiles = ["src/pumpController.c""src/utils.c"];%% Parse codeobj.parse; parseobj = obj.ParseInfo
ans = ParseInfo with properties: Success: 1 AvailableFunctions: ["Controller" "setFanTempThreshold" "setPumpTempThreshold"] EntryFunctions: ["Controller" "setFanTempThreshold" "setPumpTempThreshold"] AvailableTypes: "pump_control_bus" Errors: []
fcnobj = parseobj.getFunctions(["Controller"])
fcnobj = Function with properties: Name: "Controller" CPrototype: "pump_control_bus Controller(real_T Tset, real_T Troom_in);" PortSpecification: [1×1 Simulink.CodeImporter.SimulinkPortSpecification] IsEntry: 1 IsDefined: 1 IsStub: 0 ArrayLayout: NotSpecified IsDeterministic: 0

                     

Version History

Introduced in R2021a