課程章節
培訓 · 第 9 單元:SysML v2 基礎 · 第 9.5 章,共 8 章
9.5 需求 4:15
撰寫可檢查的需求、將它們巢狀放入規格中,並看看一個未被滿足的需求。
展示 Holarch 2.22。
您將學到
- 將需求的限制值命名為帶單位的屬性
- 撰寫具有編號、陳述、主體與 require 約束的需求定義
- 將需求用法巢狀放入規格中,並以 `:>>` 為它們指定各自的限制值
- 說明什麼滿足了需求,並在設計不符合時閱讀編輯器的標記
- 在品質頁面上檢查需求陳述
在 Holarch 中撰寫 SysML v2 需求,依循 SysML v2 教學課程 Requirements,以一個小型 Hybrid Car 專案進行:具名的限制值、具有編號、陳述、主體與 require 約束的需求定義、插入、含巢狀需求的規格、satisfy、轎車不再滿足的需求、需求表格、需求檢視以及品質檢查。SysML 是 Object Management Group, Inc. 的註冊商標。
練習
在 Holarch 中於 Hybrid Car 示範專案(SysML v2)上親自操作。
- 開啟您的 Hybrid Car 示範專案(如有需要請建立:管理專案 → 專案檔案 ▾ → 新增示範專案 → Hybrid Car (SysML v2)),開啟模型 → 編輯器以及套件
VehicleRequirements。 - 在
attribute minElectricRange之後新增attribute minTopSpeed : SpeedValue = 180 [km/h];。 - 在
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 }。 - 在其他
satisfy行之後新增satisfy requirement roadsterSpeed : TopSpeed by fleet.roadster;。 - 將
minTopSpeed改為220 [km/h]。將指標移到編輯器標在 satisfy 上的標記,閱讀它比較的數值,然後按 ⌘Z / Ctrl+Z。 - 開啟需要與需求 → 需求並找到 VR-8,然後開啟需要與需求 → 品質並按一下檢查品質。
當 VR-8 出現在需求表格中、satisfy 在 180 km/h 時沒有標記,且「檢查品質」已為其陳述評分時,即完成。
自我檢查
- 為什麼要將
maxCurbMass之類的限制值保存為具名屬性,而不是在每個約束中寫入數字? - 在
requirement <'VR-1.1'> sedanMass : CurbMass { attribute :>> limit = maxCurbMass; }中,:>>做什麼? satisfy carSpec by fleet.sedan;讓 Holarch 能檢查什麼?- 您在需求頁面上設定需求的狀態與優先順序。SysML 文字會改變嗎?
顯示答案
為什麼要將
maxCurbMass之類的限制值保存為具名屬性,而不是在每個約束中寫入數字?每個使用該名稱的需求都只需一次編輯就會跟著更新,而且限制值帶有單位,因此檢查器會以單位比較數值。
在
requirement <'VR-1.1'> sedanMass : CurbMass { attribute :>> limit = maxCurbMass; }中,:>>做什麼?它重新定義 sedanMass 從 CurbMass 繼承的
limit屬性,為這個用法提供自己的數值。satisfy carSpec by fleet.sedan;讓 Holarch 能檢查什麼?轎車的數值是否符合 carSpec 的約束。如果轎車的整備質量超過限制,編輯器會標記 satisfy 並顯示比較的數值。
您在需求頁面上設定需求的狀態與優先順序。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.