主要内容

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

rmi

使用 Requirements Toolbox 以编程方式工作

说明

获取链接信息

linkedDest = rmi("get",modelOrBlock) 返回 modelOrBlock 指定的模型或模型元素的传出链接的链接目标。

示例

numLinks = rmi("count",modelOrBlock) 返回来自 modelOrBlock 指定的顶级模型或模型元素的传出链接数。

示例

descriptions = rmi("descriptions",modelOrBlock) 返回 modelOrBlock 指定的模型或模型元素的链接目标的描述。

示例

codeComments = rmi("codeComment",modelOrBlock) 返回与 modelOrBlock 指定的模型或模型元素链接的需求相对应的代码注释。当您从模型生成代码时,Requirements Toolbox™ 会在生成的代码中插入这些注释。有关详细信息,请参阅将需求追溯到从模型生成的代码

示例

linkedDest = rmi("codeReqs",modelOrBlock) 返回 Requirements Toolbox 在生成的代码中包含的链接目标,用于链接到 modelOrBlock 指定的模型或模型元素的需求。如果模型元素是来自 Simulink® 库的模块的引用实例,则链接目标包括来自库模块以及引用模块的链接。如果模型元素不是来自 Simulink 库的模块的引用实例,则该函数的输出与 rmi("get",modelOrBlock) 的输出相同。有关库模块引用实例的更多信息,请参阅 链接模块 (Simulink)

示例

删除链接

rmi("clearAll",modelOrBlock) 打开一个对话框,提示您从顶级模型或模型元素中删除传出链接。

示例

rmi("clearAll",model,"deep") 打开一个对话框,提示您从模型中删除传出链接。

示例

rmi(___,"noPrompt") 删除外部链接而不打开对话框。使用前两种语法之一,后跟参量 noPrompt

示例

处理模型

rmi("highlightModel",model) 突出显示 model 指定的模型中具有传出链接的模型元素。

示例

rmi("unhighlightModel",model) 关闭 model 指定的模型中的突出显示。

示例

[blockHandles,modelIndices,isSf,objSIDs] = rmi("getObjectsInModel",model)model 指定的模型中的每个模型元素返回模块句柄 blockHandles、模型层次结构索引 parentIndices、模型元素是否属于 Stateflow® 图的指示符、isSf,以及模型元素 SID objSIDs

示例

[modelOrBlockName,modelOrBlockType] = rmi("getObjLabel",modelOrBlock) 返回 modelOrBlock 指定的模型或模型元素的名称和类型。

示例

guidChar = rmi("guidGet",modelOrBlock) 返回 modelOrBlock 指定的模型或模型元素的全局唯一标识符。如果 modelOrBlock 没有全局唯一标识符,该函数将创建一个。只有 REQ 文件使用全局唯一标识符。

示例

handle = rmi("guidLookup",model,guid) 返回与 guid 指定的 Simulink 模型中的全局唯一标识符 model 相对应的模型或模型元素的数字句柄。只有 REQ 文件使用全局唯一标识符。

示例

报告可追溯性

rmi("report",artifactToReport)artifactToReport 指定的工件生成 HTML 格式的可追溯性报告。有关可追溯性报告的更多信息,请参阅创建和自定义需求可追溯性报告

示例

rmi projectReport 为当前工程中的文件生成 HTML 格式的可追溯性报告。此报告的顶层页面包含指向每个具有传出链接的工程文件的报告的链接。有关详细信息,请参阅为工程创建需求可追溯性报告

示例

与第三方工具集成

rmi register myCustomDocInterface 注册由注册函数 myCustomDocInterface 指定的自定义文档接口,使您能够创建指向 Requirements Toolbox 未提供内置支持的第三方应用程序中的需求的直接链接。有关详细信息,请参阅定义自定义文档界面以直接链接到需求

示例

rmi unregister myCustomDocInterface 取消注册由注册函数 myCustomDocInterface 指定的自定义文档接口。有关详细信息,请参阅定义自定义文档界面以直接链接到需求

示例

rmi httpLink 激活一个内部 HTTP 服务器,您可以使用它从使用 HTTP 协议的基于浏览器的第三方需求工具中的反向链接导航到 MATLAB® 或 Simulink 中的链接项。HTTPS 服务器上的反向链接导航默认处于启用状态。

注意

或者,您可以使用 rmipref 功能并将 UnsecureHttpRequests 首选项设置为 true 来激活内部 HTTP 服务器。当 UnsecureHttpRequests 预设项为 true 时,MATLAB 在启动时激活内部 HTTP 服务器。

示例

connectorStatus = rmi("httpLink","status") 返回内部 HTTP 服务器的端口号。如果端口号是 0,则服务器未处于活动。

示例

rmi setup 在命令行提示您配置 Requirements Toolbox 以便与 Microsoft® Office 和 IBM® DOORS® 进行交互。有关详细信息,请参阅配置 Requirements Toolbox 以便与 Microsoft Office 和 IBM DOORS 交互

示例

