Hauptinhalt

coder.asap2.Group

R2026b

Create group object

Since R2023b

Description

Create a group object to view characteristics and measurements together and export it to an ASAP2 file.

Creation

groupObj = coder.asap2.Group creates a group object. You can use the object to define list of characteristic, measurements, subgroups to the group and export it to an ASAP2 file.

Properties

expand all

Specify a name for the custom group.

Example: "CustomGroup_1"

Specify comments and description of the group.

Example: "Description of the group"

Specify the list of parameters referred in the group.

Example: ["Parameter1", "Parameter2"]

Specify the list of signals referred in the group.

Example: ["Signal1", "Signal2"]

Specifies the root of the group's hierarchy.

Example: 1

Specify the list of sub groups referred in the group.

Example: ["Subgroup1", "Subgroup2"]

Specify any additional description that needs to be populated in the group.

Example: "additional information"

Examples

collapse all

This example shows how to add, modify, and remove custom groups in an ASAP2 file.

Groups organize characteristics and measurements in an ASAP2 file so that calibration tools can present related data elements together.

In this example, you:

  • Build a model and create an ECU description object

  • Find and filter groups by properties

  • Add a custom group with referenced characteristics and measurements

  • Modify group properties and export the ASAP2 file

Open and Build the Model

Open the example model ASAP2Demo and generate code from it. Building the model is a prerequisite for creating the ECU description object.

open_system("ASAP2Demo");

slbuild("ASAP2Demo");
### Searching for referenced models in model 'ASAP2Demo'.
### Total of 2 models to build.
### Starting serial code generation build.
### Starting model reference code generation target build for: ASAP2DemoModelRef
### Successfully updated the model reference code generation target for: ASAP2DemoModelRef
### Starting top model code generation target build 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 10.07s

Top model targets:

Model      Build Reason                         Status                        Build Duration
============================================================================================
ASAP2Demo  Target (ASAP2Demo.c) did not exist.  Code generated and compiled.  0h 0m 19.22s

2 of 2 models built (0 models already up to date)
Build duration: 0h 0m 31.536s

Create and Explore ECU Descriptions

Create the ECU description object for the built model. Use the find function to list available groups.

descObj = coder.asap2.getEcuDescriptions("ASAP2Demo");
Export duration: 0h 0m 0s 217ms
find(descObj, "Group")
ans = 1×2 string
    "ASAP2Demo"    "ASAP2Demo.ASAP2DemoModelRef.ASAP2DemoModelRef"

Filter the groups to get only those that have Root set to true.

find(descObj, "Group", Root=true)
ans = 
"ASAP2Demo"

Add a Custom Group

Create a group that references specific characteristics and measurements, and add it to the ECU description object.

groupObj = coder.asap2.Group;
groupObj.Name = "CustomGroup_1";
groupObj.LongIdentifier = "New test group";
groupObj.RefCharacteristic = ["ydata3", "ydata4"];
groupObj.RefMeasurement = ["ASAP2Demo_Y.Out3", "ASAP2Demo_Y.Out3"];
groupObj.Root = true;
add(descObj, groupObj);

Verify the properties of the newly added group.

get(descObj, "Group", "CustomGroup_1")
ans = 
  Group with properties:

                 Name: "CustomGroup_1"
       LongIdentifier: "New test group"
    RefCharacteristic: ["ydata3"    "ydata4"]
       RefMeasurement: ["ASAP2Demo_Y.Out3"    "ASAP2Demo_Y.Out3"]
                 Root: 1
             SubGroup: [1×0 string]
           CustomData: [1×0 string]

Update the LongIdentifier property using the set function.

set(descObj, "Group", "CustomGroup_1", LongIdentifier="Group 1 new long identifier")

Export the Customized ASAP2 File

Export the ASAP2 file using the updated ECU description object. Verify that the generated file contains the group CustomGroup_1.

coder.asap2.export("ASAP2Demo", CustomEcuDescriptions=descObj);

Remove the Custom Group

Remove the custom group from the ECU description object.

delete(descObj, "Group", "CustomGroup_1");

Version History

Introduced in R2023b