主要内容

在 Simulink 中查看和链接需求

您可以使用需求透视查看、编写、编辑需求并将其链接到 Simulink 模型元素,而无需退出 Simulink 编辑器。

本教程介绍如何使用需求透视来查看、创建和导航 Simulink® 模块之间的链接。

打开工程文件

打开 CruiseRequirementsExample 工程,其中包含汽车巡航控制系统的需求、模型和测试。然后,打开 crs_controller 模型。

openProject("CruiseRequirementsExample");
open_system("models/crs_controller")

打开需求透视

在 Simulink 模型中,点击右下角的“透视”图标 来打开需求透视,然后点击需求

The mouse points to the Requirements button in the lower-right corner.

“需求浏览器”仅显示与模型相关联的需求集。在 crs_controller 模型中,它会列出 crs_req_func_spec 需求集。

The Requirements Browser shows the crs_req_func_spec requirement set, which has 4 top-level requirements and one top-level justification.

在“需求浏览器”中选择索引 2 来检查具有该索引的需求。属性检查器会显示有关需求的详细信息,并突出显示模型中链接的子系统。

The requirement with index 2 is selected in the Requirements Browser. The linked subsystem is highlighted.

同样,在模型中选择 CruiseControlMode 子系统会在“需求浏览器”中突出显示 Cruise Control Mode 需求。

创建链接

在“需求浏览器”中,通过在搜索栏中输入摘要 Enable Switch Detection,找到具有该摘要的需求。

The Requirements Browser shows only the requirement that has the summary Enable Switch Detection, with the summary highlighted in yellow, and its parent requirement.

在 Simulink 模型中,找到连接到 DriverSwRequest 子系统的输入端口的 enbl 模块。

The enbl block is selected, which is one of 6 input ports to the DriverSwRequest subsystem.

Enable switch detection 需求拖放至 enbl 模块,以此在需求与模块之间创建链接。点击 Simulink 编辑器中的空白处来创建带有默认注解的链接。您还可以通过以下方法创建链接:选择需求,右键点击模块并选择需求 > 链接到需求浏览器中的所选内容。链接的模块会显示“需求”图标

显示需求注解

您可以使用需求注解直接在 Simulink 编辑器中显示有关链接的需求的详细信息。选择“需求”图标 并点击显示来显示链接的需求的注解。注解会显示需求 ID、摘要和链接类型。

An annotation for the Enable Switch Detection requirement is shown on the Simulink Editor.

要在注解中显示需求描述,请双击注解。

在链接的需求与模块之间导航

您可以使用 Simulink 编辑器中的超链接在链接的需求与模块之间导航。要从模块导航到链接的需求,请选择 enbl 模块上的“需求”图标 ,然后点击启用 Switch 检测

The mouse points to the hyperlink for the Enable Switch Detection requirement from the enbl block.

软件会在“需求浏览器”中突出显示链接的需求。或者,您可以通过右键点击注解并选择在需求浏览器中选择,从需求注解导航到需求。

从需求导航到 enbl 模块。在“需求浏览器”窗格中,选择需求。在属性检查器链接下,点击 enbl

In the Property Inspector, the mouse points to the enbl block under Links.

软件会在 Simulink 编辑器中突出显示 enbl 模块。

另请参阅

主题