Historically, when linking requirements documents to Simulink objects, link information is stored with the model file. Model files are therefore modified every time you add, modify, or delete links to requirements documents. An alternative is to store link information in a separate file. Extra care is, of course, required to keep track of the separate files, but it becomes possible to manage requirements links while keeping Simulink model's timestamp and version number intact.
This example will use the Power Window Controller model to demonstrate how to work with externally stored RMI links. In case your tried this model before, click to clear any stored mappings (more on this later). Open the model by running the following commands:
rmimap.map('slvnvdemo_powerwindowController', 'clear'); % forget previous .req file if any open_system('slvnvdemo_powerwindowController');
Removing all mapping for [MATLAB]/toolbox/slvnv/rmidemos/slvnvdemo_powerwindowController.slx
Select Analysis > Requirements Traceability > Settings to open the Settings dialog box to Storage tab and click Store externally option button.
The default file name for saving requirements links data is ModelName
.req. If the file is not present in the model folder, the model is assumed to have no links to requirements, as you can verify by highlighting the model.
rmipref('StoreDataExternally', true); rmi('highlightModel', 'slvnvdemo_powerwindowController');
You create and manage links in exactly same way you do with internal storage. As an example, create one new link from model to document:
Find the subheader passenger input consists of a vector with three elements under High Level Discrete Event Control Specification section,
Select the subheader with the mouse
Right-click the corresponding Mux block
Click Requirements Traceability > Link to Selection in Word.
If the model is still highlighted, the Mux block highlights to indicate associated requirements data. Note that the title bar does not indicate unsaved changes. New link information is stored separately from the model.
testReqLink = rmi('createEmpty'); testReqLink.description = 'testReqLink'; testReqLink.doc = 'powerwin_reqs\PowerWindowSpecification.docx'; testReqLink.id = '?passenger input consists of a vector with three elements'; rmi('set', 'slvnvdemo_powerwindowController/Mux4', testReqLink);
While working with a model that stores RMI data externally, changes to requirement links are saved when you:
Save or Save As the Simulink model, even if the title bar does not indicate unsaved changes.
Close the model. You will be prompted to save links changes if any.
Use Save links or Save links as shortcuts near the top of Requirements Traceability submenu.
Close the model. You will be prompted about the link that you just created. You may save the links file with the default ModelName
.req name in the model directory, or choose a different file name and/or location.
When you open a model, RMI will try to load requirements links data from the recently used location for this model. You may also select Requirements Traceability > Load links to choose a different
.req file. This allows to use several sets of links with the same model, for example, links to design change descriptions that are different from links to original design specifications.
Highlight requirements in the model to confirm that an alternative set of links is now associated with the model. You can navigate and modify these links in the same way you would work with embedded (in-model) links.
open_system('slvnvdemo_powerwindowController'); otherReqFile = fullfile(matlabroot, 'toolbox', 'slvnv', 'rmidemos', 'powerwin_reqs', 'slvnvdemo_powerwindowRequirements.req'); rmimap.map('slvnvdemo_powerwindowController', otherReqFile); rmi('highlightModel', 'slvnvdemo_powerwindowController');
Mapping [MATLAB]/toolbox/slvnv/rmidemos/slvnvdemo_powerwindowController.slx to [MATLAB]/toolbox/slvnv/rmidemos/powerwin_reqs/slvnvdemo_powerwindowRequirements.req
A model with existing embedded requirements links can convert to external storage. References to documents get stripped from the model file and stored in a new
.req file. To try this out:
Open another model that has internally stored RMI data.
Resave with a new name to create a writeable copy.
Select Analysis > Requirements Traceability > Move to file to open a file browser.
Choose a file name for the new external
.req file and click OK. Model is resaved with no embedded links and a new
.req file is created. Note the "Saving data to ..." message in the command window.
Your ability to use and manage links in this model now depend on the external file.
Reopen the model. Note the "Loading reqs from ..." message in the command window.
Highlight requirements to confirm that the data is available.
Delete the temporary copy of the model.
Points to keep in mind before you move internally stored links to an external file:
You will need to carry an extra
.req file along with the model file.
Non-default file name and location associations are stored in user preferences. If you move or rename the
.req 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
.req 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.
open_system('slvnvdemo_fuelsys_officereq') save_system('slvnvdemo_fuelsys_officereq', 'fuelsys_officereq_copy'); rmidata.export('fuelsys_officereq_copy'); rmi('highlightModel', 'fuelsys_officereq_copy');
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 Requirements Traceability > Copy to model. The model is modified and left dirty. You will have to explicitly Save the changes. The external
.req 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
Open the model. RMI data is loaded from last used
Click Requirements Traceability > Copy to model to import the data. Notice that the model window title bar now indicates unsaved changes.
The model file is not writeable, but you can save the model with a new name. The new model has RMI data embedded and does not depend on external
Points to keep in mind before you embed RMI data with the model file:
Every change to RMI links will modify the model file.
You will not be able to switch between different sets of links: only one set of RMI links can be embedded in model file.
Steps in this example might have created files inside the examples folder and modified your stored mapping of
.req file names. Click to cleanup.
close_system('slvnvdemo_powerwindowController', 0); % close demo model, discard changes tmpfilepath = fullfile(matlabroot, 'toolbox', 'slvnv', 'rmidemos', 'slvnvdemo_powerwindowController.mdl'); rmimap.map(tmpfilepath, 'clear'); % forget mdl-to-req mappings tmpfilepath = strrep(tmpfilepath, '.mdl', '.req'); if exist(tmpfilepath, 'file') == 2, delete(tmpfilepath); end % delete .req file we just saved close_system('fuelsys_officereq_copy', 0); tmpfilepath = which('fuelsys_officereq_copy'); if ~isempty(tmpfilepath) delete(tmpfilepath); % delete tmp .mdl or .slx we just created rmimap.map(tmpfilepath, 'clear'); % forget mdl-to-req mappings tmpfilepath = strrep(tmpfilepath, '.slx', '.req'); if exist(tmpfilepath, 'file') == 2, delete(tmpfilepath); end % delete .req file we just saved end clear tmpfilepath; rmiut.closeDlg(getString(message('Slvnv:reqmgt:highlightObjectsWithReqs'))); % close popup if still open
Nothing to clear for [MATLAB]/toolbox/slvnv/rmidemos/slvnvdemo_powerwindowController.mdl Nothing to clear for .../fuelsys_officereq_copy.slx