Main Content

Use a Custom Document Interface to Link External Application Requirements

You can link Simulink® models, subsystems, and blocks to requirements in an external application by using a custom document interface. You can also use a custom document interface to import requirements. Before you link to or import requirements, you must first define and register the custom document interface.

In this example, you link Simulink® blocks to a PowerPoint presentation that contains requirements. Afterwards, you import the requirements into the model. The model represents the controls for a car window.

Define and Register a Custom Document Interface

In this example, you use a premade custom document interface contained in the file rmidemo_pp.m. Custom document interfaces set properties and provide callbacks that allow Requirements Toolbox to interface with an external application. For more information, see Define Custom Document Interface for Direct Linking to Requirements.

The rmidemo_pp.m file:

  • Sets PPT and PPTX as the supported file types.

  • Defines how Requirements Toolbox interprets PowerPoint documents.

  • Uses the Office VBA language to access and navigate to PowerPoint documents. For more information about Office VBA for PowerPoint, see the Microsoft Developer Reference pages.

To use a custom document interface, register the associated file in Requirements Toolbox.

rmi register rmidemo_pp

Create Links by Using Slide Numbers

After you register the custom document interface, you can link to a specific slide number in the PowerPoint presentation. If the slide order changes, the link does not update to match the new location.

Link to the fifth slide, which contains the requirements for the driver input.

  1. Right-click the Truth Table block, which connects to the driver input of the control chart. Select Requirements > Open Outgoing Links Dialog.

  2. In the Outgoing Links dialog box, click New.

  3. In the Description, enter Driver input.

  4. In the Document type drop-down, select Microsoft PowerPoint.

  5. Click Browse. Select powerwindowController.pptx and click Open.

  6. In the Location (Type/Identifier) text field, enter 5.

  7. Click OK.

  8. Right-click the truth table block and expand the Requirements submenu. Driver input appears as a menu option. When you click this menu option, MATLAB opens the PowerPoint document to the fifth slide.

customlinktype_driverinput.png

Create Persistent Links by Using Slide IDs

You can create a persistent link to a slide by using the slide ID. If the slide order changes, the link continues to point to the correct slide.

To find the ID of the fifth slide, open powerwindowController.pptx and use the MATLAB command line to query Office VBA:

hApp = actxGetRunningServer('powerpoint.application');
hDoc = hApp.ActivePresentation;
hDoc.Slides.Item(5).SlideID 
ans = 
260

Link a block to the slide.

  1. Right-click the Truth Table block and select Requirements > Open Outgoing Links Dialog.

  2. In the Outgoing Links dialog box, click New.

  3. In the Description, enter Driver input (ID).

  4. In the Document type drop-down, select Microsoft PowerPoint.

  5. Click Browse. Select powerwindowController.pptx and click Open.

  6. In the Location (Type/Identifier) drop-down, select Named Item.

  7. In the Location (Type/Identifier) text, enter 260.

  8. Click OK.

  9. Right-click the truth table block and expand the Requirements submenu. Driver input (ID) appears as a menu option. When you click this menu option, MATLAB opens the PowerPoint document to the appropriate slide.

Create Persistent Links by Using the Document Index Tab

You can also create persistent links by using the Document Index tab of the Outgoing Links dialog box. To use the Document Index tab, your custom document interface must use the ContentsFcn method to store the slide ID. For more information about ContentsFcn, see Define Custom Document Interface.

  1. Right-click the Truth Table1 block, which connects to the passenger input of the control chart. Select Requirements > Open Outgoing Links Dialog.

  2. In the Outgoing Links dialog box, click New.

  3. In the Document type drop-down, select Microsoft PowerPoint.

  4. Click Browse. Select powerwindowController.pptx and click Open.

  5. Click the Document Index tab.

  6. Click Refresh.

  7. Double-click Passenger Input consists of a vector with three elements. The Description and Location (Type/Indentifier) fields automatically populate.

  8. Click OK.

  9. Right-click the Truth Table1 block and expand the Requirements submenu. Passenger Input consists of a vector with three elements in powerwindowController.pptx appears as a menu option. When you click this menu option, MATLAB opens the PowerPoint document to the appropriate slide.

customlinktype_docindex.png

Create Persistent Link to Current Slide

You can create a persistent link to the active slide in an open PowerPoint presentation.

  1. Open the PowerPoint presentation.

  2. Go to the sixth slide Top or bottom of the window frame is reached.

  3. Return to the Simulink model and right-click the endstop block. Select Requirements > Link to Slide in PowerPoint. Requirements Toolbox creates a link to the open slide.

  4. Right-click the endstop block and expand the Requirements submenu. Top or bottom of the window frame is rea... appears as a menu option. When you click this menu option, MATLAB opens the PowerPoint document to the appropriate slide.

Create Bidirectional Links

You can enable Requirements Toolbox to automatically create bidirectional links. When you enable bidirectional links, linking to a requirement in an external application also creates a link from the external application to your model, subsystem, or block.

To create bidirectional links, your custom document interface must use the SelectLinkFcn method to insert the hyperlink. For more information about SelectionLinkFcn, see Define Custom Document Interface.

First, enable bidirectional linking.

  1. In the Apps tab, open Requirements Manager.

  2. In the Requirements pane, in the View drop-down menu, select Links.

  3. Select the Requirements tab.

  4. Click Link Settings > Linking Options to open the Selection Linking tab in the Requirements Setting window.

  5. Select the Modify destination for bidirectional linking checkbox.

  6. Click Close.

Then, add the bidirectional link.

  1. Open the PowerPoint presentation.

  2. Go to the seventh slide Obstacle is present between the window and its frame.

  3. Return to the Simulink model.

  4. Right-click the obstacle block and select Requirements > Link to Slide in PowerPoint. The slide now has a MATLAB link icon in the top-left corner.

  5. Return to the slide and control-click the link icon. The obstacle block is highlighted.

Bidirectional links only appear for links created after you enable the Modify destination for bidirectional linking option. Clearing the Enable external connectivity at MATLAB startup check box may prevent PowerPoint from connecting to MATLAB when you select a link.

Import Requirements

You can use the custom document interface to import requirements from an external application.

  1. In the Requirements pane, in the View drop-down menu, select Requirements.

  2. Open the PowerPoint document.

  3. In the Requirements tab, click Import.

  4. In the Document Type drop-down, select Microsoft PowerPoint.

  5. Click Use Current. The Document location will automatically populate.

  6. Click Import.

  7. In the Requirements tab, in the Requirement Set section, click Requirements Editor to see the imported requirements.

The instructions above may be incompatible with files on Microsoft OneDrive or other network locations. If you receive an error stating that importing the import isn't possible, follow these steps:s

  1. Close powerwindowController.pptx.

  2. Create a local copy of powerwindowController.pptx.

  3. Open the local copy.

  4. Import the requirements again.

customlinktype_reqeditor.png

Remove Custom Document Interface

Use the unregister command to remove custom document interfaces you no longer require. After unregistering, links that use the custom document interface do not work.

rmi unregister rmidemo_pp

See Also

Related Topics