Generate and merge asap2 files

Generate an ASAP2 File

About Generating ASAP2 Files

You can generate an ASAP2 file from your model in one of the following ways:

  • Use the Generic Real-Time Target or a Embedded Coder target to generate an ASAP2 file as part of the code generation and build process.

  • Use the ASAM-ASAP2 Data Definition Target to generate only an ASAP2 file, without building an executable.

This section discusses how to generate an ASAP2 file by using the targets that have built-in ASAP2 support. For an example, see the ASAP2 example model rtwdemo_asap2.

Use GRT or ERT System Target File

The procedure for generating the ASAP2 data definition for a model using the Generic Real-Time Target or Embedded Coder system target file is as follows:

  1. Use the Model Data Editor (View > Model Data Editor) to apply storage classes to signals, block states, and block parameters as described in Apply Storage Classes to Individual Signal, State, and Parameter Data Elements. Use signal and state names to refer to corresponding MEASUREMENT records and parameter object names to refer to CHARACTERISTIC records.

    Use any storage class or custom storage class other than AutoFileScope, or, if you set the default storage class of the corresponding data category to Default in the Code Mapping Editor (the default setting), Model default. For example, using ExportedGlobal configures the data item as an unstructured global variable in the generated code.

    Note

    The data item is not represented in the ASAP2 file if any of the following conditions exist:

    • You apply one of the storage classes AutoFileScope, or Default (through Model default).

    • You apply a custom storage class that causes the code generator to generate a macro or non-addressable variable.

  2. Use the Model Data Editor to configure the remaining properties as desired for each data item.

  3. On the Code Generation pane, click Browse to open the System Target File Browser. In the browser, select grt.tlc or an ERT based target file and click OK.

  4. On the Code Generation > Interface pane, in the Data exchange interface subgroup, select ASAP2 interface.

  5. Select the Generate code only check box on the Code Generation pane.

  6. Click Apply.

  7. Build the model.

    The code generator writes the ASAP2 file to the build folder. By default, the file is named model.a2l, where model is the name of the model. The ASAP2 setup file controls the ASAP2 file name. For details, see Customize Generated ASAP2 File.

Use the ASAM-ASAP2 Data Definition Target

The procedure for generating the ASAP2 data definition for a model using the ASAM-ASAP2 Data Definition Target is as follows:

  1. Use the Model Data Editor (View > Model Data Editor) to apply storage classes to signals, block states, and block parameters as described in Apply Storage Classes to Individual Signal, State, and Parameter Data Elements. Use signal and state names to refer to corresponding MEASUREMENT records and parameter object names to refer to CHARACTERISTIC records.

    Use any storage class or custom storage class other than AutoFileScope, or, if you set the default storage class of the corresponding data category to Default in the Code Mapping Editor (the default setting), Model default. For example, using ExportedGlobal configures the data item as an unstructured global variable in the generated code.

    Note

    The data item is not represented in the ASAP2 file if any of the following conditions exist:

    • You apply one of the storage classes AutoFileScope, or Default (through Model default).

    • You apply a custom storage class that causes the code generator to generate a macro or non-addressable variable.

  2. Use the Model Data Editor to configure the remaining properties as desired for each data item.

  3. On the Code Generation pane, click Browse to open the System Target File Browser. In the browser, select asap2.tlc and click OK.

  4. Select the Generate code only check box on the Code Generation pane.

  5. Click Apply.

  6. Build the model.

    The Simulink Coder code generator writes the ASAP2 file to the build folder. By default, the file is named model.a2l, where model is the name of the model. The ASAP2 setup file controls the ASAP2 file name. For details, see Customize Generated ASAP2 File.

Generate ASAP2 Files for Referenced Models

The build process can generate an ASAP2 file for each referenced model in a model reference hierarchy. In the generated ASAP2 file, MEASUREMENT records represent signals and states inside the referenced model.

To generate ASAP2 files for referenced models, select ASAP2 file generation for the top model and for each referenced model in the reference hierarchy. For example, if you are using the Generic Real-Time Target or an Embedded Coder target, follow the procedure described in Use GRT or ERT System Target File for the top model and each referenced model.

Merge ASAP2 Files for Top and Referenced Models

Use function rtw.asap2MergeMdlRefs to merge the ASAP2 files generated for top and referenced models. The function has the following syntax:

[status,info] = rtw.asap2MergeMdlRefs(topModelName,asap2FileName)

 

  • topModelName is the name of the model containing one or more referenced models.

  • asap2FileName is the name you specify for the merged ASAP2 file.

  • Optional:status returns false (logical 0) if the merge completes and true (logical 1) otherwise.

  • Optional:info returns additional information about merge failure if status is true. Otherwise, it returns an empty character vector.

 

Consider the following example.

[status,info] = rtw.asap2MergeMdlRefs('myTopMdl','merged.a2l')

This command merges the ASAP2 files generated for the top model myTopMdl and its referenced models in the file merged.a2l.

 

The example model rtwdemo_asap2 includes an example of merging ASAP2 files.

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值