Main Content

在生成的代码中添加全局评论

这些例子展示了如何添加一个全球评论a Simulink®模型使评论文本出现在生成的文件或文件中。用Simulink指定模板符号名称万博1manbetxDOCBLOCK,sim万博1manbetxulink注释或状态流®note. You can also use a sorted-notes capability that works with Simulink annotations or Stateflow notes, but notDOCBLOCKs。有关模板符号的更多信息,请参阅Template Symbols and Rules

笔记

模板符号名称描述andModel Informationare fields in the物业检查员对话框。如果您使用以下符号名称之一进行全局评论文本及其物业检查员字段中还包含文本,两个名称都出现在生成的文件中。

用一个万博1manbetx放映以添加评论

  1. 打开模型。万博1manbetx

    model='rtwdemo_codetemplate'; open_system(model)

  2. 在配置参数下,设置代码模板rtwdemocodetemplate.cgt。此代码模板包含生成全局注释的所需自定义。

  3. 右键单击DOCBLOCK并选择蒙版>掩码参数

  4. In the代码生成模板符号框,键入以下内容之一:

    • 抽象的

    • 描述

    • 历史

    • 笔记

    点击OK。模板符号名称对大小写。

    If you are using aDOCBLOCK要向您的代码添加注释,请设置文档类型文本。If you set文档类型RTForhtml, your comments do not appear in the code.

  5. 在“块属性”对话框中块注释选项卡,选择然后单击OK。您在上一步中键入的符号名称现在出现在DOCBLOCK在模型中。

  6. 保存模型。生成代码后,代码生成器将注释放在每个生成的文件中,其模板具有您指定的符号名称。代码生成器将评论放在生成的文件中,位于与模板文件中符号名称所在的位置相对应的位置。

    该模型生成文件的相关片段是:

    * *摘要: *此文本映射到代码模板%符号。

  7. 要向生成的文件添加更多注释,请重复步骤2-6。

用一个万博1manbetx注释添加评论

  1. Open the modelrtwdemo_codetemplate

  2. Double-click the unoccupied area on the model where you want to place the comment. See使用笔记和注释描述模型

  3. 类型其次是评论。符号_name是以下之一:

    • 抽象的

    • 描述

    • 历史

    • 笔记

    例如,键入这是我想要的描述。模板符号名称对大小写。If you want the code generator to sort multiple comments for the笔记符号名称,将下一步替换为使用排序的注释添加评论

  4. 点击outside the annotation rectangle and save the model. After you generate code, the code generator places the comment in each generated file whose template has the symbol name that you assigned. The code generator places the comment in the generated file at the location that corresponds to where the symbol name is located in the template file. If you want the code generator to sort multiple comments for the笔记符号名称,将下一步替换为使用排序的注释添加评论

  5. 要向生成的文件添加一个或多个注释,请重复步骤2-4。

使用排序的注释添加评论

排序的音符功能使您可以在生成的文件中添加排序的注释。代码生成器将这些注释放在每个生成的文件中笔记符号位于模板文件中。

代码生成器使用此排序顺序:

  • 字母前的数字。

  • Among numbers, zero is placed first.

  • Among letters, uppercase letters are placed before lowercase letters.

您可以使用分类的注释进行模拟链接注释或状态流笔记,但不能使用万博1manbetxDOCBLOCK

  • In the Simulink annotation or the Stateflow note, type其次是第一个评论。y是数字或字母。

  • Repeat this process for as many additional comments you want. Replacey随后的号码或字母。

该图说明了模型上的分类注释。它显示代码生成器将每个音符放在生成文件中的位置。

该模型生成文件的相关片段是:

* *注意: *注意:此Simulink注释映射万博1manbetx到代码模板%符号。* Note1:另一个Simuli万博1manbetxnk注释。*

限制

您无法使用Simulink中的模板符号名称生成全局评论万博1manbetxDOCBLOCK, 当。。。的时候语言对于代码生成是C ++

Related Topics