rmi setup doors 在命令行提示您配置 Requirements Toolbox 以便与 IBM DOORS 交互。有关详细信息,请参阅配置 Requirements Toolbox 以便与 Microsoft Office 和 IBM DOORS 交互

示例

rmi("doorsSync",model) 打开 model 指定的 IBM 模型的 DOORS Simulink 同步设置对话框。有关 IBM DOORS 同步的更多信息,请参阅 使用替代模块同步 IBM DOORS 中的需求可追溯性

示例

currentSettings = rmi("doorsSync",model,"settings") 返回 model 指定的 IBM 模型的当前 DOORS Simulink 同步设置。要更改设置,请使用 IBM DOORS 同步设置对话框进行更改,然后点击保存设置

提示

要返回默认设置,请将 model 指定为 []

示例

rmi("doorsSync",model,syncSettings) 使用 syncSettings 指定的同步设置从 model 指定的 IBM 模型创建 DOORS Simulink 代理模块。如果 IBM DOORS 代理模块已经存在,此函数将重新同步模型和模块并更新代理模块。有关 IBM DOORS 同步的更多信息,请参阅 使用替代模块同步 IBM DOORS 中的需求可追溯性

示例

numScreenshots = rmi("surrogateUpdateScreenshots",model) 将屏幕截图添加到与代理模块中的对象对应的每个模型元素的代理模块中,并返回添加的屏幕截图的数量。如果代理模块已经有截图,该函数会更新截图。

示例

currentTemplate = rmi("getDoorsLabelTemplate") 返回 IBM DOORS 中需求链接标签的当前模板。

示例

tf = rmi("setDoorsLabelTemplate",customTemplate) 将当前 IBM DOORS 模板的链接标签设置为需求为 customTemplate 指定的格式并返回成功状态。默认标签模板包含 DOORS 需求链接目标的章节编号和对象标题。

提示

要将链接标签模板恢复为默认模板,请在 MATLAB 命令提示符下输入此代码:

tf = rmi("setDoorsLabelTemplate","")

示例

label = rmi("doorsLabel",moduleID,doorsReqID) 返回 Requirements Toolbox 在 doorsReqID 指定的模块中创建指向 moduleID 指定的 IBM DOORS 需求的链接时使用的链接标签。

示例

numUpdatedLinkLabels = rmi("updateDoorsLabels",model)model 指定的模型更新 IBM DOORS 中需求的传出链接的链接标签,并输出更新的链接标签数量。该函数使用当前链接标签模板 currentTemplate

示例

检查链接的有效性和一致性

validationProblems = rmi("checkDoc") 检查 Microsoft WordMicrosoft Excel® 或 IBM DOORS 中需求链接的有效性。该函数在命令行上提示您输入文档类型、文档名称,返回检测到的问题数量,并打开包含有关链接有效性信息的报告。有关详细信息,请参阅验证需求文档中的需求链接

示例

validationProblems = rmi("checkDoc",docName) 检查 docName 指定文档中需求链接的有效性,返回检测到的链接验证问题的数量,并为文档打开链接验证报告。有关详细信息,请参阅验证需求文档中的需求链接

示例

consistencyProblems = rmi("check",artifactToCheck) 检查 artifactToCheck 指定的工件的链接一致性,并为该文件打开链接一致性报告。有关详细信息,请参阅检查直接链接的有效性

示例

示例

全部折叠

打开 CruiseRequirementsExample 工程。加载 crs_controller 模型。

openProject("CruiseRequirementsExample");
model = "crs_controller";
load_system(model);

获取 OpMode 子系统的 CruiseControlMode 子系统中 Switch 模块的链接目标。

modelElement = model+"/CruiseControlMode/opMode/Switch";
linkedDest = rmi("get",modelElement)
linkedDest = struct with fields:
            doc: 'crs_req_func_spec.slreqx'
             id: '25'
         linked: 1
    description: '#25: Precedence of mode determination'
       keywords: ''
         reqsys: 'linktype_rmi_slreq'

打开 CruiseRequirementsExample 工程并加载 crs_controller 模型。

openProject("CruiseRequirementsExample");
model = "crs_controller";
load_system(model)

获取具有传出链接的模型元素的模块句柄和 Stateflow® ID。

[blockHandles,sfIDs] = rmi("getHandlesWithRequirements",model);

创建一个名为 modelElement 的变量,并将第一个模块句柄分配为该值。

modelElement = blockHandles(1);

从模型元素中获取链接数。

numLinks = rmi("count",modelElement)
numLinks = 
1

获取链接的链接描述。

desc = rmi("descriptions",modelElement)
desc = 1×1 cell array
    {'#19: Cruise Control Mode'}

获取与链接需求对应的代码注释。

codeComment = rmi("codeComment",modelElement)
codeComment = 
    '*  1. Cruise Control Mode
     *  2. [crs_controllerdic.sldd:brake_threshold] Threshold value for brake pressure
     *  3. [crs_controllerdic.sldd:tsp_max] Maximum Target Speed
     *  4. [crs_controllerdic.sldd:tsp_min] Minimum Target Speed'

