slreq.find error searching requirements with a specific stereotype property.

2 ビュー (過去 30 日間)
Alberto Estrada
Alberto Estrada 2023 年 12 月 29 日
コメント済み: Josh Kahn 2024 年 1 月 8 日
CONTEXT OF THE PROBLEM:
I have created a requirement set called "reqset.slreqx", a profile called "prof.xml" in the same folder. The profile contains a first stereotype called "stereo1" applicable to Requirements with 2 properties called "prop1" enumeration type (Red, Green, Blue) and "prop2" type int8. I have created a second stereotype "stereo2" with similar properties. Requirement set and profile have been linked:
In the Requirements Editor,I have created 2 container requirements in the "reqset.slreqx" with 3 and 2 children requirement as it follows:
PROBLEM DESCRIPTION:
I want to retrieve/find which requirements in "reqset.slreqx" have the stereotype property "prop1" set to "Green".
Using the programmatic function slreq.find in the MATLAB command window as it follows:
slreq.find("Type","Requirement","prof.stereo1.prop1","Green")
The following error is shown:
Error using slreq.datamodel.RequirementData/find
No such attribute.
Error in slreq.data.ReqData/query
Error in slreq.find
Error in slreq.find
WHAT I HAVE DONE:
I have read https://es.mathworks.com/help/slrequirements/ref/slreq.find.html, and different chapters of the user guide and reference pdf.
  • slreq.find works well with custom attributes of the requirement set.
  • slreq.find("Type","Requirement","ReqType","prof.stereo1"); finds correctly the 3 "stereo1" requirements.
  • getAttribute of a "green" "prop1" requirement
SET UP:
MATLAB, SIMULINK, Requirements Toolbox versions 2023a.

採用された回答

Josh Kahn
Josh Kahn 2024 年 1 月 2 日
編集済み: Josh Kahn 2024 年 1 月 2 日
This is a known limitation in 23a.
Here's a workaround for you:
reqs = slreq.find(Type='Requirement', ReqType='prof.stereo1');
matchLogIdx = arrayfun(@(req) isequal(getAttribute(req, 'prof.stereo1.prop1'), enumeration_class.Green), reqs);
matchReqs = reqs(matchLogIdx);
Hope this helps,
Josh
  2 件のコメント
Alberto Estrada
Alberto Estrada 2024 年 1 月 8 日
Thank you very much @Josh Kahn for the quick reply. I have applied your solution and it is quite accurate.
Anyway, it could be good that MATLAB implement this functionality directly in the SLREQ library, so code is easier.
Josh Kahn
Josh Kahn 2024 年 1 月 8 日
Glad to help and thank you for the feedback!
Josh

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAutomated Driving Toolbox についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by