Requirement Links
Track how your requirements relate to your model design by usingRequirements Toolbox™to create links between your requirements and various Simulink®model elements, including blocks, Stateflow®objects,Simulink Test™test objects, Simulink data dictionary entries, MATLAB®code lines, and other requirements.
Each link has a correspondingslreq.Link
object. The link points from asource itemto adestination item.
You can create links to blocks and Stateflow objects from the Simulink Editor by dragging requirements from theRequirements Browserin the Requirements Perspective View. You can create links toSimulink Testtest objects from the Test Manager or from theRequirements Editor. For more information on linking Simulink model elements to requirements, seeLink Blocks and RequirementsandLink to Test Cases from Requirements.
Requirement links identify the requirement by the Session Independent Identifier (SID) instead of the Custom ID, such that the link remains functional if the Custom ID is modified.
Linkable Items
You can create links between these requirements items, model entities, test artifacts, and code:
Requirements Toolboxobjects:
slreq.Requirement
objectsslreq.Reference
objectsslreq.Justification
objects
Simulink entities:
Blocks
Subsystems
Simulink data dictionary entries
Stateflow objects:
States
Charts and subcharts
Transitions
System Composer™ architecture entities:
Components
Ports
Views
Simulink Testobjects:
Test files
Test suites
Test cases
Iterations
Assessments
Lines of MATLAB code in:
MATLAB
.m
files.MATLAB Function blocks. For more information, seeIntegrate Basic Algorithms Using MATLAB Function Block(Simulink).
MATLAB-based Simulink tests. For more information, seeTest Models Using MATLAB-Based Simulink Tests(Simulink Test).
You can set external artifacts like URLs as link destinations by creating MATLAB structures. There are two approaches available:
Create a link destination structure, then create a link between the requirement and the destination.
myLinkDest = struct('domain','linktype_rmi_url','artifact',...'//www.tatmou.com/nl/','id','') myLinkDest = structwithfields:domain:'linktype_rmi_url'artifact:'www.tatmou.com'id:''slreq.createLink(myReq, myLinkDest);
Create a requirement links data structure using
rmi('createempty')
. Seermi
.
Link Types
Each link has a type that describes the relationship between the source and destination items. The link type refers to theslreq.Link
object'sTypeproperty value.
Each link type has an intended use case. For example, theImplement
link type indicates a relationship between a requirement and a design item that implements the requirement. When you create a link between two items,Requirements Toolboxsets the link type and designates the items as 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. It 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
.
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, clickShow Links. Select a link and, in theDetailspane, underProperties, select the desired link type from theTypelist.
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 | Source-to-Destination Example | Forward Direction | Backward Direction |
---|---|---|---|---|
Relate |
|
Requirement to requirement | The first requirement isrelated tothe second requirement. |
The second requirement isrelated tothe first requirement. |
Implement |
For more information, seeReview Requirements Implementation Status. |
Simulink model element to requirement | The Simulink model elementimplementsthe requirement. |
The requirement isimplemented bythe Simulink model element. |
Verify |
For more information, seeReview Requirements Verification Status. |
Simulink test case to requirement | The Simulink test caseverifiesthe requirement. |
The requirement isverified bythe Simulink test case. |
Derive |
Specifies which source item derives the destination item |
Importedreferenced requirementto requirement | The imported referenced requirementderivesthe requirement. |
The requirement isderived fromthe imported referenced requirement. |
Refine |
傅指定哪个源项添加细节nctionality 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 |
For more information, seeInclude Results from External Sources in Verification Status. |
Requirement to external test result | The requirement isconfirmed bythe external test result. |
The external test resultconfirmsthe requirement. |
TheImplement
andVerify
link types describe requirement-to-model and requirement-to-test relationships. Specify the source and the destination artifacts carefully because 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 a Traceability Diagram.
Custom Link Types
除了内置类型,您可以定义custom link types. Custom link types must be a subtype of one of the built-in types. 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, seeDefine Custom Requirement and Link Types.
Review Requirement Links
You can review links in theRequirements Editoror the Requirements Browser. To view links in theRequirements Editor, clickShow Links. To view links in the Requirements Browser, selectLinks
from theViewdrop-down menu.
When working in the Simulink Editor, you can review requirement links for individual requirements. In the Requirements Browser, selectRequirements
from theViewdrop-down menu and select a requirement. The links are displayed in the Property Inspector, underLinks.
By default, all the outgoing links from a source artifact are stored in a Link Set file (.slmx
). SeeRequirements Link Storagefor more information on requirements links storage.
When you delete a link, all related data is deleted including associated comments and custom attributes.
Resolve Links
For a link to be resolved, you must be able to navigate to the source item and to the destination item. If the source, destination, or both are not available, the link is unresolved. The source or destination items can be unavailable because:
The design artifact that contains the source or destination item is not loaded. For example, if you load a requirement set that has incoming links from a Simulink model, this also loads the link set that belongs to the model. However, if you do not load the Simulink model, the links are unresolved because the link sources are not available.
The design artifact loaded, but the specified ID does not exist. For example, if you delete a linked requirement, the link becomes unresolved because the stored ID no longer corresponds to a valid item.
If a link is unresolved because the specified ID does not exist, it is a broken link.
To see the unresolved links, in theRequirements Editor, clickShow Links. Unresolved links are denoted by.
If a link is unresolved because the source or destination is not loaded, you can resolve the link by loading the file that contains the unloaded source or destination. If a link is broken, you can use thesetSource
andsetDestination
methods to repair the link.
Load Link Information
For artifacts such as requirement sets, Simulink models, data dictionaries, test files, and MATLAB files, all link information related to the artifacts that are on the MATLAB or Project path are automatically loaded when that artifact is loaded.
The link information loading can be summarized by the rules as follows:
Rule 1: Loading an artifact such as requirement sets, Simulink models, data dictionaries, test files, and MATLAB files, that are on the MATLAB or Project path loads all incoming and outgoing link sets for that artifact. Each artifact can have one outgoing link set and one or more link sets containing link information from other artifacts.
Rule 2: If the loaded artifact has outgoing links to a requirement set, then the requirement set is also loaded along with the link information. This loaded requirement set is also eligible to follow Rule 1 to further load link information.
The application of these rules can be illustrated using theslreqCCProjectStart
project in three scenarios. Follow these steps:
Close all the Simulink models and requirement sets before opening the project.
Load the
slreqCCProjectStart
in the MATLAB:slreqCCProjectStart
Scenario 1:
Open the model
crs_controller.slx
:open_system('crs_controller.slx');
OpenRequirements Editor:
slreq.editor
TheRequirements Editorshows following information:
Link information from outgoing link set
crs_controller.slmx
is loaded according to Rule 1.Requirement set
crs_req_func_spec.slreqx
and link setscrs_req.slmx
,crs_controllerdic.slmx
,DriverSWRequest_Tests.slmx
, andcrs_plant.slmx
are loaded according to Rule 2.Close the model and theRequirements Editor.
Scenario 2:
Open the requirement set
crs_req_func_spec.slreqx
:slreq.open('crs_req_func_spec.slreqx');
TheRequirements Editoropens and shows following information:
Link sets View
All link sets which contain incoming link information for loaded requirement set are loaded according to Rule 1.
Close theRequirements Editor.
Scenario 3:
Open the model
crs_plant.slx
:open_system('crs_plant.slx');
OpenRequirements Editor:
slreq.editor
TheRequirements Editorshows following information:
Link information from outgoing link set
crs_plant.slmx
is loaded according to Rule 1.Requirement sets
crs_req_func_spec.slreqx
andcrs_req.slreqx
和所有链接集包含的链接信息rmation for these requirements are loaded according to Rule 2.Close the model and theRequirements Editor.
Link information is not automatically loaded if you save your links with the model as an embedded link set. You can also load link information by using theslreq.refreshLinkDependencies
command.
Unload Link Information
Link information is automatically unloaded when you unload all the related artifacts from memory.
Delete a Link Set
Link sets are stored in.slmx
files. Deleting the.slmx
file while the links are loaded in memory may lead to unexpected behavior.
Note
If you want to delete a link set file associated with a Simulink model, ensure that the links are stored externally. To read more about how to store links externally from a Simulink model, seeRequirements Link Storage.
To delete a link set:
Locate the
.slmx
file. By default, when you create a link, it is stored in a link set with the same name as the artifact that the source item belongs to. The.slmx
file is stored in the same directory as the source artifact.It is best to close all loaded artifacts before deleting a link set. This includes requirement sets,Simulink Testfiles, MATLAB code, Simulink data dictionaries, and Simulink, Stateflow or System Composer models. Manually close all of these artifacts.
At the MATLAB command line, clear loaded links by entering:
slreq.clear
Delete the
.slmx
file.
After deleting the link set file, you can re-open artifacts as needed.
See Also
setSource
|setDestination
|slreq.refreshLinkDependencies