Main Content

coder.asap2.Group

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

Add, update, filter, find, and remove ECU descriptions for groups in an ASAP2 file.

Open and Build Example Model

Open the example model ASAP2Demo

open_system("ASAP2Demo");

Build the model.

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 9.0669s 

Top model targets:

Model      Build Reason                                         Status                        Build Duration
============================================================================================================
ASAP2Demo  Information cache folder or artifacts were missing.  Code generated and compiled.  0h 0m 24.641s 

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

Create the ECU description object for the model.

descObj = coder.asap2.getEcuDescriptions("ASAP2Demo");

Get the list of available groups in the description object.

find(descObj,"Group")
ans = 1x2 string
    "ASAP2Demo"    "ASAP2Demo_ASAP2DemoModelRef_ASAP2DemoModelRef"

Filter the groups and get a list of groups that has Root set to true.

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

Create and Add Custom Group

To add a new group to the ASAP2 file, create a custom group.

GroupObj_GR1 = coder.asap2.Group;
GroupObj_GR1.Name = 'CustomGroup_1';
GroupObj_GR1.LongIdentifier = 'New test group';
GroupObj_GR1.RefCharacteristic = ["ydata3", "ydata4"];
GroupObj_GR1.RefMeasurement = ["ASAP2Demo_Y.Out3", "ASAP2Demo_Y.Out3"];
GroupObj_GR1.Root = true;

Add the custom group to the ECU description object.

add(descObj,GroupObj_GR1);

Get Group Properties

Get the properties of newly added group by using this command.

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: [1x0 string]
           CustomData: [1x0 string]

Update Group Properties

To modify a property of the group, use set function. Update the LongIdentifier field of the group.

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

Generate the ASAP2 file using the updated ECU description object and verify that the ASAP2 file contains the group CustomGroup_1.

coder.asap2.export("ASAP2Demo",CustomEcuDescriptions=descObj);
Following Characteristics or Measurements with unsupported data types are not exported in ASAP2 file. "ASAP2Demo_DW.ASAP2DemoModelRef_InstanceData"

Delete Group

Remove the newly added group from the description object.

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

Version History

Introduced in R2023b