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