从模型元素中获取 Requirements Toolbox™ 在模型生成的代码中包含的链接的链接目标。

linkedDest = rmi("codeReqs",modelElement)
linkedDest=4×1 struct array with fields:
    doc
    id
    linked
    description
    keywords
    reqsys

打开 CruiseRequirementsExample 工程并加载 crs_controllercrs_plant 模型。

openProject("CruiseRequirementsExample");
model1 = "crs_controller";
load_system(model1);
model2 = "crs_plant";
load_system(model2);

从模型元素中删除链接

获取 crs_controller 模型中具有出站链接的模型元素。

[blockHandles,sfIDs] = rmi("getHandlesWithRequirements",model1);

检查第一个模型元素的链接。

modelElement = blockHandles(1);
linkedDest = rmi("get",modelElement)
linkedDest = struct with fields:
            doc: 'crs_req_func_spec.slreqx'
             id: '19'
         linked: 1
    description: '#19: Cruise Control Mode'
       keywords: ''
         reqsys: 'linktype_rmi_slreq'

按照提示从第一个模型元素中删除链接。

rmi("clearAll",modelElement)

确认您已删除该链接。

linkedDest = rmi("get",modelElement)
linkedDest =

     []

检查第二个模型元素的链接。

modelElement = blockHandles(2);
linkedDest = rmi("get",modelElement)
linkedDest = struct with fields:
            doc: 'crs_req_func_spec.slreqx'
             id: '36'
         linked: 1
    description: '#36: Disabling override'
       keywords: ''
         reqsys: 'linktype_rmi_slreq'

删除第二个模型元素的链接而不打开对话框。

rmi("clearAll",modelElement,"noprompt")

确认您已删除该链接。

linkedDest = rmi("get",modelElement)
linkedDest =

     []

从模型中删除链接

获取 crs_controller 模型中具有出站链接的模型元素。

[blockHandles,~] = rmi("getHandlesWithRequirements",model1)
blockHandles = 62×1
103 ×

    0.3360
    0.3470
    0.3630
    0.3790
    0.3840
    0.3890
    0.4360
    0.4830
    0.4880
    0.4930
      ⋮

按照提示从 crs_controller 模型中删除出站链接。

rmi("clearAll",model1,"deep")

确认您已删除链接。

[blockHandles,~] = rmi("getHandlesWithRequirements",model1)
blockHandles =

  0×1 empty double column vector

获取 crs_plant 模型中具有出站链接的模型元素。

[blockHandles,~] = rmi("getHandlesWithRequirements",model2)
blockHandles = 5×1
103 ×

    2.1400
    2.1420
    2.1440
    2.1460
    2.4080

按照提示从 crs_controller 模型中删除出站链接。

rmi("clearAll",model2,"deep","noprompt")

确认您已删除链接。

[blockHandles,~] = rmi("getHandlesWithRequirements",model2)
blockHandles =

  0×1 empty double column vector

打开 CruiseRequirementsExample 工程并加载 crs_controller 模型。

openProject("CruiseRequirementsExample");
model = "crs_controller";
load_system(model);

突出显示具有传出链接的模型元素并打开模型。

rmi("highlightModel",model)
open_system(model);

关闭模型中的突出显示。

rmi("unhighlightModel",model)

打开 CruiseRequirementsExample 工程。加载 crs_controller 模型。

openProject("CruiseRequirementsExample");
model = "crs_controller";
load_system(model);

获取 enbl 输入端口的全局唯一标识符。

modelElement = model+"/enbl";
guID = rmi("guIDGet",modelElement)
guID = 
'GIDa_69736d09_e527_45f7_b302_c9b5b8678aff'

从模型元素的全局唯一标识符获取数字模块句柄。

handle = rmi("guidlookup",model,guID)
handle = 
155.0002

打开 CruiseRequirementsExample 工程。加载 crs_controller 模型。

openProject("CruiseRequirementsExample");
model = "crs_controller";
load_system(model);

获取 crs_controller 模型中的对象。

[blockHandles,modelIndices,isSf,objSIDs] = rmi( ...
    "getObjectsInModel",model);

获取第 13 个模型元素的模块名称和模块类型。

modelElement = blockHandles(13);
[blockName,blockType] = rmi("getObjLabel",modelElement)
blockName = 
'CruiseControlMode'
blockType = 
'SubSystem'

打开 CruiseRequirementsExample 工程。加载 crs_controller 模型。

openProject("CruiseRequirementsExample");
model = "crs_controller";
load_system(model);

crs_controller 模型生成可追溯性报告。

