Main Content

Integrating Results from an External Result file

In this example, you link a requirement to a result file in Excel Format. The verification status in the Simulink Requirements Editor reflects the test results. This example performs the steps described in Linking to a Result File. To run this example, click Open Example and run it. This example uses:

  • A requirements set file named counter_req.slreqx.

  • A test results file named results.xlsx. This file contains a test case named counterSetsValue.

Step 1: Register the Link Type.

Before creating the links, you need to register the link type from the requirements set file. 1.Open the requirements file counter_req.slreqx in the Requirements Editor:

reqSet = slreq.open('counter_req.slreqx');

Register the link type that is specific to the external results file. The domain registration needed for this example is linktype_myexcelresults.m. To register the custom linktype link type_myexcelresults.m, type:

rmi register linktype_myexcelresults;

The custom logic in the GetResultFcn function locates the result file that corresponds to the test case and fetches the results from that result file. For more information about GetResultFcn, see Links and Link Types. Note: If the register command returns any warning, then you must unregister the file and run the command again. To unregister the file, enter rmi unregister linktype_myexcelresults.

Step 2: Create the Link

Make the struct containing properties of the external result. To create the link, at the command prompt, enter:

externalSource.id = 'counterSetsValue';
externalSource.artifact = 'results.xlsx';
externalSource.domain = 'linktype_myexcelresults';

The requirement related to the link has its SID set to 4. To find the requirement related to the link, enter:

requirement = reqSet.find('Type', 'Requirement', 'SID', 4);

To create the link, enter:

link = slreq.createLink(requirement, externalSource);

This command creates the link between the test case counterSetsValue and the requirement with the SID of 4. In Requirements Editor, the link appears in the Links > Confirmed By section.

Step 3: View the Verification Status

To view the verification status, you need to first update the verification status for the requirement set. At the MATLAB command prompt, type:

 reqSet.updateVerificationStatus;

To see the verification status column in the Requirements Editor, ensure that Display > Verification Status is selected. After the update, fetch the verification status for the requirement:

status = reqSet.getVerificationStatus
status = struct with fields:
         total: 3
        passed: 1
        failed: 0
    unexecuted: 0
     justified: 0
          none: 2

Open the Requirements Editor to see the verification status:

reqSet = slreq.open('counter_req.slreqx');

The Requirements Editor shows the verification status for each requirement in the requirement set.

The verification status for requirements for the counterSetsValue is fully verified.

The verification status shows that out of three tests, one test passed. Click Refresh to see the verification status for the requirements in the Requirements Editor.

Cleanup

Clear open requirement sets and link sets, and close any open models without saving changes. Unregister the linktype.

slreq.clear;
bdclose('all');
rmi unregister linktype_myexcelresults;

Related Topics