Main Content

Create and Store Links

You can use links and link sets to trace requirements to the design and test items that implement and verify them. Each link and link set has a corresponding API object. You can use theRequirements Editor, Requirements Perspective, a traceability matrix, or the MATLAB®command line to create links between requirements, MATLAB code, Simulink®blocks,动态仿真模块Test™test cases, and other items. You can also view and edit the links.

Link Objects, Sources, and Destinations

Each link has a correspondingslreq.Linkobject. You can provide additional traceability information by using link properties, custom attributes, and stereotypes. For more information, see:

Links point from source items to destination items, which are contained in source artifacts and destination artifacts, respectively. For example, consider a link that points from a Simulink block to a requirement. The Simulink model is the source artifact and the block is the source item. The requirement set is the destination artifact and it contains the requirement, which is the destination item.

相关项如果是有外向链接urce of a link. Conversely, an item has an incoming link if it is the destination of a link. For example, if a link points from a Simulink block to a requirement, the Simulink block has an outgoing link and the requirement has an incoming link.

Link Storage

Link sets contain links. Each link set you load has a correspondingslreq.LinkSetobject. When you create a link, Requirements Toolbox™ creates a link set and saves it as an SLMX file in the same folder as the source artifact. The link set name is the source artifact base name and the source artifact extension, separated by a tilde. For example, Requirements Toolbox stores outgoing links from a MATLAB function calledmyFunction.min a link set file calledmyFunction~m.slmx.

Note

Link sets that contain links from Simulink models combine the model base name and~mdlto prevent link resolution issues if the model file extension changes between.mdland.slx. For example, Requirements Toolbox stores outgoing links fromvdp.slxin a link set file calledvdp~mdl.slmx.

年代ave Links

When you create links from artifacts such as Simulink models or动态仿真模块Testfiles, you can save the changes to the link set by saving the artifact.

To save the changes to a link set when you create or edit links to lines of MATLAB code or plain-text external code, use one of these approaches:

  • In the MATLAB Editor, right-click and selectRequirements>年代ave Links.

  • In theRequirements Editor, click年代how Links. Select the link set, and click年代ave.

  • At the MATLAB command line, usesave.

Linkable Items

You can create links between these requirements items, model entities, test artifacts, and code:

Create Links

You can use theRequirements Editor, Requirements Perspective, a traceablity matrix, or the MATLAB command line to create links.

To create a link from a design or test item to a requirement by using theRequirements Editor:

  1. 年代elect one of these items:

    • 动态仿真模块or Stateflow model element

    • 年代ystem Composer architecture element

    • 动态仿真模块Testtest case

    • Code range in the MATLAB Editor

    • 动态仿真模块data dictionary entry

    Tip

    To link to MATLAB functions and enable change tracking for the entire body of the function, create the link to the line that contains thefunctionkeyword.

  2. In theRequirements Editor, select the requirement.

  3. ClickAdd Link, then select the menu option that contains the selection that you want to link to.

To create a requirement-to-requirement link:

  1. 年代elect the requirement that you want to link as the source item.

  2. ClickAdd Link>年代elect for Linking with Requirement.

  3. 年代elect the requirement that you want to link as the destination item.

  4. Create the link by selectingAdd Link>Create a link from.

Tip

Create Links Programmatically

To create links at the MATLAB command line:

  1. Get the object or handle for the link source. For example:

    open_system("vdp") src = get_param("vdp/Mu","Handle");

  2. Get the object or handle for the link destination. For example:

    dest = slreq.find(Type="Requirement",Summary="My requirement");
  3. Use theslreq.createLinkfunction to create the link.

    newLink = slreq.createLink(src,dest);

To create links to MATLAB code or plain-text external code programmatically, useslreq.TextRange对象。有关更多信息,请参见Requirements Traceability for MATLAB Code.

Link Types

Each link has a type that describes the relationship between the source and destination items. TheTypeproperty value of theslreq.Linkobject describes the link type.

Assigned Link Types

Each link type has an intended use case. For example, theImplementlink type indicates a relationship between a requirement and a design item that implements the requirement. When you create a link between two items,Requirements Toolbox设置链接类型和指定items as the source or destination depending on the type of artifact that they belong to. For example, if you create a link between a requirement and a Simulink model element,Requirements Toolboxassumes that the model element implements the requirement, sets the link type toImplement, and designates the model element as the source and the requirement as the destination.

If there is no assumed link type for a link created between two items, thenRequirements Toolboxsets the link type toRelate. For example, requirement-to-requirement links and links from plain-text external code default toRelate.