rmi("report",model)
    Beginning report
    Looping on model "crs_controller"
    Looping on system "CruiseControlMode"
    Looping on system "DriverSwRequest"
    Looping on system "TargetSpeedThrottle"
    Looping on system "disableCaseDetection"
    Looping on system "opMode"
    Looping on system "outOfRange"
    Looping on system "decrement"
    Looping on system "doNot Repeat"
    Looping on system "increment"
    Looping on system "activated"
    Looping on system "disabled"
    Looping on system "enabled"
    Looping on system "targetSpeed"
    Looping on system "IsKeyPositionOn"
    Looping on system "IsShiftDrive"
    Looping on system "isbrake"
    Looping on system "IncrementDecrement"
    Looping on system "activateCondition"
    Looping on system "disableCondition"
    Looping on system "enableCondition"
    Looping on system "resumeCondition"
    Looping on system "counter"
    Looping on system "getNewTargetSpeed"
    Looping on system "getThrottleValue"
    Looping on system "PI controller"
  "chapter" contains no content and will not be inserted into document
    Converting report
    Report complete

生成工程的可追溯性报告。

rmi projectReport
    Beginning report
    Converting report
    Report complete
C:\Users\jdoe\CruiseRequirementsExample\data\crs_controllerdic.sldd done.
    Beginning report
    Looping on model "crs_controller"
    Looping on system "CruiseControlMode"
CPPMICROSERVICE WARNING: Empty mw.installpath for bundle: com_mathworks_dastudio_test_blocks
    Looping on system "DriverSwRequest"
    Looping on system "TargetSpeedThrottle"
    Looping on system "disableCaseDetection"
    Looping on system "opMode"
    Looping on system "outOfRange"
    Looping on system "decrement"
    Looping on system "doNot Repeat"
    Looping on system "increment"
    Looping on system "activated"
    Looping on system "disabled"
    Looping on system "enabled"
    Looping on system "targetSpeed"
    Looping on system "IsKeyPositionOn"
    Looping on system "IsShiftDrive"
    Looping on system "isbrake"
    Looping on system "IncrementDecrement"
    Looping on system "activateCondition"
    Looping on system "disableCondition"
    Looping on system "enableCondition"
    Looping on system "resumeCondition"
    Looping on system "counter"
    Looping on system "getNewTargetSpeed"
    Looping on system "getThrottleValue"
    Looping on system "PI controller"
  "chapter" contains no content and will not be inserted into document
    Converting report
    Report complete
C:\Users\jdoe\CruiseRequirementsExample\models\crs_controller.slx done.
    Beginning report
    Looping on model "crs_plant"
    Looping on system "crs_plant"
    Looping on system "Vehicle1"
    Looping on chart "shift_logic"
    Looping on and state "gear_state"
    Looping on and state "selection_state"
    Looping on or state "fourth"
    Looping on or state "third"
    Looping on or state "second"
    Looping on or state "first"
    Looping on or state "steady_state"
    Looping on or state "upshifting"
    Looping on or state "downshifting"
  "chapter" contains no content and will not be inserted into document
    Converting report
    Report complete
C:\Users\jdoe\CruiseRequirementsExample\models\crs_plant.slx done.
    Beginning report
    Running FOR loop, RPTGEN_LOOP = 1
    Converting report
    Report complete
C:\Users\jdoe\CruiseRequirementsExample\tests\DriverSwRequest_Tests.mldatx done.
    Beginning report
  "chapter" contains no content and will not be inserted into document
    Converting report
    Report complete

注册一个自定义文档界面,能够直接链接到 Microsoft® PowerPoint® 演示文稿中的需求。

rmi register customPowerPointInterface

取消注册接口。

rmi unregister customPowerPointInterface

获取内部 HTTP 服务器状态。

status = rmi("httpLink","status")
status = struct with fields:
     httpPort: 0
    httpsPort: 31515

激活内部 HTTP 服务器。

rmi httpLink

获取内部 HTTP 服务器状态。

status = rmi("httpLink","status")
status = struct with fields:
     httpPort: 31415
    httpsPort: 31515

配置 Requirements Toolbox 以便与 Microsoft Office 和 IBM DOORS 进行交互。

rmi setup
Ensuring required Active-X controls ..
Verifying MATLAB automation server path ..

Register this MATLAB installation as ActiveX Automation Server? (Y/N):_y
Registering this MATLAB executable as an automation server ..
 
Welcome to the DOORS-MATLAB Interface setup utility.
This will perform all the steps necessary so that you
can start using Simulink and Stateflow with IBM DOORS.
 
NOTE: You should close IBM DOORS before continuing with
this installation.
 
Checking Windows Registry to locate IBM DOORS installation(s)...
 
Please select IBM DOORS installation to configure for MATLAB:
    [1]  9.6  C:\Program Files\IBM\Rational\DOORS\9.6\
 
If your target IBM DOORS Client installation is not listed above,
select one of the following options:
    [2]  Manually enter IBM DOORS installation directory
    [3]  Exit, making no changes
    [4]  Make no changes in IBM DOORS directory but ensure IBM DOORS integration is enabled in MATLAB
 
Selection: 1
 
C:\Program Files\IBM\Rational\DOORS\9.6\lib\dxl\addins\dmi\dmi.inc is up to date.

通过执行以下代码配置 Requirements Toolbox™ 以与 IBM DOORS 交互:

rmi setup doors

开放 DOORS 工程

在此示例中,您使用 IBM DOORS 中的 faultTolerantControlSystem.dpa 文件,其中包含描述容错控制系统的需求模块。

