Holarch
课程章节

培训 · 课程 9. SysML v2 基础 · 第 9.5 章,共 8 章

9.5 需求 4:15

编写可检查的需求,将它们嵌套在规格说明中,并查看一条未被满足的需求。

演示 Holarch 2.22。

您将学到

  • 将需求限值命名为带单位的属性
  • 编写带编号、陈述、主题和 require 约束的需求定义
  • 在规格说明中嵌套需求用法,并用 `:>>` 为它们赋予各自的限值
  • 说明什么满足一条需求,并在设计不满足时查看编辑器的标记
  • 在“质量”页面上检查需求陈述

在 Holarch 中编写 SysML v2 需求,基于一个小型 Hybrid Car 项目,依照 SysML v2 教程“需求”:命名的限值、带编号、陈述、主题和 require 约束的需求定义、插入、带嵌套需求的规格说明、satisfy、一条轿车不再满足的需求、需求表、需求视图以及质量检查。SysML 是 Object Management Group, Inc. 的注册商标。

项目文件

  • 完成项目 (.holarch.json;管理项目 → 项目文件 ▾ → 导入项目 (.json)…)

视频从 holarch.app 播放;参见隐私政策。

练习

在 Holarch 中基于 Hybrid Car 演示项目 (SysML v2) 亲自完成此操作。

  1. 打开您的 Hybrid Car 演示项目(如有需要,请创建:管理项目 → 项目文件 ▾ → 新建演示项目 → Hybrid Car (SysML v2)),打开 模型 → 编辑器 和包 VehicleRequirements。
  2. 在 attribute minElectricRange 之后添加 attribute minTopSpeed : SpeedValue = 180 [km/h];。
  3. 在 requirement def <'VR-5'> ChargeTime 下方选择 插入 ▾ → 需求定义,编写 <'VR-8'> TopSpeed,其陈述为 The sports car shall reach at least the minimum top speed.,主题为 car : SportCar,并包含 require constraint { car.topSpeed >= minTopSpeed }。
  4. 在其他 satisfy 行之后添加 satisfy requirement roadsterSpeed : TopSpeed by fleet.roadster;。
  5. 将 minTopSpeed 改为 220 [km/h]。将指针指向编辑器在 satisfy 上放置的标记,查看它比较的数值,然后按 ⌘Z / Ctrl+Z。
  6. 打开 需要与需求 → 需求 并找到 VR-8,然后打开 需要与需求 → 质量 并单击 检查质量。

当 VR-8 出现在需求表中、satisfy 在 180 km/h 时没有标记,且“检查质量”已为其陈述评分时,即完成练习。

自测

  1. 为什么要将 maxCurbMass 等限值保留为命名属性,而不是在每个约束中写入数字?
  2. 在 requirement <'VR-1.1'> sedanMass : CurbMass { attribute :>> limit = maxCurbMass; } 中,:>> 起什么作用?
  3. satisfy carSpec by fleet.sedan; 让 Holarch 能够检查什么?
  4. 您在需求页面上设置了需求的 Status 和 Priority。SysML 文本会改变吗?
显示答案
  1. 为什么要将 maxCurbMass 等限值保留为命名属性,而不是在每个约束中写入数字?

    使用该名称的每条需求都随一次编辑而更新,并且限值带有单位,因此检查器会比较带单位的数值。

  2. 在 requirement <'VR-1.1'> sedanMass : CurbMass { attribute :>> limit = maxCurbMass; } 中,:>> 起什么作用?

    它重定义 sedanMass 从 CurbMass 继承的 limit 属性,为此用法赋予自己的值。

  3. satisfy carSpec by fleet.sedan; 让 Holarch 能够检查什么?

    轿车的数值是否满足 carSpec 的约束。如果轿车的整备质量超过限值,编辑器会标记该 satisfy 并显示所比较的数值。

  4. 您在需求页面上设置了需求的 Status 和 Priority。SysML 文本会改变吗?

    不会。状态、优先级和验证方法是保存在模型旁边的 Holarch 数据;它们从不更改文本。

延伸阅读

文字稿

显示文字稿 (旁白和屏幕内容)

Introduction

Chapter five: requirements. In SysML v2 a requirement can carry a constraint, so the model can check whether a design meets it.

In this chapter you write limits and requirement definitions, nest requirements in a specification, say what satisfies them, and see a requirement that is not met.

Start the tutorial

Start the tutorial Requirements from Project Files, Start a Tutorial. Its starter project holds a small copy of the design: a battery, a car, and a fleet with a sedan of fifteen hundred eighty kilograms.

On screen: Project Files ▾ → Start a Tutorial… → SysML v2: Requirements → Start; Model → Editor.

Requirement definitions

Keep limits as named values, so one edit updates every requirement that uses them. After the requirements comment, add the maximum curb mass and the minimum battery capacity.

On screen: After // ---- Requirements ----: maxCurbMass and minBatteryCapacity.

Below the limits, write the first requirement definition. V R one is its number, doc is its statement, subject is what it is about, and require constraint makes it checkable: Holarch evaluates it with units.

On screen: Below the limits: requirement def <'VR-1'> CurbMass.

Insert

Insert writes the frame of a construct for you. Below the curb mass requirement, open Insert and choose Requirement Definition. Type its number and name, then press Tab to move to the subject, its type and the statement.

On screen: Insert ▾ (open on camera) → Requirement Definition; <'VR-3'> BatteryCapacity, Tab, battery, Tab, Battery, Tab, statement.

Then give it its constraint: the battery's capacity is at least the minimum.

On screen: After the doc line: require constraint { battery.capacity >= minBatteryCapacity }

Specification and satisfy

A specification holds the sedan's requirements. Each one is a usage of a definition, and the symbol after attribute redefines the limit with the sedan's own value.

On screen: After BatteryCapacity: requirement carSpec with sedanMass : CurbMass.

Now say what satisfies them. The sedan of the fleet satisfies the car specification, and a named satisfy says that the sedan's battery satisfies the battery capacity requirement.

On screen: After carSpec: satisfy carSpec by fleet.sedan; satisfy requirement batterySpec …

Break a requirement on purpose. In the fleet, change the sedan's curb mass from fifteen hundred eighty to seventeen hundred kilograms.

On screen: In fleet: curbMass = 1580 → 1700.

The Editor marks the satisfy: the sedan no longer meets V R one point one. Point at the mark to read the values it compared.

On screen: The mark on the satisfy; its information card.

Change it back, or press Command Z, and the mark clears.

On screen: curbMass = 1700 → 1580; No problems.

Pages on the model

The requirements pages work on the model. Open Needs and Requirements, then Requirements. The model's requirements are the rows, numbered by their short names. Status, priority and verification method are Holarch data next to the model; they never change the text.

On screen: Needs & Requirements → Requirements.

Open the Diagrams page, click New Diagram, and choose Requirement View. Choose the car specification under Shows, and click Create: the specification as a tree, with what satisfies it.

On screen: Diagrams → + New Diagram → Requirement View; Shows: VehicleRequirements::carSpec; Create.

Last, open Needs and Requirements, then Quality, and click Check Quality. Each requirement's statement is scored on the quality criteria, as in an LML project.

On screen: Needs & Requirements → Quality → Check Quality.

Recap

Every step is ticked off. Click Mark as Done.

On screen: Step panel → Mark as Done.

Let's recap. You named the limits, wrote requirement definitions with a number, a statement, a subject and a constraint, used Insert, nested requirements in a specification, said what satisfies them, and saw the Editor mark a requirement that was not met.

Next, verification cases check these requirements, and the matrix traces them.