Class: slreq.Requirement
Package: slreq
Copy and paste requirement
tf = copy(req1,location,req2)
copies requirement tf
= copy(req1
,location
,req2
)req1
and pastes it under, before, or after requirement
req2
depending on the location specified by
location
. The function returns 1
if the copy and
paste is performed successfully.
Note
If you copy a requirement and paste it within the same requirement set, the copied requirement retains the same custom attribute values as the original. If the requirement is pasted into a different requirement set, the copied requirement does not retain the custom attribute values.
req1
— Requirement to copyslreq.Requirement
objectRequirement to copy, specified as an slreq.Requirement
object.
location
— Requirement paste location'under'
| 'before'
| 'after'
Paste location, specified as 'under'
,
'before'
, or 'after'
.
req2
— Requirementslreq.Requirement
objectRequirement, specified as an slreq.Requirement
object.
tf
— Paste success status0
|
1
Paste success status, returned as a 1
or 0
of
data type logical
.
This example shows how to copy a requirement and paste it under, before, or after another requirement.
Load the crs_req_func_spec
requirement file, which describes a cruise control system, and assign it to a variable. Find two requirements by index. The first requirement will be copied and pasted in relation to the second requirement.
rs = slreq.load('crs_req_func_spec'); req1 = find(rs,'Type','Requirement','Index','1'); req2 = find(rs,'Type','Requirement','Index','2');
Paste Under a Requirement
Copy and paste the first requirement, req1
, under the second requirement, req2
. The first requirement becomes the last child requirement of req2
, which you can verify by finding children of req2
and comparing the summary of the last child and req1
.
tf = copy(req1,'under',req2);
Warning: Error occurred while executing the listener callback for event ReqDataChange defined for class slreq.data.ReqData: Dot indexing is not supported for variables of this type. Error in slreq.das.ReqRoot/recAddDasObjctsIfNeeded (line 835) idx = parentDas.dataModelObj.indexOf(reqDataObj); Error in slreq.das.ReqRoot/onReqDataChange (line 474) addedReq = this.recAddDasObjctsIfNeeded(parentDas,req); Error in slreq.das.ReqRoot>@(varargin)this.onReqDataChange(varargin{:}) (line 21) this.reqDataChangeListener = this.reqData.addlistener('ReqDataChange', @this.onReqDataChange); Error in slreq.data.ReqData/pasteFromClipboard (line 88) this.notify('ReqDataChange', slreq.data.ReqDataChangeEvent('Requirement Pasted', destObj)); Error in slreq.data.ReqData/copyRequirement (line 20) this.pasteFromClipboard(dstDataReq); Error in slreq.BaseEditableItem/copy (line 158) reqData.copyRequirement(this.dataObject, this.supportedDestMap(charInput), dstReq.dataObject); Error in CopyAndPasteARequirementExample (line 4) tf = copy(req1,'under',req2); Error in matlab.internal.editor.evaluateRegions (line 84) regionEvaluator.evalRegions(regionList, editorId, fullText, filePath, lastDocumentState, shouldUseTempFile, lineToCallbackMap, isPrewarmExecution); Error in matlab.internal.editor.EvaluationOutputsService.evalRegions (line 98) evaluateRegions(editorId, regionList, fullText, shouldResetState, shouldUseTempFile, filePath, lastDocumentState, ... Error in matlab.internal.liveeditor.LiveEditorUtilities.execute (line 43) matlab.internal.editor.EvaluationOutputsService.evalRegions(editorId, uuid, regionDataList, fullFileText, false, true, fileName, -1); Error in mwtools.liveCodeToDocbook>doRun (line 364) LiveEditorUtilities.execute(editorId, source); Error in mwtools.liveCodeToDocbook>doRunConvert (line 314) [exampleTime,exampleWarnings, exampleErrors] = doRun(javaRichDocument, source); Error in mwtools.liveCodeToDocbook (line 143) [exampleTime,exampleRunWarnings,exampleRunErrors] = doRunConvert(... Error in BML (line 13) evalin('base', s);
childReqs = children(req2); lastChild = childReqs(numel(childReqs)); lastChild.Summary
ans = 'Driver Switch Request Handling'
req1.Summary
ans = 'Driver Switch Request Handling'
Paste Before a Requirement
Copy and paste the first requirement, req1
, before the second requirement, req2
. Confirm that the requirement was pasted before req2
by checking the index and Summary. The old index of req2
was 2
. The index of the pasted requirement should be 2
and the index of req2
should be 3
.
tf = copy(req1,'before',req2);
Warning: Error occurred while executing the listener callback for event ReqDataChange defined for class slreq.data.ReqData: Index exceeds the number of array elements (2). Error in slreq.das.BaseObject/insertChildObject (line 211) this.children = [this.children(1:newindex-1) obj this.children(newindex:end)]; Error in slreq.das.ReqRoot/recAddDasObjctsIfNeeded (line 836) parentDas.insertChildObject(reqDasObj,idx); Error in slreq.das.ReqRoot/recAddDasObjctsIfNeeded (line 845) added = [added this.recAddDasObjctsIfNeeded(reqDasObj,objChildren(n))]; %#ok<AGROW> Error in slreq.das.ReqRoot/onReqDataChange (line 474) addedReq = this.recAddDasObjctsIfNeeded(parentDas,req); Error in slreq.das.ReqRoot>@(varargin)this.onReqDataChange(varargin{:}) (line 21) this.reqDataChangeListener = this.reqData.addlistener('ReqDataChange', @this.onReqDataChange); Error in slreq.data.ReqData/copyRequirement (line 18) this.notify('ReqDataChange', slreq.data.ReqDataChangeEvent('Requirement Pasted', dataReqSet)); Error in slreq.BaseEditableItem/copy (line 158) reqData.copyRequirement(this.dataObject, this.supportedDestMap(charInput), dstReq.dataObject); Error in CopyAndPasteARequirementExample (line 9) tf = copy(req1,'before',req2); Error in matlab.internal.editor.evaluateRegions (line 84) regionEvaluator.evalRegions(regionList, editorId, fullText, filePath, lastDocumentState, shouldUseTempFile, lineToCallbackMap, isPrewarmExecution); Error in matlab.internal.editor.EvaluationOutputsService.evalRegions (line 98) evaluateRegions(editorId, regionList, fullText, shouldResetState, shouldUseTempFile, filePath, lastDocumentState, ... Error in matlab.internal.liveeditor.LiveEditorUtilities.execute (line 43) matlab.internal.editor.EvaluationOutputsService.evalRegions(editorId, uuid, regionDataList, fullFileText, false, true, fileName, -1); Error in mwtools.liveCodeToDocbook>doRun (line 364) LiveEditorUtilities.execute(editorId, source); Error in mwtools.liveCodeToDocbook>doRunConvert (line 314) [exampleTime,exampleWarnings, exampleErrors] = doRun(javaRichDocument, source); Error in mwtools.liveCodeToDocbook (line 143) [exampleTime,exampleRunWarnings,exampleRunErrors] = doRunConvert(... Error in BML (line 13) evalin('base', s);
pastedReq = find(rs,'Type','Requirement','Index','2'); pastedReq.Summary
ans = 'Driver Switch Request Handling'
req2.Index
ans = '3'
Paste After a Requirement
Copy and paste the first requirement, req1
, after the second requirement, req2
. Confirm that the requirement was pasted after req2
by checking the index. The index of req2
is 3
and should not change, which means the index of the pasted requirement should be 4
.
tf = copy(req1,'after',req2);
Warning: Error occurred while executing the listener callback for event ReqDataChange defined for class slreq.data.ReqData: Index exceeds the number of array elements (2). Error in slreq.das.BaseObject/insertChildObject (line 211) this.children = [this.children(1:newindex-1) obj this.children(newindex:end)]; Error in slreq.das.ReqRoot/recAddDasObjctsIfNeeded (line 836) parentDas.insertChildObject(reqDasObj,idx); Error in slreq.das.ReqRoot/recAddDasObjctsIfNeeded (line 845) added = [added this.recAddDasObjctsIfNeeded(reqDasObj,objChildren(n))]; %#ok<AGROW> Error in slreq.das.ReqRoot/onReqDataChange (line 474) addedReq = this.recAddDasObjctsIfNeeded(parentDas,req); Error in slreq.das.ReqRoot>@(varargin)this.onReqDataChange(varargin{:}) (line 21) this.reqDataChangeListener = this.reqData.addlistener('ReqDataChange', @this.onReqDataChange); Error in slreq.data.ReqData/copyRequirement (line 18) this.notify('ReqDataChange', slreq.data.ReqDataChangeEvent('Requirement Pasted', dataReqSet)); Error in slreq.BaseEditableItem/copy (line 158) reqData.copyRequirement(this.dataObject, this.supportedDestMap(charInput), dstReq.dataObject); Error in CopyAndPasteARequirementExample (line 13) tf = copy(req1,'after',req2); Error in matlab.internal.editor.evaluateRegions (line 84) regionEvaluator.evalRegions(regionList, editorId, fullText, filePath, lastDocumentState, shouldUseTempFile, lineToCallbackMap, isPrewarmExecution); Error in matlab.internal.editor.EvaluationOutputsService.evalRegions (line 98) evaluateRegions(editorId, regionList, fullText, shouldResetState, shouldUseTempFile, filePath, lastDocumentState, ... Error in matlab.internal.liveeditor.LiveEditorUtilities.execute (line 43) matlab.internal.editor.EvaluationOutputsService.evalRegions(editorId, uuid, regionDataList, fullFileText, false, true, fileName, -1); Error in mwtools.liveCodeToDocbook>doRun (line 364) LiveEditorUtilities.execute(editorId, source); Error in mwtools.liveCodeToDocbook>doRunConvert (line 314) [exampleTime,exampleWarnings, exampleErrors] = doRun(javaRichDocument, source); Error in mwtools.liveCodeToDocbook (line 143) [exampleTime,exampleRunWarnings,exampleRunErrors] = doRunConvert(... Error in BML (line 13) evalin('base', s);
pastedReq2 = find(rs,'Type','Requirement','Index','4'); pastedReq2.Summary
ans = 'Driver Switch Request Handling'
req2.Index
ans = '3'
Cleanup
Clear the open requirement sets and link sets, and close the open models without saving changes.
slreq.clear;
bdclose all;
move
| moveDown
| moveUp
| slreq.Requirement
You have a modified version of this example. Do you want to open this example with your edits?