在 IBM DOORS 中,创建一个新工程:

  1. 选择文件 > 新建 > 工程

  2. 在新建工程对话框中,将名称设置为 faultTolerantControlSystem

  3. 描述字段中,输入 Fault-tolerant control system project

  4. 选择使用工程存档

  5. 点击浏览并选择 faultTolerantControlSystem.dpa

  6. 点击确定创建工程。

The New Project dialog box in DOORS. The Use a project archive button is selected and the file path specifies the faultTolerantControlSystem.dpa archive file.

获取同步设置

打开 faultTolerantControlSystem 模型。

model = "faultTolerantControlSystem";

获取模型的当前同步设置。

currentSettings = rmi("doorsSync",model,"settings")
currentSettings = struct with fields:
    surrogatePath: '/faultTolerantControlSystem/faultTolerantControlSystem'
      detailLevel: 4
        doorsToSl: 0
        slToDoors: 1
    purgeSimulink: 0
       purgeDoors: 1
        saveModel: 1
    saveSurrogate: 1

detailLevel 字段的值设置为 4

currentSettings.detailLevel = 4;

创建代理模块

创建代理模块。

rmi("doorsSync",model,currentSettings)
Verifying MATLAB automation server path ..
Registering this MATLAB executable as an automation server ..

将屏幕截图添加到模型中。

numScreenshots = rmi("surrogateUpdateScreenshots",model)
    Beginning report
    Looping on system "faultTolerantControlSystem"
    Looping on system "engine gas dynamics"
    Looping on system "Mixing & Combustion"
    Looping on system "system lag"
    Looping on system "Throttle & Manifold"
    Looping on system "Intake Manifold"
    Looping on system "Throttle"
    Looping on system "fuel rate controller"
    Looping on system "Airflow calculation"
    Looping on system "Fuel  Calculation"
    Looping on system "Switchable Compensation"
    Looping on system "LOW Mode"
    Looping on system "RICH Mode"
    Looping on system "Sensor correction and Fault Redundancy"
    Looping on system "MAP Estimate"
    Looping on system "Speed Estimate"
    Looping on system "Throttle Estimate"
    Looping on chart "control logic"
    Converting report
    Report complete
Using ./snapshots_html_files/image-001-sl.png for faultTolerantControlSystem

Missing screenshot for faultTolerantControlSystem/Test inputs

Using ./snapshots_html_files/image-003-sl.png for faultTolerantControlSystem/engine
gas
dynamics

Using ./snapshots_html_files/image-005-sl.png for faultTolerantControlSystem/engine
gas
dynamics/Mixing & Combustion

Using ./snapshots_html_files/image-007-sl.png for faultTolerantControlSystem/engine
gas
dynamics/Mixing & Combustion/system lag

Using ./snapshots_html_files/image-009-sl.png for faultTolerantControlSystem/engine
gas
dynamics/Throttle & Manifold

Using ./snapshots_html_files/image-011-sl.png for faultTolerantControlSystem/engine
gas
dynamics/Throttle & Manifold/Intake Manifold

Using ./snapshots_html_files/image-013-sl.png for faultTolerantControlSystem/engine
gas
dynamics/Throttle & Manifold/Throttle

Using ./snapshots_html_files/image-015-sl.png for faultTolerantControlSystem/fuel rate
controller

Using ./snapshots_html_files/image-017-sl.png for faultTolerantControlSystem/fuel rate
controller/Airflow calculation

Using ./snapshots_html_files/image-019-sl.png for faultTolerantControlSystem/fuel rate
controller/Fuel  Calculation

Using ./snapshots_html_files/image-021-sl.png for faultTolerantControlSystem/fuel rate
controller/Fuel  Calculation/Switchable
Compensation

Using ./snapshots_html_files/image-023-sl.png for faultTolerantControlSystem/fuel rate
controller/Fuel  Calculation/Switchable
Compensation/LOW Mode

Using ./snapshots_html_files/image-025-sl.png for faultTolerantControlSystem/fuel rate
controller/Fuel  Calculation/Switchable
Compensation/RICH Mode

Using ./snapshots_html_files/image-027-sl.png for faultTolerantControlSystem/fuel rate
controller/Sensor correction and
Fault Redundancy

Using ./snapshots_html_files/image-029-sl.png for faultTolerantControlSystem/fuel rate
controller/Sensor correction and
Fault Redundancy/MAP Estimate

Using ./snapshots_html_files/image-031-sl.png for faultTolerantControlSystem/fuel rate
controller/Sensor correction and
Fault Redundancy/Speed Estimate

Using ./snapshots_html_files/image-033-sl.png for faultTolerantControlSystem/fuel rate
controller/Sensor correction and
Fault Redundancy/Throttle Estimate

Using ./snapshots_html_files/image-035-sf.png for faultTolerantControlSystem/fuel rate
controller/control logic

Processed 19 subsystems, 0 items added in module 0000010e
numScreenshots = 19

加载 faultTolerantControlSystem 模型。

model = "faultTolerantControlSystem";
load_system(model)

