主要内容

本页采用了机器翻译。点击此处可查看最新英文版本。

systemcomposer.updateLinksToReferenceRequirements

将需求链接重定向到模型引用需求

    说明

    systemcomposer.updateLinksToReferenceRequirements(modelName,linkDomain,documentPathOrID) 将外部需求文档导入 Requirements Toolbox™ 作为引用需求,并重定向需求链接指向导入的需求集。

    您可以使用 System Composer™ 中的 systemcomposer.updateLinksToReferenceRequirements 函数,使需求链接指向导入的引用需求,而不是外部文档。

    示例

    示例

    全部折叠

    从文件导入需求链接后,需将链接重定向到模型中的引用需求。在将链接转换为引用需求链接后,这些链接会以 SLREQX 文件的形式包含在模型中,以充分利用 Requirements Toolbox™ 的功能。

    从 Word 文件导入需求链接

    运行代码前,请按照以下步骤准备工作区。

    注意:仅在 Windows® 上支持从导入的文件中导入或链接需求。不支持从存储在 SharePoint® 或 OneDrive 中基于网页的 Microsoft® Office 文件进行操作。请将此文件及其支持文件保存在本地文件夹中,以便继续。

    1.打开 Microsoft Word 文件 Functional_Requirements.docx,其中列出了各项需求。突出显示要链接的需求。例如,突出显示以下几行。

    1.1.2	Flight Computer
    ID: 25
    Description: Aircraft shall provide a flight computer to autonomously
    conduct safe flight operations from launch to recovery
    

    2.打开 reqImportExample.slx 模型。

    model = systemcomposer.openModel("reqImportExample");
    

    3.在模型中,选择要链接需求的组件 FlightComputer。右键点击 FlightComputer 组件,然后选择需求 > 链接到 Word 中的所选内容。保持 Word 文件 Functional_Requirements.docx 打开,以便进行后续操作。

    The Select Link to Selection in Word option is selected in the context menu for the component.

    在模型中整合需求链接之前,这些链接依赖于源文档,即 Word 文件 Functional_Requirements.docx。要查看需求链接,请从 reqImportExample.slx 模型选项板的右下角打开“需求透视”。

    The Requirements Perspective shows a requirement link that references a word document and not a requirement set imported into the model.

    将链接重定向到引用需求

    按照以下步骤重定向需求链接,以便与模型集成并在模型中引用。

    1.导出 reqImportExample.slx 模型并保存到外部文件:exportedModel.xls

    exportedSet = systemcomposer.exportModel("reqImportExample");
    SaveToExcel("exportedModel",exportedSet);
    

    2.使用外部文件 exportedModel.xls 将需求链接导入另一个模型:reqNewExample.slx

    structModel = ImportModelFromExcel("exportedModel.xls","Components","Ports", ...
    "Connections","PortInterfaces","RequirementLinks");
    structModel.readTableFromExcel
    
    systemcomposer.importModel("reqNewExample",structModel.Components, ...
    structModel.Ports,structModel.Connections,structModel.Interfaces,structModel.RequirementLinks);
    

    3.将需求链接整合到新模型 reqNewExample.slx,在模型内重定向引用。

    systemcomposer.updateLinksToReferenceRequirements("reqNewExample",...
    "linktype_rmi_word","Functional_Requirements.docx")
    

    4.将视图设置为需求,从模型调板右下角打开“需求透视”,查看 FlightComputer 组件上的新 Flight Computer 需求。

    The Requirements Perspective shows a referenced requirement saved in a requirement set associated with the model.

    该需求保存在需求集 Functional_Requirements.slreqx 中,并直接用于需求链接。将视图更改为链接以查看需求链接。

    The Requirements Perspective shows a requirement link that is linked to a requirement from a requirement set and a component in the model.

    输入参数

    全部折叠

    模型名称,指定为字符向量或字符串。

    示例: "exMobileRobot"

    数据类型: char | string

    链接域,指定为字符向量或字符串。有关识别链接类型或生成自定义链接类型的更多信息,请参阅 链接类型 (Requirements Toolbox)

    示例: "linktype_rmi_word"

    数据类型: char | string

    完整的文档路径,指定为字符向量或字符串。

    示例: "Functional_Requirements.docx"

    数据类型: char | string

    详细信息

    全部折叠

    版本历史记录

    在 R2020b 中推出