Main Content

slreq.getExternalURL

Get navigation URL for link source or destination, requirement, test or Simulink model element

    Description

    example

    navURL = slreq.getExternalURL(myDesignItem) returns a navigation URL to a link source or destination, requirement, test or Simulink® model element specified by myDesignItem.

    Note

    The MATLAB® embedded web server must run on HTTP port 31415 to create the navigation URLs. If your MATLAB session is not configured for this HTTP port number, an error occurs when you try to create a link. Use connector.port to check the configured port number. If connector.port returns 0, use rmipref('UnsecureHttpRequests',true) to enable the embedded HTTP server. If connector.port returns a number that is not 31415, close all instances of MATLAB and reopen one instance.

    example

    [navURL,navLabel] = slreq.getExternalURL(myDesignItem) also returns an external navigation label, navLabel.

    Examples

    collapse all

    Open the Requirements Definition for a Cruise Control Model project. Load the crs_req requirement set.

    slreqCCProjectStart;
    slreq.load('crs_req');

    Find the crs_req link set. Find the link with description #9: Enable Switch Detection.

    myLinkSet = slreq.find('Type','LinkSet','Name','crs_req');
    myLink = find(myLinkSet,'Description','#9: Enable Switch Detection')
    myLink = 
      Link with properties:
    
               Type: 'Derive'
        Description: '#9: Enable Switch Detection'
           Keywords: {}
          Rationale: ''
          CreatedOn: 20-May-2017 13:14:10
          CreatedBy: 'itoy'
         ModifiedOn: 02-Feb-2018 14:28:04
         ModifiedBy: 'itoy'
           Revision: 4
                SID: 1
           Comments: [0×0 struct]
    
    

    Get a navigation URL to the link source.

    navURL1 = slreq.getExternalURL(myLink.source)
    navURL1 = 
    'http://localhost:31415/matlab/feval/rmi.navigate?arguments=[%22linktype_rmi_slreq%22,%22crs_req.slreqx%22,%2210%22,%22%22]'
    

    Get a navigation URL to the link destination.

    navURL2 = slreq.getExternalURL(myLink.destination)
    navURL2 = 
    'http://localhost:31415/matlab/feval/rmi.navigate?arguments=[%22linktype_rmi_slreq%22,%22crs_req_func_spec.slreqx%22,%229%22,%22%22]'
    

    Cleanup

    Clear the loaded requirement sets and link sets.

    slreq.clear;

    Open the Requirements Definition for a Cruise Control Model project. Load the crs_req_func_spec requirement set and open it in the Requirements Editor.

    slreqCCProjectStart;
    rs = slreq.open('crs_req_func_spec');
    rs2 = slreq.open('crs_req');

    In the Requirements Editor, in the crs_req_func_spec requirement set, select the requirement with ID #1. Get an API object for the requirement using slreq.getCurrentObject. Then get an external navigation URL for the requirement and a label for the URL.

    req = slreq.getCurrentObject;
    [navURL1,navLabel1] = slreq.getExternalURL(req)
    navURL1 = 
    'http://localhost:31415/matlab/feval/rmi.navigate?arguments=[%22linktype_rmi_slreq%22,%22crs_req_func_spec.slreqx%22,%221%22,%22%22]'
    
    navLabel1 = 
    'Driver Switch Request Handling'
    

    Find a justification in the requirement set with ID #72. Get an external URL navigation URL for the justification and a label for the URL.

    jt = find(rs,'Type','Justification','ID','#72');
    [navURL2,navLabel2] = slreq.getExternalURL(jt)
    navURL2 = 
    'http://localhost:31415/matlab/feval/rmi.navigate?arguments=[%22linktype_rmi_slreq%22,%22crs_req_func_spec.slreqx%22,%2272%22,%22%22]'
    
    navLabel2 = 
    'Non-functional requirement'
    

    Find all loaded referenced requirements. Get an external navigation URL for the third referenced requirement and a label for the URL.

    refs = find(rs2,'Type','Reference');
    ref = refs(3);
    [navURL3,navLabel3] = slreq.getExternalURL(ref)
    navURL3 = 
    'http://localhost:31415/matlab/feval/rmi.navigate?arguments=[%22linktype_rmi_slreq%22,%22crs_req.slreqx%22,%223%22,%22%22]'
    
    navLabel3 = 
    'System overview'
    

    Cleanup

    Clear the loaded requirement sets and link sets. Close the Requirements Editor and the current project.

    slreq.clear;
    close(currentProject);

    Open the Requirements Definition for a Cruise Control Model project. Open the crs_plant model.

    slreqCCProjectStart;
    open_system('crs_plant');

    Select the Transmission subsystem and use gcb or gcbh to get a path or handle to the subsystem. Then get an external navigation URL to the subsystem and a label for the URL.

    subsys = gcb
    subsys = 
    'crs_plant/Transmission'
    
    [navURL1,navLabel1] = slreq.getExternalURL(subsys)
    navURL1 = 
    'http://localhost:31415/matlab/feval/rmiobjnavigate?arguments=[%22crs_plant.slx%22,%22:414%22]'
    
    navLabel1 = 
    'Transmission'
    

    Look inside the shift_logic mask by clicking the icon. Select the first Stateflow® state and use sfgco to get a handle to the state. Then get an external navigation URL to the state and a label for the URL.

    firstState = sfgco
    firstState =
    
                         Path: 'crs_plant/shift_logic/gear_state'
                           Id: 462
                      Machine: [1×1 Stateflow.Machine]
                   SSIdNumber: 6
                         Name: 'first'
                  Description: ''
                  LabelString: 'first↵'
                     FontSize: 10
                    ArrowSize: 9.2240
                    TestPoint: 0
                        Chart: [1×1 Stateflow.Chart]
              BadIntersection: 0
                    Subviewer: [1×1 Stateflow.Chart]
                     Document: ''
                          Tag: []
              RequirementInfo: ''
               ExecutionOrder: 0
        ContentPreviewEnabled: 0
                     Position: [1×4 double]
                Decomposition: 'EXCLUSIVE_OR'
                         Type: 'OR'
                   IsSubchart: 0
                    IsGrouped: 0
                        Debug: [1×1 Stateflow.StateDebug]
                 InlineOption: 'Auto'
                  LoggingInfo: [1×1 Stateflow.SigLoggingInfo]
                HasOutputData: 0
                   OutputData: []
         OutputMonitoringMode: 'SelfActivity'
        IsExplicitlyCommented: 0
        IsImplicitlyCommented: 0
                  CommentText: ''
    
    [navURL2,navLabel2] = slreq.getExternalURL(firstState)
    navURL2 = 
    'http://localhost:31415/matlab/feval/rmiobjnavigate?arguments=[%22crs_plant.slx%22,%22:413:6%22]'
    
    navLabel2 = 
    'first'
    

    Cleanup

    Clear the loaded requirement sets and link sets. Close all open models.

    slreq.clear;
    bdclose('all');

    Open the Requirements Definition for a Cruise Control Model project. Load the DriverSwRequest_Tests test file.

    slreqCCProjectStart;
    tf = sltest.testmanager.load('DriverSwRequest_Tests.mldatx');

    Get the test suite in the test file.

    suite = getTestSuites(tf);

    Get the test cases in the test suite. Get an external navigation URL for the first test case and get a label for the navigation URL.

    cases = getTestCases(suite)
    cases=1×8 object
      1×8 TestCase array with properties:
    
        Name
        TestFile
        TestPath
        TestType
        RunOnTarget
        Parent
        Requirements
        Description
        Enabled
        ReasonForDisabling
        Tags
    
    
    case1 = cases(1)
    case1 = 
      TestCase with properties:
    
                Name: 'Enable button'
            TestFile: [1×1 sltest.testmanager.TestFile]
            TestPath: 'DriverSwRequest_Tests > Unit test for DriverSwRequest > Enable button'
            TestType: 'simulation'
         RunOnTarget: {[0]}
              Parent: [1×1 sltest.testmanager.TestSuite]
        Requirements: [1×1 struct]
         Description: ''
             Enabled: 1
                Tags: [0×0 string]
    
    
    [navURL,navLabel] = slreq.getExternalURL(case1)
    navURL = 
    'http://localhost:31415/matlab/feval/rmitmnavigate?arguments=[%22DriverSwRequest_Tests.mldatx%22,%223b7651c7-826b-431c-928b-f1f80a674351%22]'
    
    navLabel = 
    'Enable button'
    

    Cleanup

    Clear the loaded requirement sets and link sets. Clear the loaded test files.

    slreq.clear;
    sltest.testmanager.clear;

    Input Arguments

    collapse all

    Item in MATLAB or Simulink, specified as:

    Output Arguments

    collapse all

    External navigation URL, returned as a character array.

    External navigation URL label, returned as a character array.

    Tips

    • You can copy the external navigation URL to your clipboard for a:

      • Simulink Requirements requirement, referenced requirement, or justification

      • Simulink, Stateflow, or System Composer model element

      • Simulink data dictionary entry

      Right-click one of these items in the Requirements Editor or Simulink Editor and select Copy URL to Clipboard, or select Requirements > Copy URL to Clipboard.

    See Also

    | | | (Stateflow) | (Simulink Test)

    Introduced in R2021a