打开模型的 IBM DOORS 同步设置对话框。

rmi("doorsSync",model)

通过执行以下代码配置 Requirements Toolbox™ 以与 IBM® DOORS® 交互:

rmi setup doors

加载 slvnvdemo_fuelsys_doorsreq 模型。获取模型的链接集的句柄。

model = "slvnvdemo_fuelsys_doorsreq";
load_system(model);
myLinkSet = slreq.load(model);

开放 DOORS 工程

在此示例中,您使用 IBM DOORS 中的 faultTolerantControlSystem.dpa 文件,其中包含描述容错控制系统的需求模块。

在 IBM DOORS 中,创建一个新工程:

  1. 选择文件 > 新建 > 工程

  2. 在新建工程对话框中,将名称设置为 faultTolerantControlSystem

  3. 描述字段中,输入 Fault-tolerant control system project

  4. 选择使用工程存档

  5. 点击浏览并选择 faultTolerantControlSystem.dpa

  6. 点击确定创建工程。

The New Project dialog in DOORS. The Use a project archive button is selected and the file path specifies the faultTolerantControlSystem.dpa archive file.

重定向 DOORS 工程的链接

将链接重定向至新工程中的 IBM DOORS 模块 ID。

在 IBM DOORS 中,打开 faultTolerantControlSystem 工程。

The DOORS Database window shows the faultTolerantControlSystem project.

打开 faultTolerantControlSystem 模块并选择一个需求。获取需求的模块 ID。更新链接目标以指向新工程中的 faultTolerantControlSystem 模块。

newModuleID = rmidoors.getCurrentObj;
oldModuleID = "00000160";
count = updateDocUri(myLinkSet,oldModuleID,newModuleID)
count = 235

打开 FuelSys Design Description 模块并选择一个需求。获取需求的模块 ID。更新链接目标以指向新工程中的 FuelSys Design Description 模块。

newModuleID = rmidoors.getCurrentObj;
oldModuleID = "00000161";
count = updateDocUri(myLinkSet,oldModuleID,newModuleID)
count = 6

打开 FuelSys Requirements Specification 模块并选择一个需求。获取需求的模块 ID。更新链接目标以指向新工程中的 FuelSys Requirements Specification 模块。

newModuleID = rmidoors.getCurrentObj;
oldModuleID = "00000141";
count = updateDocUri(myLinkSet,oldModuleID,newModuleID)
count = 1

获取并设置链接标签模板

获取 IBM DOORS 中需求链接的当前标签模板。

currentTemplate = rmi("getDoorsLabelTemplate")
currentTemplate = 
'%M:%h'

设置模板显示模块名称和对象标题,以冒号分隔。

customTemplate = "%M:%h";
tf = rmi("setDoorsLabelTemplate",customTemplate)
tf = logical
   0

确认您已更新链接标签模板。

currentTemplate = rmi("getDoorsLabelTemplate")
currentTemplate = 
'%M:%h'

更新链接标签

根据当前模板获取 27 模块中需求编号 FuelSys Requirements Specification 的链接标签。

doorsReqID = "27";
newModuleID = "00000101";
label = rmi("doorsLabel",newModuleID,doorsReqID)
label = 
'FuelSys Requirements Specification:Normal Mode of Operation'

加载 slvnvdemo_fuelsys_doorsreq 模型,然后更新从模型到 IBM DOORS 中的需求的传出链接的链接标签。

model = "slvnvdemo_fuelsys_doorsreq";
load_system(model);
numUpdatedLinks = rmi("updateDoorsLabels",model)
slvnvdemo_fuelsys_doorsreq/fuel rate controller/throttle  (Inport):
    changing "1.1.1.1  Throttle Sensor" to "FuelSys Design Description:Throttle Sensor"

slvnvdemo_fuelsys_doorsreq/fuel rate controller/MAP  (Inport):
    changing "1.1.1.2  Manifold Absolute Pressure Sensor " to "FuelSys Design Description:Manifold Absolute Pressure Sensor"

slvnvdemo_fuelsys_doorsreq/fuel rate controller/Airflow calculation  (SubSystem):
    changing "1.2.1  Mass airflow estimation " to "FuelSys Design Description:Mass airflow estimation"

slvnvdemo_fuelsys_doorsreq/.../Sensor correction and Fault Redundancy/MAP Estimate  (SubSystem):
    changing "1.3.1.3  Manifold pressure failure mode " to "FuelSys Design Description:Manifold pressure failure mode"

slvnvdemo_fuelsys_doorsreq/.../Sensor correction and Fault Redundancy/Speed Estimate  (SubSystem):
    changing "2.2.6 	Speed Sensor Failure" to "FuelSys Requirements Specification:Speed Sensor Failure"

slvnvdemo_fuelsys_doorsreq/.../control logic/Rich_Mixture (State):
    changing "1.3.1.2  Enriched mixture usage " to "FuelSys Design Description:Enriched mixture usage"

