How do I check for unresolved requirements links programmatically?

조회 수: 5 (최근 30일)
Pat Canny
Pat Canny 2019년 11월 18일
편집: Pat Canny 2019년 11월 18일
I would like to check for any "bad" requirements implementation links as part of a Continuous Integration (CI) workflow.
For example, a "bad" link could be due to a Simulink block being removed.
How would I do this programmtically, i.e. through a MATLAB script?

채택된 답변

Pat Canny
Pat Canny 2019년 11월 18일
This can be accomplished using the isResolved method within the slreq.Link class.
You can also use the isResolvedSource and isResolvedDestination if you are concerned with a specific link direction. The isResolved method will return FALSE if the link is "unresolved" in either direction.
You need to load the model to memory, otherwise the link will appear as unresolved.
In the example code below, the source is the model element, so I will use isResolvedSource.
(Using an example model from this File Exchange entry)
myModel = 'CruiseControl_TestSuite';
load_system(myModel)
myLinkSet = slreq.load(myModel); % load linkset associated with model
mySources = sources(myLinkSet); % get list of link sources
% Check if first link is resolved
outLinkTest = slreq.outLinks(mySources(1)); % link source is CruiseOnOff inport in model
first_link_resolved = isResolvedSource(outLinkTest); % should be TRUE
% CHECK TO MAKE SURE THIS WORKS
% Open model, remove first inport "CruiseOnOff", then save
open_system(myModel)
% MANUALLY REMOVE CruiseOnOff INPORT
% Re-check whether link is resolved
first_link_resolved = isResolvedSource(outLinkTest); % should now be FALSE
You can use a for loop to iterate through all of the link sources in the link set.

추가 답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by