slreq.find error searching requirements with a specific stereotype property.
조회 수: 10 (최근 30일)
이전 댓글 표시
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1578621/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1578626/image.png)
In the Requirements Editor,I have created 2 container requirements in the "reqset.slreqx" with 3 and 2 children requirement as it follows:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1578631/image.png)
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1578636/image.png)
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1578641/image.png)
SET UP:
MATLAB, SIMULINK, Requirements Toolbox versions 2023a.
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Automated Driving Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!