课程章节
培训 · 课程 9. SysML v2 基础 · 第 9.6 章,共 8 章
9.6 验证和可追溯性 3:32
编写验证用例,查看 RVTM,在矩阵中追溯一个步骤,并派生一条需求。
演示 Holarch 2.22。
您将学到
- 编写带目标和 verdict 的验证定义,并将其应用于一个主题
- 在“验证用例”页面上记录步骤和结果
- 在 RVTM 中查看需求的验证用例和状态
- 在可追溯性矩阵中将需求追溯到动作
- 使用 Derivation 连接从一条需求派生另一条需求
在 Holarch 中验证和追溯 SysML v2 需求,基于一个小型 Hybrid Car 项目,依照 SysML v2 教程“验证和可追溯性”:目标验证某条需求的验证定义、应用于轿车的验证用法、“验证用例”页面和 RVTM、在可追溯性矩阵中建立的 satisfy、需求之间的派生,以及模型检查。SysML 是 Object Management Group, Inc. 的注册商标。
练习
在 Holarch 中基于 Hybrid Car 演示项目 (SysML v2) 亲自完成此操作。
- 打开您的 Hybrid Car 演示项目(如有需要,请创建:管理项目 → 项目文件 ▾ → 新建演示项目 → Hybrid Car (SysML v2)),打开 模型 → 编辑器 和包
VehicleRequirements。 - 在
verification <'VC-1.1'> sedanWeighing之后添加verification def <'VC-2'> BatteryWeighing { subject battery : Battery; objective { verify batteryMassLimit; } return verdict : Boolean = battery.mass <= 50 [kg]; }和verification <'VC-2.1'> sedanBatteryWeighing : BatteryWeighing { subject battery = fleet.sedan.powertrain.battery; }。 - 打开 验证 → 验证用例。在新用例所在行中单击 + 步骤,然后单击 + 添加步骤,在 操作 下输入
Weigh the battery on a bench scale,单击 应用,再单击其状态按钮中的 通过。 - 打开 验证 → RVTM,找到 VR-6
batteryMassLimit及新用例和其状态。 - 打开 验证 → 可追溯性矩阵,以需求为行、以类 Action 为列,单击
sedanAcceleration与accelerate交叉的单元格,然后选择 satisfied by。 - 在包的末尾添加
requirement <'VR-9'> tankVolume { doc /* The fuel tank shall hold at least 40 L. */ subject tank : FuelTank; }和connection tankDerivation : Derivation connect carSpec.sedanRange to tankVolume;。然后打开 验证 → 模型检查。
当 RVTM 将新用例列为针对 VR-6 已通过、编辑器包含新的 satisfy 和 tankDerivation,且状态报告没有问题时,即完成练习。
自测
- 在
objective massObjective { verify carSpec.sedanMass; }中,verify表达了什么?您在哪里能看到它? - 验证用例的 verdict 与“验证用例”页面上的状态有什么区别?
- 什么时候使用
satisfy,什么时候使用Derivation? - 在可追溯性矩阵单元格中选择 satisfied by 时会发生什么?
显示答案
在
objective massObjective { verify carSpec.sedanMass; }中,verify表达了什么?您在哪里能看到它?表示此验证用例验证需求 sedanMass。RVTM 会将该用例列在该需求下。
验证用例的 verdict 与“验证用例”页面上的状态有什么区别?
verdict 是模型的一部分:一个表达式,这里是整备质量是否在限值以内。步骤、结果和测试运行的状态是保存在模型旁边的 Holarch 数据。
什么时候使用
satisfy,什么时候使用Derivation?satisfy表示某个设计元素(例如部件或动作)满足一条需求。Derivation 将原始需求连接到由其派生的需求;它需要private import RequirementDerivation::*;。在可追溯性矩阵单元格中选择 satisfied by 时会发生什么?
Holarch 会在 SysML 文本中写入一条
satisfy,因此该追溯是模型的一部分,并显示在编辑器中。
延伸阅读
文字稿
显示文字稿 (旁白和屏幕内容)
Introduction
Chapter six: verification and traceability. A verification case says how a requirement is checked, and traceability shows what connects to what.
In this chapter you write a verification case and apply it to the sedan, check the RVTM, trace a step to a requirement in the matrix, and derive a requirement.
Start the tutorial
Start the tutorial Verification and Traceability from Project Files, Start a Tutorial. Its starter project holds the curb mass requirement and the car specification, a short drive cycle, and two more requirements: a battery mass limit and stopping from cruise.
On screen: Project Files ▾ → Start a Tutorial… → SysML v2: Verification and Traceability → Start; Model → Editor.
Verification cases
After the verification comment, write the verification definition. Its objective names the requirement it verifies, and its verdict passes when the curb mass is within the limit.
On screen: After // ---- Verification ----: verification def <'VC-1'> CurbMassTest.
Below it, apply it to the sedan: a verification usage that weighs the sedan of the fleet.
On screen: Below it: verification <'VC-1.1'> sedanWeighing : CurbMassTest.
Open Verification, then Verification Cases. The model's verification cases are the test cases here. Steps, results and status are Holarch data next to the model, kept on this page.
On screen: Verification → Verification Cases; the Sedan Weighing row.
In the Sedan Weighing row, click Steps, then Add Step. Type weigh the car as the action, and click Apply.
On screen: + Steps → + Add Step; Action: Weigh the car; Apply.
Then set the result: click Passed in its status buttons.
On screen: Status buttons → Passed.
Open the RVTM. Each requirement is listed with its verification method, the cases that verify it, and their status.
On screen: Verification → RVTM.
Traceability
Now trace a step to a requirement. Open the Traceability Matrix. Its rows are the requirements; open Columns, and choose the class Action.
On screen: Verification → Traceability Matrix; rows: Requirement; Columns: class Action; Done.
Click the cell where stop from cruise meets the brake step, and choose satisfied by. Holarch writes a satisfy into the text.
On screen: Cell stopFromCruise × brake → satisfied by.
In the Editor, the satisfy is there. To derive a requirement, first import the requirement derivation package after the other imports.
On screen: Model → Editor: the new satisfy; import RequirementDerivation.
Then, at the end of the package, connect the sedan's mass requirement to the battery mass limit with a derivation: the battery limit is derived from the curb mass requirement.
On screen: After sedanWeighing: connection batteryMassDerivation : Derivation connect carSpec.sedanMass to batteryMassLimit;
Last, open Verification, then Model Checks. Rules run over the whole model, for example requirements without a satisfy or a verify, and each finding links to its element.
On screen: Verification → Model Checks.
Recap
Every step is ticked off. Click Mark as Done.
On screen: Step panel → Mark as Done.
Let's recap. You wrote a verification case with an objective and a verdict, applied it to the sedan, opened the Verification Cases and the RVTM, traced a step to a requirement in the matrix, and derived one requirement from another.
Next, constraints and calculations evaluate the sedan's values.