slvnvdemo_fuelsys_doorsreq/.../control logic/[speed==0 & press < zero_thresh]/ Fail.INC (Transition):
    changing "1.3.1.4  Speed sensor failure detection " to "FuelSys Design Description:Speed sensor failure detection"
numUpdatedLinks = 7

此示例显示如何以交互方式检查链接的有效性。

注意

您只能在 Windows® 平台上运行此示例。

打开从 Simulink 模块链接并导航到 Excel 中的需求示例。

openExample(['slrequirements/' ...
    'LinkRequirementsInExcelToSimulinkBlocksExample'])

打开 slvnvdemo_FuelSys_TestScenarios Microsoft Excel 文档。

doc = which("slvnvdemo_FuelSys_TestScenarios.xlsx");
winopen(doc);

检查文档链接的有效性。按照命令行窗口中的提示进行操作。

validationProblems = rmi("checkDoc")
Please choose target document type:
1 - Microsoft Word document
2 - Microsoft Excel document
3 - DOORS module
[1,2,3]? 2
Microsoft Excel document to check: (current)
Checking 'C:/Users/jdoe/MATLAB/slrequirements-ex78700367/slvnvdemo_FuelSys_TestScenarios.xlsx' (Y/n) ? y
Reading "C:/Users/jdoe/MATLAB/slrequirements-ex78700367/slvnvdemo_FuelSys_TestScenarios.xlsx" ...
found 2 links

validationProblems =

     1

打开 slvnvdemo_FuelSys_TestScenarios Microsoft® Excel® 文档。

doc = which("slvnvdemo_FuelSys_TestScenarios.xlsx");
winopen(doc);

检查链接的有效性。

validationProblems = rmi("checkDoc",doc)
Reading "C:/Users/jdoe/MATLAB/slrequirements-ex78700367/slvnvdemo_FuelSys_TestScenarios.xlsx" ...
found 2 links
validationProblems = 1

打开 ShortestPath 示例。

openProject("ShortestPath");

检查来自 shortest_path MATLAB® 代码文件的链接是否一致。

artifactToCheck = "shortest_path.m";
consistencyProblems = rmi("check",artifactToCheck)
consistencyProblems = 4×1

     0
     0
    11
     0

输入参数

全部折叠

要检查链接一致性的工件,指定为包含工件文件名的字符串标量或字符向量。该工件可以是 Simulink 数据字典文件或 MATLAB 代码文件。

示例: "shortest_path.m"

要生成可追溯性报告的工件,指定为包含工件文件名的字符串标量或字符向量。该工件可以是 MATLAB 代码文件、Simulink 模型、Simulink 数据字典文件或 Simulink Test™ 测试文件。如果您指定 Simulink 模型,请不要包含 SLX 扩展。

示例: "crs_controller"

示例: "shortest_path.m"

用于链接到 IBM DOORS 需求的标签模板,指定为字符串标量或字符向量。

使用这些格式说明符来定义链接标签模板:

模板格式说明符

信息来自 IBM DOORS

%h对象标题
%t对象文本
%p模块前缀
%n对象绝对数
%m模块 ID
%P工程名称
%M模块名称
%UDOORS URL
%<ATTRIBUTE_NAME>您指定的其他 DOORS 属性

示例: "%h:%t"

第三方需求文档名称,指定为字符串标量或字符向量,定义 Microsoft WordMicrosoft Excel 文档的名称或 IBM DOORS 模块 ID。

IBM DOORS 需求 ID,指定为字符串标量或字符向量。

示例: "27"

模型或模型元素的全局唯一标识符,指定为字符串标量或字符向量。只有 REQ 文件使用全局唯一标识符。

示例: "GIDa_56a78985_b045_4313_a3f6_10be3c4f06df"

数据类型: char

Simulink 模型名称,指定为定义模型名称的字符串标量或字符向量,或定义模型句柄的 double。如果指定模型名称,请不要包含 SLX 文件扩展名。

示例: "crs_controller"

IBM DOORS 模块 ID,指定为字符串标量或字符向量。

示例: "00000081"

Simulink 或 Stateflow 模型或模型元素,指定为定义模型名称或模块路径的字符串标量或字符向量,或定义模型或模块句柄的 double

示例: "crs_controller/enbl"

示例: 164.0762

数据类型: double | char | string

自定义文档接口用于直接链接到 Requirements Toolbox 未提供内置支持的第三方应用程序中的需求,指定为定义自定义文档接口的函数名称。有关详细信息,请参阅定义自定义文档界面以直接链接到需求

示例: rmi register customInterface

IBM DOORS 同步设置,指定为具有以下字段的结构体:

  • surrogatePath - DOORS 工程中代理模块的路径,指定为字符向量。

  • detailLevel - 指定在代理模块中包含哪些 Simulink 模型元素的设置,指定为 double

  • doorsToSl - 设置将不匹配的链接从 IBM DOORS 代理模块复制到 Simulink 模型,指定为 double

  • slToDoors - 设置将不匹配的链接从 Simulink 模型复制到 IBM DOORS 代理模块,指定为 double

  • purgeSimulink - 设置删除 Simulink 模型中不匹配的链接,指定为 double

  • purgeDoors - 设置删除 IBM DOORS 代理模块中不匹配的链接,指定为 double

  • saveModel - 设置在同步后保存 Simulink 模型,指定为 double

  • saveSurrogate - 设置在同步后保存 IBM DOORS 代理模块,指定为 double

