coder.asap2.Function
Description
Create a function object to define function description and export it to an ASAP2 file.
Creation
creates a
function object. You can use the object to define new function description and export it to an
ASAP2 file.userFunction
= coder.asap2.Function
Properties
Name
— Function name
character vector | string scalar
Specify a name for the function.
Example:
"CustomFunction_1"
LongIdentifier
— Function description
character vector | string scalar
Specify comments and description for the custom function.
Example:
"Description of the function"
FunctionVersion
— Function version
character vector | string scalar
Specify the version for the custom function.
Example:
"Custom_Function_version"
Annotation
— Notes
character vector | string scalar
Set of notes represented as multi-line ASCII description texts.
Example:
"Custom_Function_Annotation"
InMeasurements
— Input measurements
character vector | string scalar | array
Specify array of input measurements.
Example:
["measurement1","measurement2"]
OutMeasurements
— Output measurements
character vector | string scalar | array
Specify array of output measurements.
Example:
["measurement1","measurement2"]
LocMeasurements
— Local measurements
character vector | string scalar | array
Specify array of local measurements.
Example:
["measurement1","measurement2"]
DefCharacteristics
— Defined characteristics
character vector | string scalar | array
Specify array of defined characteristics.
Example:
["characteristic1","characteristic2"]
RefCharacteristics
— Referenced characteristics
character vector | string scalar | array
Specify array of referenced characteristics.
Example:
["characteristic1","characteristic2"]
SubFunctions
— Sub functions
character vector | string scalar | array
Specify array of sub functions.
Example:
["function1","function2"]
Examples
Create and Add Custom Function
This example shows how to add a custom function to the ASAP2 file.
Create ECU Description Object
Open a model, build, and create ECU description object.
open_system("ASAP2Demo") slbuild("ASAP2Demo")
### Searching for referenced models in model 'ASAP2Demo'. ### Found 1 model reference targets to update. ### Starting serial model reference code generation build. ### Successfully updated the model reference code generation target for: ASAP2DemoModelRef ### Starting build procedure for: ASAP2Demo ### Successful completion of build procedure for: ASAP2Demo Build Summary Model reference code generation targets: Model Build Reason Status Build Duration ============================================================================================================ ASAP2DemoModelRef Target (ASAP2DemoModelRef.c) did not exist. Code generated and compiled. 0h 0m 28.223s Top model targets: Model Build Reason Status Build Duration ============================================================================================================ ASAP2Demo Information cache folder or artifacts were missing. Code generated and compiled. 0h 0m 30.534s 2 of 2 models built (0 models already up to date) Build duration: 0h 1m 9.3503s
descObj=coder.asap2.getEcuDescriptions("ASAP2Demo")
descObj = Data with no properties.
Create Custom Function
Create a function object template and add the necessary fields.
userFunction = coder.asap2.Function
userFunction = Function with properties: Name: "undefined" FunctionVersion: [1x0 char] LongIdentifier: [1x0 char] Annotation: [1x0 char] InMeasurements: [1x0 string] OutMeasurements: [1x0 string] LocMeasurements: [1x0 string] DefCharacteristics: [1x0 string] RefCharacteristics: [1x0 string] SubFunctions: [1x0 string]
userFunction.Name = 'Custom_Function1'
userFunction = Function with properties: Name: 'Custom_Function1' FunctionVersion: [1x0 char] LongIdentifier: [1x0 char] Annotation: [1x0 char] InMeasurements: [1x0 string] OutMeasurements: [1x0 string] LocMeasurements: [1x0 string] DefCharacteristics: [1x0 string] RefCharacteristics: [1x0 string] SubFunctions: [1x0 string]
userFunction.LongIdentifier = 'Custom Function by user'
userFunction = Function with properties: Name: 'Custom_Function1' FunctionVersion: [1x0 char] LongIdentifier: 'Custom Function by user' Annotation: [1x0 char] InMeasurements: [1x0 string] OutMeasurements: [1x0 string] LocMeasurements: [1x0 string] DefCharacteristics: [1x0 string] RefCharacteristics: [1x0 string] SubFunctions: [1x0 string]
Export the Function to ASAP2 File
Add the function to ECU description object and generate ASAP2 file using the description object.
add(descObj,userFunction)
coder.asap2.export("ASAP2Demo",CustomEcuDescriptions=descObj)
Following Characteristics or Measurements with unsupported data types are not exported in ASAP2 file. "ASAP2Demo_DW.ASAP2DemoModelRef_InstanceData"
Version History
Introduced in R2022b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)