Managing Requirements Without Modifying Simulink Model Files
You can store link data for Simulink® models by storing link data in the Simulink model .slx
file or storing links in an external .slmx
file.
Use external link storage to manage changes to the model file separately from changes to the requirements links. Additionally, using external link storage allows you to manage multiple sets of requirements links for the same model, by loading different .slmx
files.
This example shows how to work with externally stored RMI links. Click Open Example to create a working folder of the example files. Run the following commands:
rmimap.map('slvnvdemo_powerwindowController','clear');
Nothing to clear for .../slvnvdemo_powerwindowController.slx
open_system('slvnvdemo_powerwindowController'); rmipref('UnsecureHttpRequests',true);
Set Up Requirements Manager to Work with Links
In the Apps tab, open Requirements Manager.
In the Requirements tab, ensure Layout > Requirements Browser is selected.
In the Requirements Browser, in the View drop-down menu, select
Links
.
In this example, you will work exclusively in the Requirements tab and any references to toolstrip buttons are in this tab.
Configure RMI to Store Links Externally
In the Requirements tab, select Link Settings > Default Link Storage. This opens the Requirements Settings dialog box.
Select Store externally (in a separate *.slmx file).
rmipref('StoreDataExternally',true);
The default file name for saving requirements links data is ModelName.slmx
. The links file must be in the same folder as the model for the links to resolve.
Creating and Managing RMI Links
Create a link from model to document.
Open the
PowerWindowSpecification.docx
file in the current directory.
Select the subheader passenger input consists of a vector with three elements under the High Level Discrete Event Control Specification section.
Find the block
Mux4.
rmidemo_callback('locate','slvnvdemo_powerwindowController/Mux4');
Right click Mux4
and select Requirements > Link to Selection in Word.
You can also enter the following to create the link:
testReqLink = rmi('createEmpty'); testReqLink.description = 'testReqLink'; testReqLink.doc = 'PowerWindowSpecification.docx'; testReqLink.id = '?passenger input consists of a vector with three elements';
Create the link:
rmi('set','slvnvdemo_powerwindowController/Mux4',testReqLink)
If the model is still highlighted, the Mux4
block highlights to indicate associated requirements data. New link information is stored separately from the model and saves when the model is saved.
Saving Requirements Links Data to External Files
When saving requirements data externally, you can save changes to requirements by:
Clicking Save or Save As the Simulink model, even if the model does not have unsaved changes.
Closing the model. You will be prompted to save links changes.
Clicking Link Settings > Save Links As.
Click Link Settings > Save Links As and save them with the name slvnvdemo_powerwindowController.slmx.
Close the model.
close_system('slvnvdemo_powerwindowController',1)
Save the links file with the default ModelName.slmx
name in the model folder, or choose a different file name and/or location.
Loading Requirements Links from External Files
When you open a model, the RMI will try to load requirements links data from the recently used location for this model. You may also select Load Links to choose a different .slmx
or .req
file. In this way you can use several sets of links with the same model. For example, you can use links to design change descriptions that are different from links to original design specifications.
Reopen the model and select Load Links to open a file browser and point to slvnvdemo_powerwindowRequirements.slmx
in the working directory, or evaluate the following code.
open_system('slvnvdemo_powerwindowController'); otherReqFile = 'slvnvdemo_powerwindowRequirements.slmx'; rmimap.map('slvnvdemo_powerwindowController', otherReqFile);
Mapping .../slvnvdemo_powerwindowController.slx to .../slvnvdemo_powerwindowRequirements.slmx
Click Highlight Links in the toolstrip to confirm that an alternative set of links is now associated with the model, or evaluate the following code.
rmi('highlightModel','slvnvdemo_powerwindowController');
You can navigate and modify these links in the same way you would work with embedded (in-model) links.
Moving RMI Links from Internal to External Storage
A model with existing embedded requirements links can be converted to external storage. Link data will no longer be stored in .slx file, but in a new .slmx
file. Try this out with the following steps.
Open another model that has internally stored RMI data by evaluating the following code.
open_system('slvnvdemo_fuelsys_officereq');
Select Link Settings > Save Links As Link Set File to open a file browser. Choose a file name for the new external .slmx
file and click OK. The model is resaved with no embedded links, and a new .slmx
file is created. You can also evaluate the following code.
rmidata.saveAs('slvnvdemo_fuelsys_officereq','slvnvdemo_fuelsys_officereq.slmx');
The requirements links now depend on the external file.
Click Highlight Links to confirm that the link data is available, or evaluate the following code.
rmi('highlightModel','slvnvdemo_fuelsys_officereq');
Close the model manually and delete the external .slmx
file, or evaluate the following code.
close_system('slvnvdemo_fuelsys_officereq',1);
Use the following code to delete the file:
rmidemo_callback('remove','slvnvdemo_fuelsys_officereq.slmx')
Manually reopen the model or evaluate the following code.
open_system('slvnvdemo_fuelsys_officereq');
Click Highlight Links or evaluate the following to highlight the links:
rmi('highlightModel', 'slvnvdemo_fuelsys_officereq')
Nothing is highlighted because the data is no longer available. Recreate the slvnvdemo_fuelsys_officereq.slmx
file and map it to the slvndemo_fuelsys_officereq
Simulink model by evaluating the following code.
rmimap.map('slvnvdemo_fuelsys_officereq','backup_reqs.slmx');
Mapping .../slvnvdemo_fuelsys_officereq.slx to .../backup_reqs.slmx
rmidata.saveAs('slvnvdemo_fuelsys_officereq','slvnvdemo_fuelsys_officereq.slmx');
Points to keep in mind before you move internally stored links to an external file:
You will need to carry an extra
.slmx
file along with the model file.Non-default file name and location associations are stored in user preferences. If you move or rename the
.slmx
file outside MATLAB®, you will have to manually point RMI to the new location when the model is reopened.When one user has configured a non-default location or name for the
.slmx
file associated with the model, other RMI users will need to manually select Load links when they open the model. The specified location will persist in each user's preferences and does not need to change unless files are moved or renamed again.
Moving RMI Links from External to Internal Storage
To embed RMI data with the Simulink model, so that all information is in one place and you do not need to track extra files, select Link Settings > Save Links in Model File. The external .slmx
file still exists, but it is not read when you reopen the model that now has embedded RMI data. You can try this out with the slvnvdemo_fuelsys_officereq.slx
model from the previous section.
Alternatively, evaluate the following code.
rmipref('StoreDataExternally',false); save_system('slvnvdemo_fuelsys_officereq');
Points to keep in mind before you embed RMI data with the model file:
Every change to RMI links will modify the model file.
External
.slmx
files are disregarded when.slx
file contains traceability links data.
Cleanup
Clear the open requirement sets and link sets. Close all open models.
slreq.clear;
bdclose 'all';