Edit the Link Type

After you create the link, you can edit the link type in theRequirements Editor, the Requirements Perspective, or at the MATLAB command line. In theRequirements Editor, click年代how Links. Select a link and, in the right pane, underProperties, select the desired link type from theTypelist.

Built-in Link Types

Requirements Toolboxprovides six built-in link types.

The forward direction indicates how the source relates to the destination. Similarly, the backward direction indicates how the destination relates to the source.

Type Description 年代ource-to-Destination Example Forward Direction Backward Direction
Relate
  • General relationship between items for most use cases

  • Bi-directional link

Requirement to requirement

The first requirement isrelated tothe second requirement.

The second requirement isrelated tothe first requirement.

Implement
  • 年代pecifies the source item that implements the requirement

  • Contributes to the implementation status

有关更多信息,请参见Review Requirements Implementation Status.

动态仿真模块model element to requirement

The Simulink model elementimplementsthe requirement.

The requirement isimplemented bythe Simulink model element.

Verify
  • 年代pecifies which source item verifies the requirement

  • Contributes to the verification status if the source item is one of the accepted item types

有关更多信息,请参见Review Requirements Verification Status.

动态仿真模块test case to requirement

The Simulink test caseverifiesthe requirement.

The requirement isverified bythe Simulink test case.

Derive

年代pecifies which source item derives the destination item

Importedreferenced requirementto requirement

The imported referenced requirementderivesthe requirement.

The requirement isderived fromthe imported referenced requirement.

Refine

年代pecifies which source item adds detail for the functionality specified by the destination item

Low-level requirement to high-level requirement

The low-level requirementrefinesthe high-level requirement.

The high-level requirement isrefined bythe low-level requirement.

Confirm
  • 年代pecifies a relationship between a requirement and an external test result source

  • Can contribute to the verification status in certain cases

有关更多信息,请参见Include Results from External Sources in Verification Status.

Requirement to external test result

The requirement isconfirmed bythe external test result.

The external test resultconfirmsthe requirement.

TheImplementandVerifylink types describe requirement-to-model and requirement-to-test relationships. These links affect the implementation status and verification status. For more information, seeReview Requirements Implementation StatusandReview Requirements Verification Status.

The link type also affects the impact direction in the Traceability Diagram window. For more information, seeVisualize Links with Traceability Diagrams.

Custom Link Types

In addition to the built-in types, you can define custom link types. Custom link types must use one of the built-in types as the base behavior. The custom link type inherits some functionality from the built-in type, including how the link type contributes to the implementation and verification statuses. For more information, seeChoose a Built-in Type as a Base Behavior.

You can define custom link types by using stereotypes or by usingsl_customizationfiles. For more information, seeDefine Custom Requirement and Link Types and Properties.

View and Edit Links

To view the loaded link sets and the links they contain, in theRequirements Editor, clickView Links. You can then select a link and view or edit its properties or custom attributes. For more information, see年代et Link Properties, Custom Attributes, or Stereotype Properties.

You can also view the links for a particular requirement in theRequirements Editorwhen you select a requirement. In the right pane, underLinks, the outgoing links iconOutgoing links icon.indicates outgoing links and the incoming links iconIncoming links icon.indicates incoming links.

To view links in the Simulink Editor by using the Requirements Perspective:

  1. Open the Requirements Perspective in a Simulink model by clicking the年代how Perspectives viewsicon in the lower-right corner of the model canvas and selectRequirements.

  2. In theRequirementstab, ensure thatLayout>Requirements Browser被选中。

  3. In theRequirementspane, in theViewmenu, selectLinks.

To visualize links, create a traceability matrix or traceability diagram. For more information, seeTrack Requirement Links with a Traceability MatrixandVisualize Links with Traceability Diagrams.

Delete Links and Link Sets

To delete a link, in theRequirements Editor, click年代how Links. Select a link and, in theLinkssection, clickDelete links icon..

To delete a link set:

  1. Locate the SLMX file that contains the link set. By default, link set files are in the same folder as the source artifact.

  2. Close the linked artifacts before deleting a link set, including requirement sets,动态仿真模块Testfiles, MATLAB code, Simulink data dictionaries, and Simulink, Stateflow or System Composer models.

  3. At the MATLAB command line, clear the loaded requirements and links by entering:

    slreq.clear

  4. Delete the SLMX file.

Note

If you want to delete a link set file associated with a Simulink model, ensure that the links are stored externally. For more information about how to store links externally, seeRequirements Link Storage.

年代ee Also

|

Related Topics

Baidu
map