Main Content

slreq.getExternalURL

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

Since R2021a

    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 CruiseRequirementsExample 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");

    Get a navigation URL to the link source.

    navURL1 = slreq.getExternalURL(myLink.source)
    navURL1 = 
    'http://127.0.0.1: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://127.0.0.1:31415/matlab/feval/rmi.navigate?arguments=[%22linktype_rmi_slreq%22,%22crs_req_func_spec.slreqx%22,%229%22,%22%22]'
    

    Open the CruiseRequirementsExample project. Load the crs_req_func_spec requirement set and open it in the Requirements Editor.

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

    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 by 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://127.0.0.1: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(rs2,Type="Justification",ID="#72");
    [navURL2,navLabel2] = slreq.getExternalURL(jt)
    navURL2 = 
    'http://127.0.0.1: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(rs,Type="Reference");
    ref = refs(3);
    [navURL3,navLabel3] = slreq.getExternalURL(ref)
    navURL3 = 
    'http://127.0.0.1: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.

    slreq.clear;

    Open the CruiseRequirementsExample 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://127.0.0.1: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 = 
      State with properties:
    
                         Name: 'first'
                           Id: 28
                         Path: 'crs_plant/shift_logic/gear_state'
                   SSIdNumber: 6
                    Subviewer: [1×1 Stateflow.Chart]
                  Description: ''
                  LabelString: 'first↵'
                  EntryAction: ''
                 DuringAction: ''
                   ExitAction: ''
                     OnAction: {0×1 cell}
                  MooreAction: ''
                     FontSize: 10
                    ArrowSize: 9.2240
                    TestPoint: 0
                        Chart: [1×1 Stateflow.Chart]
              BadIntersection: 0
                     Document: ''
              RequirementInfo: ''
               ExecutionOrder: 0
        ContentPreviewEnabled: 0
                          Tag: []
                   IsSubchart: 0
                    IsGrouped: 0
                        Debug: [1×1 Stateflow.StateDebug]
                 EnumTypeName: 'firstModeType'
                     Position: [50.7030 39.5270 85.3400 36.9140]
                  LoggingInfo: [1×1 Stateflow.SigLoggingInfo]
             LogStateActivity: 0
        ASLEnabledViaAncestor: 0
        IsExplicitlyCommented: 0
        IsImplicitlyCommented: 0
                  CommentText: ''
                Decomposition: 'EXCLUSIVE_OR'
                         Type: 'OR'
                 InlineOption: 'Auto'
                      Machine: [1×1 Stateflow.Machine]
                HasOutputData: 0
         OutputMonitoringMode: 'SelfActivity'
                   OutputData: []
    
    
    [navURL2,navLabel2] = slreq.getExternalURL(firstState)
    navURL2 = 
    'http://127.0.0.1:31415/matlab/feval/rmiobjnavigate?arguments=[%22crs_plant.slx%22,%22:413:6%22]'
    
    navLabel2 = 
    'first'
    

    Open the CruiseRequirementsExample 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://127.0.0.1:31415/matlab/feval/rmitmnavigate?arguments=[%22DriverSwRequest_Tests.mldatx%22,%223b7651c7-826b-431c-928b-f1f80a674351%22]'
    
    navLabel = 
    'Enable button'
    

    Cleanup

    Clear the loaded test files.

    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:

      • Requirements Toolbox 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.

    Version History

    Introduced in R2021a

    See Also

    | (Simulink) | (Simulink) | (Stateflow) | (Simulink Test)