您可以通过执行此代码返回当前同步设置:

syncSettings = rmi("doorsSync",model,"settings")

输出参量

全部折叠

模块的数字句柄,以 double 数组形式返回。

来自模型或模型元素的链接需求的代码注释,以字符向量的形式返回。

来自工件的链接的一致性问题的数量,以 double 数组的形式返回。双精度数组中的行包含链接的数量:

  1. 缺少目标工件

  2. 缺少目标

  3. 其描述与链接需求的文本不匹配

  4. 使用与用户路径偏好不一致的路径类型

当前 IBM DOORS 同步设置,以包含以下字段的结构体返回:

  • surrogatePath - DOORS 工程中代理模块的路径,以字符向量形式返回。

  • detailLevel - 指定在代理模块中包含哪些 Simulink 模型元素的设置,以 double 的形式返回。

  • doorsToSl - 设置将不匹配的链接从 IBM DOORS 代理模块复制到 Simulink 模型,以 double 的形式返回。

  • slToDoors - 设置将不匹配的链接从 Simulink 模型复制到 IBM DOORS 代理模块,以 double 的形式返回。

  • purgeSimulink - 设置删除 Simulink 模型中不匹配的链接,以 double 的形式返回。

  • purgeDoors - 设置删除 IBM DOORS 代理模块中不匹配的链接,以 double 的形式返回。

  • saveModel - 设置在同步后保存 Simulink 模型,以 double 形式返回。

  • saveSurrogate - 设置在同步后保存 IBM DOORS 代理模块,以 double 形式返回。

当前指向 IBM DOORS 中需求的链接标签模板,以字符向量形式返回。

示例: '%h'

链接目标描述,以字符向量元胞数组数组形式返回。

示例: {'#68: Maximum Target Speed'}

模型或模型元素的全局唯一标识符,以字符向量形式返回。只有 REQ 文件使用全局唯一标识符。

示例: 'GIDa_56a78985_b045_4313_a3f6_10be3c4f06df'

模块或模型的数字句柄,以 double 形式返回。

模型元素是否属于 Stateflow 图,以 logical 数组形式返回。

IBM DOORS 中需求链接的标签,以字符向量形式返回。该标签对应于链接目标结构体的 description 字段。

模型或模块链接到的目标,以包含以下字段的结构体或结构体数组的形式返回:

  • doc - 包含链接目标的文档的路径,以字符向量形式返回。

  • id - 链接目标的 ID,以字符向量形式返回。当链接目标是外部文档中的需求时,包含特殊字符与文本或数字组合的字符向量可以识别该需求:

    第一个字符标识符描述示例

    ?

    通过指定搜索文本来识别需求。文档中文本的第一个实例标识了需求。

    '?Requirement 1'

    @

    通过指定命名项(例如 Microsoft Word 中的书签)来识别需求。

    '@my_req'

    #

    通过指定页码或项编号来识别需求。

    '#21'

    >

    通过指定项编号或行号来识别需求。

    '>3156'

    $

    通过在 Microsoft Excel 电子表格中指定单元格地址来识别需求。

    '$A2:C5'

  • linked - 指示链接是否包含在可追溯性报告中,以 logical 形式返回。当 linked1 时,该链接包含在可追溯性报告中。

  • description - 链接描述,以字符数组形式返回。

  • keywords - 链接关键字,以字符数组形式返回。

  • reqsys - 文档接口名称,以字符数组形式返回。文档接口名称与包含链接目标的工件类型相对应。

模型层次结构索引,以 double 数组形式返回。

Simulink 或 Stateflow 模型或模型元素名称,以字符向量形式返回。

示例: 'enbl'

Simulink 或 Stateflow 模型或模型元素类型,以字符向量形式返回。

示例: 'Inport'

模型元素的传出链接数,以 double 形式返回。

在代理模块中添加或更新的屏幕截图数量,以 double 的形式返回。

Simulink 标识符,以元胞数组形式返回。

内部 HTTP 和 HTTPS 服务器状态,以包含以下字段的结构体返回:

  • httpPort - HTTP 端口号,以 double 形式返回。如果 HTTP 端口号是 0,则表示服务未处于活动。

  • httpsPort - HTTPS 端口号,以 double 形式返回。

外部文档链接的验证问题数量,以 double 形式返回。

备选方法

  • getSimulinkBlockHandle (Simulink) 函数返回模块的数字句柄,并且不需要此语法所需的全局唯一标识符:

    handle = rmi("guidLookup",model,guid)

  • 要生成需求集的报告,您可以使用 slreq.generateReport 函数。有关详细信息,请参阅报告需求信息。该报告是 rmi("report",artifactToReport)rmi projectReport 生成的可追溯性报告的替代方案。

版本历史记录

在 R2006b 中推出

全部展开