Main Content

slreq.structToObj

Convert link source or destination information from structure to model object type

Description

ot = slreq.structToObj(linkinfo) converts the source or destination link information in the structure linkinfo to the corresponding object type, ot. The object type returned can include Simulink® blocks, Simulink Test™ test cases, or other object types compatible with Requirements Toolbox™.

example

Examples

collapse all

This example shows how to get the structure containing unique requirement source and destination information, then convert the structure information to the specific source and destination model entity.

Load Model, Requirement Set, and Links

load_system("reqs_validation_property_proving_original_model");
reqset = slreq.load("original_thrust_reverser_requirements.slreqx");
linkset = slreq.load( ...
    "reqs_validation_property_proving_original_model.slmx");

For a Link Set

Get sources from a link set, get a single source, and convert the structure to the model entity.

linkSources = sources(linkset);
linkSource1 = linkSources(1);
modelSource1 = slreq.structToObj(linkSource1);

For a Link

Get a link from the link set, get the source and destination for that link.

links = getLinks(linkset);
link2 = links(2);
linkSource2 = source(link2);
linkDest2 = destination(link2);

Convert the source and destination structure to the model entity.

modelSource2 = slreq.structToObj(linkSource2);
modelDest2 = slreq.structToObj(linkDest2);

This example shows how to get information for a link source, then convert the information to the corresponding object type. In this example, the source object type is a Simulink Test test case.

Open the project and load the requirement set, link set, and test file.

openProject("CruiseRequirementsSafetyExample");
reqSet = slreq.load("crs_req.slreqx");
linkSet = slreq.load("DriverSwRequest_Tests.slmx");
testFile = sltest.testmanager.load("DriverSwRequest_Tests.mldatx");

Get the links in the link set. Then, get the source information for a link.

linkArray = getLinks(linkSet);
link = linkArray(1);
linkSource = source(link);

Convert the structure containing the source information for the link to a test case.

testCase = slreq.structToObj(linkSource);

Input Arguments

collapse all

Link information from a slreq.Link or slreq.LinkSet object, specified as a structure array. The fields of the structure array must contain source artifact and unique identification information for a link, as returned by these methods:

Example: linkSources = sources(linkset); slreq.structToObj(linkSources(1))

Example: slreq.structToObj(source(link))

Example: slreq.structToObj(destination(link))

Data Types: struct

Output Arguments

collapse all

Requirement, model, or data entity corresponding to the source artifact and unique identification information in linkinfo, returned as one of these values:

Version History

Introduced in R2018a